summaryrefslogtreecommitdiff
path: root/rapid/rapid.py
diff options
context:
space:
mode:
authorJulien Valroff <julien@kirya.net>2010-01-01 13:19:13 +0100
committerJulien Valroff <julien@kirya.net>2010-01-01 13:19:13 +0100
commit8fbe87935ed50510fb6206af65ef01177835a756 (patch)
tree8ff4e0a390228bea046d45e2206f74b4f5b025da /rapid/rapid.py
parenta7c0460e520ad4601af6537b40fb5ecec63fd074 (diff)
Imported Upstream version 0.1.0+bzr20100101upstream/0.1.0+bzr20100101
Diffstat (limited to 'rapid/rapid.py')
-rwxr-xr-xrapid/rapid.py28
1 files changed, 26 insertions, 2 deletions
diff --git a/rapid/rapid.py b/rapid/rapid.py
index a18f88e..ae7394c 100755
--- a/rapid/rapid.py
+++ b/rapid/rapid.py
@@ -363,6 +363,7 @@ class RapidPreferences(prefs.Preferences):
"auto_download_upon_device_insertion": prefs.Value(prefs.BOOL, False),
"auto_unmount": prefs.Value(prefs.BOOL, False),
"auto_exit": prefs.Value(prefs.BOOL, False),
+ "auto_delete": prefs.Value(prefs.BOOL, False),
"indicate_download_error": prefs.Value(prefs.BOOL, True),
"download_conflict_resolution": prefs.Value(prefs.STRING,
config.SKIP_DOWNLOAD),
@@ -912,6 +913,8 @@ class PreferencesDialog(gnomeglade.Component):
self.prefs.auto_unmount)
self.auto_exit_checkbutton.set_active(
self.prefs.auto_exit)
+ self.auto_delete_checkbutton.set_active(
+ self.prefs.auto_delete)
def _setupErrorTab(self):
@@ -1129,6 +1132,10 @@ class PreferencesDialog(gnomeglade.Component):
def on_auto_unmount_checkbutton_toggled(self, checkbutton):
self.prefs.auto_unmount = checkbutton.get_active()
+
+ def on_auto_delete_checkbutton_toggled(self, checkbutton):
+ self.prefs.auto_delete = checkbutton.get_active()
+
def on_auto_exit_checkbutton_toggled(self, checkbutton):
self.prefs.auto_exit = checkbutton.get_active()
@@ -1374,7 +1381,7 @@ class CopyPhotos(Thread):
2.b.1 don't allow any other thread to rename a file
2.b.2 check file name
2.b.3 adding suffix if it is not unique, being careful not to overwrite any existing file with a suffix
- 2.b.4 rename it to the "real"" name, effectively performing a mv
+ 2.b.4 rename it to the "real" name, effectively performing a mv
2.b.5 allow other threads to rename files
3. Backup the image, using the same filename as was used when it was downloaded
@@ -1564,7 +1571,6 @@ class CopyPhotos(Thread):
with self.fileSequenceLock:
for possibleName, problem in self.imageRenamePrefsFactory.generateNameSequencePossibilities(imageMetadata,
originalName, self.stripCharacters, subfolder):
-# print "checking", possibleName, "using", originalName
if possibleName:
# no need to check for any problems here, it's just a temporary name
possibleFile = os.path.join(path, possibleName)
@@ -1850,6 +1856,7 @@ class CopyPhotos(Thread):
i = 0
sizeDownloaded = noImagesDownloaded = noImagesSkipped = 0
+ imagesDownloadedSuccessfully = []
sizeImages = self.cardMedia.sizeOfImages(humanReadable = False)
display_queue.put((self.parentApp.addToTotalDownloadSize, (sizeImages, )))
@@ -1909,6 +1916,7 @@ class CopyPhotos(Thread):
if imageDownloaded:
noImagesDownloaded += 1
+ imagesDownloadedSuccessfully.append(image)
else:
noImagesSkipped += 1
try:
@@ -1931,6 +1939,22 @@ class CopyPhotos(Thread):
with self.statsLock:
self.downloadStats.adjust(sizeDownloaded, noImagesDownloaded, noImagesSkipped, self.noWarnings, self.noErrors)
+
+ if self.prefs.auto_delete:
+ j = 0
+ for image in imagesDownloadedSuccessfully:
+ try:
+ os.unlink(image)
+ j += 1
+ except OSError, (errno, strerror):
+ logError(config.SERIOUS_ERROR, _("Could not delete image from image device"),
+ _("Image: %(source)s\nError: %(errno)s %(strerror)s")
+ % {'source': image, 'errno': errno, 'strerror': strerror})
+ except:
+ logError(config.SERIOUS_ERROR, _("Could not delete image from image device"),
+ _("Image: %(source)s"))
+
+ cmd_line(_("Deleted %i images from image device") % j)
# must manually delete these variables, or else the media cannot be unmounted (bug in pyexiv or exiv2)
del self.subfolderPrefsFactory, self.imageRenamePrefsFactory