[or-cvs] r21235: {projects} Rename .exe files for split downloads (projects/gettor/lib/gettor)

kaner at seul.org kaner at seul.org
Wed Dec 16 21:37:55 UTC 2009


Author: kaner
Date: 2009-12-16 16:37:54 -0500 (Wed, 16 Dec 2009)
New Revision: 21235

Modified:
   projects/gettor/lib/gettor/packages.py
   projects/gettor/lib/gettor/utils.py
Log:
Rename .exe files for split downloads


Modified: projects/gettor/lib/gettor/packages.py
===================================================================
--- projects/gettor/lib/gettor/packages.py	2009-12-16 20:35:17 UTC (rev 21234)
+++ projects/gettor/lib/gettor/packages.py	2009-12-16 21:37:54 UTC (rev 21235)
@@ -213,11 +213,27 @@
                 continue
             if re.compile(".*split.part.*").match(splitfile):
                 ascfile = splitdir + "/signatures/" + splitfile + ".asc"
+                # Rename .exe if needed
+                if gettor.utils.hasExe(ascfile):
+                    try:
+                        ascfile = gettor.utils.renameExe(ascfile)
+                    except:
+                        log.error("Could not rename exe file")
                 file = splitdir + "/" + splitfile
+                if gettor.utils.hasExe(file):
+                    try:
+                        file = gettor.utils.renameExe(file)
+                    except:
+                        log.error("Could not rename exe file")
                 zipFileName = packSplitDir + "/" + splitfile + ".z"
+                if gettor.utils.hasExe(file):
+                    try:
+                        zipFileName = gettor.utils.renameExe(zipFileName)
+                    except:
+                        log.error("Could not rename exe file")
                 if os.access(ascfile, os.R_OK) and os.access(file, os.R_OK):
                     zip = zipfile.ZipFile(zipFileName, "w")
-                    zip.write(splitdir + "/" + splitfile, os.path.basename(file))
+                    zip.write(file, os.path.basename(file))
                     zip.write(ascfile, os.path.basename(ascfile))
                     zip.close()
                 else:
@@ -226,17 +242,3 @@
 
         log.info("Done.")
         return True
-
-if __name__ == "__main__" :
-    c = gettor_config.Config()
-    p = gettorPackages("rsync.torproject.org", c)
-    print "Building packagelist.."
-    if p.syncwithMirror() != 0:
-        print "Failed."
-        exit(1)
-    if not p.buildPackageList():
-        print "Failed."
-        exit(1)
-    print "Done."
-    for (pack, file) in p.getPackageList().items():
-        print "Bundle is mapped to file: ", pack, file

Modified: projects/gettor/lib/gettor/utils.py
===================================================================
--- projects/gettor/lib/gettor/utils.py	2009-12-16 20:35:17 UTC (rev 21234)
+++ projects/gettor/lib/gettor/utils.py	2009-12-16 21:37:54 UTC (rev 21235)
@@ -13,6 +13,7 @@
 
 import os
 import sys
+import re
 import subprocess
 import hashlib
 import datetime
@@ -269,6 +270,22 @@
         log.error("Verifying password failed: %s" % e)
         return False
 
+def hasExe(filename):
+    if re.compile(".*.exe.*").match(filename):
+        return True
+    else:
+        return False
+
+def renameExe(filename):
+    if not os.access(filename, os.R_OK):
+        log.error("Could not access file %s" % filename)
+        raise OSError
+
+    newfilename = filename.replace(".exe", ".ex_RENAME", 1)
+    os.rename(filename, newfilename)
+
+    return newfilename
+
 # Helper routines go here ####################################################
 
 def installMo(poFile, targetDir):



More information about the tor-commits mailing list