Beispiel #1
0
 def __init__(self):
     Thread.__init__(self)
     self.setName('restWkr')
     self.dbutil = globalProperty.getDbUtil()
     #Update machine here once worker started up
     self.dbutil.updateMachineInfo()
     self.dbutil.getTask()
     logging.config.fileConfig('log.config')
     self.logger = logging.getLogger()
     self.logger.info('-----Startup restTask worker')
     self.__taskListSorted = [] 
     self.__taskDic = {}
     self.__currentExeId = None
     self.__currentFile = None
     self.__currentTask = None
     self.__pendingJob = None
     self.__pendingJogPri = None
     self.__pendingJogNote = None
     self.__currentTaskPriority = 0
     self.__sortlinear = False
     #global field so that when all task is done executing, job status can be reflected
     self.__lastStatus = None
     self.__lastErrorMsg = None
     self.__taskMonitorFile = os.path.join(os.getcwd(), 'taskMonitor.txt')
     self.__versionFile = os.path.join(os.getcwd(), 'version.txt')
     self.__readPendingJobs()
     self.__working = False
     
     #Create a synchronized queue
     self.taskFileQueue = Queue()
 def __initParameter(self, parameter):
     self.parameter = parameter
     self.__dbutil = globalProperty.getDbUtil()
     self.__downloadedFileList=[]
     self.__toBeDownloadedFileList=[]
     
     # Init value for parameters used in this task
     self._Host = ''
     self._User = self.__dbutil.getAppInfo('common_domain') + "\\" + self.__dbutil.getAppInfo('common_user')
     self._Password = self.__dbutil.getAppInfo('common_password')
     self._FilePath = ''
     self._Pattern = ''#This pattern is for full path of the target file in the FTP Server
     self._FolderPattern = ''#This is for locate the folder containing target file quickly
     self._BaseDir = ''#This is the name of base folder align with the FTP Server
     self._Repository = ''#This is the path for storing the downloaded File
     self._FolderTimeConstrain = 'False'#This is the flag that the folder checked should match the time constrain
     self._KickAutoTest = 'False'
     self._Latest = '60'#This value means the default time constrain for downloading file is latest 3 days according to current time
     self._FTPRepository = ''
     self._UpdateLatest = 'True'
             
     self._Product = ''
     self._Version = ''
     self._Platform = ''
     self._BuildNum = ''
     self._Language = ''
     self._CertLevel = 'Not Tested'
     self._SubProduct = 'Application'
     self._LatestBuildLocation = ''
     self._LatestFolderPattern = ''
     
     self.__initializeParameter()
     self.__unFinishedDic = {}#The dictionary for recording unfinished item      
     self.__emailFrom = '*****@*****.**'
     self.__emailTo = '*****@*****.**'
Beispiel #3
0
    def __init__(self, type, priority):
        logging.config.fileConfig("log.config")
        self.logger = logging.getLogger()
        self.logger.info("Create a new " + type + " task with priority " + str(priority))
        self.type = type
        self.runFlag = False
        self.finishFlag = False
        self.parameter = {}
        self.priority = priority
        self.note = ""
        self._schTkMgr = globalProperty.getRestSchTkMgrInstance()
        self._commonDomain = globalProperty.getCommonDomain()
        self._commonUser = globalProperty.getCommonUser()
        self._commonPassword = globalProperty.getCommonPassword()
        self._dbutil = globalProperty.getDbUtil()
        self.__toolsDir = os.path.join(os.getcwd(), "tools")

        self.macAddress = globalProperty.getMacAddress()

        # Following 2 initialization occur in restWkr
        self.jobId = None
        self.exeId = None

        if os.name == "posix":
            self.platform = "osx10"
        elif os.name == "nt":
            self.platform = "win32"
    def __init__(self, type, overdueDir, scheduleDir, tasklist=[], timeTactic=[0, 0, 0], repeat=True):
        self.logger = logging.getLogger()
        self.logger.info("-----Generete a new Type Manager:" + type)
        self._worker = globalProperty.getRestWorkerInstance()
        self._dbutil = globalProperty.getDbUtil()

        self.type = type
        self.overdueDir = overdueDir
        self.scheduleDir = scheduleDir
        self.tasklist = tasklist
        self.timeSpaceHolder = ["0", "0", "0"] * 3
        self.timeTactic = timeTactic
        self.repeat = repeat

        self.__timerDic = {}
Beispiel #5
0
 def __init__(self, host='', port=21567, bufsiz=1024):
     Thread.__init__(self)
     self.setName('restAdm')
     logging.config.fileConfig('log.config')
     self.logger = logging.getLogger()
     self.logger.info('-----Startup restTask Admin')
     
     self.__host = host
     self.__port = port
     self.__bufsiz = bufsiz
     self.__tcpSerSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     self.__tcpSerSock.bind((host, port))
     self.__tcpSerSock.listen(5)
     self.__dbutil = globalProperty.getDbUtil()
     self.__dropBigSizeLoggingFile()
         try:
             self.__updateScheduleTask(scheduleJobFile, True)
         except Exception, e:
             deleteFlag = False
             self.logger.warning(e)
     
     if os.path.exists(overdueJobFile):
         try:
             self.__updateScheduleTask(overdueJobFile, True)
             os.remove(overdueJobFile)
         except Exception, e:
             deleteFlag = False
             self.logger.warning(e)
     
     if deleteFlag:
         globalProperty.getDbUtil().deleteTask(jobId)
         
 def updateScheduleTask(self, tkfilename, attrs, overdue=False, immediate=False):
     self.logger.debug('Task file ' + tkfilename + '\'s Type:' + str(attrs['type']))
     tks = self.doc.getElementsByTagName(attrs['type'])[0]
     newTask = self.doc.createElement("Task")
     newTask.setAttribute('fileName', tkfilename)
     for key in attrs.keys():
         if key=='type':
             continue
         newTask.setAttribute(key, attrs[key])
     tksMgr = None
     commandStr = 'tksMgr = self.%sMgr' %(attrs['type'])
     exec commandStr
     attrs['fileName'] = tkfilename
     attrs.pop('type')
 def __init__(self):
     self.__lock = RLock()#Thread relative
     self.__dbutil = globalProperty.getDbUtil()