def nginx_server(self,turn=True):
        'E:\cygwin\bin\nginx'
        if turn == True:
            #dont slient output on cmd.exe, by leave default stdout, change also for stdin,stderr since we use py2exe to deploy app
            #remove this: Popen("your-command", stdin=PIPE, stdout=PIPE, stderr=PIPE)
            p = Popen([myFuncs.resource_path(':cmd/nginx.bat'),'start'] )   #allow python open cmd for getting admin permission
            self.log("Start nginx server")
        else:
            p = Popen([myFuncs.resource_path(':cmd/nginx.bat'), 'stop'], shell=True)
            # also kill nginx process if can't stop from bat file
            #pids=get_pid_by_name("nginx.exe")
            #self.killprocess(pids)
            self.log("Stop nginx server")

        output, err = p.communicate()
        #p.kill()       #kill this process
        if output != None: self.log( "console:"+ str(output))
        return p
        pass
    def start_screencast_ffmpeg(self):
        from subprocess import Popen, PIPE
        localip = self.localIP  #socket.gethostbyname(socket.gethostname())
        #do not need to kill because ffmpeg can broadcast more stream but only one stream for current playing set by ffmpeg
        #make sure to work i think
        self.stop_stream()
        self.log( "starting stream")
        #dont slient output on cmd.exe, by leave default stdout, change also for stdin,stderr since we use py2exe to deploy app
        #remove this: stdin=PIPE, stdout=PIPE, stderr=PIPE
        #because we need to show debug on red5.bat and it should work property
        #p = Popen(myFuncs.resource_path('data/ffmpeg-stream.bat '+localip+' test') )
        #set delay time before next statement :D
        self.log(myFuncs.resource_path('data/ffmpeg-stream.bat '+localip+' test'));
        p = Popen(myFuncs.resource_path('data/ffmpeg-stream.bat '+localip+' test') )
        #p = Popen(myFuncs.readFileContent(':cmd/ffmpeg-stream.bat '+localip+' test') )
        #p.kill()       #kill this process
        output, err = p.communicate()

        if output!=None: self.log('console:'+ str(output))
        
        pass
    def start_red5_server(self,force=True, callback=None):

        #result= subprocess.check_output(["red5.bat"],shell=True)
        #result.find("Process finished with exit code 0")
        msg = []
        myred5_port = 9991
        self.log( "Starting red5 server")
        # check my server status
        pids = myFuncs.get_pid_by_port(myred5_port)
        if len(pids)!=0:
            self.log( "started red5 server before.")
            if force == False:
                if hasattr(callback, '__call__') == True: callback(msg)
                return       #force restart my red5 server again

        #dont slient output on cmd.exe, by leave default stdout, change also for stdin,stderr since we use py2exe to deploy app
        #set slient output out,in,error: Popen("your-command", stdin=PIPE, stdout=PIPE, stderr=PIPE)
        #because we need to show debug on red5.bat and it should work property
        p = Popen([myFuncs.resource_path('data/red5.bat'),''] )
        #p = Popen(myFuncs.readFileContent(':cmd/red5.bat') )
        #p.kill()       #kill this process
        output, err = p.communicate()   #b"input data that is passed to subprocess' stdin"
        rc = p.returncode
        if str(output).find("Bootstrap exit") != -1: #error
            if hasattr(self,'tryRed5_count')==False: self.tryRed5_count=0
            self.tryRed5_count+=1

            if self.tryRed5_count<3:
                pids = myFuncs.get_pid_by_port(myred5_port)
                if len(pids)!=0:
                    self.killprocess(pids)

                #self.start_red5_server() #restart red5
            pass

        self.log( "red5 server started.")
        if output!=None: self.log("console:"+ str(output))

        if hasattr(callback, '__call__') == True: callback(msg)

        pass
    def stop_red5_server(self):
        red5_pid = myFuncs.get_pid_by_commandline("org.red5.server.Bootstrap","java.exe")
        if len(red5_pid)==0:
            self.log("not found red5 running")
            return

        #dont slient output on cmd.exe, by leave default stdout, change also for stdin,stderr since we use py2exe to deploy app
        #set slient output out,in,error: Popen("your-command", stdin=PIPE, stdout=PIPE, stderr=PIPE)
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

        p = Popen([myFuncs.resource_path(':cmd/red5-shutdown.bat'), ''] , startupinfo=startupinfo,stdin=PIPE, stdout=PIPE, stderr=PIPE)  #want this task slient
        #p = Popen(myFuncs.readFileContent(':cmd/red5-shutdown.bat') ,stdin=PIPE, stdout=PIPE, stderr=PIPE)  #want this task slient
        #p.kill()       #kill this process
        output, err = p.communicate()
        self.log("stop red5 server")
        if output != None: self.log("console:" + output)

        #find out pid for java.exe with red5 arguments
        red5_pid = myFuncs.get_pid_by_commandline("org.red5.server.Bootstrap","java.exe")
        if len(red5_pid):
            self.killprocess(red5_pid)
        return output
        pass