本文整理汇总了Python中shell.Shell类的典型用法代码示例。如果您正苦于以下问题:Python Shell类的具体用法?Python Shell怎么用?Python Shell使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Shell类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: create_interface
def create_interface(self, vip):
try:
vip=vip.split("/",1)[0]
Shell.run('ifconfig lo:1 %s netmask 255.255.255.255 up' % (vip))
logging.debug("Assigned VIP to the loopback interface")
except Exception as ex:
logging.error(ex)
开发者ID:sanabby,项目名称:bird-bgp-ospf,代码行数:7,代码来源:vip_intf_manager.py
示例2: clear_interface
def clear_interface(self, vip):
try:
vip=vip.split("/",1)[0]
Shell.run('ifconfig lo:1 %s netmask 255.255.255.255 down' % (vip))
logging.debug("Removed VIP from loopback interface due to all backend failures")
except Exception as ex:
logging.error(ex)
开发者ID:sanabby,项目名称:bird-bgp-ospf,代码行数:7,代码来源:vip_intf_manager.py
示例3: is_ambari_installed
def is_ambari_installed():
sh = Shell()
output = sh.run('which ambari-server')
if len(output[0]) == 0:
return False
else:
return True
开发者ID:ZacBlanco,项目名称:DeviceManagerDemo,代码行数:7,代码来源:service_installer.py
示例4: __init__
def __init__(self, basename):
self.print_backtrace = True
self.reader = 0
self.logger = None
Shell.__init__(self, basename)
self.register_commands(self, self.NOCARD_COMMANDS)
self.set_prompt("(No card) ")
开发者ID:12019,项目名称:cyberflex-shell,代码行数:7,代码来源:cyberflex-shell.py
示例5: post
def post(self):
sh = Shell()
for line in request.form['code'].split('\n'):
retval = sh.push(line)
return {'retval': retval.strip() }
开发者ID:thgp,项目名称:yoda,代码行数:7,代码来源:ycode.py
示例6: namespace_init
def namespace_init(self, daemon):
output = Shell.run('ip netns list')
for line in output.split():
if line == 'ns-' + daemon:
return False
Shell.run('ip netns add ns-%s' % daemon)
return True
开发者ID:WIZARD-CXY,项目名称:contrail-kubernetes,代码行数:7,代码来源:lxc_manager.py
示例7: test_chaining
def test_chaining(self):
sh = Shell(has_input=True)
output = sh.run('cat -u').write('Hello, world!').output()
self.assertEqual(output, ['Hello, world!'])
output = shell('cat -u', has_input=True).write('Hello, world!').output()
self.assertEqual(output, ['Hello, world!'])
开发者ID:GiorgosPa,项目名称:shell,代码行数:7,代码来源:tests.py
示例8: test__handle_output_norecord
def test__handle_output_norecord(self):
sh = Shell(record_output=False, record_errors=False)
self.assertEqual(sh._stdout, '')
self.assertEqual(sh._stderr, '')
sh._handle_output('another.txt\n', 'Error: Please supply an arg.')
self.assertEqual(sh._stdout, '')
self.assertEqual(sh._stderr, '')
开发者ID:GiorgosPa,项目名称:shell,代码行数:8,代码来源:tests.py
示例9: is_hdp_select_installed
def is_hdp_select_installed():
sh = Shell()
output = sh.run('which hdp-select')
if len(output[0]) == 0:
return False
else:
return True
开发者ID:ZacBlanco,项目名称:DeviceManagerDemo,代码行数:8,代码来源:service_installer.py
示例10: output
def output(self):
for ok in self.messages['ok']:
print(Shell.color(ok, 'white', 'green'))
for warning in self.messages['warning']:
print(Shell.color(warning, 'yellow', 'black'))
for error in self.messages['error']:
print(Shell.color(error, 'white', 'red'))
开发者ID:Salamek,项目名称:git-deploy,代码行数:9,代码来源:log.py
示例11: run
def run(self):
shell = Shell()
print(self.three_level_dir_repr(), end='')
command = input().strip()
while(command != 'exit'):
ret_msg = shell.process_command(command)
print(ret_msg)
print(self.three_level_dir_repr(), end='')
command = input().strip()
开发者ID:nwdev,项目名称:pyTerm,代码行数:9,代码来源:terminal.py
示例12: _get_master_ifname
def _get_master_ifname(self, daemon, ifname_instance):
output = Shell.run('ip netns exec ns-%s ethtool -S %s' %
(daemon, ifname_instance))
m = re.search(r'peer_ifindex: (\d+)', output)
ifindex = m.group(1)
output = Shell.run('ip link list')
expr = '^' + ifindex + ': (\w+): '
regex = re.compile(expr, re.MULTILINE)
m = regex.search(output)
return m.group(1)
开发者ID:WIZARD-CXY,项目名称:contrail-kubernetes,代码行数:10,代码来源:lxc_manager.py
示例13: install_nifi
def install_nifi():
logger.info('Attempting to install NiFi to the cluster')
if not is_ambari_installed():
logger.error('Ambari must be installed to install NiFi as well.')
raise EnvironmentError('You must install the demo on the same node as the Ambari server. Install Ambari here or move to another node with Ambari installed before continuing')
if not is_hdp_select_installed():
installed = install_hdp_select()
if not installed:
logger.error('hdp-select must be installed to install NiFi')
raise EnvironmentError('hdp-select could not be installed. Please install it manually and then re-run the setup.')
conf = config.read_config('service-installer.conf')
cmds = json.loads(conf['NIFI']['install-commands'])
sh = Shell()
logger.info('Getting HDP Version')
version = sh.run(cmds[0])
logger.info('HDP Version: ' + version[0])
fixed_copy = cmds[2].replace('$VERSION', str(version[0])).replace('\n', '')
fixed_remove = cmds[1].replace('$VERSION', str(version[0])).replace('\n', '')
logger.info('NiFi Clean Command: ' + fixed_copy)
logger.info('NiFi Copy Command: ' + fixed_remove)
remove = sh.run(fixed_remove)
copy = sh.run(fixed_copy)
logger.info('Attempting to restart Ambari...')
restart = sh.run(cmds[3])
print("Please open the Ambari Interface and manually deploy the NiFi Service.")
raw_input("Press enter twice to continue...")
raw_input("Press enter once to continue...")
# We've copied the necessary files. Once that completes we need to add it to Ambari
logger.info('Waiting for user to install service in Ambari to continue')
print('Checking to make sure service is installed')
ambari = config.read_config('global.conf')['AMBARI']
installed = check_ambari_service_installed('NIFI', ambari)
logger.info('NiFi installed successfully')
cont = ''
if not installed:
print('Unable to contact Ambari Server. Unsure whether or not Zeppelin was installed')
while not (cont == 'y' or cont == 'n'):
cont = raw_input('Continue attempt to set up NiFi for demo?(y/n)')
if not (cont == 'y' or cont == 'n'):
print('Please enter "y" or "n"')
else:
cont = 'y'
if cont == 'n':
return False
elif cont == 'y':
return True
开发者ID:ZacBlanco,项目名称:DeviceManagerDemo,代码行数:54,代码来源:service_installer.py
示例14: test__handle_output_simple
def test__handle_output_simple(self):
sh = Shell()
self.assertEqual(sh._stdout, '')
self.assertEqual(sh._stderr, '')
sh._handle_output('another.txt\n', None)
self.assertEqual(sh._stdout, 'another.txt\n')
self.assertEqual(sh._stderr, '')
sh._handle_output('something.txt\n', 'Error: Please supply an arg.\n')
self.assertEqual(sh._stdout, 'another.txt\nsomething.txt\n')
self.assertEqual(sh._stderr, 'Error: Please supply an arg.\n')
开发者ID:GiorgosPa,项目名称:shell,代码行数:12,代码来源:tests.py
示例15: is_hdp_select_installed
def is_hdp_select_installed():
'''Checks if ``hdp-select`` is installed.
Returns:
bool: True if installed (available as shell command), False if not installed'''
sh = Shell()
output = sh.run('which hdp-select')
if len(output[0]) == 0:
return False
else:
return True
开发者ID:ZacBlanco,项目名称:hdp-demo-bootstrap,代码行数:12,代码来源:service_installer.py
示例16: is_ambari_installed
def is_ambari_installed():
'''Determines whether or not ``ambari-server`` is available (In order to start/stop/restart Ambari)
Returns:
bool: True is ``ambari-server`` is available as a shell command. False otherwise.
'''
sh = Shell()
output = sh.run('which ambari-server')
if len(output[0]) == 0:
return False
else:
return True
开发者ID:ZacBlanco,项目名称:hdp-demo-bootstrap,代码行数:13,代码来源:service_installer.py
示例17: main_loop
def main_loop(self):
while(self.__location <> "quit"):
try:
gesture = self.show(self.__location)
if gesture[0] != "!":
self.__history.append(gesture)
page = self(gesture)
if page is not None: self.__location = page
except KeyboardInterrupt:
break
except Exception, e:
Shell.show_message(`e`, 1)
raise
开发者ID:BackupTheBerlios,项目名称:pylilac-svn,代码行数:13,代码来源:application.py
示例18: teardown
def teardown(pod_namespace, pod_name, docker_id):
manager = LxcManager()
short_id = docker_id[0:12]
api = ContrailVRouterApi()
uid, podName = getDockerPod(docker_id)
vmi, _ = vrouter_interface_by_name(podName)
if vmi is not None:
api.delete_port(vmi)
manager.clear_interfaces(short_id)
Shell.run('ip netns delete %s' % short_id)
开发者ID:Juniper,项目名称:contrail-kubernetes,代码行数:13,代码来源:plugin.py
示例19: interface_find_peer_name
def interface_find_peer_name(self, nsname):
ifname_instance = Shell.run(
'ip netns exec %s ip link show eth0 | '
'awk \'/eth0/{split($2, array, \":\"); print array[1];}\'' %
nsname)
logging.debug('instance interface %s' % ifname_instance)
# Get ifindex of ifname_instance
ns_ifindex = Shell.run('ip netns exec %s ethtool -S eth0 | '
'grep peer_ifindex | awk \'{print $2}\''
% (nsname))
ifname = ifindex2name(int(ns_ifindex))
return ifname
开发者ID:Juniper,项目名称:contrail-kubernetes,代码行数:14,代码来源:lxc_manager.py
示例20: interface_update
def interface_update(self, daemon, vmi, ifname_instance):
"""
1. Make sure that the interface exists in the name space.
2. Update the mac address.
"""
output = Shell.run('ip netns exec ns-%s ip link list' % daemon)
if not self._interface_list_contains(output, ifname_instance):
ifname_master = self.create_interface('ns-%s' % daemon, ifname_instance)
else:
ifname_master = self._get_master_ifname(daemon, ifname_instance)
mac = vmi.virtual_machine_interface_mac_addresses.mac_address[0]
Shell.run('ip netns exec ns-%s ifconfig %s hw ether %s' %
(daemon, ifname_instance, mac))
return ifname_master
开发者ID:WIZARD-CXY,项目名称:contrail-kubernetes,代码行数:15,代码来源:lxc_manager.py
注:本文中的shell.Shell类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论