[Rpm-metadata] replacing os.chdir calls with basedir config option

Paul Nasrat pnasrat at redhat.com
Fri Nov 11 18:17:57 UTC 2005


On Fri, 2005-11-11 at 08:44 -0500, Dennis Gregorovic wrote:
> I've started using createrepo as a library instead of a standalone app.
> The only issue that I've run into so far is that the os.chdir() calls
> can cause problems, especially if you have multiple threads using
> createrepo in parallel.
> 
> Attached is a patch that removes the os.chdir() calls and introduces a
> 'basedir' config option, settable with --basedir and defaulting to
> os.getcwd().

There seems to be some whitespace damage in your patches:


-    def __init__(self, ts, filename, options):
+    def __init__(self, ts, basedir, filename, options):
         try:
-            stats = os.stat(filename)
+            stats = os.stat(os.path.join(basedir, filename))
             self.size = stats[6]
             self.mtime = stats[8]
             del stats
-        except OSError, e:
-            raise MDError, "Error Stat'ing file %s" % filename
-
You remove the exception above yet the following is not indented.

         self.options = options
         self.localurl = options['baseurl']
         self.relativepath = filename
-        fd = returnFD(filename)
+            fd = returnFD(os.path.join(basedir, filename))
This is indented for no reason.

Please can you rediff.

Paul





More information about the Rpm-metadata mailing list