Commit 9076762b by willmcgugan

Improved error on fscp

parent 3f3138fe
...@@ -27,13 +27,12 @@ class FileOpThread(threading.Thread): ...@@ -27,13 +27,12 @@ class FileOpThread(threading.Thread):
path_type, fs, path, dest_path = self.queue.get(timeout=0.1) path_type, fs, path, dest_path = self.queue.get(timeout=0.1)
except queue.Empty: except queue.Empty:
continue continue
try: try:
if path_type == FScp.DIR: if path_type == FScp.DIR:
self.dest_fs.makedir(path, recursive=True, allow_recreate=True) self.dest_fs.makedir(path, recursive=True, allow_recreate=True)
else: else:
self.action(fs, path, self.dest_fs, dest_path, overwrite=True) self.action(fs, path, self.dest_fs, dest_path, overwrite=True)
except Exception, e: except Exception, e:
print e
self.on_error(e) self.on_error(e)
self.queue.task_done() self.queue.task_done()
break break
...@@ -183,14 +182,14 @@ Copy SOURCE to DESTINATION""" ...@@ -183,14 +182,14 @@ Copy SOURCE to DESTINATION"""
for thread in threads: for thread in threads:
thread.join() thread.join()
complete = True complete = True
self.post_actions() if not any_error():
self.post_actions()
dst_fs.close() dst_fs.close()
if self.action_errors: if self.action_errors:
for error in self.action_errors: for error in self.action_errors:
self.error(self.wrap_error(unicode(error)) + '\n') self.error(self.wrap_error(unicode(error)) + '\n')
sys.stdout.write('\n')
sys.stdout.flush() sys.stdout.flush()
else: else:
if complete and options.progress: if complete and options.progress:
...@@ -216,8 +215,7 @@ Copy SOURCE to DESTINATION""" ...@@ -216,8 +215,7 @@ Copy SOURCE to DESTINATION"""
finally: finally:
self.lock.release() self.lock.release()
def on_error(self, e): def on_error(self, e):
print e
self.lock.acquire() self.lock.acquire()
try: try:
self.action_errors.append(e) self.action_errors.append(e)
...@@ -239,10 +237,8 @@ Copy SOURCE to DESTINATION""" ...@@ -239,10 +237,8 @@ Copy SOURCE to DESTINATION"""
done_steps = int(done * bar_width) done_steps = int(done * bar_width)
bar_steps = ('#' * done_steps).ljust(bar_width) bar_steps = ('#' * done_steps).ljust(bar_width)
msg = '%s %i%%' % (msg, int(done * 100.0))
msg = '%s %i%%' % (msg, int(done * 100.0))
msg = msg.ljust(20) msg = msg.ljust(20)
if total == remaining: if total == remaining:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment