Changeset 1148


Ignore:
Timestamp:
05/22/13 12:45:35 (8 years ago)
Author:
joergs
Message:

various improvements

Location:
baculafs/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • baculafs/trunk/README.txt

    r788 r1148  
    33a python-fuse based virtual filesystem for recovery
    44
    5 currentl status:  prototype/proof of concept
     5current status:  prototype/proof of concept
    66
    77to demonstrate access to backuped files information
     
    1313- only readdir and stat. No reading or opening of files
    1414- currently, only most recent backup for a client is implemented.
    15   Change to selection nummers in the source code to change this
     15  Change the selection nummers in the source code to change this
    1616- relies on cached information. Cached is filled by readdir.
    1717  If you want to access a subdirectory, make sure, you have read the upper directories before
  • baculafs/trunk/baculafs.py

    r789 r1148  
    4343class Bconsole:
    4444
    45     def __init__(self):
     45    def __init__(self, timeout = 300):
    4646        #logging.debug('BC init')
    4747
     48        self.timeout = timeout
    4849        self.cwd = "/"
    4950        self.state = BconsoleState.UNKNOWN
    5051        self.last_items_dict = {}
    5152
    52         self.bconsole = pexpect.spawn( BACULA_CMD, logfile=file(LOG_BCONSOLE_DUMP, 'w'), timeout=10 )
     53        self.bconsole = pexpect.spawn( BACULA_CMD, logfile=file(LOG_BCONSOLE_DUMP, 'w'), timeout=timeout )
    5354        self.bconsole.setecho( False )
    5455        self.bconsole.expect( BCONSOLE_CMD_PROMPT )
     
    101102            logging.error( "EOF bconsole" )
    102103        except pexpect.TIMEOUT:
    103             logging.error( "TIMEOUT  bconsole" )
     104            logging.error( "TIMEOUT bconsole" )
     105            raise
    104106
    105107        return self.state
     
    149151
    150152    def cd_restore(self, path):
     153       
     154        result = False
     155
    151156        logging.debug( "(" + path + ")" )
    152157
     
    155160        #self.bconsole.sendline( 'pwd' )
    156161
    157         index = self.bconsole.expect( ["cwd is: " + path + "[/]?", BCONSOLE_RESTORE_PROMPT, pexpect.EOF, pexpect.TIMEOUT ] )
    158         logging.debug( "cd result: " + str(index) )
    159 
    160         if index == 0:
    161             # path ok, now wait for prompt
    162             self.bconsole.expect( BCONSOLE_RESTORE_PROMPT )
    163             return True
    164         elif index == 1:
    165             #print "wrong path"
    166             return False
    167         elif index == 2:
     162        try:
     163            index = self.bconsole.expect( ["cwd is: " + path + "[/]?", BCONSOLE_RESTORE_PROMPT ] )
     164            logging.debug( "cd result: " + str(index) )
     165
     166            if index == 0:
     167                # path ok, now wait for prompt
     168                self.bconsole.expect( BCONSOLE_RESTORE_PROMPT )
     169                result = True
     170            elif index == 1:
     171                # TODO: this is even returned, if path is correct. fix this.
     172                logging.warning( "wrong path" )
     173            else:
     174                logging.error( "unexpected result" )
     175
     176        except pexpect.EOF:
    168177            logging.error( "EOF bconsole" )
    169             #raise?
    170             return False
    171         elif index == 3:
    172             logging.error( "TIMEOUT  bconsole" )
    173             return False
     178        except pexpect.TIMEOUT:
     179            logging.error( "TIMEOUT bconsole" )
     180            #raise
     181
     182        return result
     183
    174184
    175185    def ls(self, path):
     
    296306                    self.files[path + "/" + i] = { 'type': self.TYPE_FILE }
    297307
     308        except pexpect.TIMEOUT:
     309            logging.error( "failed to access path " + path + " (TIMEOUT)" )
    298310        except Exception as e:
    299311            logging.exception(e)
Note: See TracChangeset for help on using the changeset viewer.