当前位置: 首页>>代码示例>>Python>>正文


Python JobManager.instance方法代码示例

本文整理汇总了Python中JobManager.instance方法的典型用法代码示例。如果您正苦于以下问题:Python JobManager.instance方法的具体用法?Python JobManager.instance怎么用?Python JobManager.instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JobManager的用法示例。


在下文中一共展示了JobManager.instance方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getJobLog

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def getJobLog(jobId, useCompression = True):
	"""
	Gets the current log for an existing job.
	
	@since: 1.0

	@type  jobId: integer
	@param jobId: the job ID identifying the job whose log should be retrieved
	@type  useCompression: bool
	@param useCompression: if set to True, compress the log using zlib before encoding the response in base64
	
	@rtype: string
	@returns: the job's log in utf-8 encoded XML,
	          optionally gzip + base64 encoded if useCompression is set to True
	"""
	getLogger().info(">> getJobLog(%d, %s)" % (jobId, str(useCompression)))
	res = None
	try:
		log = JobManager.instance().getJobLog(jobId)
		if log is not None:
			if useCompression:
				res = base64.encodestring(zlib.compress(log))
			else:
				res = base64.encodestring(log)
	except Exception, e:
		e =  Exception("Unable to complete getJobLog operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< getJobLog(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:30,代码来源:WebServices.py

示例2: getJobDetails

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def getJobDetails(jobId):
	"""
	Gets a specific job's details.

	@since: 1.8

	@type  jobId: integer
	@param jobId: the job ID identifying the job whose status should be retrieved.
	
	@throws Exception: in case of an internal error.

	@rtype: dict
	       {'id': integer, 'parent-id': integer, 'name': string,
	        'state': string in ['waiting', 'running', 'stopped', 'cancelled', 'killed', 'paused'],
	        'running-time': float or None, 'result': integer or None, 'username': string, 
					'start-time': float or None, 'stop-time': float or None, 'scheduled-at': float,
	        'type': string in ['ats', 'campaign'],
					'path': string (docroot-based path for jobs whose source is in docroot) or None (client-based source),
					'te-filename': string or None
					'te-input-parameters': dict or None
					'te-command-line': string or None
					'source': base64-encoded string
	       }
	@returns: a dict of info for the given job, or None if not found.

	@throws Exception: when the job was not found, or when the job file was removed.
	"""
	getLogger().info(">> getJobDetails(%s)" % str(jobId))
	res = []
	try:
		res = JobManager.instance().getJobDetails(jobId)
	except Exception, e:
		e =  Exception("Unable to complete getJobDetails operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< getJobDetails(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:37,代码来源:WebServices.py

示例3: getJobInfo

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def getJobInfo(jobId = None):
	"""
	Gets a job or all jobs information.

	@since: 1.0

	@type  jobId: integer, or None
	@param jobId: the job ID identifying the job whose status should be retrieved, or None for all jobs.
	
	@throws Exception: in case of an internal error.

	@rtype: a list of dict
	       {'id': integer, 'parent-id': integer, 'name': string,
	        'state': string in ['waiting', 'running', 'stopped', 'cancelled', 'killed', 'paused'],
	        'running-time': float or None, 'result': integer or None, 'username': string, 
					'start-time': float or None, 'stop-time': float or None, 'scheduled-at': float,
	        'type': string in ['ats', 'campaign'],
					'path': string (docroot-based path for jobs whose source is in docroot) or None (client-based source)
	       }
	@returns: a list of info for the given job, or for all jobs in the queue if jobId is None.

	@throws Exception: when the job was not found, or when the job file was removed.
	"""
	getLogger().info(">> getJobInfo(%s)" % str(jobId))
	res = []
	try:
		res = JobManager.instance().getJobInfo(jobId)
	except Exception, e:
		e =  Exception("Unable to complete getJobInfo operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< getJobInfo(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:33,代码来源:WebServices.py

示例4: persistJobQueue

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def persistJobQueue():	
	"""	
	Persists the current job queue to the standard persistence file.
	This administrative function may be convenient when you're about
	to kill the server violently.
	
	@since: 1.5

	@throws Exception in case of an error
	
	@rtype: None
	"""
	getLogger().info(">> persistJobQueue()")
	
	try:
		res = JobManager.instance().persist()
	except Exception, e:
		e =  Exception("Unable to complete persistJobQueue operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< persistJobQueue(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:22,代码来源:WebServices.py

示例5: getJobLogFilename

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def getJobLogFilename(jobId):
	"""
	Gets an existing job's log filename.
	
	@since: 1.0

	@type  jobId: integer
	@param jobId: the job ID identifying the job whose log filename should be retrieved
	
	@rtype: string, or None
	@returns: the log filename relative to the docroot,
	          or None if the job was not found
	"""
	getLogger().info(">> getJobLogFilename(%d)" % jobId)
	res = None
	try:
		res = JobManager.instance().getJobLogFilename(jobId)
	except Exception, e:
		e =  Exception("Unable to complete getJobLogFilename operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< getJobLogFilename(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:23,代码来源:WebServices.py

示例6: sendSignal

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def sendSignal(jobId, signal):
	"""
	Sends a signal to the job id'd by jobId.
	
	@since: 1.0

	@type  jobId: integer
	@param jobId: the job Id
	@type  signal: string
	@param signal: the signal to send to the job 
	
	@throws Exception: in case of an internal error.

	@rtype: bool
	@returns: True if successfully sent, or False if the job was not found.
	"""
	getLogger().info(">> sendSignal(%d, %s)" % (jobId, signal))
	ret = False
	try:
		ret = JobManager.instance().sendSignal(jobId, signal)
	except Exception, e:
		e =  Exception("Unable to perform operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< sendSignal(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:26,代码来源:WebServices.py

示例7: rescheduleJob

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def rescheduleJob(jobId, at):
	"""
	Reschedules a job to start at <at>.

	@since: 1.2

	@type  jobId: integer
	@param jobId: the jobId identifying the job that needs rescheduling
	@type  at: float
	@param at: the timestamp of the new scheduled start
	
	@throws Exception: in case of an internal error.

	@rtype: bool
	@returns: True if the rescheduling was OK, False otherwise (job already started)
	"""
	getLogger().info(">> rescheduleJob(%s)" % str(jobId))
	res = False
	try:
		res = JobManager.instance().rescheduleJob(jobId, at)
	except Exception, e:
		e =  Exception("Unable to complete rescheduleJob operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< rescheduleJob(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:26,代码来源:WebServices.py

示例8: purgeJobQueue

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def purgeJobQueue(older_than):
	"""
	Purges jobs in the queue that:
	- are completed (any status)
	- and whose completion time is strictly older than the provided older_than timestamp (UTC)

	@since: 1.5

	@type  older_than: float (timestamp)
	@param older_than: the epoch timestamp of the older job to keep

	@throws Exception in case of an error

	@rtype: int
	@returns: the number of purged jobs
	"""
	getLogger().info(">> purgeJobQueue(%s)" % older_than)
	res = 0
	try:
		res = JobManager.instance().purgeJobs(older_than)
	except Exception, e:
		e =  Exception("Unable to complete purgeJobs operation: %s\n%s" % (str(e), Tools.getBacktrace()))
		getLogger().info("<< purgeJobQueue(...): Fault:\n%s" % str(e))
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:26,代码来源:WebServices.py

示例9: scheduleCampaign

# 需要导入模块: import JobManager [as 别名]
# 或者: from JobManager import instance [as 别名]
def scheduleCampaign(source, campaignId, username, session, at, path = None):
	"""
	Schedule an ATS to start at <at>
	
	@since: 1.2

	@type  ats: string
	@param ats: the ats contents, as a utf-8 string
	@type  atsId: string
	@param atsId: a friendly identifier/job label
	@type  username: string
	@param username: the username of the user who scheduled this ATS
	@type  session: dict[utf-8 strings] of utf8 strings
	@param session: input session variables (may be empty)
	@type  at: float, or None
	@param at: the timestamp at which the ats should be started.
	           If set to None or lower than current (server) time, immediate start.
	@type  path: string, or None
	@param path: the complete docroot-path to the file associated to the source,
	             if any. For source files not located on the server, set to None.
	             For the other ones, enables to know where to search dependencies
	             from.
	
	@throws Exception: in case of an internal error

	@rtype: dict { 'job-uri': string, 'job-id': integer, 'message': string }
	@returns: a dict containing: 
	          job-uri: the newly created job uri, only valid if status == 0
	          job-id: the newly created job id, only valid if status == 0
	          message: a human readable string indicating what was done.
	"""
	getLogger().info(">> scheduleCampaign(..., session = %s)" % str(session))

	try:
		# FIXME: ats and the dict of string seems to be received as unicode,
		# whereas they were sent by the client as UTF-8.
		# I should check on the wire and/or an XML-RPC feature somewhere (default encoding, etc).

		# Translate the session into a dict[unicode] of unicode
		s = {}
		if session:
			for (k, v) in session.items():
				s[k] = v
		
		source = source.encode('utf-8')
		
		job = JobManager.CampaignJob(campaignId, source, path)
		job.setUsername(username)
		job.setScheduledStartTime(at)
		job.setScheduledSession(s)
		jobId = JobManager.instance().submitJob(job)
		message = ""
		if at is None or at <= time.time():
			message = "immediate start"
		else:
			message = "will start on %s" % time.strftime("%Y%m%d, at %H:%M:%S", time.localtime(job.getScheduledStartTime()))
		res = { 'job-id': jobId, 'job-uri': job.getUri(), 'message': "Campaign scheduled, %s. Its job ID is %d" % (message, jobId) }
	except Exception, e:
		e =  Exception("Scheduling error: %s" % (str(e)))
		getLogger().info("<< scheduleCampaign(...): Fault:\n%s" % Tools.getBacktrace())
		raise(e)
开发者ID:rolfschr,项目名称:testerman,代码行数:63,代码来源:WebServices.py


注:本文中的JobManager.instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。