Make it possible to stop scanner more cleanly

This commit is contained in:
Thomas Adamcik 2011-06-02 18:41:43 +02:00
parent 94cae3be42
commit acad477c8a
2 changed files with 9 additions and 3 deletions

View File

@ -20,7 +20,10 @@ if __name__ == '__main__':
print >> sys.stderr, 'Scanning %s' % settings.LOCAL_MUSIC_PATH
scanner = Scanner(settings.LOCAL_MUSIC_PATH, store, debug)
scanner.start()
try:
scanner.start()
except KeyboardInterrupt:
scanner.stop()
print >> sys.stderr, 'Done'

View File

@ -82,8 +82,11 @@ class Scanner(object):
data = dict([(k, data[k]) for k in data.keys()])
data['uri'] = unicode(self.uribin.get_property('uri'))
data['duration'] = self.get_duration()
self.data_callback(data)
self.next_uri()
try:
self.data_callback(data)
self.next_uri()
except KeyboardInterrupt:
self.stop()
def process_error(self, bus, message):
if self.error_callback: