def instance_already_running(): try: sh.pgrep("gmi") sh.pgrep("notmuch") return True except sh.ErrorReturnCode_1: pass
def estimate_ngram_pids(): """ Returns a set of all estimate-ngram pids belonging to this process. """ pid = os.getpid() output = pgrep('estimate-ngram', parent=pid, _ok_code=[0,1]) return set(int(pid) for pid in output.rstrip().split())
def estimate_ngram_pids(): """ Returns a set of all estimate-ngram pids belonging to this process. """ pid = os.getpid() output = pgrep('estimate-ngram', parent=pid, _ok_code=[0, 1]) return set(int(pid) for pid in output.rstrip().split())
def stop(self): print('Stopping service: ', self.name) if settings.TEST_SERVER == 'localhost': pids = sh.pgrep('-f', 'manage.py runserver', _ok_code=[0, 1]) for pid in pids: sh.kill(pid.rstrip()) else: sh.ssh(settings.TEST_SERVER, 'sudo supervisorctl stop all')
def KillProcess(): try: pid = sh.pgrep(sh.ps("aux"), 'minergate-cli') for a in pid.split('\n'): if a != '': os.kill(int(a), signal.SIGKILL) return True except: return False
def get_remote_ssh_pid(self): socket = self.get_socket() pgrep_search = f'ssh -Nf -L {socket}' try: proc = sh.pgrep('-f', pgrep_search) except sh.ErrorReturnCode_1: raise ErrorMessage('remote ssh process not found') return int(proc.stdout.decode('utf8').strip())
def restart(): pids = set(sh.pgrep("-f", "borgmacator").stdout.decode().splitlines()) pids.discard(str(os.getpid())) if pids: sh.kill(*pids) p = sh.dbus_send( "--session", "--type=method_call", "--dest=org.gnome.Shell", "/org/gnome/Shell", "org.gnome.Shell.Eval", "string:'const Util = imports.misc.util; Util.spawnCommandLine(\"%s\");'" % sh.which("borgmacator")) print("Run the following if borgmacator didn't start") print(b" ".join(p.cmd).decode())
def projectm_toggle(qtile): """ Toggle the prescence of a ProjetM visualizer """ try: pid = str(pgrep('projectM')).strip() except sh.ErrorReturnCode: qtile.cmd_spawn('projectM-pulseaudio') else: window = [_ for _ in qtile.windowMap.values() if _.name == 'projectM'][0] window.kill()
def CheckProcess(): try: pid = sh.pgrep(sh.ps("aux"), 'minergate-cli') return True except: return False
data["data"][username]["last_processed"] = time.time() else: data["data"][username] = { "notify": True, "last_processed": time.time() } tobenotified.append(display) print("[+] {} ({}) {}".format(display, game, time.strftime("%Y-%m-%d %H:%M:%S"))) online_display = [i["channel"]["display_name"] for i in online] tobenotified = [i for i in tobenotified if i in online_display] blocked = False for pname in blocking: try: sh.pgrep(pname) blocked = True if len(tobenotified) > 0: print("{} notifications blocked by {}".format(len(tobenotified), pname)) break except sh.ErrorReturnCode_1: pass for pname in required: try: sh.pgrep(pname) except sh.ErrorReturnCode_1: blocked = True print(pname, "required") break if not blocked and tobenotified: