当前位置: 首页>>代码示例>>Python>>正文


Python misc.execute函数代码示例

本文整理汇总了Python中ubiquity.misc.execute函数的典型用法代码示例。如果您正苦于以下问题:Python execute函数的具体用法?Python execute怎么用?Python execute使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了execute函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: chroot_cleanup

def chroot_cleanup(target, x11=False):
    """Undo the work done by chroot_setup."""
    if target == '/':
        return

    if x11 and 'DISPLAY' in os.environ:
        misc.execute('umount', os.path.join(target, 'tmp/.X11-unix'))
        try:
            os.rmdir(os.path.join(target, 'tmp/.X11-unix'))
        except OSError:
            pass
        osextras.unlink_force(os.path.join(target,
                                           'root/.Xauthority'))

    chrex(target, 'umount', '/sys')
    chrex(target, 'umount', '/proc')
    misc.execute('umount', os.path.join(target, 'dev'))

    initctl = os.path.join(target, 'sbin/initctl')
    if os.path.exists('%s.REAL' % initctl):
        os.rename('%s.REAL' % initctl, initctl)

    start_stop_daemon = os.path.join(target, 'sbin/start-stop-daemon')
    if os.path.exists('%s.REAL' % start_stop_daemon):
        os.rename('%s.REAL' % start_stop_daemon, start_stop_daemon)
    else:
        osextras.unlink_force(start_stop_daemon)

    policy_rc_d = os.path.join(target, 'usr/sbin/policy-rc.d')
    osextras.unlink_force(policy_rc_d)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:30,代码来源:install_misc.py

示例2: progress_loop

    def progress_loop(self):
        """prepare, copy and config the system in the core install process."""

        self.start_debconf()
        dbfilter = partman_commit.PartmanCommit(self)
        if dbfilter.run_command(auto_process=True) != 0:
            print >>self.console, '\nUnable to commit the partition table, exiting.'
            return

        self.start_debconf()
        dbfilter = install.Install(self)
        ret = dbfilter.run_command(auto_process=True)
        if ret == 0:
            dbfilter = plugininstall.Install(self)
            ret = dbfilter.run_command(auto_process=True)
        if ret == 0:
            self.run_success_cmd()
            print >>self.console, 'Installation complete.'
            if self.get_reboot():
                misc.execute("reboot")
        if ret != 0:
            if ret == 3:
                # error already handled by Install
                sys.exit(ret)
            elif (os.WIFSIGNALED(ret) and
                  os.WTERMSIG(ret) in (signal.SIGINT, signal.SIGKILL,
                                       signal.SIGTERM)):
                sys.exit(ret)
            elif os.path.exists('/var/lib/ubiquity/install.trace'):
                tbfile = open('/var/lib/ubiquity/install.trace')
                realtb = tbfile.read()
                tbfile.close()
                raise RuntimeError("Install failed with exit code %s\n%s" %
                                  (ret, realtb))
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:34,代码来源:noninteractive.py

示例3: install

 def install(self, target, progress, *args, **kwargs):
     progress.info('ubiquity/install/locales')
     rv = InstallPlugin.install(self, target, progress, *args, **kwargs)
     if not rv:
         # fontconfig configuration needs to be adjusted based on the
         # selected locale (from language-selector-common.postinst). Ignore
         # errors.
         misc.execute('chroot', target, 'fontconfig-voodoo', '--auto', '--force', '--quiet')
     return rv
开发者ID:guadalinex-archive,项目名称:guadalinex-v7,代码行数:9,代码来源:ubi-welcome.py

示例4: chroot_setup

