]> khamidou — GitHub mirrors - liszt.git/commitdiff
quoted url parameters and added error message for a connection error
authorkhamidou <khamidou@gmail.com>
Tue, 2 Feb 2010 09:05:23 +0000 (10:05 +0100)
committerkhamidou <khamidou@gmail.com>
Tue, 2 Feb 2010 09:05:23 +0000 (10:05 +0100)
.gitignore [new file with mode: 0644]
liszt

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..b25c15b
--- /dev/null
@@ -0,0 +1 @@
+*~
diff --git a/liszt b/liszt
index 2c0f317bcb0e7fce3615109e1bb97c5ce86c7a11..3b1330b284571f6d40d3cfa50a31ab62bc89435b 100755 (executable)
--- a/liszt
+++ b/liszt
@@ -5,7 +5,7 @@ import os
 from datetime import datetime
 import urllib, urllib2, cookielib
 from urllib import quote
-from urllib2 import HTTPError
+from urllib2 import HTTPError, URLError
 import fnmatch
 
 import ConfigParser
@@ -19,6 +19,8 @@ base = "http://0.0.0.0:8080/api"
 
 conf = ConfigParser.RawConfigParser()
 conf.read(os.path.expanduser('~/.liszt/config'))
+username = conf.get('Credentials', 'username')
+password = conf.get('Credentials', 'password')
 
 def bailout(msg):
     print msg
@@ -41,6 +43,8 @@ class LisztSession:
             urllib2.urlopen(base + "/login/", ed)
         except HTTPError:
             bailout("Unable to log you in - are you credentials correct ?")
+        except URLError:
+            bailout("Unable to connect to the remote host.")
 
     def create_list(self, listname):
         try:
@@ -109,22 +113,23 @@ class LisztSession:
         except HTTPError:
             bailout("Unable to glob list pattern")
 
-def help():
-    print "liszt c|create listname ?entryname? "
-    print "liszt r[remove|d|delete listname ?entryindex?"
-    print "liszt s listname ?entryindex?"
-    print "liszt chk|check listname index"
-    print "liszt m|mod|modify listname index ?'new description'? ?'check'? ?'date'?"
+class CommandParser(object):
 
-def parse_create(args):
-    pass
+    def help():
+        print "liszt c|create listname ?entryname? "
+        print "liszt r[remove|d|delete listname ?entryindex?"
+        print "liszt s listname ?entryindex?"
+        print "liszt chk|check listname index"
+        print "liszt~ m|mod|modify listname index ?'new description'? ?'check'? ?'date'?"
+    
+        def parse_create(args):
+            pass
 
-def parse_remove(args):
-    pass
+        def parse_remove(args):
+            pass
 
-def parse_show(args):
-    
-    pass
+        def parse_show(args):
+            pass
 
 dispatch = {"create" : parse_create,
             "remove" : parse_remove,
@@ -137,8 +142,8 @@ if __name__ == "__main__":
 #         sys.exit(0)
 
     session = LisztSession()
-    session.login("s", "s")
-    session.show_list("*")
+    session.login(username, password)
+
 
 #     if sys.argv[1] in dispatch:
 #         dispatch[sys.argv[1]](sys.argv[2:])