• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python executil.system函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parun

def parun(commands, minheight=DEFAULT_MINHEIGHT, daemon=False, session_name=None):
    if (termcap_get_lines() - len(commands)) / len(commands) >= minheight:
        split = True
    else:
        split = False

    stdin = None
    if not os.isatty(sys.stdin.fileno()):
        stdin = TempFile()
        stdin.write(sys.stdin.read())
        stdin.close()

    # screen wants stdin to be connected to a tty
    os.dup2(sys.stderr.fileno(), sys.stdin.fileno())

    screens = fmt_screens(commands, stdin)
    if split:
        screenrc = "split\nfocus\n".join([ screen + "\n" for screen in screens ])
    else:
        screenrc = "\n".join(screens) + "\n" + "windowlist -b" + "\n"

    screenrc_tmp = TempFile()
    screenrc_tmp.write(screenrc)
    screenrc_tmp.close()

    args = ["-c", screenrc_tmp.path]
    if daemon:
        args += [ "-dm" ]

    if session_name:
        args += [ "-S", session_name ]

    executil.system("screen", *args)
    if daemon:
        time.sleep(1)
开发者ID:lirazsiri,项目名称:parun,代码行数:35,代码来源:parun.py


示例2: get

def get(url, dest):
    """Get file from <url> and save it to <dest>.

    Tries to retrieve <url> from cache, otherwise stores it in
    cache following retrieval.
    """
    url = urllib.unquote(url)
    if url.endswith("/"):
        raise Error("illegal url - can't get a directory")

    if os.path.isdir(dest):
        dest = os.path.join(dest, os.path.basename(url))
    else:
        if dest.endswith("/"):
            raise Error("no such directory: " + dest)

    if os.path.lexists(dest):
        raise Error("won't overwrite already existing file: " + dest)

    cache = Cache()
    cached_path = cache.retrieve(url, dest)
    if cached_path:
        print "* get: retrieved file from cache"
    else:
        print "* get: retrieving file from network..."
        system("curl -L -f %s -o %s" % (mkarg(url), mkarg(dest)))
        cached_path = cache.store(url, dest)

    return cached_path
开发者ID:vinodpanicker,项目名称:ccurl,代码行数:29,代码来源:ccurl.py


示例3: _amitools_cmd

def _amitools_cmd(command, opts):
    amitools_path = _get_amitools_path()
    os.environ["EC2_AMITOOL_HOME"] = amitools_path

    log.debug("amitools_cmd - %s %s", command, opts)
    cmd = os.path.join(amitools_path, 'bin', command)
    executil.system(cmd, *opts)
开发者ID:vinodpanicker,项目名称:buildtasks,代码行数:7,代码来源:s3_bundle.py


示例4: cpp

def cpp(input, cpp_opts=[]):
    """preprocess <input> through cpp -> preprocessed output
       input may be path/to/file or iterable data type
    """
    args = [ "-Ulinux" ]

    for opt, val in cpp_opts:
        args.append(opt + val)

    include_path = os.environ.get('FAB_PLAN_INCLUDE_PATH')
    if include_path:
        for path in include_path.split(':'):
            args.append("-I" + path)

    command = ["cpp", input]
    if args:
        command += args

    trap = stdtrap.StdTrap()
    try:
        executil.system(*command)
    except ExecError, e:
        trap.close()
        trapped_stderr = trap.stderr.read()
        raise ExecError(" ".join(command), e.exitcode, trapped_stderr)
开发者ID:Dude4Linux,项目名称:fab,代码行数:25,代码来源:cpp.py


示例5: index

    def index(self, component, arch):
        component_dir = join(self.pool, component)
        if not exists(join(self.path, component_dir)):
            raise Error('component does not exist', join(self.path, component_dir))

        output_dir = '%s/dists/%s/%s/binary-%s' % (self.path, self.release,
                                                   component, arch)
        if not exists(output_dir):
            os.makedirs(output_dir)

        output = self._archive_cmd('--arch=%s packages' % arch, component_dir)
        fh = file(join(output_dir, 'Packages'), "w")
        fh.write(output)
        if output:
            # append newline if packages were in pool
            print >> fh
        fh.close()

        executil.system("gzip -c %s > %s" % (join(output_dir, 'Packages'),
                                             join(output_dir, 'Packages.gz')))

        executil.system("bzip2 -c %s > %s" % (join(output_dir, 'Packages'),
                                              join(output_dir, 'Packages.bz2')))

        fh = file(join(output_dir, 'Release'), "w")
        print >> fh, "Origin: %s" % self.origin
        print >> fh, "Label: %s" % self.origin
        print >> fh, "Archive: %s" % self.release
        print >> fh, "Version: %s" % self.version
        print >> fh, "Component: %s" % component
        print >> fh, "Architecture: %s" % arch
        fh.close()
