Exemplo n.º 1
0
    def __server_thread(self):
        """Thread function to (re)connect active connection to remote host.

        .. warning:: Do not call this directly, for internal use only.
        """
        sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        if not isWindows():
            sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        sock.bind(('', self.remotePort))
        sock.listen(1)

        while True:
            accept_result = sock.accept()
            if accept_result is None:
                continue

            (self.sock, (sourceIP, sourcePort)) = accept_result

            # setup socket
            self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)

            # make socket nonblocking
            self.sock.setblocking(0)

            # start the receiver thread
            self._start_receiver()

            sock.close()

            return
Exemplo n.º 2
0
def get_reg(REG_PATH, name):
    if isWindows():
        import _winreg
        if REG_PATH.split("\\")[0] == "HKEY_LOCAL_MACHINE":
            rootName = _winreg.HKEY_LOCAL_MACHINE

        elif REG_PATH.split("\\")[0] == "HKEY_CLASSES_ROOT":
            rootName = _winreg.HKEY_CLASSES_ROOT

        elif REG_PATH.split("\\")[0] == "HKEY_CURRENT_USER":
            rootName = _winreg.HKEY_CURRENT_USER

        elif REG_PATH.split("\\")[0] == "HKEY_USERS":
            rootName = _winreg.HKEY_USERS

        elif REG_PATH.split("\\")[0] == "HKEY_CURRENT_CONFIG":
            rootName = _winreg.HKEY_CURRENT_CONFIG

        else:
            rootName = ""
            REG_PATH = ""
            print "no find root name :", REG_PATH.split("\\")[0]
        REG_PATH = REG_PATH[len(REG_PATH.split("\\")[0]) + 1:]

        try:
            registry_key = _winreg.OpenKey(rootName, REG_PATH, 0,
                                           _winreg.KEY_READ)
            value, regtype = _winreg.QueryValueEx(registry_key, name)
            _winreg.CloseKey(registry_key)
            return value
        except WindowsError, e:
            print "get_reg error,message : ", e
            return None
Exemplo n.º 3
0
def clearWebexPackage():
    """clear webex package
    @param filePath: service path on windows
    @type filePath: string
    @return: operation result 
    @rtype: tuple
    """
    result = False,'clear package fail'
    if isWindows():
        resultlist=[]
        resultlist=[]
        directoryList = ['C:\Users\Administrator\AppData\Local\Webex',
                         'C:\Users\Administrator\AppData\LocalLow\Webex',
                         'C:\ProgramData\Webex']
        for dire in directoryList:
            print 'delete directory :' + dire
            p = subprocess.Popen(('rd /s /q '+dire),shell = True)
            ret = p.wait()
            print 'delete directory result :' + str(ret)
            p.kill()
            resultlist.append(ret)

        filePathList = [r'C:\Windows\Downloaded Program Files\ieatgpc.dll',
                        r'C:\Users\Administrator\AppData\Roaming\Mozilla\plugins\npatgpc.dll',
                         r'C:\Program Files\Google\Chrome\Application\Plugins\npatgpc.dll',
                         r'C:\Program Files (x86)\Google\Chrome\Application\Plugins\npatgpc.dll',
                         r'C:\Program Files\Mozilla Firefox\browser\plugins\npatgpc.dll',
                         r'C:\Program Files (x86)\Mozilla Firefox\browser\plugins\npatgpc.dll',
                         r'C:\Users\Administrator\AppData\Local\WebEx\ChromeNativeHost\ciscowebexstart.exe']
        for file in filePathList:
            print 'delete file :' + file
            p = subprocess.Popen(('del /f /s /q /a '+'"'+file+'"'),shell = True)
            ret = p.wait()
            print 'delete file result :' + str(ret)
            p.kill()
            resultlist.append(ret)
        
        for resultT in resultlist:
            if resultT in [0,1,2]:
                result = True,''
                
            
    elif isMacOSX():
        resultlist=[]   
        p6=subprocess.Popen('rm -rf ~/Library/Application\ Support/WebEx\ Folder',shell=True) 
        ret6 = p6.wait()
        resultlist.append(ret6)
        for resultT in resultlist:
            if resultT in [0]:
                result = True,''
    return result
Exemplo n.º 4
0
    def start(self):
        """Starts the server and returns. It will launch a listener running in background to wait for incoming connections."""
        self.listenSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        if not isWindows():
            self.listenSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)

        self.listenSock.bind(('', self.port))
        self.listenSock.listen(1)
        self.listenSock.setblocking(0)

        self.listenThread = threading.Thread(target=self._listen_thread, args=(), name="secsgem_hsmsMultiPassiveServer_listenThread_{}".format(self.port))
        self.listenThread.start()

        self.logger.debug("listening")
