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


Python LocalProcess.get_output方法代码示例

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


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

示例1: _get_cms_cert

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
def _get_cms_cert(config):
	config = config.change_view(set_sections=['cms', 'access', 'proxy'])
	try:
		access = AccessToken.create_instance('VomsAccessToken', config, 'cms-proxy')
	except Exception:
		if os.environ.get('X509_USER_PROXY'):
			return os.environ['X509_USER_PROXY']
		raise CMSAuthenticationException('Unable to find grid environment')
	can_submit = ignore_exception(Exception, False, access.can_submit, 5 * 60, True)
	if not can_submit:
		logging.getLogger('access.cms').warning('The grid proxy has expired or is invalid!')
		role = config.get_list('new proxy roles', '', on_change=None)
		timeout = config.get_time('new proxy timeout', 10, on_change=None)
		lifetime = config.get_time('new proxy lifetime', 192 * 60, on_change=None)
		# password in variable name removes it from debug log
		password = getpass.getpass('Please enter proxy password: ')
		try:
			proxy_init_exec = resolve_install_path('voms-proxy-init')
			proc = LocalProcess(proxy_init_exec, '--voms', str.join(':', ['cms'] + role),
				'--valid', '%d:%d' % (lifetime / 60, lifetime % 60), logging=False)
			if password:
				proc.stdin.write(password + '\n')
				proc.stdin.close()
			proc.get_output(timeout=timeout)
		except Exception:
			raise CMSAuthenticationException('Unable to create new grid proxy')
		access = AccessToken.create_instance('VomsAccessToken', config, 'cms-proxy')  # new instance
		can_submit = ignore_exception(Exception, False, access.can_submit, 5 * 60, True)
		if not can_submit:
			raise CMSAuthenticationException('Newly created grid proxy is also invalid')
	return access.get_auth_fn_list()[0]
开发者ID:grid-control,项目名称:grid-control,代码行数:33,代码来源:access_cms.py

示例2: getVersion

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
def getVersion():
	try:
		proc_ver = LocalProcess('svnversion', '-c', pathPKG())
		version = proc_ver.get_output(timeout = 10).strip()
		if version != '':
			assert(lfilter(str.isdigit, version))
			proc_branch = LocalProcess('svn info', pathPKG())
			if 'stable' in proc_branch.get_output(timeout = 10):
				return '%s - stable' % version
			return '%s - testing' % version
	except Exception:
		clear_current_exception()
	return __import__('grid_control').__version__ + ' or later'
开发者ID:Fra-nk,项目名称:grid-control,代码行数:15,代码来源:__init__.py

示例3: _script_thread

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def _script_thread(self, script, task, jobnum=None, job_obj=None, add_dict=None):
		# Get both task and job config / state dicts
		try:
			tmp = {}
			if job_obj is not None:
				for key, value in job_obj.get_dict().items():
					tmp[key.upper()] = value
			tmp['GC_WORKDIR'] = self._path_work
			if jobnum is not None:
				tmp.update(task.get_job_dict(jobnum))
			tmp.update(add_dict or {})
			env = dict(os.environ)
			for key, value in tmp.items():
				if not key.startswith('GC_'):
					key = 'GC_' + key
				env[key] = str(value)

			script = task.substitute_variables('monitoring script', script, jobnum, tmp)
			if not self._silent:
				proc = LocalProcess(*shlex.split(script), **{'env_dict': env})
				proc_output = proc.get_output(timeout=self._script_timeout)
				if proc_output.strip():
					self._log.info(proc_output.strip())
			else:
				os.system(script)
		except Exception:
			self._log.exception('Error while running user script')
			clear_current_exception()
开发者ID:mschnepf,项目名称:grid-control,代码行数:30,代码来源:event_basic.py

示例4: _scriptThread

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def _scriptThread(self, script, jobNum = None, jobObj = None, allDict = None):
		try:
			tmp = {}
			if jobNum is not None:
				tmp.update(self._task.getSubmitInfo(jobNum))
			if jobObj is not None:
				tmp.update(jobObj.getAll())
			tmp['WORKDIR'] = self._workPath
			tmp.update(self._task.getTaskConfig())
			if jobNum is not None:
				tmp.update(self._task.getJobConfig(jobNum))
				tmp.update(self._task.getSubmitInfo(jobNum))
			tmp.update(allDict or {})
			for key, value in tmp.items():
				if not key.startswith('GC_'):
					key = 'GC_' + key
				os.environ[key] = str(value)

			script = self._task.substVars(script, jobNum, tmp)
			if not self._silent:
				proc = LocalProcess(script)
				self._log.info(proc.get_output(timeout = self._runningMax))
			else:
				os.system(script)
		except Exception:
			self._log.exception('Error while running user script!')
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:28,代码来源:monitoring.py

