示例#1
0
    def system_piped(self, cmd):
        """Call the given cmd in a subprocess, piping stdout/err

        Parameters
        ----------
        cmd : str
            Command to execute (can not end in '&', as background processes are
            not supported.  Should not be a command that expects input
            other than simple text.
        """
        if cmd.rstrip().endswith('&'):
            # this is *far* from a rigorous test
            # We do not support backgrounding processes because we either use
            # pexpect or pipes to read from.  Users can always just call
            # os.system() or use ip.system=ip.system_raw
            # if they really want a background process.
            raise OSError("Background processes not supported.")

        # we explicitly do NOT return the subprocess status code, because
        # a non-None value would trigger :func:`sys.displayhook` calls.
        # Instead, we store the exit_code in user_ns.
        # Also, protect system call from UNC paths on Windows here too
        # as is done in InteractiveShell.system_raw
        if sys.platform == 'win32':
            cmd = self.var_expand(cmd, depth=1)
            from IPython.utils._process_win32 import AvoidUNCPath
            with AvoidUNCPath() as path:
                if path is not None:
                    cmd = 'pushd %s &&%s' % (path, cmd)
                self.user_ns['_exit_code'] = system(cmd)
        else:
            self.user_ns['_exit_code'] = system(self.var_expand(cmd, depth=1))
示例#2
0
文件: path.py 项目: xguse/ipython
def target_update(target,deps,cmd):
    """Update a target with a given command given a list of dependencies.

    target_update(target,deps,cmd) -> runs cmd if target is outdated.

    This is just a wrapper around target_outdated() which calls the given
    command if target is outdated."""

    if target_outdated(target,deps):
        system(cmd)
示例#3
0
文件: path.py 项目: marcosptf/fedora
def target_update(target,deps,cmd):
    """Update a target with a given command given a list of dependencies.

    target_update(target,deps,cmd) -> runs cmd if target is outdated.

    This is just a wrapper around target_outdated() which calls the given
    command if target is outdated."""

    if target_outdated(target,deps):
        system(cmd)
示例#4
0
文件: page.py 项目: jhmsd1981/ipython
def page_file(fname, start=0, pager_cmd=None):
    """Page a file, using an optional pager command and starting line.
    """

    pager_cmd = get_pager_cmd(pager_cmd)
    pager_cmd += " " + get_pager_start(pager_cmd, start)

    try:
        if os.environ["TERM"] in ["emacs", "dumb"]:
            raise EnvironmentError
        system(pager_cmd + " " + fname)
    except:
        try:
            if start > 0:
                start -= 1
            page(open(fname).read(), start)
        except:
            print "Unable to show file", ` fname `
示例#5
0
文件: page.py 项目: terrdavis/ipython
def page_file(fname, start=0, pager_cmd=None):
    """Page a file, using an optional pager command and starting line.
    """

    pager_cmd = get_pager_cmd(pager_cmd)
    pager_cmd += " " + get_pager_start(pager_cmd, start)

    try:
        if os.environ["TERM"] in ["emacs", "dumb"]:
            raise EnvironmentError
        system(pager_cmd + " " + fname)
    except:
        try:
            if start > 0:
                start -= 1
            page(open(fname).read(), start)
        except:
            print("Unable to show file", repr(fname))
示例#6
0
文件: page.py 项目: 7924102/ipython
def page_file(fname, start=0, pager_cmd=None):
    """Page a file, using an optional pager command and starting line.
    """

    pager_cmd = get_pager_cmd(pager_cmd)
    pager_cmd += ' ' + get_pager_start(pager_cmd,start)

    try:
        if os.environ['TERM'] in ['emacs','dumb']:
            raise EnvironmentError
        system(pager_cmd + ' ' + fname)
    except:
        try:
            if start > 0:
                start -= 1
            page(open(fname).read(),start)
        except:
            print('Unable to show file',repr(fname))
示例#7
0
def page_file(fname, start=0, pager_cmd=None):
    """Page a file, using an optional pager command and starting line.
    """

    pager_cmd = get_pager_cmd(pager_cmd)
    pager_cmd += ' ' + get_pager_start(pager_cmd, start)

    try:
        if os.environ['TERM'] in ['emacs', 'dumb']:
            raise EnvironmentError
        system(pager_cmd + ' ' + fname)
    except:
        try:
            if start > 0:
                start -= 1
            page(open(fname).read(), start)
        except:
            print('Unable to show file', repr(fname))
示例#8
0
 def test_system(self):
     system('python "%s"' % self.fname)