def chroot_setup(target, x11=False):
    """Set up /target for safe package management operations."""
    if target == '/':
        return

    policy_rc_d = os.path.join(target, 'usr/sbin/policy-rc.d')
    f = open(policy_rc_d, 'w')
    print >>f, """\
#!/bin/sh
exit 101"""
    f.close()
    os.chmod(policy_rc_d, 0755)

    start_stop_daemon = os.path.join(target, 'sbin/start-stop-daemon')
    if os.path.exists(start_stop_daemon):
        os.rename(start_stop_daemon, '%s.REAL' % start_stop_daemon)
    f = open(start_stop_daemon, 'w')
    print >>f, """\
#!/bin/sh
echo 1>&2
echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2
exit 0"""
    f.close()
    os.chmod(start_stop_daemon, 0755)

    initctl = os.path.join(target, 'sbin/initctl')
    if os.path.exists(initctl):
        os.rename(initctl, '%s.REAL' % initctl)
        f = open(initctl, 'w')
        print >>f, """\
#!/bin/sh
echo 1>&2
echo 'Warning: Fake initctl called, doing nothing.' 1>&2
exit 0"""
        f.close()
        os.chmod(initctl, 0755)

    if not os.path.exists(os.path.join(target, 'proc/cmdline')):
        chrex(target, 'mount', '-t', 'proc', 'proc', '/proc')
    if not os.path.exists(os.path.join(target, 'sys/devices')):
        chrex(target, 'mount', '-t', 'sysfs', 'sysfs', '/sys')
    misc.execute('mount', '--bind', '/dev', os.path.join(target, 'dev'))

    if x11 and 'DISPLAY' in os.environ:
        if 'SUDO_USER' in os.environ:
            xauthority = os.path.expanduser('~%s/.Xauthority' %
                                            os.environ['SUDO_USER'])
        else:
            xauthority = os.path.expanduser('~/.Xauthority')
        if os.path.exists(xauthority):
            shutil.copy(xauthority,
                        os.path.join(target, 'root/.Xauthority'))

        if not os.path.isdir(os.path.join(target, 'tmp/.X11-unix')):
            os.mkdir(os.path.join(target, 'tmp/.X11-unix'))
        misc.execute('mount', '--bind', '/tmp/.X11-unix',
                     os.path.join(target, 'tmp/.X11-unix'))
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:57,代码来源:install_misc.py

示例5: apply_real_keyboard

 def apply_real_keyboard(self, model, layout, variant, options):
     args = []
     if model is not None and model != "":
         args.extend(("-model", model))
     args.extend(("-layout", layout))
     if variant != "":
         args.extend(("-variant", variant))
     for option in options:
         args.extend(("-option", option))
     misc.execute("setxkbmap", *args)
开发者ID:guadalinex-archive,项目名称:guadalinex-v5,代码行数:10,代码来源:console_setup.py

示例6: apply_real_keyboard

 def apply_real_keyboard(self, model, layout, variant, options):
     args = []
     if model is not None and model != '':
         args.extend(("-model", model))
     args.extend(("-layout", layout))
     if variant != '':
         args.extend(("-variant", variant))
     args.extend(("-option", ""))
     for option in options:
         args.extend(("-option", option))
     print >>sys.stderr,' ----->DENTRO APPLY REAL KEYBOARD'
     misc.execute("setxkbmap", *args)
开发者ID:guadalinex-archive,项目名称:guadalinex-v7,代码行数:12,代码来源:ubi-welcome.py

示例7: umount_source

    def umount_source(self):
        """umounting loop system from cloop or squashfs system."""

        devs = self.devs
        devs.reverse()
        mountpoints = self.mountpoints
        mountpoints.reverse()

        for mountpoint in mountpoints:
            if not misc.execute("umount", mountpoint):
                raise install_misc.InstallStepError("Failed to unmount %s" % mountpoint)
        for dev in devs:
            if dev != "" and dev != "unused" and not misc.execute("losetup", "-d", dev):
                raise install_misc.InstallStepError("Failed to detach loopback device %s" % dev)
开发者ID:27Paolo,项目名称:ubiquity,代码行数:14,代码来源:install.py

示例8: umount_source

    def umount_source(self):
        """umounting loop system from cloop or squashfs system."""

        devs = self.devs
        devs.reverse()
        mountpoints = self.mountpoints
        mountpoints.reverse()

        for mountpoint in mountpoints:
            if not misc.execute('umount', mountpoint):
                raise install_misc.InstallStepError("Failed to unmount %s" % mountpoint)
        for dev in devs:
            if (dev != '' and dev != 'unused' and
                not misc.execute('losetup', '-d', dev)):
                raise install_misc.InstallStepError(
                    "Failed to detach loopback device %s" % dev)
开发者ID:Alberto-Beralix,项目名称:Beralix,代码行数:16,代码来源:install.py