开发者ID:vinodpanicker,项目名称:repo,代码行数:32,代码来源:repo.py


示例6: run

    def run(self, passphrase, creds=None, debug=False):
        sys.stdout.flush()

        if creds:
            os.environ['AWS_ACCESS_KEY_ID'] = creds.accesskey
            os.environ['AWS_SECRET_ACCESS_KEY'] = creds.secretkey
            os.environ['X_AMZ_SECURITY_TOKEN'] = ",".join([creds.producttoken, creds.usertoken])

        if PATH_DEPS_BIN not in os.environ['PATH'].split(':'):
            os.environ['PATH'] = PATH_DEPS_BIN + ':' + os.environ['PATH']

        if PATH_DEPS_PYLIB:
            os.environ['PYTHONPATH'] = PATH_DEPS_PYLIB

        os.environ['PASSPHRASE'] = passphrase

        if debug:
            import executil
            shell = os.environ.get("SHELL", "/bin/bash")
            if shell == "/bin/bash":
                shell += " --norc"
            executil.system(shell)

        child = Popen(self.command)
        del os.environ['PASSPHRASE']

        exitcode = child.wait()
        if exitcode != 0:
            raise Error("non-zero exitcode (%d) from backup command: %s" % (exitcode, str(self)))
开发者ID:84danielwhite,项目名称:tklbam,代码行数:29,代码来源:duplicity.py


示例7: _is_alive

    def _is_alive(self):
        try:
            system('mysqladmin -s ping >/dev/null 2>&1')
        except ExecError:
            return False

        return True
开发者ID:ghoulmann,项目名称:Psiphon-TKLPatch,代码行数:7,代码来源:mysqlconf.py


示例8: ebsmount_add

def ebsmount_add(devname, mountdir):
    """ebs device attached"""

    matching_devices = []
    for device in udevdb.query():
        if device.name.startswith(basename(devname)):
            matching_devices.append(device)

    for device in matching_devices:
        devpath = join('/dev', device.name)
        mountpath = join(mountdir, device.env.get('ID_FS_UUID', devpath[-1])[:4])
        mountoptions = ",".join(config.mountoptions.split())
        scriptpath = join(mountpath, ".ebsmount")

        filesystem = device.env.get('ID_FS_TYPE', None)
        if not filesystem:
            log(devname, "could not identify filesystem: %s" % devpath)
            continue

        if not filesystem in config.filesystems.split():
            log(devname, "filesystem (%s) not supported: %s" % (filesystem,devpath))
            continue

        if is_mounted(devpath):
            log(devname, "already mounted: %s" % devpath)
            continue

        mount(devpath, mountpath, mountoptions)
        log(devname, "mounted %s %s (%s)" % (devpath, mountpath, mountoptions))

        if exists(scriptpath):
            cmd = "run-parts --verbose --exit-on-error %s" % scriptpath
            cmd += " 2>&1 | tee -a %s" % config.logfile
            system(cmd)
开发者ID:shevron,项目名称:ebsmount,代码行数:34,代码来源:ebsmount.py


示例9: update

def update(section, name, value):
    config_path = "/var/www/piwik/config/config.ini.php"
    if not os.path.exists(config_path):
        raise Error("config file does not exist: %s" % config_path)

    config_new = []
    in_section = False
    seen = False
    for line in file(config_path).readlines():
        line = line.rstrip()
        if line.startswith("["):
            if line == section:
                in_section = True
            else:
                in_section = False

        if in_section and line.startswith("%s =" % name) and seen == False:
            line = "%s = \"%s\"" % (name, value)
            seen = True

        config_new.append(line)

    # write out updated config
    file(config_path, "w").write("\n".join(config_new) + "\n")

    # set ownership and permissions
    system("chown www-data:www-data %s" % config_path)
    system("chmod 640 %s" % config_path)
开发者ID:gns-support,项目名称:piwik,代码行数:28,代码来源:piwik_config.py


示例10: _checkout

 def _checkout(self, arg):
     orig_cwd = os.getcwd()
     os.chdir(self.git.path)
     try:
         system("sumo-checkout", arg)
     finally:
         os.chdir(orig_cwd)
开发者ID:vinodpanicker,项目名称:verseek,代码行数:7,代码来源:verseek.py


