Changeset 785
- Timestamp:
- Aug 27, 2009, 5:34:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
baculafs/trunk/baculafs.py
r784 r785 28 28 #BACULA_CMD = 'strace -f -o /tmp/bconsole.strace /usr/sbin/bconsole -n' 29 29 BACULA_CMD = '/usr/sbin/bconsole -n' 30 # .clients31 # 5: ting-fd32 BACULA_CLIENT='5'33 30 34 31 BCONSOLE_CMD_PROMPT='\*' … … 37 34 38 35 36 class BconsoleState: 37 UNKNOWN = '' 38 SELECT_PROMPT = BCONSOLE_SELECT_PROMPT 39 RESTORE_PROMPT = BCONSOLE_RESTORE_PROMPT 40 ERROR = "error" 41 42 39 43 class Bconsole: 40 44 41 def __init__(self , client=BACULA_CLIENT):45 def __init__(self): 42 46 #logging.debug('BC init') 43 47 44 48 self.cwd = "/" 49 self.state = BconsoleState.UNKNOWN 45 50 46 51 self.bconsole = pexpect.spawn( BACULA_CMD, logfile=file(LOG_BCONSOLE_DUMP, 'w'), timeout=10 ) … … 51 56 self.bconsole.sendline( "5" ) 52 57 #self.bconsole.expect( BCONSOLE_SELECT_PROMPT ) 53 54 55 58 56 59 #self.bconsole.sendline( BACULA_CLIENT ) … … 81 84 82 85 83 def cd(self,path): 84 path = self._normalize_dir( path ) 85 logging.debug( "(" + path + ")" ) 86 87 if path = "": 88 return True 86 87 def wait_for_prompt(self): 88 89 # set to error state. 90 # Only set back to valid state, 91 # if a valid prompt is received 92 self.state=BconsoleState.ERROR 89 93 90 94 try: … … 92 96 if index == 0: 93 97 # SELECT_PROMPT 94 return self.cd_select( path ) 98 self.state=BconsoleState.SELECT_PROMPT 99 return BCONSOLE_SELECT_PROMPT 95 100 elif index == 1: 96 101 # RESTORE_PROMPT 97 return self.cd_restore( path ) 102 self.state=BconsoleState.RESTORE_PROMPT 103 return BCONSOLE_RESTORE_PROMPT 104 else: 105 logging.error( "unexpected result" ) 98 106 except pexpect.EOF: 99 107 logging.error( "EOF bconsole" ) 100 108 except pexpect.TIMEOUT: 101 109 logging.error( "TIMEOUT bconsole" ) 110 111 return self.state 112 113 114 def cd(self,path): 115 path = self._normalize_dir( path ) 116 logging.debug( "(" + path + ")" ) 117 118 if not path: 119 return True 120 121 state = self.wait_for_prompt() 122 if state == BconsoleState.SELECT_PROMPT: 123 return self.cd_select( path ) 124 elif state == BconsoleState.RESTORE_PROMPT: 125 return self.cd_restore( path ) 126 # else error 127 return False 102 128 103 129
Note:
See TracChangeset
for help on using the changeset viewer.