#!/usr/bin/env python # FuseArchive: # Copyright (C) 2009 Steve Slaven # # This program can be distributed under the terms of the GNU GPL. # See the file COPYING. # import logging, sys, os, fuse import FuseArchive enable_stats = False enable_psyco = False if enable_psyco: # Import Psyco if available try: import psyco psyco.full() except ImportError: pass def main(): usage = """ Userspace filesystem that uses chunks to eliminate multiple copies of parts of files for long term storage """ + fuse.Fuse.fusage server = FuseArchive.FileSystem(version="%prog " + fuse.__version__, usage=usage, dash_s_do='setsingle') server.multithreaded = False server.parse(values=server, errex=1) if server.parser.largs == None or len(server.parser.largs) != 2: print "Usage: " + sys.argv[0] + " storageDirectory mountDirectory" sys.exit(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 else: # Null-out the logging.debug statement, otherwise it's a top-3 cpu # eater in stat profiling logging.debug = lambda x: 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' ) # Get backing store directory server.root = server.parser.largs[0] 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) server.main() if enable_stats: import hotshot prof = hotshot.Profile( "fusearchive_stats" ) prof.runcall(main) prof.close() else: main()