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


Python os.execlp方法代码示例

本文整理汇总了Python中os.execlp方法的典型用法代码示例。如果您正苦于以下问题:Python os.execlp方法的具体用法?Python os.execlp怎么用?Python os.execlp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


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

示例1: spawn

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def spawn(argv, master_read=_read, stdin_read=_read):
    """Create a spawned process."""
    if type(argv) == type(''):
        argv = (argv,)
    pid, master_fd = fork()
    if pid == CHILD:
        os.execlp(argv[0], *argv)
    try:
        mode = tty.tcgetattr(STDIN_FILENO)
        tty.setraw(STDIN_FILENO)
        restore = 1
    except tty.error:    # This is the same as termios.error
        restore = 0
    try:
        _copy(master_fd, master_read, stdin_read)
    except (IOError, OSError):
        if restore:
            tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)

    os.close(master_fd) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:pty.py

示例2: run

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def run(command):
    child_pid = os.fork()
    if child_pid == 0:
        os.execlp(command[0], *command)
    else:
        while True:
            try:
                os.waitpid(child_pid, 0)
            except OSError as error:
                if error.errno == errno.ECHILD:
                    # No child processes.
                    # It has exited already.
                    break
                elif error.errno == errno.EINTR:
                    # Interrupted system call.
                    # This happens when resizing the terminal.
                    pass
                else:
                    # An actual error occurred.
                    raise 
开发者ID:claranet,项目名称:ssha,代码行数:22,代码来源:ssh.py

示例3: create_execl

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def create_execl(original_name):

    def new_execl(path, *args):
        """
        os.execl(path, arg0, arg1, ...)
        os.execle(path, arg0, arg1, ..., env)
        os.execlp(file, arg0, arg1, ...)
        os.execlpe(file, arg0, arg1, ..., env)
        """
        if _get_apply_arg_patching():
            args = patch_args(args, is_exec=True)
            send_process_created_message()

        return getattr(os, original_name)(path, *args)

    return new_execl 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:18,代码来源:pydev_monkey.py

示例4: _parse

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def _parse(self, parser):
        options, args = parser.parse_args()

        if not options.allow_root and self._is_root():
            parser.error(
                "running as root - " +
                "run as a different user or specify the --allow-root " +
                "command line option")

        if options.python is not None:
            os.execlp(options.python, options.python, sys.argv[0], *args)
        if sys.version_info < (2, 6):
            version = platform.python_version()
            parser.error(
                "this tool requires python >= 2.6 " +
                "(you are running python " + version + "), " +
                "use the option -p/--python to define a suitable python " +
                "executable")

        return options, args 
开发者ID:abusesa,项目名称:abusehelper,代码行数:22,代码来源:botnet.py

示例5: __call__

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def __call__(self, *objs):
        if self._fo is None:
            masterfd, slavefd = os.openpty()
            pid = os.fork()
            if pid: # parent
                os.close(masterfd)
                self._fo = os.fdopen(slavefd, "w+b", 0)
                if self._do_stderr:
                    os.close(2)
                    os.dup2(slavefd, 2)
            else: # child
                os.close(slavefd)
                os.execlp("urxvt", "urxvt", "-pty-fd", str(masterfd))
        fo = self._fo
        fo.write("{}: ".format(datetime.now()).encode("utf-8"))
        lo = len(objs) - 1
        for i, o in enumerate(objs):
            fo.write(repr(o).encode("utf-8"))
            if i < lo:
                fo.write(b", ")
        fo.write(b"\n")


# automatic, lazy construction of DEBUG object 
开发者ID:kdart,项目名称:pycopia,代码行数:26,代码来源:logwindow.py

示例6: __init__

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def __init__(self):
        masterfd, slavefd = os.openpty()
        pid = os.fork()
        if pid: # parent
            os.close(masterfd)
            self._fo = os.fdopen(slavefd, "w+", 0)
        else: # child
            os.close(slavefd)
            os.execlp("urxvt", "urxvt", "-pty-fd", str(masterfd))
        self.mode = "rw"
        self.closed = 0
        self.softspace = 0
        # reading methods
        self.read = self._fo.read
        self.readline = self._fo.readline
        self.readlines = self._fo.readlines
        # writing methods
        self.write = self._fo.write
        self.flush = self._fo.flush
        self.writelines = self._fo.writelines 
