本文整理汇总了Python中termstyle.green函数的典型用法代码示例。如果您正苦于以下问题:Python green函数的具体用法?Python green怎么用?Python green使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了green函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: do_show_nat_cfg
def do_show_nat_cfg (self, line):
"""Outputs the loaded nat provided configuration"""
try:
self.platform.dump_obj_config('nat')
print termstyle.green("*** End of nat configuration ***")
except UserWarning as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例2: do_show_static_route_cfg
def do_show_static_route_cfg (self, line):
"""Outputs the loaded static route configuration"""
try:
self.platform.dump_obj_config('static_route')
print termstyle.green("*** End of static route configuration ***")
except UserWarning as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例3: do_show_nbar_stats
def do_show_nbar_stats(self, line):
"""Fetches NBAR classification stats from the platform.\nStats are available both as raw data and as percentage data."""
try:
print self.platform.get_nbar_stats()
print termstyle.green("*** End of show_nbar_stats output ***")
except PlatformResponseMissmatch as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例4: do_no_nat
def do_no_nat(self, arg):
"""Removes NAT configuration from all non-duplicated interfaces"""
try:
self.platform.config_no_nat()
print termstyle.green("NAT configuration removed successfully.")
except UserWarning as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例5: do_show_cpu_util
def do_show_cpu_util(self, line):
"""Fetches CPU utilization stats from the platform"""
try:
print self.platform.get_cpu_util()
print termstyle.green("*** End of show_cpu_util output ***")
except PlatformResponseMissmatch as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例6: do_no_static_route
def do_no_static_route(self, line):
"""Removes IPv4 static route configuration from all non-duplicated interfaces"""
try:
self.platform.config_no_static_routing()
print termstyle.green("IPv4 static routing configuration removed successfully.")
except UserWarning as inst:
print termstyle.magenta(inst)
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:7,代码来源:interactive_platform.py
示例7: do_show_reservation_status
def do_show_reservation_status (self, line):
"""Prompts if TRex is currently reserved or not"""
if self.trex.is_reserved():
print "TRex is reserved"
else:
print "TRex is NOT reserved"
print termstyle.green("*** End of reservation status prompt ***")
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:7,代码来源:client_interactive_example.py
示例8: __init__
def __init__ (self, *args, **kwargs):
sys.stdout.flush()
unittest.TestCase.__init__(self, *args, **kwargs)
if CTRexScenario.is_test_list:
return
# Point test object to scenario global object
self.configuration = CTRexScenario.configuration
self.benchmark = CTRexScenario.benchmark
self.trex = CTRexScenario.trex
self.stl_trex = CTRexScenario.stl_trex
self.trex_crashed = CTRexScenario.trex_crashed
self.modes = CTRexScenario.modes
self.GAManager = CTRexScenario.GAManager
self.no_daemon = CTRexScenario.no_daemon
self.skipping = False
self.fail_reasons = []
if not hasattr(self, 'unsupported_modes'):
self.unsupported_modes = []
self.is_loopback = True if 'loopback' in self.modes else False
self.is_virt_nics = True if 'virt_nics' in self.modes else False
self.is_VM = True if 'VM' in self.modes else False
if not CTRexScenario.is_init:
if self.trex and not self.no_daemon: # stateful
CTRexScenario.trex_version = self.trex.get_trex_version()
if not self.is_loopback:
# initilize the scenario based on received configuration, once per entire testing session
CTRexScenario.router = CPlatform(CTRexScenario.router_cfg['silent_mode'])
device_cfg = CDeviceCfg()
device_cfg.set_platform_config(CTRexScenario.router_cfg['config_dict'])
device_cfg.set_tftp_config(CTRexScenario.router_cfg['tftp_config_dict'])
CTRexScenario.router.load_platform_data_from_file(device_cfg)
CTRexScenario.router.launch_connection(device_cfg)
if CTRexScenario.router_cfg['forceImageReload']:
running_image = CTRexScenario.router.get_running_image_details()['image']
print('Current router image: %s' % running_image)
needed_image = device_cfg.get_image_name()
if not CTRexScenario.router.is_image_matches(needed_image):
print('Setting router image: %s' % needed_image)
CTRexScenario.router.config_tftp_server(device_cfg)
CTRexScenario.router.load_platform_image(needed_image)
CTRexScenario.router.set_boot_image(needed_image)
CTRexScenario.router.reload_platform(device_cfg)
CTRexScenario.router.launch_connection(device_cfg)
running_image = CTRexScenario.router.get_running_image_details()['image'] # verify image
if not CTRexScenario.router.is_image_matches(needed_image):
self.fail('Unable to set router image: %s, current image is: %s' % (needed_image, running_image))
else:
print('Matches needed image: %s' % needed_image)
CTRexScenario.router_image = running_image
if self.modes:
print(termstyle.green('\t!!!\tRunning with modes: %s, not suitable tests will be skipped.\t!!!' % list(self.modes)))
CTRexScenario.is_init = True
print(termstyle.green("Done instantiating TRex scenario!\n"))
# raise RuntimeError('CTRexScenario class is not initialized!')
self.router = CTRexScenario.router
开发者ID:danklein10,项目名称:trex-core,代码行数:59,代码来源:trex_general_test.py
示例9: do_start_and_return
def do_start_and_return (self, line):
"""Start TRex run and once in 'Running' mode, return to cmd prompt"""
print termstyle.green("*** Starting TRex run, wait until in 'Running' state ***")
try:
ret = self.trex.start_trex(**self.run_params)
print termstyle.green("*** End of scenario (TRex is probably still running!) ***")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:8,代码来源:client_interactive_example.py
示例10: do_stop_trex
def do_stop_trex (self, line):
"""Try to stop TRex run (if TRex is currently running)"""
print termstyle.green("*** Starting TRex termination ***")
try:
ret = self.trex.stop_trex()
print termstyle.green("*** End of scenario (TRex is not running now) ***")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:8,代码来源:client_interactive_example.py
示例11: do_reserve_trex
def do_reserve_trex (self, user):
"""Reserves the usage of TRex to a certain user"""
try:
if not user:
ret = self.trex.reserve_trex()
else:
ret = self.trex.reserve_trex(user.split(' ')[0])
print termstyle.green("*** TRex reserved successfully ***")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py
示例12: do_reload
def do_reload (self, line):
"""Reloads the platform"""
ans = misc_methods.query_yes_no('This will reload the platform. Are you sure?', default = None)
if ans:
# user confirmed he wishes to reload the platform
self.platform.reload_platform(self.device_cfg)
print(termstyle.green("*** Platform reload completed ***"))
else:
print(termstyle.green("*** Platform reload aborted ***"))
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:interactive_platform.py
示例13: do_kill_indiscriminately
def do_kill_indiscriminately (self, line):
"""Force killing of running TRex process (if exists) on the server."""
print termstyle.green("*** Starting TRex termination ***")
ret = self.trex.force_kill()
if ret:
print termstyle.green("*** End of scenario (TRex is not running now) ***")
elif ret is None:
print termstyle.magenta("*** End of scenario (TRex termination aborted) ***")
else:
print termstyle.red("*** End of scenario (TRex termination failed) ***")
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py
示例14: do_cancel_reservation
def do_cancel_reservation (self, user):
"""Cancels a current reservation of TRex to a certain user"""
try:
if not user:
ret = self.trex.cancel_reservation()
else:
ret = self.trex.cancel_reservation(user.split(' ')[0])
print termstyle.green("*** TRex reservation canceled successfully ***")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:10,代码来源:client_interactive_example.py
示例15: do_switch_cfg
def do_switch_cfg (self, cfg_file_path):
"""Switch the current platform interface configuration with another one"""
if cfg_file_path:
cfg_yaml_path = os.path.abspath(cfg_file_path)
self.device_cfg = CDeviceCfg(cfg_yaml_path)
self.platform.load_platform_data_from_file(self.device_cfg)
if not self.virtual_mode:
self.platform.reload_connection(self.device_cfg)
print termstyle.green("Configuration switching completed successfully.")
else:
print termstyle.magenta("Configuration file is missing. Please try again.")
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:11,代码来源:interactive_platform.py
示例16: do_update_run_params
def do_update_run_params(self, json_str):
"""Updates provided parameters on TRex running configuration. Provide using JSON string"""
if json_str:
try:
upd_params = self.decoder.decode(json_str)
self.run_params.update(upd_params)
print termstyle.green("*** End of TRex parameters update ***")
except ValueError as inst:
print termstyle.magenta("Provided illegal JSON string. Please try again.\n[", inst,"]")
else:
print termstyle.magenta("JSON configuration string is missing. Please try again.")
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:11,代码来源:client_interactive_example.py
示例17: do_check_image_existence
def do_check_image_existence(self, arg):
"""Check if specific image file (usually *.bin) is already stored in platform drive"""
if arg:
try:
res = self.platform.check_image_existence(arg.split(' ')[0])
print res
print termstyle.green("*** Check image existence completed ***")
except PlatformResponseAmbiguity as inst:
print termstyle.magenta(inst)
else:
print termstyle.magenta("Please provide an image name in order to check for existance.")
开发者ID:RaminNietzsche,项目名称:trex-core,代码行数:11,代码来源:interactive_platform.py
示例18: do_push_files
def do_push_files (self, filepaths):
"""Pushes a custom file to be stored locally on TRex server.\nPush multiple files by spefiying their path separated by ' ' (space)."""
try:
filepaths = filepaths.split(' ')
print termstyle.green("*** Starting pushing files ({trex_files}) to TRex. ***".format (trex_files = ', '.join(filepaths)) )
ret_val = self.trex.push_files(filepaths)
if ret_val:
print termstyle.green("*** End of TRex push_files method (success) ***")
else:
print termstyle.magenta("*** End of TRex push_files method (failed) ***")
except IOError as inst:
print termstyle.magenta(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:13,代码来源:client_interactive_example.py
示例19: do_poll_once
def do_poll_once (self, line):
"""Performs a single poll of TRex current data dump (if TRex is running) and prompts and short version of latest result_obj"""
print termstyle.green("*** Trying TRex single poll ***")
try:
last_res = dict()
if self.trex.is_running(dump_out = last_res):
obj = self.trex.get_result_obj()
print obj
else:
print termstyle.magenta("TRex isn't currently running.")
print termstyle.green("*** End of scenario (TRex is posssibly still running!) ***")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:13,代码来源:client_interactive_example.py
示例20: do_run_until_finish
def do_run_until_finish (self, sample_rate):
"""Starts TRex and sample server until run is done."""
print termstyle.green("*** Starting TRex run_until_finish scenario ***")
if not sample_rate: # use default sample rate if not passed
sample_rate = 5
try:
sample_rate = int(sample_rate)
ret = self.trex.start_trex(**self.run_params)
self.trex.sample_to_run_finish(sample_rate)
print termstyle.green("*** End of TRex run ***")
except ValueError as inst:
print termstyle.magenta("Provided illegal sample rate value. Please try again.\n[", inst,"]")
except TRexException as inst:
print termstyle.red(inst)
开发者ID:Pojen-Huang,项目名称:trex-core,代码行数:15,代码来源:client_interactive_example.py
注:本文中的termstyle.green函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论