Python os.execl() Examples
The following are 30
code examples of os.execl().
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: platform.py From BitTorrent with GNU General Public License v3.0 | 8 votes |
def spawn(*args): if os.name == 'nt': # do proper argument quoting since exec/spawn on Windows doesn't bargs = args args = [] for a in bargs: if not a.startswith("/"): a.replace('"', '\"') a = '"%s"' % a args.append(a) argstr = ' '.join(args[1:]) # use ShellExecute instead of spawn*() because we don't want # handles (like the controlsocket) to be duplicated win32api.ShellExecute(0, "open", args[0], argstr, None, 1) # 1 == SW_SHOW else: if os.access(args[0], os.X_OK): forkback = os.fork() if forkback == 0: # BUG: stop IPC! print "execl ", args[0], args os.execl(args[0], *args) else: #BUG: what should we do here? pass
Example #2
Source File: session.py From brave with Apache License 2.0 | 6 votes |
def end(self, restart=False, use_current_config=False): ''' Called when the user has requested the service to end. ''' # If we're restarting, we need to know the arguements used to start us args = sys.argv if restart and use_current_config: args = self._put_current_config_in_args(args) for block_collection in [self.inputs, self.mixers, self.outputs]: for name, block in block_collection.items(): block.set_pipeline_state(Gst.State.NULL) if hasattr(self, 'mainloop'): self.mainloop.quit() if restart: os.execl(sys.executable, sys.executable, *args)
Example #3
Source File: update.py From dongerdong with GNU General Public License v3.0 | 6 votes |
def doit(irc, target, source): commands = ["git fetch", "git rebase --stat --preserve-merges"] for command in commands: child = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE) (out, err) = child.communicate() ret = child.returncode await irc.message(source, "{0} returned code {1}".format(command, ret)) for line in (out + err).splitlines(): await irc.message(source, line.decode("utf-8")) irc.eventloop.schedule(irc.quit, "Updating...") irc.eventloop.schedule(os.execl, sys.executable, sys.executable, *sys.argv)
Example #4
Source File: parent.py From mitogen with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _first_stage(): R,W=os.pipe() r,w=os.pipe() if os.fork(): os.dup2(0,100) os.dup2(R,0) os.dup2(r,101) os.close(R) os.close(r) os.close(W) os.close(w) if sys.platform == 'darwin' and sys.executable == '/usr/bin/python': sys.executable += sys.version[:3] os.environ['ARGV0']=sys.executable os.execl(sys.executable,sys.executable+'(mitogen:CONTEXT_NAME)') os.write(1,'MITO000\n'.encode()) C=_(os.fdopen(0,'rb').read(PREAMBLE_COMPRESSED_LEN),'zip') fp=os.fdopen(W,'wb',0) fp.write(C) fp.close() fp=os.fdopen(w,'wb',0) fp.write(C) fp.close() os.write(1,'MITO001\n'.encode()) os.close(2)
Example #5
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 #6
Source File: manage.py From simplecoin_multi with MIT License | 6 votes |
def forward_coinservs(host): """ Given a hostname, connects to a remote and tunnels all coinserver ports to local ports. Useful for development testing. """ args = [host, "-N"] for currency in currencies.itervalues(): if not currency.coinserv: continue args.append("-L {0}:127.0.0.1:{0}" .format(currency.coinserv.config['port'])) for pp in powerpools.itervalues(): parts = urlparse(pp.monitor_address) if parts.hostname not in ['localhost', '127.0.0.1']: continue args.append("-L {0}:127.0.0.1:{0}".format(parts.port)) current_app.logger.info(("/usr/bin/ssh", "/usr/bin/ssh", args)) os.execl("/usr/bin/ssh", "/usr/bin/ssh", *args)
Example #7
Source File: Chucky.py From Chuckyfix with MIT License | 6 votes |
def restart_program(): python = sys.executable os.execl(python, python, * sys.argv)
Example #8
Source File: userbot.py From userbot with GNU General Public License v3.0 | 6 votes |
def restart(self, *args, git_update=False, pip=False): """ Shoutout to the Userg team for this.""" await self.stop() try: c_p = psutil.Process(os.getpid()) for handler in c_p.open_files() + c_p.connections(): os.close(handler.fd) except Exception as c_e: print(c_e) if git_update: os.system('git reset --hard') os.system('git pull') if pip: os.system('pip install -U -r requirements.txt') os.execl(sys.executable, sys.executable, '-m', self.__class__.__name__.lower()) sys.exit()
Example #9
Source File: prankpy3.py From prankpy3 with GNU General Public License v3.0 | 5 votes |
def restartBot(): print ("[ INFO ] BOT RESETTED") python = sys.executable os.execl(python, python, *sys.argv)
Example #10
Source File: sb.py From sb with GNU General Public License v3.0 | 5 votes |
def restartBot(): print ("[ INFO ] BOT RESETTED") time.sleep(3) python = sys.executable os.execl(python, python, *sys.argv)
Example #11
Source File: pydev_monkey.py From filmkodi with Apache License 2.0 | 5 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) """ import os args = patch_args(args) return getattr(os, original_name)(path, *args) return new_execl
Example #12
Source File: brute.py From HPAS1369 with GNU General Public License v3.0 | 5 votes |
def restart_program(): python = sys.executable os.execl(python, python, * sys.argv) curdir = os.getcwd()
Example #13
Source File: pydev_monkey.py From filmkodi with Apache License 2.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) if sys.platform != 'win32': 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)
Example #14
Source File: context.py From furnace with GNU Lesser General Public License v2.1 | 5 votes |
def do_exec(self, control_read, control_write): logger.debug("Executing {} {}".format(sys.executable, pid1.__file__)) params = json.dumps({ "loglevel": logging.getLevelName(logger.getEffectiveLevel()), "root_dir": self.root_dir, "control_read": control_read, "control_write": control_write, "isolate_networking": self.isolate_networking, "bind_mounts": self.bind_mounts, }, cls=PathEncoder) os.execl(sys.executable, sys.executable, pid1.__file__, params)
Example #15
Source File: lzmcore.py From HPAS1369 with GNU General Public License v3.0 | 5 votes |
def restart_program(): python = sys.executable os.execl(python, python, * sys.argv) curdir = os.getcwd()
Example #16
Source File: qomui_gui.py From qomui with GNU General Public License v3.0 | 5 votes |
def restart_qomui(self): self.kill() self.disconnect_bypass() try: systemctl_check = check_call(["systemctl", "is-active", "--quiet", "qomui"]) if systemctl_check == 0: self.logger.debug("Qomui-service running as systemd service - restarting") self.notify("Qomui", "Restarting Qomui now...", icon="Information") self.dbus_call("restart") os.execl(sys.executable, sys.executable, * sys.argv) else: self.logger.debug("No instance of qomui-service running with systemd found") self.notify( "Restarting qomui-service failed", "Please restart qomui-gui and qomui-service manually", icon="Error" ) except CalledProcessError as e: self.logger.debug("No instance of qomui-service running with systemd found") self.notify( "Restarting qomui-service failed", "Please restart qomui-gui and qomui-service manually", icon="Error" )
Example #17
Source File: bootstrap.py From rhinobot_heroku with MIT License | 5 votes |
def _restart(self, *cmds): # TODO: os.execl pass # Restart with 3.5 if needed
Example #18
Source File: coffeegrindsize.py From coffeegrindsize with MIT License | 5 votes |
def reset_gui(self): python = sys.executable os.execl(python, python, * sys.argv) #Method to quit user interface
Example #19
Source File: HPAS1369.py From HPAS1369 with GNU General Public License v3.0 | 5 votes |
def restart_program(): python = sys.executable os.execl(python, python, * sys.argv) curdir = os.getcwd()
Example #20
Source File: main.py From PiHole-Panel with GNU General Public License v3.0 | 5 votes |
def restart_program(): """Restarts the current program. Note: this function does not return. Any cleanup action (like saving data) must be done before calling this function.""" python = sys.executable os.execl(python, python, * sys.argv) # This function makes the keys in the dictionary human-readable
Example #21
Source File: dwarf.py From Dwarf with GNU General Public License v3.0 | 5 votes |
def _on_restart(): print('restarting dwarf...') os.execl(sys.executable, os.path.abspath(__file__), *sys.argv)
Example #22
Source File: update.py From PhyloSuite with GNU General Public License v3.0 | 5 votes |
def exec_restart(self): # self.label.setText("Update successfully") python = sys.executable os.execl(python, python, *sys.argv)
Example #23
Source File: funcs.py From NotSoBot with MIT License | 5 votes |
def restart_program(self): python = sys.executable os.execl(python, python, * sys.argv)
Example #24
Source File: power_tools.py From BotHub with Apache License 2.0 | 5 votes |
def _(event): if event.fwd_from: return # await asyncio.sleep(2) # await event.edit("Restarting [██░] ...\n`.ping` me or `.helpme` to check if I am online") # await asyncio.sleep(2) # await event.edit("Restarting [███]...\n`.ping` me or `.helpme` to check if I am online") # await asyncio.sleep(2) await event.edit("Restarted. `.ping` me or `.helpme` to check if I am online") await borg.disconnect() # https://archive.is/im3rt os.execl(sys.executable, sys.executable, *sys.argv) # You probably don't need it but whatever quit()
Example #25
Source File: thermostat.py From thermostat with MIT License | 5 votes |
def restart(): log( LOG_LEVEL_STATE, CHILD_DEVICE_NODE, MSG_SUBTYPE_CUSTOM + "/restart", "Thermostat restarting...", single=True ) GPIO.cleanup() if logFile is not None: logFile.flush() os.fsync( logFile.fileno() ) logFile.close() if mqttEnabled: mqttc.disconnect() os.execl( sys.executable, 'python', __file__, *sys.argv[1:] ) # This does not return!!!
Example #26
Source File: app.py From vitrage with Apache License 2.0 | 5 votes |
def build_uwsgi_server(uwsgi): major = str(sys.version_info.major) minor = str(sys.version_info.minor) plugin = ''.join(('python', major, minor)) args = [ "--if-not-plugin", "python", "--plugin", plugin, "--endif", "--http-socket", "%s:%d" % (CONF.api.host, CONF.api.port), "--master", "--enable-threads", "--thunder-lock", "--hook-master-start", "unix_signal:15 gracefully_kill_them_all", "--die-on-term", "--processes", str(math.floor(CONF.api.workers * 1.5)), "--threads", str(CONF.api.workers), "--lazy-apps", "--chdir", "/", "--buffer-size", "65535", "--wsgi-file", wsgi_file(), "--procname-prefix", "vitrage", "--pyargv", " ".join(sys.argv[1:]), ] virtual_env = os.getenv("VIRTUAL_ENV") if virtual_env is not None: args.extend(["-H", os.getenv("VIRTUAL_ENV", ".")]) return os.execl(uwsgi, uwsgi, *args)
Example #27
Source File: please.py From BAJINGANv6 with Apache License 2.0 | 5 votes |
def restart(): ngulang = sys.executable os.execl(ngulang, ngulang, *sys.argv)
Example #28
Source File: payloads.py From byob with GNU General Public License v3.0 | 5 votes |
def restart(self, output='connection'): """ Restart the shell """ try: log("{} failed - restarting in 3 seconds...".format(output)) self.kill() time.sleep(3) os.execl(sys.executable, 'python', os.path.abspath(sys.argv[0]), *sys.argv[1:]) except Exception as e: log("{} error: {}".format(self.restart.__name__, str(e)))
Example #29
Source File: payloads.py From byob with GNU General Public License v3.0 | 5 votes |
def restart(self, output='connection'): """ Restart the shell """ try: log("{} failed - restarting in 3 seconds...".format(output)) self.kill() time.sleep(3) os.execl(sys.executable, 'python', os.path.abspath(sys.argv[0]), *sys.argv[1:]) except Exception as e: log("{} error: {}".format(self.restart.__name__, str(e)))
Example #30
Source File: cogs.py From Discord-SelfBot with MIT License | 5 votes |
def restart(self, ctx): """Restart the SelfBot.""" with open('restart.txt', 'w') as re: re.write(str(ctx.channel.id)) log.info('Restarting....') await ctx.message.edit(content='Good Bye :wave:') await asyncio.sleep(.5) await ctx.message.delete() python = sys.executable os.execl(python, python, *sys.argv)