[Spambayes-checkins] spambayes/spambayes Options.py, 1.59, 1.60 Version.py, 1.12, 1.13

Tony Meyer anadelonbrin at users.sourceforge.net
Tue Jul 29 00:32:50 EDT 2003


Update of /cvsroot/spambayes/spambayes/spambayes
In directory sc8-pr-cvs1:/tmp/cvs-serv28220/spambayes

Modified Files:
	Options.py Version.py 
Log Message:
Add options to store information about a HTTP proxy.  This can be used by the version checker,
plus anything else that wants to do HTTP (like the urlslurper stuff that was tested a while back).
Note that storing passwords is awkward because we store them in clear text and this might bother
the users ;).  If it does and we care about them, then we need to provide password prompts at the
time of use.

Also upgrade the version checker so that it uses this information so those stuck behind proxies (like
me!) can check for the latest version.

Index: Options.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Options.py,v
retrieving revision 1.59
retrieving revision 1.60
diff -C2 -d -r1.59 -r1.60
*** Options.py	24 Jul 2003 21:31:24 -0000	1.59
--- Options.py	29 Jul 2003 06:32:48 -0000	1.60
***************
*** 921,924 ****
--- 921,940 ----
       platform.""",
       ("best", "db3hash", "dbhash", "gdbm", "dumbdbm"), RESTORE),
+ 
+     ("proxy_username", "HTTP Proxy Username", "",
+      """The username to give to the HTTP proxy when required.  If a
+      username is not necessary, simply leave blank.""",
+      r"[\w]+", DO_NOT_RESTORE),
+     ("proxy_password", "HTTP Proxy Password", "",
+      """The password to give to the HTTP proxy when required.  This is
+      stored in clear text in your configuration file, so if that bothers
+      you then don't do this.  You'll need to use a proxy that doesn't need
+      authentication, or do without any SpamBayes HTTP activity.""",
+      r"[\w]+", DO_NOT_RESTORE),
+     ("proxy_server", "HTTP Proxy Server", "",
+      """If a spambayes application needs to use HTTP, it will try to do so
+      through this proxy server.  The port defaults to 8080, or can be
+      entered with the server:port form.""",
+      SERVER, DO_NOT_RESTORE),
    ),
  }

Index: Version.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/spambayes/Version.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** Version.py	29 Jul 2003 02:59:25 -0000	1.12
--- Version.py	29 Jul 2003 06:32:48 -0000	1.13
***************
*** 119,122 ****
--- 119,137 ----
  
      import urllib2
+     from spambayes.Options import options
+     server = options["globals", "proxy_server"]
+     if server != "":
+         if ':' in server:
+             server, port = server.split(':', 1)
+         else:
+             port = 8080
+         username = options["globals", "proxy_username"]
+         password = options["globals", "proxy_password"]
+         proxy_support = urllib2.ProxyHandler({"http" :
+                                               "http://%s:%s@%s:%d" % \
+                                               (username, password, server,
+                                                port)})
+         opener = urllib2.build_opener(proxy_support, urllib2.HTTPHandler)
+         urllib2.install_opener(opener)
      stream = urllib2.urlopen(url)
      cfg = MySafeConfigParser()





More information about the Spambayes-checkins mailing list