[scannermain] Write to tempdir if needed
authorJohan Dahlin <johan@gnome.org>
Wed, 1 Sep 2010 23:53:32 +0000 (20:53 -0300)
committerJohan Dahlin <johan@gnome.org>
Wed, 1 Sep 2010 23:55:13 +0000 (20:55 -0300)
If the current directory is not writable nor if
the directory of the output file isn't, use the standard
temporayr directory as a last resort.

giscanner/scannermain.py

index 587c661a9ef61bb0f8230204e970f362d7be9c78..2d3ced4b74864ffc2a3f341153e1cc2296fc0caa 100644 (file)
@@ -358,6 +358,8 @@ def scanner_main(args):
     data = writer.get_xml()
     if options.output and options.output != "-":
         tempdir = os.path.dirname(options.output) or os.getcwd()
+        if not os.access(tempdir, os.W_OK):
+            tempdir = tempfile.gettempdir()
         main_f = tempfile.NamedTemporaryFile(suffix='.gir', dir=tempdir, delete=False)
         main_f.write(data)
         main_f.close()