예제 #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
파일: archive.py 프로젝트: rekursiv/systor
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
파일: archive.py 프로젝트: rekursiv/systor
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))
예제 #22
0
 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)
예제 #24
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
파일: archive.py 프로젝트: rekursiv/systor
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
파일: archive.py 프로젝트: rekursiv/systor
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)