def testrefresh(self): adm_queue = 'mobyle' self.assertEqual(self.adm.getQueue(), None) adm = Admin(Admin.FILENAME) adm.setQueue(adm_queue) adm.commit() self.assertEqual(self.adm.getQueue(), None) self.adm.refresh() self.assertEqual(self.adm.getQueue(), adm_queue)
def testQueue(self): adm_queue = "adm_dummy" ## Default os.unlink(Admin.FILENAME) Admin.create(self.cfg.test_dir, None, None, None) adm = Admin(Admin.FILENAME) self.assertEqual(adm.getQueue(), None) ## Set value adm.setQueue(adm_queue) self.assertEqual(adm.getQueue(), adm_queue) ## Missing key adm.me.clear() self.assertEqual(adm.getQueue(), None)
def run( self , commandLine , dirPath , serviceName , jobState , xmlEnv = None): """ @param execution_config: the configuration of the Execution @type execution_config: ExecutionConfig instance @param commandLine: the command to be executed @type commandLine: String @param dirPath: the absolute path to directory where the job will be executed (normaly we are already in) @type dirPath: String @param serviceName: the name of the service @type serviceName: string @param jobState: @type jobState: a L{JobState} instance """ self.jobState = jobState if dirPath[-1] == '/': dirPath = dirPath[:-1] jobKey = os.path.split( dirPath )[1] if os.getcwd() != os.path.abspath( dirPath ): msg = "the child process execute itself in a wrong directory" self._logError( dirPath , serviceName ,jobKey, userMsg = "Mobyle internal server error" , logMsg = msg ) raise MobyleError , msg protectedCommandLine = '' for c in commandLine: protectedCommandLine += '\\'+ c if xmlEnv is None: xmlEnv = {} dispatcher = self._cfg.getDispatcher() queue = dispatcher.getQueue( jobState ) adm = Admin( dirPath ) adm.setQueue( queue ) adm.commit() new_path = '' binary_path = self._cfg.binary_path() if binary_path : new_path = ":".join( binary_path ) if xmlEnv.has_key( 'PATH' ) : new_path = "%s:%s" %( xmlEnv[ 'PATH' ] , new_path ) if new_path : xmlEnv[ 'PATH' ] = "%s:%s" %( new_path , os.environ[ 'PATH' ] ) else: xmlEnv[ 'PATH' ] = os.environ[ 'PATH' ] for var in os.environ.keys(): if var != 'PATH': xmlEnv[ var ] = os.environ[ var ] self._returncode = None accounting = self._cfg.accounting() if accounting: beg_time = time.time() ################################### mobyleStatus = self._run( commandLine , dirPath , serviceName , jobKey , jobState , queue , xmlEnv ) ################################### if accounting: end_time = time.time() elapsed_time = end_time - beg_time a_log = getLogger( 'Mobyle.account' ) #%d trunc time to second #%f for millisecond a_log.info("%(serviceName)s/%(jobkey)s : %(exec_class)s/%(queue)s : %(beg_time)d-%(end_time)d %(ela_time)d : %(status)s" %{ 'serviceName':serviceName , 'jobkey':jobKey, 'exec_class':self.execution_config.execution_class_name , 'queue': queue, 'beg_time':beg_time , 'end_time':end_time , 'ela_time':elapsed_time , 'status': mobyleStatus , } ) self.status_manager.setStatus( dirPath , mobyleStatus )