instance.py

changeset 32
06fc14211ba9
parent 31
b4b4bb7a2ec5
child 34
9fce700d42de
equal deleted inserted replaced
31:b4b4bb7a2ec5 32:06fc14211ba9
41 def launch(self, passphrase=None): 41 def launch(self, passphrase=None):
42 cmd=self.construct_cmdline() 42 cmd=self.construct_cmdline()
43 43
44 logger.info('Launching ' + str(cmd)) 44 logger.info('Launching ' + str(cmd))
45 45
46 # Set passphrase if not, or set to empty if not known, so borg
47 # won't hang waiting for it, which seems to happen even if we
48 # close stdin.
46 env=os.environ.copy() 49 env=os.environ.copy()
47 if passphrase: 50 env['BORG_PASSPHRASE']=passphrase or ''
48 env['BORG_PASSPHRASE']=passphrase
49 51
50 # Workaround: if launched is a standalone app created with py2app, 52 # Workaround: if launched is a standalone app created with py2app,
51 # borg will fail unless Python environment is reset. 53 # borg will fail unless Python environment is reset.
52 # TODO: Of course, this will fail if the system needs the variables 54 # TODO: Of course, this will fail if the system needs the variables
53 # PYTHONPATH or PYTHONHOME set to certain values. 55 # PYTHONPATH or PYTHONHOME set to certain values.
69 logger.debug('Borg stdout pipe EOF?') 71 logger.debug('Borg stdout pipe EOF?')
70 return None 72 return None
71 73
72 try: 74 try:
73 return json.loads(line) 75 return json.loads(line)
74 except: 76 except Exception as err:
75 logger.warning('JSON parse failed on: "%s"' % line) 77 logger.warning('JSON parse failed on: "%s"' % line)
76 return None 78 return None
77 79
78 def read_log(self): 80 def read_log(self):
79 stream=self.proc.stderr 81 stream=self.proc.stderr

mercurial