示例9: install

 def install(self, target, progress, *args, **kwargs):
     progress.info('ubiquity/install/locales')
     rv = plugin.InstallPlugin.install(
         self, target, progress, *args, **kwargs)
     if not rv:
         if 'UBIQUITY_OEM_USER_CONFIG' not in os.environ:
             # Start using the newly-generated locale, if possible.
             try:
                 locale.setlocale(locale.LC_ALL, '')
             except locale.Error:
                 pass
         # fontconfig configuration needs to be adjusted based on the
         # selected locale (from language-selector-common.postinst). Ignore
         # errors.
         misc.execute(
             'chroot', target, 'fontconfig-voodoo',
             '--auto', '--force', '--quiet')
     return rv
开发者ID:johannesthoma,项目名称:ubiquity,代码行数:18,代码来源:ubi-language.py

示例10: __init__

 def __init__(self):
     self.suffix = misc.dmimodel()
     if self.suffix:
         self.suffix = '-%s' % self.suffix
     else:
         if misc.execute("laptop-detect"):
             self.suffix = '-laptop'
         else:
             self.suffix = '-desktop'
     self.allow_password_empty = False
开发者ID:pkt,项目名称:ubiquity.squibby,代码行数:10,代码来源:ubi-usersetup.py

示例11: mount_one_image

    def mount_one_image(self, fsfile, mountpoint=None):
        if os.path.splitext(fsfile)[1] == '.cloop':
            blockdev_prefix = 'cloop'
        elif os.path.splitext(fsfile)[1] == '.squashfs':
            blockdev_prefix = 'loop'

        if blockdev_prefix == '':
            raise install_misc.InstallStepError(
                "No source device found for %s" % fsfile)

        dev = ''
        sysloops = sorted([x for x in os.listdir('/sys/block')
                           if x.startswith(blockdev_prefix)])
        for sysloop in sysloops:
            try:
                with open(os.path.join('/sys/block', sysloop,
                                       'size')) as sysloopf:
                    sysloopsize = sysloopf.readline().strip()
                if sysloopsize == '0':
                    if osextras.find_on_path('udevadm'):
                        udevinfo_cmd = ['udevadm', 'info']
                    else:
                        udevinfo_cmd = ['udevinfo']
                    udevinfo_cmd.extend(
                        ['-q', 'name', '-p', os.path.join('/block', sysloop)])
                    with open('/dev/null') as devnull:
                        udevinfo = subprocess.Popen(
                            udevinfo_cmd, stdout=subprocess.PIPE,
                            stderr=devnull, universal_newlines=True)
                    devbase = udevinfo.communicate()[0]
                    if udevinfo.returncode != 0:
                        devbase = sysloop
                    dev = '/dev/%s' % devbase
                    break
            except:
                continue

        if dev == '':
            raise install_misc.InstallStepError(
                "No loop device available for %s" % fsfile)

        misc.execute('losetup', dev, fsfile)
        if mountpoint is None:
            mountpoint = '/var/lib/ubiquity/%s' % sysloop
        if not os.path.isdir(mountpoint):
            os.mkdir(mountpoint)
        if not misc.execute('mount', dev, mountpoint):
            misc.execute('losetup', '-d', dev)
            misc.execute('mount', '-o', 'loop', fsfile, mountpoint)
            dev = 'unused'

        return (dev, mountpoint)
开发者ID:Sunderland93,项目名称:ubiquity,代码行数:52,代码来源:install.py

