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

[or-cvs] r17923: {projects} Update to be more verbose and to fix some basic bugs. (projects/gettor)



Author: ioerror
Date: 2009-01-05 15:29:36 -0500 (Mon, 05 Jan 2009)
New Revision: 17923

Modified:
   projects/gettor/gettor.py
   projects/gettor/gettor_packages.py
Log:
Update to be more verbose and to fix some basic bugs.


Modified: projects/gettor/gettor.py
===================================================================
--- projects/gettor/gettor.py	2009-01-05 19:10:05 UTC (rev 17922)
+++ projects/gettor/gettor.py	2009-01-05 20:29:36 UTC (rev 17923)
@@ -85,6 +85,7 @@
     currentCronTab = getCurrentCrontab()
     newCronTab = currentCronTab + '\n' + '3 2 * * * ' + rsync
     echoCmd = ['echo', newCronTab ] 
+    print newCronTab
     cronCmd = ['crontab', '-']
     echoProc = subprocess.Popen(echoCmd, stdout=subprocess.PIPE)
     cronProc = subprocess.Popen(cronCmd, stdin=echoProc.stdout)
@@ -93,7 +94,7 @@
 
 def getCurrentCrontab():
     # This returns our current crontab
-    savedTab = "# This crontab has been tampered with by gettor.py"
+    savedTab = "# This crontab has been tampered with by gettor.py\n"
     currentTab = os.popen("crontab -l")
     for line in currentTab:
         savedTab += line
@@ -126,7 +127,7 @@
     # Initialize response
     srcEmail = conf.getSrcEmail()
     # Bail out if someone tries to be funny
-    if (srcEmail == repluTo):
+    if (srcEmail == replyTo):
         log.error(_("Won't send myself emails."))
         return False
 
@@ -172,8 +173,12 @@
     if not os.path.isdir(distDir):
         log.error(_("Sorry, %s is not a directory.") % distDir)
         return False
-    packs = gettor_packages.gettorPackages(options.mirror, conf)
     try:
+        packs = gettor_packages.gettorPackages(options.mirror, conf)
+    except IOError:
+        log.error(_("Error initiating package list."))
+        return False
+    try:
         whiteList = gettor_blacklist.BWList(conf.getWlStateDir())
         blackList = gettor_blacklist.BWList(conf.getBlStateDir())
     except IOError, e:

Modified: projects/gettor/gettor_packages.py
===================================================================
--- projects/gettor/gettor_packages.py	2009-01-05 19:10:05 UTC (rev 17922)
+++ projects/gettor/gettor_packages.py	2009-01-05 20:29:36 UTC (rev 17923)
@@ -34,7 +34,17 @@
         self.mirror = mirror
         self.packageList = {}
         self.distDir = config.getDistDir()
+        try:
+            entry = os.stat(self.distDir)
+        except OSError, e:
+            log.error("Bad dist dir %s: %s" % (self.distDir, e))
+            raise IOError
         self.packDir = config.getPackDir()
+        try:
+            entry = os.stat(self.packDir)
+        except OSError, e:
+            log.error("Bad pack dir %s: %s" % (self.packDir, e))
+            raise IOError
         self.rsync = ["rsync"]
         self.rsync.append("-a")
         # Don't download dotdirs