From 868e8d186cfa37fa32c25bf14804bf06f3dbfb72 Mon Sep 17 00:00:00 2001 From: Julien Lengrand-Lambert Date: Fri, 11 Jan 2013 14:49:07 +0100 Subject: [PATCH] Adds mechanics to add/rm hashtags. Also implements help message. FIXME: Counter still seems to be blocking when crawling through all new tweets. How to solve that? Next : Connect mechanics to actual processing --- twiderboard/command.py | 37 ++++++++++++++++++++++++++++++++++--- 1 file changed, 34 insertions(+), 3 deletions(-) diff --git a/twiderboard/command.py b/twiderboard/command.py index 8a736e0..d45f9b3 100644 --- a/twiderboard/command.py +++ b/twiderboard/command.py @@ -21,12 +21,12 @@ class Trigger(): # starting all services # Streamer - print "streamer" + print "Starting streamer" self.h = HashtagLogger(engine_url, oauth=True) self.h.start() #Counter - print "counter" + print "Starting counter" self.c = Counter(engine_url) self.c.start() @@ -37,8 +37,39 @@ class Trigger(): print "Command Line utility started:" print "Press CTRL + C to stop application" + print "type h, help or ? to get a list of possible commands" while True: - raw_input(">") + res = raw_input(">") + self.parse(res) + + def parse(self, comm): + """ + Parses the command input by the user + and triggers the corresponding action + """ + word = comm.lower() + if word in ["h", "help", "?"]: + self.help() + else: + if word.startswith("add #"): + hashtag = word.replace("add #", "") + print "hashtag is : %s" %(hashtag) + elif word.startswith("rm #"): + hashtag = word.replace("rm #", "") + print "hashtag is : %s" %(hashtag) + else: + print "Unrecognized command" + + def help(self): + """ + Prints Help message in command line + """ + print "######" + print "add [hashtag] : adds hashtag to list of interest hashtags " + print "rm [hashtag] : removes hashtag from list of interest hashtags " + print + print "WARNING: hashtag always starts with #!" + print "######" def stop_handler(self, signal, frame): """