示例12: mount_one_image

    def mount_one_image(self, fsfile, mountpoint=None):
        if os.path.splitext(fsfile)[1] == ".cloop":
            blockdev_prefix = "cloop"
        elif os.path.splitext(fsfile)[1] == ".squashfs":
            blockdev_prefix = "loop"

        if blockdev_prefix == "":
            raise install_misc.InstallStepError("No source device found for %s" % fsfile)

        dev = ""
        sysloops = sorted([x for x in os.listdir("/sys/block") if x.startswith(blockdev_prefix)])
        for sysloop in sysloops:
            try:
                with open(os.path.join("/sys/block", sysloop, "size")) as sysloopf:
                    sysloopsize = sysloopf.readline().strip()
                if sysloopsize == "0":
                    if osextras.find_on_path("udevadm"):
                        udevinfo_cmd = ["udevadm", "info"]
                    else:
                        udevinfo_cmd = ["udevinfo"]
                    udevinfo_cmd.extend(["-q", "name", "-p", os.path.join("/block", sysloop)])
                    with open("/dev/null") as devnull:
                        udevinfo = subprocess.Popen(
                            udevinfo_cmd, stdout=subprocess.PIPE, stderr=devnull, universal_newlines=True
                        )
                    devbase = udevinfo.communicate()[0]
                    if udevinfo.returncode != 0:
                        devbase = sysloop
                    dev = "/dev/%s" % devbase
                    break
            except:
                continue

        if dev == "":
            raise install_misc.InstallStepError("No loop device available for %s" % fsfile)

        misc.execute("losetup", dev, fsfile)
        if mountpoint is None:
            mountpoint = "/var/lib/ubiquity/%s" % sysloop
        if not os.path.isdir(mountpoint):
            os.mkdir(mountpoint)
        if not misc.execute("mount", dev, mountpoint):
            misc.execute("losetup", "-d", dev)
            misc.execute("mount", "-o", "loop", fsfile, mountpoint)
            dev = "unused"

        return (dev, mountpoint)
开发者ID:27Paolo,项目名称:ubiquity,代码行数:47,代码来源:install.py

示例13: apply_keyboard

def apply_keyboard():
    """Set the keyboard layout to the default layout for the language selected.

    If a user wants a different layout, they can be reasonably expected to
    change it in System -> Preferences -> Keyboard.
    """

    # Mostly taken from ubi-console-setup.

    # We need to get rid of /etc/default/keyboard, or keyboard-configuration
    # will think it's already configured and behave differently. Try to save
    # the old file for interest's sake, but it's not a big deal if we can't.
    osextras.unlink_force('/etc/default/keyboard.pre-ubiquity')
    try:
        os.rename('/etc/default/keyboard',
                  '/etc/default/keyboard.pre-ubiquity')
    except OSError:
        osextras.unlink_force('/etc/default/keyboard')

    import debconf
    dccomm = subprocess.Popen(['debconf-communicate',
                               '-fnoninteractive', 'ubiquity'],
                              stdin=subprocess.PIPE,
                              stdout=subprocess.PIPE, close_fds=True,
                              universal_newlines=True)
    try:
        dc = debconf.Debconf(read=dccomm.stdout, write=dccomm.stdin)
        try:
            # Make sure debconf doesn't do anything with crazy "preseeded"
            # answers to these questions. If you want to preseed these, use the
            # *code variants.
            dc.fset('keyboard-configuration/layout', 'seen', 'false')
            dc.fset('keyboard-configuration/variant', 'seen', 'false')
            dc.fset('keyboard-configuration/model', 'seen', 'false')
            dc.fset('console-setup/codeset47', 'seen', 'false')
        except debconf.DebconfError:
            return
    finally:
        dccomm.stdin.close()
        dccomm.wait()

    # Accept all the defaults, given the preseeded language.
    child_env = dict(os.environ)
    child_env['OVERRIDE_ALLOW_PRESEEDING'] = '1'
    subprocess.call(['dpkg-reconfigure', '-fnoninteractive',
                     'keyboard-configuration'],
                    env=child_env)
    misc.execute('setupcon', '--save-only')
    # Reprocess /lib/udev/rules.d/64-xorg-xkb.rules
    misc.execute('udevadm', 'trigger', '--subsystem-match=input',
                 '--action=change')
    misc.execute('udevadm', 'settle')
开发者ID:xifeiwu,项目名称:workcode,代码行数:52,代码来源:ubiquity.py

示例14: chrex

def chrex(target, *args):
    """executes commands on chroot system (provided by *args)."""
    return misc.execute('chroot', target, *args)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:3,代码来源:install_misc.py

示例15: __init__

 def __init__(self):
     self.laptop = execute("laptop-detect")
     self.allow_password_empty = False
开发者ID:guadalinex-archive,项目名称:guadalinex-v7,代码行数:3,代码来源:ubi-usersetup.py


注:本文中的ubiquity.misc.execute函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。