From 982aa785dc13e686c63c946980e7b7f848ee8e0e Mon Sep 17 00:00:00 2001 From: Peter Gielda Date: Sun, 6 Oct 2019 23:15:24 +0200 Subject: [PATCH] Update sargraph.py. --- sargraph.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sargraph.py b/sargraph.py index 0aa1271..73d7a76 100755 --- a/sargraph.py +++ b/sargraph.py @@ -68,13 +68,17 @@ if len(sys.argv) > 1: with open("data.txt", "r") as f: gpid = int(f.readline().decode().split(", machine:")[0].split("pid: ")[1]) except: - print("Error: cannot find pid.") - sys.exit(1) + print("Warning: cannot find pid. Probably 'data.txt' does not exist.") + gpid = -1 p = subprocess.Popen(["screen", "-S", sid, "-X", "stuff", "q\n"]) while p.poll() is None: time.sleep(0.1) - while pid_running(gpid): - time.sleep(0.25) + if gpid == -1: + print("Waiting 3 seconds.") + time.sleep(3) + else: + while pid_running(gpid): + time.sleep(0.25) elif cmd == "label": print("Adding label '%s' to sargraph session '%s'." % (label, sid)) p = subprocess.Popen(["screen", "-S", sid, "-X", "stuff", "%s\n" % label])