[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [flashproxy/master] Reorganize.



commit ba80dd5eab18f2d0270066d1e6f992d7cd927f79
Author: David Fifield <david@xxxxxxxxxxxxxxx>
Date:   Thu Sep 20 10:22:22 2012 -0700

    Reorganize.
---
 facilitator/facilitator-email-poller |   60 +++++++++++++++++-----------------
 1 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/facilitator/facilitator-email-poller b/facilitator/facilitator-email-poller
index f849fd0..ff3997c 100755
--- a/facilitator/facilitator-email-poller
+++ b/facilitator/facilitator-email-poller
@@ -77,6 +77,17 @@ class options(object):
     safe_logging = True
     imaplib_debug = False
 
+class IMAP4_SSL_REQUIRED(imaplib.IMAP4_SSL):
+    """A subclass of of IMAP4_SSL that uses ssl_version=ssl.PROTOCOL_TLSv1 and
+    cert_reqs=ssl.CERT_REQUIRED."""
+    def open(self, host = "", port = imaplib.IMAP4_SSL_PORT):
+        self.host = host
+        self.port = port
+        self.sock = socket.create_connection((host, port))
+        self.sslobj = ssl.wrap_socket(self.sock, ssl_version=ssl.PROTOCOL_TLSv1,
+            cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.certfile)
+        self.file = self.sslobj.makefile('rb')
+
 def usage(f = sys.stdout):
     print >> f, """\
 Usage: %(progname)s --key=KEYFILE --pass=PASSFILE
@@ -190,16 +201,25 @@ try:
 finally:
     key_file.close()
 
-class IMAP4_SSL_REQUIRED(imaplib.IMAP4_SSL):
-    """A subclass of of IMAP4_SSL that uses ssl_version=ssl.PROTOCOL_TLSv1 and
-    cert_reqs=ssl.CERT_REQUIRED."""
-    def open(self, host = "", port = imaplib.IMAP4_SSL_PORT):
-        self.host = host
-        self.port = port
-        self.sock = socket.create_connection((host, port))
-        self.sslobj = ssl.wrap_socket(self.sock, ssl_version=ssl.PROTOCOL_TLSv1,
-            cert_reqs=ssl.CERT_REQUIRED, ca_certs=self.certfile)
-        self.file = self.sslobj.makefile('rb')
+if options.log_filename:
+    options.log_file = open(options.log_filename, "a")
+    # Send error tracebacks to the log.
+    sys.stderr = options.log_file
+else:
+    options.log_file = sys.stdout
+
+if options.daemonize:
+    log(u"daemonizing")
+    pid = os.fork()
+    if pid != 0:
+        if options.pid_filename:
+            f = open(options.pid_filename, "w")
+            print >> f, pid
+            f.close()
+        sys.exit(0)
+
+if options.imaplib_debug:
+    imaplib.Debug = 4
 
 def find_client_addr(body):
     """Find and parse the first client line of the form
@@ -242,26 +262,6 @@ def imap_loop(imap):
 
         time.sleep(POLL_INTERVAL)
 
-if options.log_filename:
-    options.log_file = open(options.log_filename, "a")
-    # Send error tracebacks to the log.
-    sys.stderr = options.log_file
-else:
-    options.log_file = sys.stdout
-
-if options.daemonize:
-    log(u"daemonizing")
-    pid = os.fork()
-    if pid != 0:
-        if options.pid_filename:
-            f = open(options.pid_filename, "w")
-            print >> f, pid
-            f.close()
-        sys.exit(0)
-
-if options.imaplib_debug:
-    imaplib.Debug = 4
-
 def imap_login():
     """Make an IMAP connection, check the certificate and public key, and log in."""
     ca_certs_file = tempfile.NamedTemporaryFile(prefix="facilitator-email-poller-", suffix=".crt", delete=True)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits