Re: replacing os.chdir calls with basedir config option

Paul Nasrat <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Organization Red Hat, Inc.
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.