instance.py

changeset 20
fdfbe5d7b677
parent 12
16a8c63344c0
child 21
c36e549a7f12
--- a/instance.py	Sat Jan 20 23:19:16 2018 +0000
+++ b/instance.py	Sat Jan 20 23:50:36 2018 +0000
@@ -4,6 +4,7 @@
 
 import json
 import logging
+import os
 from subprocess import Popen, PIPE
 from config import settings, arglistify
 
@@ -35,12 +36,17 @@
 
         return cmd+arglistify(self.args)+[self.archive_or_repository]+self.argsl
 
-    def launch(self):
+    def launch(self, password=None):
         cmd=self.construct_cmdline()
 
         logging.info('Launching ' + str(cmd))
 
-        self.proc=Popen(cmd, stdout=PIPE, stderr=PIPE, stdin=PIPE)
+        env=None
+        if password:
+            env=os.environ.copy()
+            env['BORG_PASSPHRASE']=password
+
+        self.proc=Popen(cmd, env=env, stdout=PIPE, stderr=PIPE, stdin=PIPE)
 
         # We don't do password input etc.
         self.proc.stdin.close()

mercurial