[or-cvs] r20482: {projects} Implement the framework needed for sending split packages to (in projects/gettor: . gettor)

kaner at seul.org kaner at seul.org
Fri Sep 4 17:14:55 UTC 2009


Author: kaner
Date: 2009-09-04 13:14:55 -0400 (Fri, 04 Sep 2009)
New Revision: 20482

Modified:
   projects/gettor/GetTor.py
   projects/gettor/gettor/packages.py
   projects/gettor/gettor/requests.py
   projects/gettor/gettor/responses.py
Log:
Implement the framework needed for sending split packages to users via mail.
Now we only need to figure out how to split packages without exe files :-/


Modified: projects/gettor/GetTor.py
===================================================================
--- projects/gettor/GetTor.py	2009-09-04 16:30:06 UTC (rev 20481)
+++ projects/gettor/GetTor.py	2009-09-04 17:14:55 UTC (rev 20482)
@@ -178,9 +178,10 @@
         savedTab += line
     return savedTab
 
-def processMail(conf, logLang, packageList, blackList, whiteList):
+def processMail(conf, logLang, packs, blackList, whiteList):
     global log
 
+    packageList = packs.getPackageList()
     if packageList is None or len(packageList) < 1:
         log.error(_("Sorry, your package list is unusable."))
         log.error(_("Try running with --fetch-packages --prep-packages."))
@@ -258,7 +259,10 @@
                 status = resp.sendGenericMessage(srcEmail, replyTo, message)
                 if status != True:
                     log.info(_("Failed to send delay alert"))
-            status = resp.sendPackage(srcEmail, replyTo, packageList[package])
+            if (rmail.getSplitDelivery()):
+                status = resp.sendSplitPackage(srcEmail, replyTo, conf.getPackDir() + "/" + package + ".split")
+            else:
+                status = resp.sendPackage(srcEmail, replyTo, packageList[package])
             if status != True:
                 log.info(_("Failed at attempt to send package: %s") % str(package))
                 return False
@@ -388,7 +392,7 @@
         return success
     
     # Main loop