Exemplo n.º 5
0
    def getBrowserPID(self):
        """return webdriver process ID
        @return: browser process ID
        @rtype: int
        """
        if self.browserName.lower() == "firefox":
            return self.myDriver.binary.process.pid
        elif self.browserName.lower() == "ie":
            if isWindows():
                s  = 'iexplore.exe'
                im = '"IMAGENAME eq %s"'%s
                cmd = "tasklist /NH /FI %s"%im
                cmd = '''for /f \"tokens=2 delims=,"'''+''' %F'''+" in ('tasklist /nh /fi %s"%im+" /fo csv') do @echo %~F"
                s = os.popen(cmd).read()
                pidlist = s.split("\n")
#                 print "filter(None, pidlist)",filter(None, pidlist)
                return filter(None, pidlist)
Exemplo n.º 6
0
    def stopMeeting(self):
        """kill meeting process.
        @return: True when stop meeting successfully,otherwise return False and message
        @rtype: tuple     
        """
        
        if isWindows() :
            toKillProccessList = ["IEDriverServer.exe","chromedriver.exe"]
            resultlist = []
            if self.serviceType.lower() == "mc" or self.serviceType.lower() == "ec" or self.serviceType.lower() == "tc" :
                toKillProccessList.append("atmgr.exe")
            elif self.serviceType.lower() == "sc":
                toKillProccessList.append("atscmgr.exe")
                toKillProccessList.append("OUTLOOK.EXE")
            for processName in toKillProccessList:
                p=subprocess.Popen(("taskkill /f /im " + processName),shell=True)
                ret = p.wait()
                resultlist.append(ret)
            for resultT in resultlist:
                if resultT not in [0]:
                    return False,'stop meeting fail'
            return True,''
        elif isMacOSX():
            p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
            out, err = p.communicate()
            
            if self.serviceType.lower() == "mc":
                processName = "Meeting Center"
            elif self.serviceType.lower() == "ec":
                processName = "Event Center"
            elif self.serviceType.lower() == "tc":
                processName = "Training Center"
            elif self.serviceType.lower() == "sc":
                processName = "Session Center"
            for line in out.splitlines():
#                     print line
                if processName in line:
                    pid = int(line.split(None, 1)[0])
                    os.kill(pid, signal.SIGKILL)
        
            return True,''
Exemplo n.º 7
0
def set_reg(REG_PATH, name, valueType, value):
    #     print "value = ",value
    if isWindows():
        import _winreg
        if REG_PATH.split("\\")[0] == "HKEY_LOCAL_MACHINE":
            rootName = _winreg.HKEY_LOCAL_MACHINE

        elif REG_PATH.split("\\")[0] == "HKEY_CLASSES_ROOT":
            rootName = _winreg.HKEY_CLASSES_ROOT

        elif REG_PATH.split("\\")[0] == "HKEY_CURRENT_USER":
            rootName = _winreg.HKEY_CURRENT_USER

        elif REG_PATH.split("\\")[0] == "HKEY_USERS":
            rootName = _winreg.HKEY_USERS

        elif REG_PATH.split("\\")[0] == "HKEY_CURRENT_CONFIG":
            rootName = _winreg.HKEY_CURRENT_CONFIG

        else:
            rootName = ""
            REG_PATH = ""
            print "no find root name :", REG_PATH.split("\\")[0]
        REG_PATH = REG_PATH[len(REG_PATH.split("\\")[0]) + 1:]

        try:
            _winreg.CreateKey(rootName, REG_PATH)
            registry_key = _winreg.OpenKey(rootName, REG_PATH, 0,
                                           _winreg.KEY_WRITE)
            if valueType == "REG_SZ":
                _winreg.SetValueEx(registry_key, name, 0, _winreg.REG_SZ,
                                   value)
            else:
                _winreg.SetValueEx(registry_key, name, 0, _winreg.REG_DWORD,
                                   value)
            _winreg.CloseKey(registry_key)
            return True
        except WindowsError, e:
            print "set regitry,error is :", e
            return False
Exemplo n.º 8
0
def check_process():
    """监测进程信息"""
    # 监测进程
    # 复制进程名
    process_list = list(settings.REQUIRE_PROCESS_LIST)
    for p in psutil.process_iter():
        try:
            # 监测文件描述符是否超过最大值
            if common.isWindows():
                fds = p.get_num_handles()
                if fds > settings.MAX_HANDLES_FDS:
                    common.logger.warn(u"进程", p.name, "的句柄数超过最大值: ", fds)
            else:
                fds = p.get_num_fds()
                if fds > settings.MAX_HANDLES_FDS:
                    common.logger.warn(u"进程", p.name, "的文件描述符数超过最大值: ", fds)

            # 监测目标进程是否正在运行
            if p.name.lower() in settings.REQUIRE_PROCESS_LIST and p.is_running():
                # 检测到则移除
                process_list.remove(p.name.lower())

        except Exception, e:
            pass
