mirror of
https://github.com/arsenetar/dupeguru.git
synced 2025-03-10 13:44:37 +00:00
[#125 state:fixed] Wrapped error message around a crash when the iPhoto app can't be found.
This commit is contained in:
parent
6a6f2d51aa
commit
09082955a3
@ -63,13 +63,16 @@ http://www.hardcoded.net/licenses/bsd_license
|
|||||||
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
[_py setIgnoreHardlinkMatches:n2b([ud objectForKey:@"ignoreHardlinkMatches"])];
|
||||||
[_py setMatchScaled:[ud objectForKey:@"matchScaled"]];
|
[_py setMatchScaled:[ud objectForKey:@"matchScaled"]];
|
||||||
int r = n2i([py doScan]);
|
int r = n2i([py doScan]);
|
||||||
if (r != 0)
|
if (r != 0) {
|
||||||
[[ProgressController mainProgressController] hide];
|
[[ProgressController mainProgressController] hide];
|
||||||
if (r == 3)
|
}
|
||||||
{
|
if (r == 3) {
|
||||||
[Dialogs showMessage:@"The selected directories contain no scannable file."];
|
[Dialogs showMessage:@"The selected directories contain no scannable file."];
|
||||||
[app toggleDirectories:nil];
|
[app toggleDirectories:nil];
|
||||||
}
|
}
|
||||||
|
if (r == 4) {
|
||||||
|
[Dialogs showMessage:@"The iPhoto application couldn't be found."];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (IBAction)toggleDirectories:(id)sender
|
- (IBAction)toggleDirectories:(id)sender
|
||||||
|
@ -11,7 +11,7 @@ import plistlib
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from appscript import app, k, CommandError
|
from appscript import app, k, CommandError, ApplicationNotFoundError
|
||||||
|
|
||||||
from hsutil import io
|
from hsutil import io
|
||||||
from hsutil.str import get_file_ext, remove_invalid_xml
|
from hsutil.str import get_file_ext, remove_invalid_xml
|
||||||
@ -24,12 +24,14 @@ from core import app_cocoa, directories
|
|||||||
from . import data, _block_osx
|
from . import data, _block_osx
|
||||||
from .scanner import ScannerPE
|
from .scanner import ScannerPE
|
||||||
|
|
||||||
|
IPHOTO_PATH = Path('iPhoto Library')
|
||||||
|
|
||||||
class Photo(fs.File):
|
class Photo(fs.File):
|
||||||
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
INITIAL_INFO = fs.File.INITIAL_INFO.copy()
|
||||||
INITIAL_INFO.update({
|
INITIAL_INFO.update({
|
||||||
'dimensions': (0,0),
|
'dimensions': (0,0),
|
||||||
})
|
})
|
||||||
HANDLED_EXTS = set(['png', 'jpg', 'jpeg', 'gif', 'psd', 'bmp', 'tiff', 'tif', 'nef', 'cr2'])
|
HANDLED_EXTS = {'png', 'jpg', 'jpeg', 'gif', 'psd', 'bmp', 'tiff', 'tif', 'nef', 'cr2'}
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def can_handle(cls, path):
|
def can_handle(cls, path):
|
||||||
@ -97,7 +99,7 @@ class Directories(directories.Directories):
|
|||||||
self.iphoto_libpath = None
|
self.iphoto_libpath = None
|
||||||
|
|
||||||
def _get_files(self, from_path):
|
def _get_files(self, from_path):
|
||||||
if from_path == Path('iPhoto Library'):
|
if from_path == IPHOTO_PATH:
|
||||||
if self.iphoto_libpath is None:
|
if self.iphoto_libpath is None:
|
||||||
return []
|
return []
|
||||||
is_ref = self.get_state(from_path) == directories.STATE_REFERENCE
|
is_ref = self.get_state(from_path) == directories.STATE_REFERENCE
|
||||||
@ -110,23 +112,26 @@ class Directories(directories.Directories):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_subfolders(path):
|
def get_subfolders(path):
|
||||||
if path == Path('iPhoto Library'):
|
if path == IPHOTO_PATH:
|
||||||
return []
|
return []
|
||||||
else:
|
else:
|
||||||
return directories.Directories.get_subfolders(path)
|
return directories.Directories.get_subfolders(path)
|
||||||
|
|
||||||
def add_path(self, path):
|
def add_path(self, path):
|
||||||
if path == Path('iPhoto Library'):
|
if path == IPHOTO_PATH:
|
||||||
if path not in self:
|
if path not in self:
|
||||||
self._dirs.append(path)
|
self._dirs.append(path)
|
||||||
else:
|
else:
|
||||||
directories.Directories.add_path(self, path)
|
directories.Directories.add_path(self, path)
|
||||||
|
|
||||||
|
def has_iphoto_path(self):
|
||||||
|
return any(path == IPHOTO_PATH for path in self._dirs)
|
||||||
|
|
||||||
def has_any_file(self):
|
def has_any_file(self):
|
||||||
# If we don't do that, it causes a hangup in the GUI when we click Start Scanning because
|
# If we don't do that, it causes a hangup in the GUI when we click Start Scanning because
|
||||||
# checking if there's any file to scan involves reading the whole library. If we have the
|
# checking if there's any file to scan involves reading the whole library. If we have the
|
||||||
# iPhoto library, we assume we have at least one file.
|
# iPhoto library, we assume we have at least one file.
|
||||||
if any(path == Path('iPhoto Library') for path in self._dirs):
|
if self.has_iphoto_path():
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return directories.Directories.has_any_file(self)
|
return directories.Directories.has_any_file(self)
|
||||||
@ -158,7 +163,7 @@ class DupeGuruPE(app_cocoa.DupeGuru):
|
|||||||
self.path2iphoto[str(photo.image_path(timeout=0))] = photo
|
self.path2iphoto[str(photo.image_path(timeout=0))] = photo
|
||||||
except CommandError:
|
except CommandError:
|
||||||
pass
|
pass
|
||||||
except (CommandError, RuntimeError):
|
except (CommandError, RuntimeError, ApplicationNotFoundError):
|
||||||
pass
|
pass
|
||||||
j.start_job(self.results.mark_count, "Sending dupes to the Trash")
|
j.start_job(self.results.mark_count, "Sending dupes to the Trash")
|
||||||
self.results.perform_on_marked(op, True)
|
self.results.perform_on_marked(op, True)
|
||||||
@ -203,3 +208,12 @@ class DupeGuruPE(app_cocoa.DupeGuru):
|
|||||||
return None
|
return None
|
||||||
return ref.path
|
return ref.path
|
||||||
|
|
||||||
|
def start_scanning(self):
|
||||||
|
result = app_cocoa.DupeGuru.start_scanning(self)
|
||||||
|
if self.directories.has_iphoto_path():
|
||||||
|
try:
|
||||||
|
app('iPhoto')
|
||||||
|
except ApplicationNotFoundError:
|
||||||
|
return 4
|
||||||
|
return result
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user