39 def launch(self, passphrase=None): |
39 def launch(self, passphrase=None): |
40 cmd=self.construct_cmdline() |
40 cmd=self.construct_cmdline() |
41 |
41 |
42 logging.info('Launching ' + str(cmd)) |
42 logging.info('Launching ' + str(cmd)) |
43 |
43 |
44 env=None |
44 env=os.environ.copy() |
45 if passphrase: |
45 if passphrase: |
46 env=os.environ.copy() |
|
47 env['BORG_PASSPHRASE']=passphrase |
46 env['BORG_PASSPHRASE']=passphrase |
48 |
47 |
49 # Workaround: if launched is a standalone app created with py2app, |
48 # Workaround: if launched is a standalone app created with py2app, |
50 # borg will fail unless Python environment is reset. |
49 # borg will fail unless Python environment is reset. |
51 # TODO: Of course, this will fail if the system needs the variables |
50 # TODO: Of course, this will fail if the system needs the variables |
52 # PYTHONPATH or PYTHONHOME set to certain values. |
51 # PYTHONPATH or PYTHONHOME set to certain values. |
53 if '_PY2APP_LAUNCHED_' in env and env['_PY2APP_LAUNCHED_']=='1': |
52 if '_PY2APP_LAUNCHED_' in env: |
54 if env==None: |
53 val=env['_PY2APP_LAUNCHED_'] |
55 env=os.environ.copy() |
54 if val=='1': |
56 del env['PYTHONPATH'] |
55 del env['PYTHONPATH'] |
57 del env['PYTHONHOME'] |
56 del env['PYTHONHOME'] |
58 |
57 |
59 self.proc=Popen(cmd, env=env, stdout=PIPE, stderr=PIPE, stdin=PIPE) |
58 self.proc=Popen(cmd, env=env, stdout=PIPE, stderr=PIPE, stdin=PIPE) |
60 |
59 |
61 # We don't do passphrase input etc. |
60 # We don't do passphrase input etc. |
62 self.proc.stdin.close() |
61 self.proc.stdin.close() |