示例11: umount

    def umount(self):
        if self.mounted_devpts_myself:
            executil.system("umount", self.paths.dev.pts)
            self.mounted_devpts_myself = False

        if self.mounted_proc_myself:
            executil.system("umount", self.paths.proc)
            self.mounted_proc_myself = False
开发者ID:OnGle,项目名称:turnkey-pylib,代码行数:8,代码来源:chroot.py


示例12: mount

    def mount(self):
        if not self._is_mounted(self.paths.proc):
            executil.system("mount -t proc", "proc-chroot", self.paths.proc)
            self.mounted_proc_myself = True

        if not self._is_mounted(self.paths.dev.pts):
            executil.system("mount -t devpts", "devpts-chroot", self.paths.dev.pts)
            self.mounted_devpts_myself = True
开发者ID:OnGle,项目名称:turnkey-pylib,代码行数:8,代码来源:chroot.py


示例13: __init__

    def __init__(self):
        system("mkdir -p /var/run/mysqld")
        system("chown mysql:root /var/run/mysqld")

        self.selfstarted = False
        if not self._is_alive():
            self._start()
            self.selfstarted = True
开发者ID:ghoulmann,项目名称:Psiphon-TKLPatch,代码行数:8,代码来源:mysqlconf.py


示例14: _start

    def _start(self):
        system("mysqld --skip-networking >/dev/null 2>&1 &")
        for i in range(6):
            if self._is_alive():
                return

            time.sleep(1)

        raise Error("could not start mysqld")
开发者ID:ghoulmann,项目名称:Psiphon-TKLPatch,代码行数:9,代码来源:mysqlconf.py


示例15: _system

 def _system(self, command, *args):
     os.setuid(self.euid)
     try:
         try:
             system(command, *args)
         except ExecError, e:
             raise Error(e)
     finally:
         os.setreuid(self.uid, self.euid)
开发者ID:qrntz,项目名称:useraufs,代码行数:9,代码来源:useraufs.py


示例16: unconfigure_if

def unconfigure_if(ifname):
    try:
        ifdown(ifname)
        interfaces = EtcNetworkInterfaces()
        interfaces.set_manual(ifname)
        executil.system("ifconfig %s 0.0.0.0" % ifname)
        ifup(ifname)
    except Exception, e:
        return str(e)
开发者ID:Avamagic,项目名称:confconsole,代码行数:9,代码来源:ifutil.py


示例17: mount

def mount(devpath, mountpath, options=None):
    """mount devpath to mountpath with specified options (creates mountpath)"""
    if not os.path.exists(mountpath):
        mkdir_parents(mountpath)

    if options:
        executil.system("mount", "-o", options, devpath, mountpath)
    else:
        executil.system("mount", devpath, mountpath)
开发者ID:noderabbit-team,项目名称:ebsmount,代码行数:9,代码来源:utils.py


示例18: _shutdown

    def _shutdown(self, text, opt):
        if self.console.yesno(text) == self.OK:
            self.running = False
            cmd = "shutdown %s now" % opt
            fgvt = os.environ.get("FGVT")
            if fgvt:
                cmd = "chvt %s; " % fgvt + cmd
            executil.system(cmd)

        return "advanced"
开发者ID:CompuTEK-Industries,项目名称:confconsole,代码行数:10,代码来源:confconsole.py


示例19: luksOpen

def luksOpen(device, key):
    """open a luks encrypted <device> using <key> -> _LuksOpened(map, keyslot)
    
    <key> can be either a filename or a passphrase
    """

    try:
        system("cryptsetup isLuks", device)
    except ExecError, e:
        raise Error(e)
开发者ID:turnkeylinux,项目名称:luks,代码行数:10,代码来源:cryptsetup.py


示例20: main

def main():
    interface = ""
    if not interface:
 	d = dialog.Dialog(dialog="dialog")
    	d.add_persistent_args(["--backtitle", "Insta-Snorby - First boot configuration"])
	interface = interface_menu(d,"Please select an interface to monitor", iface_list())
	system("echo " + interface)
	system("sed -i 's/eth0/%s/g' /etc/snort/barnyard2.conf" % interface)
	system("sed -i 's/eth0/%s/g' /usr/lib/inithooks/everyboot.d/88snortstart" % interface)
	system("sed -i 's/eth0/%s/g' /root/pulledpork-0.6.1/etc/pulledpork.conf" % interface)
	system("sed -i 's/eth0/%s/g' /root/openfpc-0.6-314/etc/openfpc-default.conf" % interface)
开发者ID:Snorby,项目名称:insta-snorby,代码行数:11,代码来源:interface_select.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python executor.execute函数代码示例发布时间:2022-05-24
下一篇:
Python executil.getoutput函数代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap