From 4d8789f4ab6ec31537f889d7bbcb4a5b9c61a8c0 Mon Sep 17 00:00:00 2001 From: Alex Roitman Date: Tue, 3 Jun 2003 21:18:23 +0000 Subject: [PATCH] * src/ReadXML.py (import_data), src/WriteXML.py (export_data), src/RelImage.py (import_media_object), src/gramps_main.py (open_example), src/plugins/Check.py (cleanup_missing_photos), src/plugins/WebPage.py (write_gallery): Change shutil.copy() calls to first call shutil.copyfile() and then try setting up bits. svn: r1652 --- gramps2/src/ReadXML.py | 12 ++++++++++-- gramps2/src/RelImage.py | 12 ++++++++++-- gramps2/src/WriteXML.py | 12 ++++++++++-- gramps2/src/gramps_main.py | 6 +++++- gramps2/src/plugins/Check.py | 6 +++++- gramps2/src/plugins/WebPage.py | 12 ++++++++++-- 6 files changed, 50 insertions(+), 10 deletions(-) diff --git a/gramps2/src/ReadXML.py b/gramps2/src/ReadXML.py index ded6d3bfe..fdf209e24 100644 --- a/gramps2/src/ReadXML.py +++ b/gramps2/src/ReadXML.py @@ -185,7 +185,11 @@ def importData(database, filename, callback,cl=0): def fs_ok_clicked(obj): name = fs_top.get_filename() if os.path.isfile(name): - shutil.copy2(name,newfile) + shutil.copyfile(name,newfile) + try: + shutil.copystat(name,newfile) + except: + pass Utils.destroy_passed_object(fs_top) fs_top = gtk.FileSelection("%s - GRAMPS" % _("Select file")) @@ -210,7 +214,11 @@ def importData(database, filename, callback,cl=0): ObjectMap[NewMediaID].setPath(newfile) ObjectMap[NewMediaID].setLocal(1) try: - shutil.copy2(oldfile,newfile) + shutil.copyfile(oldfile,newfile) + try: + shutil.copystat(oldfile,newfile) + except: + pass except: if cl: print "Warning: media file %s was not found," \ diff --git a/gramps2/src/RelImage.py b/gramps2/src/RelImage.py index b5f1b1ed1..8374e070f 100644 --- a/gramps2/src/RelImage.py +++ b/gramps2/src/RelImage.py @@ -82,7 +82,11 @@ def import_media_object(filename,path,base): return "" try: - shutil.copy(filename,name) + shutil.copyfile(filename,name) + try: + shutil.copystat(filename,name) + except: + pass except IOError,msg: ErrorDialog(_("Error copying %s") % filename,str(msg)) return "" @@ -91,7 +95,11 @@ def import_media_object(filename,path,base): bname = os.path.basename(filename) l = string.split(bname,'.') name = "%s/%s.%s" % (path,base,l[-1]) - shutil.copy(filename,name) + shutil.copyfile(filename,name) + try: + shutil.copystat(filename,name) + except: + pass return name diff --git a/gramps2/src/WriteXML.py b/gramps2/src/WriteXML.py index 418576472..ccefb9e46 100644 --- a/gramps2/src/WriteXML.py +++ b/gramps2/src/WriteXML.py @@ -65,7 +65,11 @@ except: #------------------------------------------------------------------------- def exportData(database, filename, callback): if os.path.isfile(filename): - shutil.copy(filename, filename + ".bak") + shutil.copyfile(filename, filename + ".bak") + try: + shutil.copystat(filename, filename + ".bak") + except: + pass compress = GrampsCfg.uncompress == 0 and _gzip_ok == 1 @@ -78,7 +82,11 @@ def exportData(database, filename, callback): DisplayTrace.DisplayTrace() ErrorDialog(_("Failure writing %s") % filename, _("An attempt is being made to recover the original file")) - shutil.copy(filename + ".bak", filename) + shutil.copyfile(filename + ".bak", filename) + try: + shutil.copystat(filename + ".bak", filename) + except: + pass #------------------------------------------------------------------------- # diff --git a/gramps2/src/gramps_main.py b/gramps2/src/gramps_main.py index c51e4c509..f7cb9e9d4 100755 --- a/gramps2/src/gramps_main.py +++ b/gramps2/src/gramps_main.py @@ -2024,7 +2024,11 @@ class Gramps: try: dir = "%s/share/gramps/example" % const.prefixdir for file in os.listdir(dir): - shutil.copy("%s/%s" % (dir,file), dest) + shutil.copyfile("%s/%s" % (dir,file), dest) + try: + shutil.copystat("%s/%s" % (dir,file), dest) + except: + pass except IOError,msg: ErrorDialog(_('Example database not created'),str(msg)) except OSError,msg: diff --git a/gramps2/src/plugins/Check.py b/gramps2/src/plugins/Check.py index f7bc5345e..f7d9d9f8f 100644 --- a/gramps2/src/plugins/Check.py +++ b/gramps2/src/plugins/Check.py @@ -142,7 +142,11 @@ class CheckIntegrity: def fs_ok_clicked(obj): name = fs_top.get_filename() if os.path.isfile(name): - shutil.copy2(name,photo_name) + shutil.copyfile(name,photo_name) + try: + shutil.copystat(name,photo_name) + except: + pass self.replaced_photo.append(ObjectMap[ObjectId]) else: self.bad_photo.append(ObjectMap[ObjectId]) diff --git a/gramps2/src/plugins/WebPage.py b/gramps2/src/plugins/WebPage.py index 4387cff8f..938f8f208 100644 --- a/gramps2/src/plugins/WebPage.py +++ b/gramps2/src/plugins/WebPage.py @@ -362,9 +362,17 @@ class IndividualPage: base = os.path.basename(src) if self.image_dir: - shutil.copy(src,"%s/%s/%s" % (self.dir,self.image_dir,base)) + shutil.copyfile(src,"%s/%s/%s" % (self.dir,self.image_dir,base)) + try: + shutil.copystat(src,"%s/%s/%s" % (self.dir,self.image_dir,base)) + except: + pass else: - shutil.copy(src,"%s/%s" % (self.dir,base)) + shutil.copyfile(src,"%s/%s" % (self.dir,base)) + try: + shutil.copystat(src,"%s/%s" % (self.dir,base)) + except: + pass self.doc.start_row() self.doc.start_cell("ImageCell")