[gobject-introspection] [scannermain] Use shutil.move instead of os.rename



commit dfff733b154abf1e85d447d2da389b34396fe005
Author: Johan Dahlin <johan gnome org>
Date:   Wed Sep 1 20:54:16 2010 -0300

    [scannermain] Use shutil.move instead of os.rename
    
    In case that the temporary directory and the output directory
    is not on the same filesystem.

 giscanner/scannermain.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/giscanner/scannermain.py b/giscanner/scannermain.py
index 2d3ced4..8db1d2b 100644
--- a/giscanner/scannermain.py
+++ b/giscanner/scannermain.py
@@ -1,7 +1,7 @@
 #!/usr/bin/env python
 # -*- Mode: Python -*-
 # GObject-Introspection - a framework for introspecting GObject libraries
-# Copyright (C) 2008  Johan Dahlin
+# Copyright (C) 2008-2010 Johan Dahlin
 # Copyright (C) 2009 Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or
@@ -20,8 +20,10 @@
 # 02110-1301, USA.
 #
 
+import errno
 import optparse
 import os
+import shutil
 import subprocess
 import sys
 import tempfile
@@ -371,7 +373,13 @@ def scanner_main(args):
                 raise SystemExit(
 "Failed to re-parse .gir file; scanned=%r passthrough=%r" % (main_f.name, temp_f.name))
             os.unlink(temp_f.name)
-        os.rename(main_f.name, options.output)
+        try:
+            shutil.move(main_f.name, options.output)
+        except OSError, e:
+            if e.errno == errno.EPERM:
+                os.unlink(main_f.name)
+                return
+            raise
     else:
         sys.stdout.write(data)
 



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