Added pause & resume

master
Ringo Wantanabe 6 years ago
parent dd16b8e3f0
commit c25b6ef82b
No known key found for this signature in database
GPG Key ID: C1C1CD34CF2907B2

@ -370,6 +370,7 @@ class Daemon(threading.Thread):
self.buf = buf
self.running=True
self.info = info
self.paused=False
threading.Thread.__init__(self)
def _get(self,con, fr, ca=False):
if ca:
@ -403,6 +404,12 @@ class Daemon(threading.Thread):
elif cmd.uCommand == Command.CMD_INFO: #information
log("[daemon]: Recieved info")
con.send(json.dumps(self.info).encode("ascii"))
elif cmd.uCommand == Command.CMD_PAUSE:
log("[daemon]: Recieved pause")
self.paused = True
elif cmd.uCommand == Command.CMD_RESUME:
log("[daemon]: Recieved resume")
self.paused = False
else: #unknwon command
log("[daemon]: Recieved unknown command")
pass
@ -466,6 +473,10 @@ if args.daemon!=None:
try:
while runForever or daemon.running:
if(not runForever) and daemon.paused:
log("Skipping rotation")
else:
log("Reading threads for %s from %d" % (args.board, last))
posts = parse_page(args.api, args.board, "1", last)
last = pnomax(last, posts)

@ -28,6 +28,8 @@ def parsecmd(s):
elif s=="clear": return Command.CMD_CLEAR
elif s=="get-clear": return Command.CMD_GET_CLEAR
elif s=="info": return Command.CMD_INFO
elif s=="pause": return Command.CMD_PAUSE
elif s=="resume": return Command.CMD_RESUME
else: return None
parser = argparse.ArgumentParser(description="rtbwpy daemon control.")

@ -29,6 +29,8 @@ class Command(object):
CMD_SHUTDOWN = 3
CMD_GET_CLEAR = 4
CMD_INFO = 5
CMD_PAUSE = 6
CMD_RESUME = 7
def __init__(self):
self.uCommand = 0

Loading…
Cancel
Save