示例5: _get_version

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def _get_version(self, value):
		svn_proc = LocalProcess('svnversion', clean_path(value))
		version = svn_proc.get_output(timeout=10, raise_errors=False).strip().lower()
		# different SVN versions yield different output for unversioned directories:
		if ('exported' in version) or ('unversioned' in version):
			version = None
		return version or 'undefined'
开发者ID:mschnepf,项目名称:grid-control,代码行数:9,代码来源:pconfig.py

示例6: _scriptThread

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def _scriptThread(self, script, jobNum = None, jobObj = None, allDict = None):
		try:
			tmp = {}
			if jobObj is not None:
				for key, value in jobObj.get_dict().items():
					tmp[key.upper()] = value
			tmp['WORKDIR'] = self._workPath
			tmp.update(self._task.getTaskConfig())
			if jobNum is not None:
				tmp.update(self._task.getJobConfig(jobNum))
			tmp.update(allDict or {})
			env = dict(os.environ)
			for key, value in tmp.items():
				if not key.startswith('GC_'):
					key = 'GC_' + key
				env[key] = str(value)

			script = self._task.substVars('monitoring script', script, jobNum, tmp)
			if not self._silent:
				proc = LocalProcess(*shlex.split(script), **{'environment': env})
				proc_output = proc.get_output(timeout = self._runningMax)
				if proc_output.strip():
					self._log.info(proc_output.strip())
			else:
				os.system(script)
		except Exception:
			self._log.exception('Error while running user script')
开发者ID:Fra-nk,项目名称:grid-control,代码行数:29,代码来源:monitoring.py

示例7: ping_host

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
def ping_host(host):
	proc = LocalProcess('ping', '-Uqnc', 1, '-W', 1, host)
	try:
		tmp = proc.get_output(timeout = 1).splitlines()
		assert(tmp[-1].endswith('ms'))
		return float(tmp[-1].split('/')[-2]) / 1000.
	except Exception:
		return None
开发者ID:Fra-nk,项目名称:grid-control,代码行数:10,代码来源:__init__.py

示例8: bulkSubmissionBegin

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def bulkSubmissionBegin(self):
		self._submitParams.update({ '-d': None })
		if self._discovery_module:
			self._submitParams.update({ '-e': self._discovery_module.getWMS() })
		if self._useDelegate is False:
			self._submitParams.update({ '-a': ' ' })
			return True
		dID = 'GCD' + md5_hex(str(time.time()))[:10]
		activity = utils.ActivityLog('creating delegate proxy for job submission')
		deletegateArgs = []
		if self._configVO:
			deletegateArgs.extend(['--config', self._configVO])
		proc = LocalProcess(self._delegateExec, '-d', dID, '--noint', '--logfile', '/dev/stderr', *deletegateArgs)
		output = proc.get_output(timeout = 10, raise_errors = False)
		if ('glite-wms-job-delegate-proxy Success' in output) and (dID in output):
			self._submitParams.update({ '-d': dID })
		del activity

		if proc.status(timeout = 0, terminate = True) != 0:
			self._log.log_process(proc)
		return (self._submitParams.get('-d', None) is not None)
开发者ID:thomas-mueller,项目名称:grid-control,代码行数:23,代码来源:wms_glitewms.py

示例9: _begin_bulk_submission

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def _begin_bulk_submission(self):
		self._submit_args_dict.update({'-d': None})
		if self._discovery_plugin:
			self._submit_args_dict.update({'-e': self._discovery_plugin.get_endpoint()})
		if self._use_delegate is False:
			self._submit_args_dict.update({'-a': ' '})
			return True
		delegate_id = 'GCD' + md5_hex(str(time.time()))[:10]
		activity = Activity('creating delegate proxy for job submission')
		delegate_arg_list = []
		if self._config_fn:
			delegate_arg_list.extend(['--config', self._config_fn])
		proc = LocalProcess(self._delegate_exec, '-d', delegate_id,
			'--noint', '--logfile', '/dev/stderr', *delegate_arg_list)
		output = proc.get_output(timeout=10, raise_errors=False)
		if ('glite-wms-job-delegate-proxy Success' in output) and (delegate_id in output):
			self._submit_args_dict.update({'-d': delegate_id})
		activity.finish()

		if proc.status(timeout=0, terminate=True) != 0:
			self._log.log_process(proc)
		return self._submit_args_dict.get('-d') is not None
开发者ID:grid-control,项目名称:grid-control,代码行数:24,代码来源:wms_glitewms.py

示例10: image

# 需要导入模块: from grid_control.utils.process_base import LocalProcess [as 别名]
# 或者: from grid_control.utils.process_base.LocalProcess import get_output [as 别名]
	def image(self):
		proc = LocalProcess('neato', '-Tpng')
		proc.stdin.write(self._get_workflow_graph())
		proc.stdin.close()
		cherrypy.response.headers['Content-Type'] = 'image/png'
		return proc.get_output(timeout = 20)
开发者ID:artus-analysis,项目名称:grid-control,代码行数:8,代码来源:gui_cherrypy.py


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