From abae6e40ca6cd2cb40791568b54833487a12ab18 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 30 Apr 2013 17:39:31 +0200 Subject: [PATCH] warn and ignore unsupported files --- pandora_client/__init__.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pandora_client/__init__.py b/pandora_client/__init__.py index 4e25039..81f2772 100644 --- a/pandora_client/__init__.py +++ b/pandora_client/__init__.py @@ -311,7 +311,10 @@ class Client(object): break if update: info = utils.avinfo(path) - if info['size'] > 0: + if 'error' in info or info['size'] == 0: + print info + return False + else: oshash = info['oshash'] sha1 = None deleted = -1 @@ -320,8 +323,7 @@ class Client(object): c.execute(u'INSERT OR REPLACE INTO file values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', t) conn.commit() - else: - print info + return True def cmd(self, args): filename = args[0] @@ -415,6 +417,7 @@ class Client(object): files = [] unknown = [] ignored = [] + unsupported = [] for dirpath, dirnames, filenames in os.walk(path, followlinks=True): if isinstance(dirpath, str): dirpath = dirpath.decode('utf-8') @@ -432,8 +435,10 @@ class Client(object): unknown.append(f) files = list(set(files) - set(unknown)) + for f in files: - self.scan_file(f) + if not self.scan_file(f): + unsupported.append(f) if unknown: example = example_path(self) @@ -443,6 +448,13 @@ class Client(object): print '\n\t'.join([f[len(path):] for f in unknown]) print '' + if unsupported: + files = list(set(files) - set(unsupported)) + print 'The following files are in an unsupported format and will not be synced:' + print '\t', + print '\n\t'.join([f[len(path):] for f in unsupported]) + print '' + deleted_files = filter(lambda f: f not in files, known_files) new_files = filter(lambda f: f not in known_files, files) conn, c = self._conn() @@ -452,8 +464,8 @@ class Client(object): c.execute('UPDATE file SET deleted=? WHERE path=?', (deleted, f)) conn.commit() - print "scanned volume %s: %s files, %s new, %s deleted, %s ignored" % ( - name, len(files), len(new_files), len(deleted_files), len(ignored)) + print "scanned volume %s: %s files, %s new, %s deleted, %s ignored, %s unsupported" % ( + name, len(files), len(new_files), len(deleted_files), len(ignored), len(unsupported)) def extract(self, args):