-    if not processMail(conf, logLang, packs.getPackageList(), blackList,
+    if not processMail(conf, logLang, packs, blackList,
                        whiteList):
         log.error(_("Processing mail failed."))
         return False

Modified: projects/gettor/gettor/packages.py
===================================================================
--- projects/gettor/gettor/packages.py	2009-09-04 16:30:06 UTC (rev 20481)
+++ projects/gettor/gettor/packages.py	2009-09-04 17:14:55 UTC (rev 20482)
@@ -34,12 +34,12 @@
 
 class gettorPackages:
     #                "bundle name": ("single file regex", "split file regex")
-    packageRegex = { "windows-bundle": ("vidalia-bundle-.*.exe$", "vidalia-bundle-.*_split$"),
-                     "panther-bundle": ("vidalia-bundle-.*-ppc.dmg$", "vidalia-bundle-.*-ppc_split$"),
-                     "macosx-universal-bundle": ("vidalia-bundle-.*-universal.dmg$", "vidalia-bundle-.*-universal_split$"),
-                     "source-bundle": ("tor-.*.tar.gz$", "none"),
-                     "tor-browser-bundle": ("tor-browser-.*_en-US.exe$", "tor-browser-.*_en-US_split$"),
-                     "tor-im-browser-bundle": ("tor-im-browser-.*_en-US.exe$", "tor-im-browser-.*_en-US_split$"),
+    packageRegex = { "windows-bundle": ("vidalia-bundle-.*.exe$", "vidalia-bundle-.*_split"),
+                     "panther-bundle": ("vidalia-bundle-.*-ppc.dmg$", "vidalia-bundle-.*-ppc_split"),
+                     "macosx-universal-bundle": ("vidalia-bundle-.*-universal.dmg$", "vidalia-bundle-.*-universal_split"),
+                     "source-bundle": ("tor-.*.tar.gz$", "Now to something completely different"),
+                     "tor-browser-bundle": ("tor-browser-.*_en-US.exe$", "tor-browser-.*_en-US_split"),
+                     "tor-im-browser-bundle": ("tor-im-browser-.*_en-US.exe$", "tor-im-browser-.*_en-US_split"),
                      # Mike won't sign Torbutton; He doesn't get gettor support
                      #"torbutton": "torbutton-current.xpi$",
                    }

Modified: projects/gettor/gettor/requests.py
===================================================================
--- projects/gettor/gettor/requests.py	2009-09-04 16:30:06 UTC (rev 20481)
+++ projects/gettor/gettor/requests.py	2009-09-04 17:14:55 UTC (rev 20482)
@@ -58,7 +58,8 @@
             if line.startswith(">"):
                 continue
             for package in packages.keys():
-                match = re.match(package, line)    
+                matchme = ".*" + package + ".*"
+                match = re.match(matchme, line)    
                 if match: 
                     self.returnPackage = package
                     log.info(_("User requested package %s") % self.returnPackage)

Modified: projects/gettor/gettor/responses.py
===================================================================
--- projects/gettor/gettor/responses.py	2009-09-04 16:30:06 UTC (rev 20481)
+++ projects/gettor/gettor/responses.py	2009-09-04 17:14:55 UTC (rev 20482)
@@ -66,7 +66,7 @@
     If you have any questions or it doesn't work, you can contact a
     human at this support email address: tor-assistants at torproject.org
         """)
-        help = self.constructMessage(message, source, destination)
+        help = self.constructMessage(message, source, destination, "")
         try:
             status = self.sendMessage(help, source, destination)
         except:
@@ -108,7 +108,7 @@
     human at this support email address: tor-assistants at torproject.org
 
         """)
-        help = self.constructMessage(message, source, destination)
+        help = self.constructMessage(message, source, destination, "")
         try:
             status = self.sendMessage(help, source, destination)
         except:
@@ -121,7 +121,7 @@
     def sendGenericMessage(self, source, destination, message):
         """ Send a helpful message of some sort """
         self.setLang(self.mailLang)
-        help = self.constructMessage(message, source, destination)
+        help = self.constructMessage(message, source, destination, "")
         try:
             status = self.sendMessage(help, source, destination)
         except:
@@ -171,7 +171,7 @@
     human at this support email address: tor-assistants at torproject.org
 
         """)
-        package = self.constructMessage(message, source, destination, filename)
+        package = self.constructMessage(message, source, destination, "", filename)
         try:
             status = self.sendMessage(package, source, destination)
         except:
@@ -181,13 +181,88 @@
 
         return status
 
-    def sendSplitPackage(self, source, destination, filename):
-    def sendPackage(
+    def sendSplitPackage(self, source, destination, splitdir):
+        message = _("""
+    Hello! This is the "gettor" robot.
 
-    def constructMessage(self, messageText, ourAddress, recipient, fileName=None, subj=_('Re: Your "gettor" request')):
+    Here's your requested software as a zip file. Please unzip the
+    package and verify the signature.
+
+    IMPORTANT NOTE:
+    Since this is part of a split-file request, you need to wait for 
+    all split files to be received by you before you can save them all
+    into the same directory and unpack them by double-clicking the 
+    first file. 
+
+    Packages might come out of order! Please make sure you received
+    all packages before you attempt to unpack them!
+
+    Hint: If your computer has GnuPG installed, use the gpg
+    commandline tool as follows after unpacking the zip file:
+
+       gpg --verify <packagename>.asc <packagename>
+
+    The output should look somewhat like this:
+
+       gpg: Good signature from "Roger Dingledine <arma at mit.edu>"
+
+    If you're not familiar with commandline tools, try looking for
+    a graphical user interface for GnuPG on this website:
+
+       http://www.gnupg.org/related_software/frontends.html
+
+    If your Internet connection blocks access to the Tor network, you
+    may need a bridge relay. Bridge relays (or "bridges" for short)
+    are Tor relays that aren't listed in the main directory. Since there
+    is no complete public list of them, even if your ISP is filtering
+    connections to all the known Tor relays, they probably won't be able
+    to block all the bridges.
+
+    You can acquire a bridge by sending an email that contains "get bridges"
+    in the body of the email to the following email address:
+    bridges at torproject.org
+
+    It is also possible to fetch bridges with a web browser at the following
+    url: https://bridges.torproject.org/
+
+    If you have any questions or it doesn't work, you can contact a
+    human at this support email address: tor-assistants at torproject.org
+
+        """)
+        print splitdir
+        try:
+            entry = os.stat(splitdir)
+        except OSError, e:
+            log.error(_("Not a valid directory: %s" % splitdir))
+            return False
+        files = os.listdir(splitdir)
+        # Sort the files, so we can send 01 before 02 and so on..
+        files.sort()
+        nFiles = len(files)
+        num = 0
+        for filename in files:
+            fullPath = splitdir + "/" + filename
+            num = num + 1
+            subj = "[gettor] Split package [%02d / %02d] " % (num, nFiles) 
+            package = self.constructMessage(message, source, destination, subj, fullPath)
+            try:
+                status = self.sendMessage(package, source, destination)
+            except:
+                log.error(_("Could not send package %s to user" % filename))
+                # XXX What now? Keep on sending? Bail out? Use might have 
+                # already received 10 out of 12 packages..
+                status = False
+        self.setLang(self.mailLang)
+
+        return status
+            
+
+    def constructMessage(self, messageText, ourAddress, recipient, subj, fileName=None):
         """ Construct a multi-part mime message, including only the first part
         with plaintext."""
 
+        if subj == "":
+            subj =_('Re: Your "gettor" request')
         message = StringIO.StringIO()
         mime = MimeWriter.MimeWriter(message)
         mime.addheader('MIME-Version', '1.0')



More information about the tor-commits mailing list