示例#9
0
 def test_system(self):
     status = system('%s "%s"' % (python, self.fname))
     self.assertEqual(status, 0)
示例#10
0
 def test_system_quotes(self):
     status = system('%s -c "import sys"' % python)
     self.assertEqual(status, 0)
示例#11
0
文件: util.py 项目: rekursiv/systor
def info():
	print('\nSystem volume info:')
	system('lshw -class volume,disk -short')
	print('\nMount points:')
	system('mount | grep /dev/[sm]')
	print('\n')
示例#12
0
文件: drive.py 项目: rekursiv/systor
def mount(readOnly):
    if readOnly: arg = '-r '
    else: arg = ''
    system('mount {} /mnt/efi'.format(arg + device + efipart))
    system('mount {} /mnt/sys'.format(arg + device + syspart))
示例#13
0
文件: util.py 项目: rekursiv/systor
def reboot():
  system('reboot')
示例#14
0
文件: drive.py 项目: rekursiv/systor
def initDrive():
    print 'Clearing the partition table on device {}...'.format(device)
    system("sgdisk -Z -o -g {}".format(device))
示例#15
0
def unpack():
    print 'Unpacking system from folder {}...'.format(folderName)
    system('unsquashfs -f -d /mnt/efi {}/efi.sfs'.format(folderName))
    system('unsquashfs -f -d /mnt/sys {}/sys.sfs'.format(folderName))
示例#16
0
def checkEfi():
    system('mount -r {} /mnt/efi'.format(folderName + '/efi.sfs'))
    if not os.path.exists('/mnt/efi/EFI'):
        raise RuntimeError('Invalid archive file "{}"'.format(folderName +
                                                              '/efi.sfs'))
    system('umount /mnt/efi')
示例#17
0
文件: drive.py 项目: rekursiv/systor
def isEfiMounted():
    system('mountpoint /mnt/efi')
示例#18
0
 def test_system(self):
     system('python "%s"' % self.fname)
示例#19
0
文件: drive.py 项目: rekursiv/systor
def setupSys():
    print 'Setting up system partition as {}...'.format(device + syspart)
    system("sgdisk -n 2:: {}".format(device))
    print '  Formatting...'
    system("mkfs.ext4 -F {}".format(device + syspart))
示例#20
0
文件: drive.py 项目: rekursiv/systor
def setupEfi():
    print 'Setting up UEFI boot partition as {}...'.format(device + efipart)
    system("sgdisk -n 1::+512M {}".format(device))
    system("sgdisk -t 1:ef00 {}".format(device))
    print '  Formatting...'
    system("mkfs.fat -F32 {}".format(device + efipart))
示例#21
0
文件: drive.py 项目: rekursiv/systor
def printPartTable():
    system("sgdisk -p {}".format(device))
 def test_system(self):
     status = system('python "%s"' % self.fname)
     self.assertEquals(status, 0)
示例#23
0
 def test_system(self):
     status = system('%s "%s"' % (python, self.fname))
     self.assertEqual(status, 0)
 def test_system_quotes(self):
     status = system('python -c "import sys"')
     self.assertEquals(status, 0)
示例#25
0
 def command():
     return system('%s -c "import time; time.sleep(5)"' % python)
示例#26
0
文件: util.py 项目: rekursiv/systor
def poweroff():
  system('poweroff')
示例#27
0
文件: drive.py 项目: rekursiv/systor
def umount():
    system('umount ' + device + efipart)
    system('umount ' + device + syspart)
示例#28
0
 def test_system_quotes(self):
     status = system('%s -c "import sys"' % python)
     self.assertEqual(status, 0)
示例#29
0
def pack():
    print 'Archiving system into {}...'.format(folderName)
    system('mksquashfs /mnt/efi {}/efi.sfs'.format(folderName))
    system('mksquashfs /mnt/sys {}/sys.sfs'.format(folderName))
示例#30
0
 def test_system(self):
     status = system('python "%s"' % self.fname)
     self.assertEquals(status, 0)
示例#31
0
 def test_system_quotes(self):
     status = system('python -c "import sys"')
     self.assertEquals(status, 0)
示例#32
0
def checkSys():
    system('mount -r {} /mnt/sys'.format(folderName + '/sys.sfs'))
    if not os.path.exists('/mnt/sys/etc'):
        raise RuntimeError('Invalid archive file "{}"'.format(folderName +
                                                              '/sys.sfs'))
    system('umount /mnt/sys')
示例#33
0
 def test_system(self):
     status = system(f'{python} "{self.fname}"')
     self.assertEqual(status, 0)