diff options
author | btimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-04-16 20:26:44 +0000 |
---|---|---|
committer | btimby <btimby@67cdc799-7952-0410-af00-57a81ceafa0f> | 2012-04-16 20:26:44 +0000 |
commit | 831618e29f1033b4fe8db14058ab635643273c62 (patch) | |
tree | a22a3598e0da87736e28687b5c1d1de7fcf7c2f0 /fs/commands | |
parent | a2e85047e57d61719ef863e781f6c9b46b3390d2 (diff) | |
download | pyfilesystem-831618e29f1033b4fe8db14058ab635643273c62.tar.gz |
I am about to check in the addition of 'ftp' protocol, I could not help myself but to clean the extra whitespace.
I committed this first so as not to muddy the waters of my imminent commit. This is ONLY whitespace changes.
git-svn-id: http://pyfilesystem.googlecode.com/svn/trunk@764 67cdc799-7952-0410-af00-57a81ceafa0f
Diffstat (limited to 'fs/commands')
-rw-r--r-- | fs/commands/fsserve.py | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/fs/commands/fsserve.py b/fs/commands/fsserve.py index 9022f07..5a05dd8 100644 --- a/fs/commands/fsserve.py +++ b/fs/commands/fsserve.py @@ -8,10 +8,10 @@ from fs.utils import print_fs class FSServe(Command): - + usage = """fsserve [OPTION]... [PATH] Serves the contents of PATH with one of a number of methods""" - + def get_optparse(self): optparse = super(FSServe, self).get_optparse() optparse.add_option('-t', '--type', dest='type', type="string", default="http", @@ -21,42 +21,42 @@ Serves the contents of PATH with one of a number of methods""" optparse.add_option('-p', '--port', dest='port', type="int", help="Port number", metavar="") return optparse - - def do_run(self, options, args): - + + def do_run(self, options, args): + try: fs_url = args[0] except IndexError: - fs_url = './' - + fs_url = './' + fs, path = self.open_fs(fs_url) - + if fs.isdir(path): fs = fs.opendir(path) path = '/' - + self.output("Opened %s\n" % fs, verbose=True) - + port = options.port - + try: - - if options.type == 'http': - from fs.expose.http import serve_fs + + if options.type == 'http': + from fs.expose.http import serve_fs if port is None: port = 80 - self.output("Starting http server on %s:%i\n" % (options.addr, port), verbose=True) - serve_fs(fs, options.addr, port) - - elif options.type == 'rpc': + self.output("Starting http server on %s:%i\n" % (options.addr, port), verbose=True) + serve_fs(fs, options.addr, port) + + elif options.type == 'rpc': from fs.expose.xmlrpc import RPCFSServer if port is None: port = 80 s = RPCFSServer(fs, (options.addr, port)) self.output("Starting rpc server on %s:%i\n" % (options.addr, port), verbose=True) - s.serve_forever() - - elif options.type == 'sftp': + s.serve_forever() + + elif options.type == 'sftp': from fs.expose.sftp import BaseSFTPServer import logging log = logging.getLogger('paramiko') @@ -67,7 +67,7 @@ Serves the contents of PATH with one of a number of methods""" ch = logging.StreamHandler() ch.setLevel(logging.DEBUG) log.addHandler(ch) - + if port is None: port = 22 server = BaseSFTPServer((options.addr, port), fs) @@ -78,20 +78,20 @@ Serves the contents of PATH with one of a number of methods""" pass finally: server.server_close() - + else: self.error("Server type '%s' not recognised\n" % options.type) - + except IOError, e: if e.errno == 13: self.error('Permission denied\n') return 1 - else: + else: self.error(e.strerror + '\n') - return 1 - -def run(): - return FSServe().run() - + return 1 + +def run(): + return FSServe().run() + if __name__ == "__main__": sys.exit(run()) |