Python os.execlp() Examples
The following are 30
code examples of os.execlp().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: ssh.py From ssha with MIT License | 7 votes |
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
Example #2
Source File: pty.py From BinderFilter with MIT License | 7 votes |
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)
Example #3
Source File: pty.py From ironpython2 with Apache License 2.0 | 7 votes |
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)
Example #4
Source File: pty.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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)
Example #5
Source File: pty.py From ironpython3 with Apache License 2.0 | 6 votes |
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]
Example #6
Source File: pty.py From datafari with Apache License 2.0 | 6 votes |
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)
Example #7
Source File: pty.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
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)
Example #8
Source File: pty.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
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]
Example #9
Source File: __init__.py From procszoo with GNU General Public License v3.0 | 6 votes |
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()
Example #10
Source File: database.py From gigalixir-cli with MIT License | 6 votes |
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
Example #11
Source File: pty.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
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)
Example #12
Source File: runtests.py From python-xlib with GNU Lesser General Public License v2.1 | 6 votes |
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)
Example #13
Source File: ec3.py From ec3 with Apache License 2.0 | 6 votes |
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)
Example #14
Source File: pty.py From PokemonGo-DesktopMap with MIT License | 6 votes |
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)
Example #15
Source File: pty.py From android_universal with MIT License | 6 votes |
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]
Example #16
Source File: pty.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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)
Example #17
Source File: pty.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
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)
Example #18
Source File: pty.py From Imogen with MIT License | 6 votes |
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]
Example #19
Source File: IOurxvt.py From pycopia with Apache License 2.0 | 6 votes |
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
Example #20
Source File: logwindow.py From pycopia with Apache License 2.0 | 6 votes |
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
Example #21
Source File: botnet.py From abusehelper with MIT License | 6 votes |
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
Example #22
Source File: pty.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
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]
Example #23
Source File: api.py From paasta with Apache License 2.0 | 6 votes |
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", )
Example #24
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 6 votes |
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
Example #25
Source File: pty.py From oss-ftp with MIT License | 6 votes |
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)
Example #26
Source File: pty.py From Computable with MIT License | 6 votes |
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)
Example #27
Source File: run.py From MusicBot with MIT License | 5 votes |
def pyexec(pycom, *args, pycom2=None): pycom2 = pycom2 or pycom os.execlp(pycom, pycom2, *args)
Example #28
Source File: remote_dispatcher.py From polysh with GNU General Public License v2.0 | 5 votes |
def launch_ssh(self, name: str, port: str) -> None: """Launch the ssh command in the child process""" if options.user: name = '%s@%s' % (options.user, name) evaluated = options.ssh % {'host': name, 'port': port} if evaluated == options.ssh: evaluated = '%s %s' % (evaluated, name) os.execlp('/bin/sh', 'sh', '-c', evaluated)
Example #29
Source File: get.py From storybro with MIT License | 5 votes |
def get(config, name, torrent, force): '''Download a model''' installed = config.model_manager.models if torrent is None: if name not in config.model_registry.models: click.echo(f"The model `{name}` wasn't found.") return torrent = config.model_registry.models[name] model = config.model_manager.models.get(name) if model: if not force: click.echo(f"The model `{name}` is already installed. Use -f to force re-download.") return else: shutil.rmtree(model.root_path) click.echo(f"Deleted local model `{name}`. Re-downloading.") click.echo(f"Downloading torrent: {torrent}") os.execlp('aria2c', 'aria2c', "--max-connection-per-server", "16", "--bt-max-peers", "500", "--seed-time", "0", "--summary-interval", "15", "--disable-ipv6", "--split", "64", "-d", config.models_path, torrent, )
Example #30
Source File: pydev_monkey.py From PyDev.Debugger with Eclipse Public License 1.0 | 5 votes |
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)