From: khamidou Date: Wed, 24 Feb 2010 20:33:46 +0000 (+0100) Subject: some fixes to utils.py X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=59b80e4405b64e94cd0ff40a11b2617a92bc2746;p=liszt.git some fixes to utils.py --- diff --git a/libliszt/utils.py b/libliszt/utils.py index c9603d2..c4889ea 100644 --- a/libliszt/utils.py +++ b/libliszt/utils.py @@ -180,9 +180,9 @@ class LisztSession: continue def create_list(self, listname): - listname = listname.encode("utf8") + listname = unicode(listname) try: - urllib2.urlopen(base + "/create/" + quote(listname) + "/") + urllib2.urlopen(base + "/create/" + quote(listname.encode("utf8")) + "/") except HTTPError: bailout("Unable to create the list " + listname) @@ -204,6 +204,7 @@ class LisztSession: return json.load(req) def get_list(self, listname): + listname = listname.encode("utf8") req = None try: @@ -215,6 +216,8 @@ class LisztSession: return json.load(req) def get_entry(self, listname, index): + listname = listname.encode("utf8") + try: req = urllib2.urlopen(base + "/get/" + quote(listname) + "/" + str(index) + "/") except HTTPError: @@ -224,18 +227,23 @@ class LisztSession: return json.load(req) def remove_list(self, listname): + listname = listname.encode("utf8") + try: urllib2.urlopen(base + "/remove/" + quote(listname) + "/") except HTTPError: bailout("Unable to remove the list " + listname) def remove_list_entry(self, listname, index): + listname = listname.encode("utf8") + try: urllib2.urlopen(base + "/remove/" + quote(listname) + "/" + quote(index) + "/") except HTTPError: bailout("Unable to remove the entry " + index + "from list " + listname) def update_list_entry(self, listname, index, contents): + listname = listname.encode("utf8") ec = urllib.urlencode(contents) try: urllib2.urlopen(base + "/update/" + listname + "/" + str(index) + "/", ec) diff --git a/liszt b/liszt index 8cc66d1..0af50c7 100755 --- a/liszt +++ b/liszt @@ -281,9 +281,8 @@ class CommandParser(object): # Delete the list and recreate the entries. dict = {"request" : "delete-list", "listname" : listname,} create_spool_file(dict) - time.sleep(0.2) # Make sure that the list is removed before doing anything + # Recreate it - # Delete the list and recreate the entries. dict = {"request" : "create-list", "listname" : listname,} create_spool_file(dict) diff --git a/liszt-daemon b/liszt-daemon index 3499020..778adc4 100755 --- a/liszt-daemon +++ b/liszt-daemon @@ -44,11 +44,12 @@ def process_json_delayed_file(path, session): return data = json.load(fd) - + print data if "request" not in data or "listname" not in data: return # Discard incorrect files if data["request"] == "create-list": + print "let there be a list" session.create_list(data["listname"]) elif data["request"] == "create-entry": try: @@ -57,6 +58,7 @@ def process_json_delayed_file(path, session): return elif data["request"] == "delete-list": + print "let there be no list" session.remove_list(data["listname"]) elif data["request"] == "delete-entry": try: @@ -113,7 +115,6 @@ def sync_cached_list(listname): cached_list = CachedList(listname) server_list = session.get_list(listname) - print server_list for entry in server_list: if isinstance(entry, list): # Discard lists for the moment