开发者ID:kdart,项目名称:pycopia,代码行数:22,代码来源:IOurxvt.py

示例7: spawn

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def spawn(argv, master_read=_read, stdin_read=_read):
    """Create a spawned process."""
    if type(argv) == type(''):
        argv = (argv,)
    pid, master_fd = fork()
    if pid == CHILD:
        os.execlp(argv[0], *argv)
    try:
        mode = tty.tcgetattr(STDIN_FILENO)
        tty.setraw(STDIN_FILENO)
        restore = 1
    except tty.error:    # This is the same as termios.error
        restore = 0
    try:
        _copy(master_fd, master_read, stdin_read)
    except OSError:
        if restore:
            tty.tcsetattr(STDIN_FILENO, tty.TCSAFLUSH, mode)

    os.close(master_fd)
    return os.waitpid(pid, 0)[1] 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:23,代码来源:pty.py

示例8: main

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def main(argv=None):
    args = parse_paasta_api_args()

    if args.debug:
        os.environ["PAASTA_API_DEBUG"] = "1"

    if args.soa_dir:
        os.environ["PAASTA_API_SOA_DIR"] = args.soa_dir

    if args.cluster:
        os.environ["PAASTA_API_CLUSTER"] = args.cluster

    os.execlp(
        os.path.join(sys.exec_prefix, "bin", "gunicorn"),
        "gunicorn",
        "-w",
        "4",
        "--bind",
        f":{args.port}",
        "paasta_tools.api.api:application",
    ) 
开发者ID:Yelp,项目名称:paasta,代码行数:23,代码来源:api.py

示例9: xserver_start

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def xserver_start(display, executable='Xvfb', authfile=None):
    pid = os.fork()
    if pid != 0:
        return pid
    if authfile is None:
        authfile = os.devnull
    # This will make the xserver send us a SIGUSR1 when ready.
    signal.signal(signal.SIGUSR1, signal.SIG_IGN)
    cmd = [
        executable,
        '-auth', authfile,
        '-noreset',
        display,
    ]
    print('starting xserver: `{0}`'.format(' '.join(cmd)))
    os.execlp(cmd[0], *cmd) 
开发者ID:python-xlib,项目名称:python-xlib,代码行数:18,代码来源:runtests.py

示例10: default_bottom_halves_after_sync

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def default_bottom_halves_after_sync(self, *args, **kwargs):
        if self.func is None:
            if not self.nscmd:
                self.nscmd = [find_shell()]
            elif not isinstance(self.nscmd, list):
                self.nscmd = [self.nscmd]
            if "pid" not in self.namespaces:
                args = self.nscmd
            elif self.init_prog is not None:
                args = [self.init_prog] + self.nscmd
            else:
                args = [sys.executable, self.my_init, "--skip-startup-files",
                        "--skip-runit", "--quiet"] + self.nscmd
            os.execlp(args[0], *args)
        else:
            if hasattr(self.func, '__call__'):
                self.func(*args, **kwargs)
            else:
                raise NamespaceSettingError() 
开发者ID:procszoo,项目名称:procszoo,代码行数:21,代码来源:__init__.py

示例11: psql

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def psql(host, app_name):
    r = requests.get('%s/api/apps/%s/databases' % (host, quote(app_name.encode('utf-8'))), headers = {
        'Content-Type': 'application/json',
    })
    if r.status_code != 200:
        if r.status_code == 401:
            raise auth.AuthException()
        raise Exception(r.text)
    else:
        data = json.loads(r.text)["data"]
        urls = list(filter(lambda d: d["state"] == "AVAILABLE", data))
        if len(urls) > 1:
            # TODO: allow user to specify database
            click.echo("Found more than one database, using: %s" % urls[0]["id"])
        elif len(urls) < 1:
            click.echo("Sorry, no databases found.")
        else:
            url = urls[0]["url"]
            try:
                os.execlp("psql", "psql", url)
            except OSError as e:
                if e.errno == errno.ENOENT:
                    raise Exception("Sorry, we could not find psql. Try installing it and try again.")
                else:
                    raise 
开发者ID:gigalixir,项目名称:gigalixir-cli,代码行数:27,代码来源:database.py

