Commit 7efa4873 by willmcgugan@gmail.com

errno constants

parent 4e059083
...@@ -5,6 +5,7 @@ import sys ...@@ -5,6 +5,7 @@ import sys
from fs.opener import opener from fs.opener import opener
from fs.commands.runner import Command from fs.commands.runner import Command
from fs.utils import print_fs from fs.utils import print_fs
import errno
class FSServe(Command): class FSServe(Command):
...@@ -13,13 +14,13 @@ class FSServe(Command): ...@@ -13,13 +14,13 @@ class FSServe(Command):
Serves the contents of PATH with one of a number of methods""" Serves the contents of PATH with one of a number of methods"""
def get_optparse(self): def get_optparse(self):
optparse = super(FSServe, self).get_optparse() optparse = super(FSServe, self).get_optparse()
optparse.add_option('-t', '--type', dest='type', type="string", default="http", optparse.add_option('-t', '--type', dest='type', type="string", default="http",
help="Server type to create (http, rpc, sftp)", metavar="TYPE") help="Server type to create (http, rpc, sftp)", metavar="TYPE")
optparse.add_option('-a', '--addr', dest='addr', type="string", default="127.0.0.1", optparse.add_option('-a', '--addr', dest='addr', type="string", default="127.0.0.1",
help="Server address", metavar="ADDR") help="Server address", metavar="ADDR")
optparse.add_option('-p', '--port', dest='port', type="int", optparse.add_option('-p', '--port', dest='port', type="int",
help="Port number", metavar="") help="Port number", metavar="")
return optparse return optparse
def do_run(self, options, args): def do_run(self, options, args):
...@@ -90,10 +91,10 @@ Serves the contents of PATH with one of a number of methods""" ...@@ -90,10 +91,10 @@ Serves the contents of PATH with one of a number of methods"""
self.error("Server type '%s' not recognised\n" % options.type) self.error("Server type '%s' not recognised\n" % options.type)
except IOError, e: except IOError, e:
if e.errno == 13: if e.errno == errno.EACCES:
self.error('Permission denied\n') self.error('Permission denied\n')
return 1 return 1
else: else:
self.error(str(e) + '\n') self.error(str(e) + '\n')
return 1 return 1
......
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