instance.py

changeset 20
fdfbe5d7b677
parent 12
16a8c63344c0
child 21
c36e549a7f12
equal deleted inserted replaced
19:f9ce2442f14f 20:fdfbe5d7b677
2 # Borgend borg launcher / processor 2 # Borgend borg launcher / processor
3 # 3 #
4 4
5 import json 5 import json
6 import logging 6 import logging
7 import os
7 from subprocess import Popen, PIPE 8 from subprocess import Popen, PIPE
8 from config import settings, arglistify 9 from config import settings, arglistify
9 10
10 necessary_opts=['--log-json', '--progress'] 11 necessary_opts=['--log-json', '--progress']
11 12
33 if self.operation in necessary_opts_for: 34 if self.operation in necessary_opts_for:
34 cmd=cmd+necessary_opts_for[self.operation] 35 cmd=cmd+necessary_opts_for[self.operation]
35 36
36 return cmd+arglistify(self.args)+[self.archive_or_repository]+self.argsl 37 return cmd+arglistify(self.args)+[self.archive_or_repository]+self.argsl
37 38
38 def launch(self): 39 def launch(self, password=None):
39 cmd=self.construct_cmdline() 40 cmd=self.construct_cmdline()
40 41
41 logging.info('Launching ' + str(cmd)) 42 logging.info('Launching ' + str(cmd))
42 43
43 self.proc=Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE) 44 env=None
45 if password:
46 env=os.environ.copy()
47 env['BORG_PASSPHRASE']=password
48
49 self.proc=Popen(cmd, env=env, stdout=PIPE, stderr=PIPE, stdin=PIPE)
44 50
45 # We don't do password input etc. 51 # We don't do password input etc.
46 self.proc.stdin.close() 52 self.proc.stdin.close()
47 53
48 def read_result(self): 54 def read_result(self):

mercurial