diff options
author | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-12-07 00:20:10 +0000 |
---|---|---|
committer | willmcgugan <willmcgugan@67cdc799-7952-0410-af00-57a81ceafa0f> | 2010-12-07 00:20:10 +0000 |
commit | 6b1c5e2801216e185f2e781d4b2f6bd5b12fd020 (patch) | |
tree | d543000714a3f17d55c33d6b2c32eaee6522e443 /fs/commands | |
parent | f0da7f55418fd5c58161021499784584a7739243 (diff) | |
download | pyfilesystem-6b1c5e2801216e185f2e781d4b2f6bd5b12fd020.tar.gz |
Fixes for zip opener
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@542 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/commands')
-rw-r--r-- | fs/commands/fscp.py | 19 | ||||
-rw-r--r-- | fs/commands/runner.py | 14 |
2 files changed, 17 insertions, 16 deletions
diff --git a/fs/commands/fscp.py b/fs/commands/fscp.py index 5421864..81915f1 100644 --- a/fs/commands/fscp.py +++ b/fs/commands/fscp.py @@ -29,7 +29,7 @@ class FileOpThread(threading.Thread): except queue.Empty: continue try: - if path_type == FSCopy.DIR: + if path_type == FScp.DIR: self.dest_fs.makedir(path, recursive=True, allow_recreate=True) else: self.action(fs, path, self.dest_fs, dest_path, overwrite=True) @@ -43,7 +43,7 @@ class FileOpThread(threading.Thread): except Exception, e: self.on_error(e) -class FSCopy(Command): +class FScp(Command): DIR, FILE = 0, 1 @@ -54,7 +54,7 @@ Copy SOURCE to DESTINATION""" return copyfile def get_optparse(self): - optparse = super(FSCopy, self).get_optparse() + optparse = super(FScp, self).get_optparse() optparse.add_option('-p', '--progress', dest='progress', action="store_true", default=False, help="show progress", metavar="PROGRESS") optparse.add_option('-t', '--threads', dest='threads', action="store", default=1, @@ -100,8 +100,9 @@ Copy SOURCE to DESTINATION""" if src_fs.isdir(src_path): self.root_dirs.append((src_fs, src_path)) src_sub_fs = src_fs.opendir(src_path) - for dir_path, file_paths in src_sub_fs.walk(): - copy_fs_paths.append((self.DIR, src_sub_fs, dir_path, dir_path)) + for dir_path, file_paths in src_sub_fs.walk(): + if dir_path not in ('', '/'): + copy_fs_paths.append((self.DIR, src_sub_fs, dir_path, dir_path)) sub_fs = src_sub_fs.opendir(dir_path) for file_path in file_paths: copy_fs_paths.append((self.FILE, sub_fs, file_path, pathjoin(dir_path, file_path))) @@ -111,8 +112,7 @@ Copy SOURCE to DESTINATION""" else: self.error('%s is not a file or directory\n' % src_path) return 1 - - + if self.options.threads > 1: copy_fs_dirs = [r for r in copy_fs_paths if r[0] == self.DIR] copy_fs_paths = [r for r in copy_fs_paths if r[0] == self.FILE] @@ -150,8 +150,7 @@ Copy SOURCE to DESTINATION""" # caught until the queue is finished #file_queue.join() - except KeyboardInterrupt: - print "!" + except KeyboardInterrupt: options.progress = False if self.action_error: self.error(self.wrap_error(unicode(self.action_error)) + '\n') @@ -229,7 +228,7 @@ Copy SOURCE to DESTINATION""" return bar def run(): - return FSCopy().run() + return FScp().run() if __name__ == "__main__": sys.exit(run()) diff --git a/fs/commands/runner.py b/fs/commands/runner.py index f1d18e6..9a0bb9f 100644 --- a/fs/commands/runner.py +++ b/fs/commands/runner.py @@ -213,7 +213,7 @@ class Command(object): help="make output verbose", metavar="VERBOSE") return optparse - def run(self): + def run(self): parser = self.get_optparse() options, args = parser.parse_args() args = [unicode(arg, sys.getfilesystemencoding()) for arg in args] @@ -227,13 +227,15 @@ class Command(object): if self.is_terminal(): self.output("\n") return 0 + except ValueError: + pass except SystemExit: return 0 - #except IOError: - # return 1 - #except Exception, e: - # self.error(self.wrap_error('Internal Error - %s\n' % unicode(e))) - # return 1 + except IOError: + return 1 + except Exception, e: + self.error(self.wrap_error('Internal Error - %s\n' % unicode(e))) + return 1 |