def run(self, commandLine , dirPath , serviceName , jobKey , jobState , queue , xmlEnv ): """ Run the commandLine redirect the standard error and output on service.name.out and service.name.err, then restore the sys.stderr and sys.stdout @return: the L{Mobyle.Status.Status} of this job and a message @rtype: Status object """ jobKey = self.getKey() fout = open( serviceName + ".out" , 'w' ) ferr = open( serviceName + ".err" , 'w' ) try: ## execute the commandline through your favorite execution system pass except OSError, err: msg= "System execution failed: " + str(err) self._logError( dirPath , serviceName ,jobKey, userMsg = "Mobyle internal server error" , logMsg = None ) _log.critical( "%s/%s : %s" %( self.serviceName , jobKey , msg ) ) raise MobyleError , msg adm = Admin( dirPath ) adm.setExecutionAlias( self.execution_config_alias ) ## store the alias of execution config used for this job adm.setNumber( jobKey ) ## store the key to query/retrieve this job on this system execution adm.commit() ## link the .admin file in ADMINDIR which looklike to a "process table" linkName = ( "%s/%s.%s" %(self. _cfg.admindir() , serviceName , jobKey ) ) try: os.symlink( os.path.join( self.dirPath , '.admin') , linkName ) except OSError , err: msg = "can't create symbolic link %s in ADMINDIR: %s" %( linkName , err ) self._logError( dirPath , serviceName ,jobKey, userMsg = "Mobyle internal server error" , logMsg = None ) _log.critical( "%s/%s : %s" %( serviceName , jobKey , msg ) ) raise MobyleError , msg
def testExecutionAlias(self): adm_executionalias = "adm_dummy" ## Default os.unlink(Admin.FILENAME) Admin.create(self.cfg.test_dir, None, None, None) adm = Admin(Admin.FILENAME) self.assertEqual(adm.getExecutionAlias(), None) ## Set value adm.setExecutionAlias(adm_executionalias) self.assertEqual(adm.getExecutionAlias(), adm_executionalias) ## Missing key adm.me.clear() self.assertEqual(adm.getExecutionAlias(), None)
) except OSError, err: msg= "SGE execution failed: "+ str(err) self._logError( dirPath , serviceName , jobKey , admMsg = msg , userMsg = "Mobyle internal server error" , logMsg = None ) _log.critical( "%s/%s : %s" %( serviceName , jobKey , msg ) , exc_info = True ) raise MobyleError , msg adm = Admin( dirPath ) adm.setExecutionAlias( self.execution_config_alias ) adm.setNumber( jobKey ) adm.commit() linkName = ( "%s/%s.%s" %( self._cfg.admindir() , serviceName , jobKey ) ) try: os.symlink( os.path.join( dirPath , '.admin') , linkName ) except OSError , err: msg = "can't create symbolic link %s in ADMINDIR: %s" %( linkName , err ) self._logError( dirPath , serviceName , jobKey ,