示例12: run

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def run(options):
        try:
            radl = ClusterStore.load(options.clustername)
            front_system = radl.get(system("front"))
            ssh_port = get_out_port(radl, 22)
            if front_system.getValue("disk.0.os.credentials.private_key"):
                ops = CmdSsh._connect_key(front_system, ssh_port)
            else:
                ops = CmdSsh._connect_password(front_system, ssh_port)
            if options.sshcommand:
                ops.extend(options.sshcommand)
            if options.show_only:
                CLI.display(" ".join(ops))
                sys.exit(0)
            os.execlp(ops[0], *ops)
        except OSError as e:
            CLI.display("Error connecting to cluster '%s': %s\n"
                        "Probably 'sshpass' or 'ssh' program is not installed!" % (options.clustername, str(e)),
                        level=logging.ERROR)
            sys.exit(1)
        except Exception as e:
            CLI.display("Error connecting to cluster '%s': %s" % (options.clustername, str(e)),
                        level=logging.ERROR)
            sys.exit(1) 
开发者ID:grycap,项目名称:ec3,代码行数:26,代码来源:ec3.py

示例13: check_sudo

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def check_sudo():
    if os.geteuid():
        args = [sys.executable] + sys.argv
        os.execlp('sudo', 'sudo', *args) 
开发者ID:ideamark,项目名称:breadbot,代码行数:6,代码来源:setup.py

示例14: patch_new_process_functions_with_warning

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def patch_new_process_functions_with_warning():
    monkey_patch_os('execl', create_warn_multiproc)
    monkey_patch_os('execle', create_warn_multiproc)
    monkey_patch_os('execlp', create_warn_multiproc)
    monkey_patch_os('execlpe', create_warn_multiproc)
    monkey_patch_os('execv', create_warn_multiproc)
    monkey_patch_os('execve', create_warn_multiproc)
    monkey_patch_os('execvp', create_warn_multiproc)
    monkey_patch_os('execvpe', create_warn_multiproc)
    monkey_patch_os('spawnl', create_warn_multiproc)
    monkey_patch_os('spawnle', create_warn_multiproc)
    monkey_patch_os('spawnlp', create_warn_multiproc)
    monkey_patch_os('spawnlpe', create_warn_multiproc)
    monkey_patch_os('spawnv', create_warn_multiproc)
    monkey_patch_os('spawnve', create_warn_multiproc)
    monkey_patch_os('spawnvp', create_warn_multiproc)
    monkey_patch_os('spawnvpe', create_warn_multiproc)
    monkey_patch_os('posix_spawn', create_warn_multiproc)

    if not IS_JYTHON:
        if not IS_WINDOWS:
            monkey_patch_os('fork', create_warn_multiproc)
            try:
                import _posixsubprocess
                monkey_patch_module(_posixsubprocess, 'fork_exec', create_warn_fork_exec)
            except ImportError:
                pass
        else:
            # Windows
            try:
                import _subprocess
            except ImportError:
                import _winapi as _subprocess
            monkey_patch_module(_subprocess, 'CreateProcess', create_CreateProcessWarnMultiproc) 
开发者ID:fabioz,项目名称:PyDev.Debugger,代码行数:36,代码来源:pydev_monkey.py

示例15: upload_zmodem

# 需要导入模块: import os [as 别名]
# 或者: from os import execlp [as 别名]
def upload_zmodem(self, filename):
        """Call external ZMODEM program to upload a file.
        Return an ExitStatus object that should indicate success or failure.
        """
        sockfd = self.sock.fileno()
        pread, pwrite = os.pipe()
        pid = os.fork()
        if pid == 0: # child
            os.dup2(sockfd, 0)
            os.dup2(sockfd, 1)
            os.dup2(pwrite, 2)
            os.close(pread)
            os.close(pwrite)
            for fd in xrange(3,64):
                try:
                    os.close(fd)
                except:
                    pass
            os.write(0, "rz -e -q -s +30\r") # needed with -e flag on sz
            os.execlp("sz", "sz", "-e", "-q", "-y", "-L", "128", filename)
            os._exit(1) # not normally reached
        # parent
        os.close(pwrite)
        while True:
            wpid, es = os.waitpid(pid, 0)
            if wpid == pid:
                break
        errout = os.read(pread, 4096)
        es = ExitStatus("sz {}".format(filename), es)
        es.output = errout
        return es 
开发者ID:kdart,项目名称:pycopia,代码行数:33,代码来源:telnet.py


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