Changeset 780
- Timestamp:
- Jul 25, 2009, 2:19:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
baculafs/trunk/baculafs.py
r779 r780 16 16 17 17 LOG_FILENAME = '/tmp/baculafs.log' 18 LOG_BCONSOLE = '/tmp/bconsole.log'18 #LOG_BCONSOLE = '/tmp/bconsole.log' 19 19 LOG_BCONSOLE_DUMP = '/tmp/bconsole.out' 20 20 … … 33 33 class Bconsole: 34 34 35 #bconsole = None36 37 35 def __init__(self, client=BACULA_CLIENT): 38 #logging.basicConfig(filename=LOG_BCONSOLE,level=logging.DEBUG,) 39 logging.debug('BC init') 36 #logging.debug('BC init') 40 37 self.bconsole = pexpect.spawn( BACULA_CMD, logfile=file(LOG_BCONSOLE_DUMP, 'w'), timeout=10 ) 41 38 self.bconsole.setecho( False ) … … 47 44 self.bconsole.sendline( BACULA_CLIENT ) 48 45 self.bconsole.expect( BCONSOLE_RESTORE_PROMPT ) 49 logging.debug( "BC alive: " + str(self.bconsole.isalive()) )50 logging.debug('BC init done')46 #logging.debug( "BC alive: " + str(self.bconsole.isalive()) ) 47 #logging.debug('BC init done') 51 48 52 49 … … 54 51 55 52 path = path + "/" 56 logging.debug( " BC ls(" + path + ")" )53 logging.debug( "(" + path + ")" ) 57 54 58 55 self.bconsole.sendline( 'cd ' + path ) … … 61 58 62 59 index = self.bconsole.expect( ["cwd is: " + path + "[/]?", BCONSOLE_RESTORE_PROMPT, pexpect.EOF, pexpect.TIMEOUT ] ) 63 logging.debug( " BC ls:cd result: " + str(index) )60 logging.debug( "cd result: " + str(index) ) 64 61 65 62 if index == 0: … … 79 76 self.bconsole.expect( BCONSOLE_RESTORE_PROMPT ) 80 77 lines = self.bconsole.before.splitlines() 81 logging.debug( "BC ls: " +str(lines) )78 #logging.debug( str(lines) ) 82 79 return lines 83 80 … … 93 90 94 91 def __init__(self, *args, **kw): 95 logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,)96 92 logging.debug('init') 97 93 #self.console = Bconsole() … … 103 99 # TODO: may cause problems with filenames that ends with "/" 104 100 path = path.rstrip( '/' ) 105 logging.debug( "_getdir(" + path + ")")101 logging.debug( '"' + path + '"' ) 106 102 107 103 if (path in self.files): 108 logging.debug( " _getdir(" + path + ")=" + str(self.files[path]) )104 #logging.debug( "(" + path + ")=" + str(self.files[path]) ) 109 105 if self.files[path]['type'] == self.TYPE_FILE: 110 logging.debug( " type: file")106 logging.debug( '"' + path + '"=file (cached)' ) 111 107 return self.files[path] 112 108 elif ((self.files[path]['type'] == self.TYPE_DIR) and ('files' in self.files[path])): 113 logging.debug( " type: dir (cached)")109 logging.debug( '"' + path + '"=dir (cached)' ) 114 110 return self.files[path] 115 111 116 112 try: 117 113 files = Bconsole().ls(path) 118 logging.debug( " files: " + str( files ) ) 119 self.files[path] = {} 120 self.files[path]['type'] = self.TYPE_DIR 121 self.files[path]['dirs'] = [ ".", ".." ] 122 self.files[path]['files'] = [] 114 #logging.debug( " files: " + str( files ) ) 115 116 # setting initial empty directory. Add entires later in this function 117 self.files[path] = { 'type': self.TYPE_DIR, 'dirs': [ ".", ".." ], 'files': [] } 123 118 for i in files: 124 119 if i.endswith('/'): … … 133 128 self.files[path + "/" + i] = { 'type': self.TYPE_FILE } 134 129 135 except :136 logging. debug( "Unexpected error:" + sys.exc_info()[0])130 except Exception as e: 131 logging.exception(e) 137 132 logging.error( "no access to path " + path ) 138 133 self.files[path] = { 'type': TYPE_NONE } 139 logging.debug( " "+ str( self.files[path] ) )134 logging.debug( '"' + path + '"=' + str( self.files[path] ) ) 140 135 return self.files[path] 141 136 … … 144 139 # TODO: only works after readdir for the directory (eg. ls) 145 140 def getattr(self, path): 146 logging.debug( "getattr " + path )147 141 142 # TODO: may cause problems with filenames that ends with "/" 143 path = path.rstrip( '/' ) 144 logging.debug( '"' + path + '"' ) 145 146 file = self.files[path] 148 147 st = fuse.Stat() 149 148 150 149 #file = self._getdir( path ) 151 152 # TODO: may cause problems with filenames that ends with "/"153 path = path.rstrip( '/' )154 file = self.files[path]155 150 156 151 if file['type'] == self.TYPE_FILE: … … 171 166 172 167 def readdir(self, path, offset): 173 logging.debug( "readdir " + path + "(offset: " + str(offset) + ")")168 logging.debug( '"' + path + '", offset=' + str(offset) + ')' ) 174 169 175 170 dir = self._getdir( path ) … … 193 188 194 189 if __name__ == "__main__": 190 # initialize logging 191 logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG,format="%(asctime)s %(process)5d(%(threadName)s) %(levelname)-7s %(funcName)s( %(message)s )") 192 195 193 fs = BaculaFS() 196 194 fs.parse()
Note:
See TracChangeset
for help on using the changeset viewer.