1
0
mirror of https://github.com/arsenetar/dupeguru.git synced 2025-03-10 05:34:36 +00:00

[#26 state:fixed] Attempt to fix those iTunes connection errors.

--HG--
extra : convert_revision : svn%3Ac306627e-7827-47d3-bdf0-9a457c9553a1/trunk%4036
This commit is contained in:
hsoft 2009-06-10 13:54:24 +00:00
parent 8f24c2baf3
commit becc4a87a7

View File

@ -36,11 +36,12 @@ class DupeGuruME(app_cocoa.DupeGuru):
def remove_dead_tracks(self): def remove_dead_tracks(self):
def do(j): def do(j):
a = app('iTunes') a = app('iTunes')
a.activate(timeout=0)
for index, track in enumerate(j.iter_with_progress(self.dead_tracks)): for index, track in enumerate(j.iter_with_progress(self.dead_tracks)):
if index % 100 == 0: if index % 100 == 0:
time.sleep(.1) time.sleep(.1)
try: try:
track.delete() track.delete(timeout=0)
except CommandError as e: except CommandError as e:
logging.warning('Error while trying to remove a track from iTunes: %s' % unicode(e)) logging.warning('Error while trying to remove a track from iTunes: %s' % unicode(e))
@ -49,9 +50,10 @@ class DupeGuruME(app_cocoa.DupeGuru):
def scan_dead_tracks(self): def scan_dead_tracks(self):
def do(j): def do(j):
a = app('iTunes') a = app('iTunes')
a.activate(timeout=0)
try: try:
[source] = [s for s in a.sources() if s.kind() == k.library] [source] = [s for s in a.sources(timeout=0) if s.kind(timeout=0) == k.library]
[library] = source.library_playlists() [library] = source.library_playlists(timeout=0)
except ValueError: except ValueError:
logging.warning('Some unexpected iTunes configuration encountered') logging.warning('Some unexpected iTunes configuration encountered')
return return
@ -60,7 +62,7 @@ class DupeGuruME(app_cocoa.DupeGuru):
for index, track in enumerate(j.iter_with_progress(tracks)): for index, track in enumerate(j.iter_with_progress(tracks)):
if index % 100 == 0: if index % 100 == 0:
time.sleep(.1) time.sleep(.1)
if track.location() == k.missing_value: if track.location(timeout=0) == k.missing_value:
self.dead_tracks.append(track) self.dead_tracks.append(track)
logging.info('Found %d dead tracks' % len(self.dead_tracks)) logging.info('Found %d dead tracks' % len(self.dead_tracks))