Exemplo n.º 9
0
def replaceFile(filePath='',IsChrome = False):
    """replace GPC File and so on
    @param filePath: service path on windows
    @type filePath: string
    @param IsChrome: whether to copy chrome addon file,default is copy this file.
    @type IsChrome: boolean
    @return: operation result
    @rtype: boolean
    """
    if isWindows():
        print "start replace some DLL file......"
        fileFatherPath = r'C:\ProgramData\Webex\Webex'
        fileChildPath = filePath
        cashPath = r'C:\Users\Administrator\AppData\LocalLow\WebEx'
        programPath = r'C:\ProgramData\WebEx'
        downloadPath = r'C:\Windows\Downloaded Program Files'
        pluginPath = r'C:\Users\Administrator\AppData\Roaming\Mozilla\plugins'
        pluginPath1 = r'C:\Program Files\Google\Chrome\Application\Plugins'
        pluginPath2 = r'C:\Program Files (x86)\Google\Chrome\Application\Plugins'
        pluginPath3 = r'C:\Program Files\Mozilla Firefox\browser\plugins'
        pluginPath4 = r'C:\Program Files (x86)\Mozilla Firefox\browser\plugins'
        ChromeAddOnPath = r'C:\Users\Administrator\AppData\Local\WebEx'
        ChromeAddOnPath2 = r'C:\Users\Administrator\AppData\Local\WebEx\ChromeNativeHost'
        mountFilePath = r'\\tanfs.eng.webex.com\engta\share\clientta\ComponentFile_Pipeline\webex-windows-plugin\release'
        mountFilePathForChromeAddOn = r'\\tanfs.eng.webex.com\engta\share\clientta\ComponentFile_Pipeline\webex-chrome-addon\release'
        
         
        filePathList=[programPath,cashPath,downloadPath,pluginPath,
                  fileFatherPath,fileChildPath,pluginPath1,pluginPath2,ChromeAddOnPath,ChromeAddOnPath2]
        
        for fileTemp in filePathList:
#             print 'fileTemp==',fileTemp
            if not os.path.exists(fileTemp):
                try:
                    os.mkdir(fileTemp)
                except Exception,e:
                    print e          
                            
        mountfileList = []
        for (dirpath, dirnames, filenames) in os.walk(mountFilePath):
            mountfileList.extend(filenames)
            break
        fileT=''
        for fileT in mountfileList:
            if fileT in ['atgpcext.dll','atinst.exe']:
                try:
                    copyfile(mountFilePath+'\\'+fileT,fileChildPath+'\\'+fileT)
                except Exception,e:
                    print e

                     
            if fileT in ['npatgpc.dll']:
                try:
                    if not os.path.exists(pluginPath):
                        os.makedirs(pluginPath)
                    if not os.path.exists(pluginPath1):
                        os.makedirs(pluginPath1)
                    if not os.path.exists(pluginPath2):
                        os.makedirs(pluginPath2)
                    if not os.path.exists(pluginPath3):
                        os.makedirs(pluginPath3)
                    if not os.path.exists(pluginPath4):
                        os.makedirs(pluginPath4)
                    copyfile(mountFilePath+'\\'+fileT,pluginPath+'\\'+fileT)
                    copyfile(mountFilePath+'\\'+fileT,pluginPath1+'\\'+fileT)
                    copyfile(mountFilePath+'\\'+fileT,pluginPath2+'\\'+fileT)
                    copyfile(mountFilePath+'\\'+fileT,pluginPath3+'\\'+fileT)
                    copyfile(mountFilePath+'\\'+fileT,pluginPath4+'\\'+fileT)
                except Exception,e:
                    print e
Exemplo n.º 10
0
            mkParam = '&SN=' + meetingKey
        else:
            startAction = "HM"
            mkParam = '&MK=' + meetingKey
            
        url = self.siteUrl + 'm.php?AT=' + startAction + mkParam #'https://pl.qa.webex.com/fr26java2/m.php?AT=HM&MK=' + meetingKey
#         print 'start meeting url=', url
        self.log.fdbg(os.path.normpath(__file__) + '==>startMeeting : url = ' + url)
        self.myDriver.get(url)
        try:
            currentUrl=str(self.myDriver.current_url)
        except Exception,e:
            self.log.fdbg(os.path.normpath(__file__) + '==>get meeting  Url exception message :' + str(e))
        self.log.fdbg(os.path.normpath(__file__) + '==>after start meeting  Url' + currentUrl)
        #time.sleep(2)
        if isWindows():
            from common.win.wStdWindow import PyWinWindow
            from common.PyWindow import mouseOperateOnWindow,getChildWindowListByClass
            import win32gui as win32
            from common.input import mouseClick,mouseMove
            if self.browserName.lower() == 'ie' and self.downloadType.lower() in ['activex','tfs'] and not jmtFlag :
                tryTimes = 0
                installButtonList = []
                oBrowser =  []
                windowsList=getChildWindowListByClass(win32.GetDesktopWindow(),'',20,False,None)#find broswer object
                for window1 in windowsList:
                    for pid1 in self.getBrowserPID():
                        if window1.getProcessId() == int(pid1):
                            oBrowser.append(window1)
                if 0 != len(oBrowser):
                    while len(installButtonList) == 0 and tryTimes <= 30: