[csw-devel] SF.net SVN: gar:[12973] csw/mgar/gar/v2/lib/python/database.py

wahwah at users.sourceforge.net wahwah at users.sourceforge.net
Mon Jan 17 10:27:45 CET 2011


Revision: 12973
          http://gar.svn.sourceforge.net/gar/?rev=12973&view=rev
Author:   wahwah
Date:     2011-01-17 09:27:45 +0000 (Mon, 17 Jan 2011)

Log Message:
-----------
pkgdb: Tolerate the absence of /v/s/i/contents

It might be useful to run pkgdb on other systems (e.g. GNU/Linux), so it
needs to tolerate the absence of /var/sadm/install/contents.

Modified Paths:
--------------
    csw/mgar/gar/v2/lib/python/database.py

Modified: csw/mgar/gar/v2/lib/python/database.py
===================================================================
--- csw/mgar/gar/v2/lib/python/database.py	2011-01-17 09:27:26 UTC (rev 12972)
+++ csw/mgar/gar/v2/lib/python/database.py	2011-01-17 09:27:45 UTC (rev 12973)
@@ -265,14 +265,27 @@
 
   def GetFileMtime(self):
     if not self.file_mtime:
-      stat_data = os.stat(SYSTEM_PKGMAP)
-      self.file_mtime = stat_data.st_mtime
+      try:
+        stat_data = os.stat(SYSTEM_PKGMAP)
+        self.file_mtime = stat_data.st_mtime
+      except OSError, e:
+        logging.warning("Could not open %s: %s", SYSTEM_PKGMAP, e)
     return self.file_mtime
 
   def IsDatabaseUpToDate(self):
     f_mtime_epoch = self.GetFileMtime()
     d_mtime_epoch = self.GetDatabaseMtime()
-    f_mtime = time.gmtime(int(f_mtime_epoch))
+
+    # On some systems where pkgdb runs, f_mtime_epoch can be None.  To
+    # allow to run pkgdb, the absence of the SYSTEM_PKGMAP file must be
+    # tolerated.  The GetDatabaseMtime function returns None if the file
+    # is absent.  If f_mtime_epoch cannot be translated into a number,
+    # it's set to zero.
+    f_mtime = 0
+    try:
+      f_mtime = time.gmtime(int(f_mtime_epoch))
+    except TypeError, e:
+      logging.warning("Could not get file mtime: %s", e)
     d_mtime = time.gmtime(int(d_mtime_epoch))
     logging.debug("IsDatabaseUpToDate: f_mtime %s, d_time: %s", f_mtime, d_mtime)
     # Rounding up to integer seconds.  There is a race condition: 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list