read account info from a file, support ssl
authorAndrew Sutherland <asutherland@asutherland.org>
Wed, 14 Jan 2009 00:10:45 -0800
changeset 22 e54f35620881eedccdae43b4d96e807a9a3dd3ca
parent 21 0ee5c0e954f888faf5e59b6a35af45fc8525e388
child 23 199f91ec36461809b8cfa88df2eefd32512b2703
push id1
push userroot
push dateWed, 08 Apr 2009 01:46:05 +0000
read account info from a file, support ssl
server/python/junius/bootstrap.py
--- a/server/python/junius/bootstrap.py
+++ b/server/python/junius/bootstrap.py
@@ -9,19 +9,30 @@ import os, os.path, mimetypes, base64, p
 
 import junius.model as model
 
 def setup_account(dbs):
     if len(model.Account.all(dbs.accounts)):
         print 'Account presumably already exists, not adding it!'
         return
     
+    # we want a file of the form:
+    #  hostname,port,username,password,ssl?
+    # example:
+    #  mail.example.com,993,bob@example.com,sekret,True
+    import os, os.path
+    configPath = os.path.join(os.environ['HOME'], ".junius")
+    f = open(configPath, 'r')
+    data = f.read()
+    f.close()
+    host, portstr, username, password, sslstr = data.split(',')
+    
     account = model.Account(
-        kind='imap', host='mail.visophyte.org', port=993, ssl=True,
-        username='junius@visophyte.org', password='keepFallin',
+        kind='imap', host=host, port=int(portstr), ssl=bool(sslstr),
+        username=username, password=password,
     )
     account.store(dbs.accounts)
 
 def path_part_nuke(path, count):
     for i in range(count):
         path = os.path.dirname(path)
     return path