本文整理汇总了Python中cylc.cfgspec.globalcfg.GLOBAL_CFG.get方法的典型用法代码示例。如果您正苦于以下问题:Python GLOBAL_CFG.get方法的具体用法?Python GLOBAL_CFG.get怎么用?Python GLOBAL_CFG.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cylc.cfgspec.globalcfg.GLOBAL_CFG
的用法示例。
在下文中一共展示了GLOBAL_CFG.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__( self, suite ):
self.ldir = GLOBAL_CFG.get_derived_host_item( suite, 'suite log directory' )
self.path = os.path.join( self.ldir, 'log' )
self.err_path = os.path.join( self.ldir, 'err' )
self.roll_at_startup = GLOBAL_CFG.get( ['suite logging','roll over at start-up'] )
self.n_keep = GLOBAL_CFG.get( ['suite logging','rolling archive length'] )
self.max_bytes = GLOBAL_CFG.get( ['suite logging','maximum size in bytes'] )
示例2: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__( self, suite ):
sodir = GLOBAL_CFG.get_derived_host_item( suite, 'suite log directory' )
self.opath = os.path.join( sodir, 'out' )
self.epath = os.path.join( sodir, 'err' )
# use same archive length as logging (TODO: document this)
self.roll_at_startup = GLOBAL_CFG.get( ['suite logging','roll over at start-up'] )
self.arclen = GLOBAL_CFG.get( ['suite logging','rolling archive length'] )
示例3: write_environment_1
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def write_environment_1( self, BUFFER=None ):
if not BUFFER:
BUFFER = self.FILE
BUFFER.write( "\n\n# CYLC SUITE ENVIRONMENT:" )
# write the static suite variables
for var, val in sorted(self.__class__.suite_env.items()):
BUFFER.write( "\nexport " + var + "=" + str(val) )
if str(self.__class__.suite_env.get('CYLC_UTC')) == 'True':
BUFFER.write( "\nexport TZ=UTC" )
BUFFER.write("\n")
# override and write task-host-specific suite variables
suite_work_dir = GLOBAL_CFG.get_derived_host_item( self.suite, 'suite work directory', self.host, self.owner )
st_env = deepcopy( self.__class__.suite_task_env )
st_env[ 'CYLC_SUITE_RUN_DIR' ] = GLOBAL_CFG.get_derived_host_item( self.suite, 'suite run directory', self.host, self.owner )
st_env[ 'CYLC_SUITE_WORK_DIR' ] = suite_work_dir
st_env[ 'CYLC_SUITE_SHARE_DIR' ] = GLOBAL_CFG.get_derived_host_item( self.suite, 'suite share directory', self.host, self.owner )
st_env[ 'CYLC_SUITE_SHARE_PATH' ] = '$CYLC_SUITE_SHARE_DIR' # DEPRECATED
rsp = self.jobconfig['remote suite path']
if rsp:
st_env[ 'CYLC_SUITE_DEF_PATH' ] = rsp
else:
# replace home dir with '$HOME' for evaluation on the task host
st_env[ 'CYLC_SUITE_DEF_PATH' ] = re.sub( os.environ['HOME'], '$HOME', st_env['CYLC_SUITE_DEF_PATH'] )
for var, val in sorted(st_env.items()):
BUFFER.write( "\nexport " + var + "=" + str(val) )
task_work_dir = os.path.join( suite_work_dir, self.jobconfig['work sub-directory'] )
use_login_shell = GLOBAL_CFG.get_host_item( 'use login shell', self.host, self.owner )
comms = GLOBAL_CFG.get_host_item( 'task communication method', self.host, self.owner )
BUFFER.write( "\n\n# CYLC TASK ENVIRONMENT:" )
BUFFER.write( "\nexport CYLC_TASK_COMMS_METHOD=" + comms )
BUFFER.write( "\nexport CYLC_TASK_CYCLE_POINT=" + self.point_string )
BUFFER.write( "\nexport CYLC_TASK_CYCLE_TIME=" + self.point_string )
BUFFER.write( "\nexport CYLC_TASK_ID=" + self.task_id )
BUFFER.write( "\nexport CYLC_TASK_IS_COLDSTART=" + str( self.jobconfig['is cold-start']) )
BUFFER.write( "\nexport CYLC_TASK_LOG_ROOT=" + self.log_root )
BUFFER.write( "\nexport CYLC_TASK_MSG_MAX_TRIES=" + str( GLOBAL_CFG.get( ['task messaging','maximum number of tries'])) )
BUFFER.write( "\nexport CYLC_TASK_MSG_RETRY_INTVL=" + str( GLOBAL_CFG.get( ['task messaging','retry interval in seconds'])) )
BUFFER.write( "\nexport CYLC_TASK_MSG_TIMEOUT=" + str( GLOBAL_CFG.get( ['task messaging','connection timeout in seconds'])) )
BUFFER.write( "\nexport CYLC_TASK_NAME=" + self.task_name )
BUFFER.write( '\nexport CYLC_TASK_NAMESPACE_HIERARCHY="' + ' '.join( self.jobconfig['namespace hierarchy']) + '"')
BUFFER.write( "\nexport CYLC_TASK_SSH_LOGIN_SHELL=" + str(use_login_shell) )
BUFFER.write( "\nexport CYLC_TASK_SUBMIT_NUMBER=" + str(self.jobconfig['absolute submit number']) )
BUFFER.write( "\nexport CYLC_TASK_TRY_NUMBER=" + str(self.jobconfig['try number']) )
BUFFER.write( "\nexport CYLC_TASK_WORK_DIR=" + task_work_dir )
BUFFER.write( "\nexport CYLC_TASK_WORK_PATH=$CYLC_TASK_WORK_DIR") # DEPRECATED
示例4: get_port
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def get_port( suite, owner=user, host=get_hostname(), pphrase=None, pyro_timeout=None ):
# Scan ports until a particular suite is found.
pyro_base_port = GLOBAL_CFG.get( ['pyro','base port'] )
pyro_port_range = GLOBAL_CFG.get( ['pyro','maximum number of ports'] )
for port in range( pyro_base_port, pyro_base_port + pyro_port_range ):
uri = cylcid_uri( host, port )
try:
proxy = Pyro.core.getProxyForURI(uri)
except Pyro.errors.URIError, x:
# No such host?
raise SuiteNotFoundError, x
if pyro_timeout: # convert from string
pyro_timeout = float( pyro_timeout )
proxy._setTimeout(pyro_timeout)
proxy._setIdentification( pphrase )
before = datetime.datetime.now()
try:
name, xowner = proxy.id()
except Pyro.errors.TimeoutError:
warn_timeout( host, port, pyro_timeout )
pass
except Pyro.errors.ConnectionDeniedError:
#print >> sys.stderr, "Wrong suite or wrong passphrase at " + portid( host, port )
pass
except Pyro.errors.ProtocolError:
#print >> sys.stderr, "No Suite Found at " + portid( host, port )
pass
except Pyro.errors.NamingError:
#print >> sys.stderr, "Non-cylc pyro server found at " + portid( host, port )
pass
else:
if flags.verbose:
after = datetime.datetime.now()
print "Pyro connection on port " +str(port) + " took: " + str( after - before )
if name == suite and xowner == owner:
if flags.verbose:
print suite, owner, host, port
# RESULT
return port
else:
# ID'd some other suite.
#print 'OTHER SUITE:', name, xowner, host, port
pass
示例5: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__(self, hosts=None, owner=None, poll_interval=None,
is_compact=False):
# We can't use gobject.threads_init() for panel applets.
warnings.filterwarnings('ignore', 'use the new', Warning)
setup_icons()
if not hosts:
try:
hosts = GLOBAL_CFG.get(["suite host scanning", "hosts"])
except KeyError:
hosts = ["localhost"]
self.is_compact = is_compact
self.hosts = hosts
if owner is None:
owner = user
self.owner = owner
dot_hbox = gtk.HBox()
dot_hbox.show()
dot_eb = gtk.EventBox()
dot_eb.show()
dot_eb.add(dot_hbox)
image = gtk.image_new_from_stock("gcylc", gtk.ICON_SIZE_MENU)
image.show()
image_eb = gtk.EventBox()
image_eb.show()
image_eb.connect("button-press-event", self._on_button_press_event)
image_eb.add(image)
self.top_hbox = gtk.HBox()
self.top_hbox.pack_start(image_eb, expand=False, fill=False)
self.top_hbox.pack_start(dot_eb, expand=False, fill=False, padding=2)
self.top_hbox.show()
self.updater = ScanPanelAppletUpdater(hosts, dot_hbox, image,
self.is_compact,
owner=owner,
poll_interval=poll_interval)
self.top_hbox.connect("destroy", self.stop)
示例6: prompt
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def prompt(question, force=False, gui=False, no_force=False, no_abort=False):
"""Interactive Yes/No prompt for cylc CLI scripts.
For convenience, on No we just exit rather than return.
If force is True don't prompt, just return immediately.
"""
if (force or GLOBAL_CFG.get(['disable interactive command prompts'])) and (
not no_force):
return True
if gui:
import gtk
dialog = gtk.MessageDialog(
None, gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO,
question
)
gui_response = dialog.run()
response_no = (gui_response != gtk.RESPONSE_YES)
else:
cli_response = raw_input('%s (y/n)? ' % question)
response_no = (cli_response not in ['y', 'Y'])
if response_no:
if no_abort:
return False
else:
sys.exit(0)
else:
return True
示例7: handle_proxies
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def handle_proxies():
"""Unset proxies if the configuration matches this."""
from cylc.cfgspec.globalcfg import GLOBAL_CFG
if not GLOBAL_CFG.get(['communication', 'proxies on']):
import os
os.environ.pop("http_proxy", None)
os.environ.pop("https_proxy", None)
示例8: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__(self, suite, host, owner):
self.suite = suite
self.host = host
self.owner = owner
self.locn = None
self.local_path = os.path.join(
GLOBAL_CFG.get(['pyro', 'ports directory']), suite)
示例9: unregister
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def unregister(self, exp):
"""Un-register a suite."""
unregistered_set = set()
skipped_set = set()
ports_d = GLOBAL_CFG.get(['pyro', 'ports directory'])
for name in sorted(self.list_all_suites()):
if not re.match(exp + r'\Z', name):
continue
try:
data = self.get_suite_data(name)
except RegistrationError:
continue
if os.path.exists(os.path.join(ports_d, name)):
skipped_set.add((name, data['path']))
print >> sys.stderr, (
'SKIP UNREGISTER %s: port file exists' % (name))
continue
for base_name in ['passphrase', 'suite.rc.processed']:
try:
os.unlink(os.path.join(data['path'], base_name))
except OSError:
pass
unregistered_set.add((name, data['path']))
print 'UNREGISTER %s:%s' % (name, data['path'])
os.unlink(os.path.join(self.dbpath, name))
return unregistered_set, skipped_set
示例10: prompt
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def prompt( reason, force=False ):
if force or GLOBAL_CFG.get( ['disable interactive command prompts'] ):
return
response = raw_input( reason + ' (y/n)? ' )
if response == 'y':
return
else:
sys.exit(0)
示例11: prompt
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def prompt(reason, force=False):
if force or GLOBAL_CFG.get(["disable interactive command prompts"]):
return
response = raw_input(reason + " (y/n)? ")
if response == "y":
return
else:
sys.exit(0)
示例12: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__(self, suite):
Pyro.config.PYRO_MULTITHREADED = 1
# Use dns names instead of fixed ip addresses from /etc/hosts
# (see the Userguide "Networking Issues" section).
Pyro.config.PYRO_DNS_URI = True
# Base Pyro socket number.
Pyro.config.PYRO_PORT = GLOBAL_CFG.get(['pyro', 'base port'])
# Max number of sockets starting at base.
Pyro.config.PYRO_PORT_RANGE = GLOBAL_CFG.get(
['pyro', 'maximum number of ports'])
Pyro.core.initServer()
self.daemon = None
# Suite only needed for back-compat with old clients (see below):
self.suite = suite
示例13: get_host_ip_address
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def get_host_ip_address():
from cylc.cfgspec.globalcfg import GLOBAL_CFG
global host_ip_address
if host_ip_address is None:
target = GLOBAL_CFG.get( ['suite host self-identification','target'] )
# external IP address of the suite host:
host_ip_address = get_local_ip_address( target )
return host_ip_address
示例14: __init__
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def __init__(self, suite, test_params=None):
if SuiteLog.__INSTANCE:
raise Exception("Attempting to initiate a second singleton"
"instance.")
self._group = None
if not test_params:
self.is_test = False
self.max_bytes = GLOBAL_CFG.get(
['suite logging', 'maximum size in bytes'])
self.roll_at_startup = GLOBAL_CFG.get(
['suite logging', 'roll over at start-up'])
self.archive_length = GLOBAL_CFG.get(
['suite logging', 'rolling archive length'])
else:
self.is_test = True
self.max_bytes = test_params['max_bytes']
self.roll_at_startup = test_params['roll_at_startup']
self.archive_length = 4
# Log paths.
if test_params:
self.ldir = test_params['ldir']
else:
self.ldir = GLOBAL_CFG.get_derived_host_item(
suite, 'suite log directory')
self.log_paths = {}
self.log_paths[self.LOG] = os.path.join(self.ldir, self.LOG)
self.log_paths[self.OUT] = os.path.join(self.ldir, self.OUT)
self.log_paths[self.ERR] = os.path.join(self.ldir, self.ERR)
# The loggers.
self.loggers = {}
self.loggers[self.LOG] = None
self.loggers[self.OUT] = None
self.loggers[self.ERR] = None
# Filename stamp functions.
if self.is_test:
self.stamp = lambda: get_current_time_string(True, True, True
).replace('.', '-')
else:
self.stamp = lambda: get_current_time_string(False, True, True)
SuiteLog.__INSTANCE = self
示例15: get_suite_host
# 需要导入模块: from cylc.cfgspec.globalcfg import GLOBAL_CFG [as 别名]
# 或者: from cylc.cfgspec.globalcfg.GLOBAL_CFG import get [as 别名]
def get_suite_host():
from cylc.cfgspec.globalcfg import GLOBAL_CFG
global suite_host
if suite_host is None:
hardwired = GLOBAL_CFG.get( ['suite host self-identification','host'] )
method = GLOBAL_CFG.get( ['suite host self-identification','method'] )
# the following is for suite host self-identfication in task job scripts:
if method == 'name':
suite_host = hostname
elif method == 'address':
suite_host = get_host_ip_address()
elif method == 'hardwired':
if not hardwired:
sys.exit( 'ERROR, no hardwired hostname is configured' )
suite_host = hardwired
else:
sys.exit( 'ERROR, unknown host method: ' + method )
return suite_host