From 2bcce0964b8010ab7c0b53c3afc058f843f8d581 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Fri, 7 Aug 2009 10:23:13 -0700 Subject: Moved everything to main() so we can run the profiler again diff --git a/fusearchive.py b/fusearchive.py index 04e2b16..696c666 100755 --- a/fusearchive.py +++ b/fusearchive.py @@ -21,49 +21,53 @@ if enable_psyco: except ImportError: pass -if enable_stats: - import hotshot - prof = hotshot.Profile( "fusearchive_stats" ) - prof.runcall() - prof.close() +def main(): + usage = """ + Userspace filesystem that uses chunks to eliminate multiple copies of parts + of files for long term storage + + """ + fuse.Fuse.fusage -usage = """ -Userspace filesystem that uses chunks to eliminate multiple copies of parts -of files for long term storage + server = FuseArchive.FileSystem(version="%prog " + fuse.__version__, + usage=usage, + dash_s_do='setsingle') -""" + fuse.Fuse.fusage + server.multithreaded = False -server = FuseArchive.FileSystem(version="%prog " + fuse.__version__, - usage=usage, - dash_s_do='setsingle') + server.parse(values=server, errex=1) -server.multithreaded = False + if server.parser.largs == None or len(server.parser.largs) != 2: + print "Usage: " + sys.argv[0] + " storageDirectory mountDirectory" + sys.exit(1) -server.parse(values=server, errex=1) + log_level = logging.WARNING + # If debug is in the assembed opts then enable our debug too + if server.fuse_args.assemble()[ -1 ].find( 'debug' ) != -1: + log_level = logging.DEBUG -if server.parser.largs == None or len(server.parser.largs) != 2: - print "Usage: " + sys.argv[0] + " storageDirectory mountDirectory" - sys.exit(1) + logging.basicConfig( level = log_level, + format = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(module)s:%(funcName)s() %(message)s', + stream = sys.stderr, + filemode = 'w' ) -log_level = logging.WARNING -# If debug is in the assembed opts then enable our debug too -if server.fuse_args.assemble()[ -1 ].find( 'debug' ) != -1: - log_level = logging.DEBUG + # Get backing store directory + server.root = server.parser.largs[0] -logging.basicConfig( level = log_level, - format = '%(asctime)s %(levelname)s %(filename)s:%(lineno)d %(module)s:%(funcName)s() %(message)s', - stream = sys.stderr, - filemode = 'w' ) + try: + if server.fuse_args.mount_expected(): + os.chdir(server.root) + except OSError: + print >> sys.stderr, "can't enter root of underlying filesystem" + sys.exit(1) -# Get backing store directory -server.root = server.parser.largs[0] + server.main() -try: - if server.fuse_args.mount_expected(): - os.chdir(server.root) -except OSError: - print >> sys.stderr, "can't enter root of underlying filesystem" - sys.exit(1) +if enable_stats: + import hotshot + prof = hotshot.Profile( "fusearchive_stats" ) + prof.runcall(main) + prof.close() +else: + main() -server.main() -- cgit v0.10.2