def test_ls(self): gdb = None lldb = None try: import gdb except: pass try: import lldb if lldb.debugger is None: lldb = None except: pass if gdb is None and lldb is None: raise Exception('no gdb or lldb available') from six.moves import getoutput if gdb: res = gdb.execute('ls', from_tty=True, to_string=True) self.assertEqual(res, getoutput('ls') + '\n') else: ci = lldb.debugger.GetCommandInterpreter() ret = lldb.SBCommandReturnObject() ci.HandleCommand('ls', ret) self.assertEqual(ret.GetOutput(), getoutput('ls') + '\n')
def invoke(self, argument, from_tty, result=sys.stdout): """gdb support""" output = "" if platform.system() != 'windows': output = getoutput('mv %s' % argument) else: output = getoutput('MOVE %s' % argument) if len(output) > 0: six.print_(output , file = result)
def test_command(self, command, gdb, lldb): if gdb: res = gdb.execute(command, from_tty=True, to_string=True) self.assertEqual(res, getoutput(command) + '\n') else: ci = lldb.debugger.GetCommandInterpreter() ret = lldb.SBCommandReturnObject() ci.HandleCommand(command, ret) self.assertEqual(ret.GetOutput(), getoutput(command) + '\n')
def get_package_version(package_name, default_prefix="DataQuality"): """ Returns package version as determined from "cmt show versions" """ if "/" not in package_name and default_prefix: package_name = "/".join([default_prefix, package_name]) output = getoutput("cmt show versions %s" % package_name).split("\n") output = list(map(str.strip, output)) return " ".join(output[0].split()[1:])
#!/usr/bin/env python from six.moves import getoutput import os.path from os import chdir directory = os.path.dirname(os.path.abspath(__file__)) chdir(directory) print('Working directory set to {}'.format(directory)) proto_path = os.path.join('..', 'schema') python_out = os.path.join('..', 'iroha') out_pb2 = os.path.join(python_out, '*pb2*.py') protos = os.path.join(proto_path, '*.proto') endpoint_proto = os.path.join(proto_path, 'endpoint.proto') print( getoutput('protoc --proto_path={} --python_out={} {}'.format( proto_path, python_out, protos))) print( getoutput('python -m grpc_tools.protoc --proto_path={} \ --python_out={} --grpc_python_out={} {}'.format(proto_path, python_out, python_out, endpoint_proto))) print( getoutput( 'sed -i "" \'s/^\\(import.*_pb2\\)/from . \\1/\' {}'.format(out_pb2))) print('Done.')
def get_long_help(self): if platform.system() != 'windows': return getoutput('rm --help') else: return getoutput('DEL /?')
def get_long_help(self): if platform.system() != 'windows': return getoutput('mkdir --help') else: return getoutput('MKDIR /?')
def get_long_help(self): if platform.system() != 'windows': return getoutput('rmdir --help') else: return getoutput('rd [/S] [/Q] [drive:]path')
def invoke(self, argument, from_tty, result=sys.stdout): """gdb support""" if platform.system() != 'windows': six.print_(getoutput('ls %s' % argument), file=result) else: six.print_(getoutput('dir %s' % argument), file=result)
def test_getoutput(): from six.moves import getoutput output = getoutput('echo "foo"') assert output == 'foo'
def test_getoutput(): from six.moves import getoutput output = getoutput('echo "foo"') assert output == 'foo', ('six.moves.getoutput returned %s instead of foo' % output)