本文整理汇总了Python中hydratk.core.masterhead.MasterHead.get_head方法的典型用法代码示例。如果您正苦于以下问题:Python MasterHead.get_head方法的具体用法?Python MasterHead.get_head怎么用?Python MasterHead.get_head使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hydratk.core.masterhead.MasterHead
的用法示例。
在下文中一共展示了MasterHead.get_head方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FTPClient
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def FTPClient(protocol='FTP', *args, **kwargs):
"""FTP client factory method
Args:
protocol (str): FTP protocol, FTP|SFTP|TFTP
args (args): arguments
kwargs (kwargs): key value arguments
Returns:
obj: FTPClient
Raises:
error: NotImplementedError
"""
protocol = protocol.upper()
if (protocol in protocols):
mh = MasterHead.get_head()
mod = import_module(
'hydratk.lib.network.ftp.{0}'.format(protocols[protocol]))
mh.find_module('hydratk.lib.network.ftp.client', None)
return mod.FTPClient(*args, **kwargs)
else:
raise NotImplementedError('Unknown protocol:{0}'.format(protocol))
示例2: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self, secured=False, verbose=False):
"""Class constructor
Called when the object is initialized
Args:
secured (bool): secured FTP
verbose (bool): verbose mode
"""
self._mh = MasterHead.get_head()
self._secured = secured
if (not self._secured):
self._client = FTP()
else:
if (not(version_info[0] == 2 and version_info[1] == 6)):
self._client = FTP_TLS()
else:
raise NotImplementedError(
'Secured mode is not supported for Python 2.6')
self._verbose = verbose
if (self._verbose):
self._client.set_debuglevel(2)
示例3: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self):
"""Class constructor
Called when the object is initialized
Args:
none
"""
self._mh = MasterHead.get_head()
self._client = RPCClient('XMLRPC')
cfg = self._mh.cfg['Extensions']['TrackApps']['trac']
if ('return_fields' in cfg and cfg['return_fields'] != None):
self._return_fields = cfg['return_fields'].split(',')
if ('default_values' in cfg and cfg['default_values'] != None):
self._default_values = cfg['default_values']
if ('url' in cfg and cfg['url'] != None):
self._url = cfg['url']
if ('user' in cfg and cfg['user'] != None):
self._user = cfg['user']
if ('passw' in cfg and cfg['passw'] != None):
self._passw = cfg['passw']
if ('project' in cfg and cfg['project'] != None):
self._project = cfg['project']
示例4: TermClient
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def TermClient(protocol='SSH', *args, **kwargs):
"""TERM client factory method
Args:
provider (str): TERM protocol, SSH|TELNET
args (args): arguments
kwargs (kwargs): key value arguments
Returns:
obj: TermClient
Raises:
error: NotImplementedError
"""
protocol = protocol.upper()
if (protocol in protocols):
mh = MasterHead.get_head()
mod = import_module(
'hydratk.lib.network.term.{0}'.format(protocols[protocol]))
mh.find_module('hydratk.lib.network.term.client', None)
return mod.TermClient(*args, **kwargs)
else:
raise NotImplementedError('Unknown protocol:{0}'.format(protocol))
示例5: create_profiler_stats
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def create_profiler_stats(self, stats_file=None):
import StringIO
import pstats
from hydratk.core.masterhead import MasterHead
from hydratk.lib.system.fs import file_put_contents
from hydratk.lib.console.commandlinetool import CommandlineTool
if stats_file not in (None,''):
self._output_file = stats_file
mh = MasterHead.get_head()
sortby = CommandlineTool.get_input_option('pstats-sort-by')
strip_dirs = CommandlineTool.get_input_option('pstats-strip-dirs')
s = StringIO.StringIO()
if sortby == False:
sortby = 'cumulative'
else:
sortby = sortby.split(',')
mh.demsg('htk_on_debug_info', "Sorting stats using column(s): {0}".format(','.join(sortby)), mh.fromhere())
if type(sortby).__name__ == 'str':
ps = pstats.Stats(self._pr, stream=s).sort_stats(sortby)
elif type(sortby).__name__ == 'list':
ps = pstats.Stats(self._pr, stream=s).sort_stats(*sortby)
mh.demsg('htk_on_debug_info', "Writing profiler stats output to {0}".format(self._output_file), mh.fromhere())
ps.dump_stats(self._output_file)
if strip_dirs:
ps.strip_dirs()
ps.print_stats()
file_put_contents(self._output_file+'.log', s.getvalue())
示例6: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self):
"""Class constructor
Called when object is initialized
Args:
none
"""
self._test_run = testobject.TestRun(self)
self._tset_struct = None
self._tset_obj = None
self._tset_file = None
self._tset_counter = 0
self._this = None
self._parent = Parent()
self._current = Current()
self._current.te = self
self._mh = MasterHead.get_head()
self._test_simul_mode = False
self._code_stack = CodeStack()
self._run_mode_area = 'inrepo'
self._run_mode_src = 'folder'
self._ts_filter = {}
self._tca_filter = {}
self._tco_filter = {}
self._exec_level = 1
self.mp_add_hooks({
'include': self._h_include
})
示例7: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self, lay3_prot='IPv4', lay4_prot='TCP'):
"""Class constructor
Called when the object is initialized
Args:
lay3_prot (str): layer 3 protocol, IPV4|IPV6
lay4_prot (str): layer 4 protocol, TCP|UDP
Raises:
error: NotImplementedError
"""
try:
self._mh = MasterHead.get_head()
self._mh.find_module('hydratk.lib.network.inet.client', None)
self._lay3_prot = lay3_prot.upper()
self._lay4_prot = lay4_prot.upper()
if (self._lay3_prot not in self._protocols):
raise NotImplementedError(
'Unknown protocol:{0}'.format(self._lay3_prot))
elif (self._lay3_prot not in self._protocols):
raise NotImplementedError(
'Unknown protocol:{0}'.format(self._lay4_prot))
else:
self._client = socket(
self._protocols[self._lay3_prot], self._protocols[self._lay4_prot])
except error as ex:
self._mh.demsg(
'htk_on_error', 'error: {0}'.format(ex), self._mh.fromhere())
return False
示例8: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self, verbose=False, jvm_path=None, classpath=None, options=[]):
"""Class constructor
Called when the object is initialized
Uses Java client program to access JMS provider
Args:
verbose (bool): verbose mode
jvm_path (str): JVM location, default from configuration
classpath (str): Java classpath, default from configuration
options (list): JVM options
"""
try:
self._mh = MasterHead.get_head()
self._verbose = verbose
self._bridge = JavaBridge(jvm_path, classpath)
self._bridge.start(options)
self._client = self._bridge.get_class('DBClient', self._verbose)
except RuntimeError as ex:
self._mh.demsg('htk_on_error', ex, self._mh.fromhere())
示例9: DBClient
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def DBClient(engine='SQLITE', *args, **kwargs):
"""DB client factory method
Args:
engine (str): DB engine, SQLITE|ORACLE|MYSQL|POSTGRESQL|JDBC|MSSQL
NoSQL REDIS|MONGODB|CASSANDRA
args (args): arguments
kwargs (kwargs): key value arguments
Returns:
obj: DBClient
Raises:
error: NotImplementedError
"""
engine = engine.upper()
if (engine in engines):
mh = MasterHead.get_head()
mod = import_module(
'hydratk.lib.network.dbi.{0}'.format(engines[engine]))
mh.find_module('hydratk.lib.network.dbi.client', None)
return mod.DBClient(*args, **kwargs)
else:
raise NotImplementedError('Unknown engine:{0}'.format(engine))
示例10: RPCClient
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def RPCClient(provider, *args):
"""RPC client factory method
Args:
provider (str): RPC provider, RMI
args (args): arguments
kwargs (kwargs): key value arguments
Returns:
obj: RPCClient
Raises:
error: NotImplementedError
"""
provider = provider.upper()
if (provider in providers):
mh = MasterHead.get_head()
mod = import_module(
'hydratk.lib.network.rpc.{0}'.format(providers[provider]))
mh.find_module('hydratk.lib.network.rpc.client', None)
return mod.RPCClient(*args)
else:
raise NotImplementedError('Unknown provider:{0}'.format(provider))
示例11: throughput
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def throughput(n=10000):
"""Method tests event throughput
Args:
n (int): count of events
Returns:
void
"""
def _event_cb(ev):
ev.get_data('random')
return True
mh = MasterHead.get_head()
hook = {'event': 'benchmark_test_event1',
'callback': _event_cb, 'unpack_args': True}
mh.register_event_hook(hook)
for i in range(n):
ev = event.Event('benchmark_test_event1')
num = randint(0, 9)
ev.set_data('random', ('%s' % str(num)) * 1024)
mh.fire_event(ev)
示例12: EmailClient
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def EmailClient(protocol, *args, **kwargs):
"""Email client factory method
Args:
protocol (str): Email protocol, SMTP|POP|IMAP
args (args): arguments
kwargs (kwargs): key value arguments
Returns:
obj: EmailClient
Raises:
error: NotImplementedError
"""
protocol = protocol.upper()
if (protocol in protocols):
mh = MasterHead.get_head()
mod = import_module(
'hydratk.lib.network.email.{0}'.format(protocols[protocol]))
mh.find_module('hydratk.lib.network.email.client', None)
return mod.EmailClient(*args, **kwargs)
else:
raise NotImplementedError('Unknown protocol:{0}'.format(protocol))
示例13: __init__
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def __init__(self):
"""Class constructor
Called when the object is initialized
Args:
"""
self._mh = MasterHead.get_head()
示例14: run_uninstall
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def run_uninstall():
"""Method runs installation script
Args:
none
Returns:
none
"""
cnt = len(argv)
uninst_pymod = True if (cnt > 1 and argv[1] == '-y') else False
htkmod = argv[
cnt - 1] if (cnt > 2 or (cnt == 2 and argv[1] != '-y')) else 'all'
mh = MasterHead.get_head()
mh.run_fn_hook('h_bootstrap')
for title, ext in mh._ext.items():
if (htkmod in ['all', ext._ext_id] and ext._ext_id not in ['benchmark']):
if (hasattr(ext, '_uninstall')):
ext_files, ext_mods = ext._uninstall()
else:
ext_files, ext_mods = [], {}
ext_mods = _get_dependencies(ext_mods) if (uninst_pymod) else {}
uninstall_ext(ext._ext_id, ext_files, ext_mods)
import importlib
for title, mod in libs.items():
if (htkmod in ['all', title]):
try:
lib = importlib.import_module(mod)
if (hasattr(lib, '_uninstall')):
lib_files, lib_mods = lib._uninstall()
else:
lib_files, lib_mods = [], {}
lib_mods = _get_dependencies(
lib_mods) if (uninst_pymod) else {}
uninstall_lib(title, lib_files, lib_mods)
except ImportError:
pass
if (htkmod == 'all'):
cmd.uninstall_pip('hydratk')
for f in files:
cmd.remove(f)
if (uninst_pymod):
for mod in _get_dependencies(dep_modules):
if (mod != 'importlib'):
cmd.uninstall_pip(mod)
exit(0)
示例15: _get_dsn
# 需要导入模块: from hydratk.core.masterhead import MasterHead [as 别名]
# 或者: from hydratk.core.masterhead.MasterHead import get_head [as 别名]
def _get_dsn():
"""Method gets dsn from config
Args:
none
Returns:
str
"""
mh = MasterHead.get_head()
return mh.ext_cfg['Yoda']['db_testdata_dsn'].format(var_dir=syscfg.HTK_VAR_DIR)