borgend/instance.py

changeset 87
a214d475aa28
parent 86
2fe66644c50d
child 89
51cc2e25af38
equal deleted inserted replaced
86:2fe66644c50d 87:a214d475aa28
33 self.operation=operation; 33 self.operation=operation;
34 self.archive_or_repository=archive_or_repository; 34 self.archive_or_repository=archive_or_repository;
35 self.common_params=common_params 35 self.common_params=common_params
36 self.op_params=op_params 36 self.op_params=op_params
37 self.paths=paths 37 self.paths=paths
38 self.proc=None
38 39
39 def construct_cmdline(self): 40 def construct_cmdline(self):
40 cmd=([settings['borg']['executable']]+necessary_opts+ 41 cmd=([settings['borg']['executable']]+necessary_opts+
41 arglistify(self.common_params)+ 42 arglistify(self.common_params)+
42 [self.operation]) 43 [self.operation])
122 'name': 'borgend.instance.BorgInstance', 123 'name': 'borgend.instance.BorgInstance',
123 'msgid': 'Borgend.JSONFail', 124 'msgid': 'Borgend.JSONFail',
124 'message': str(errmsg)} 125 'message': str(errmsg)}
125 126
126 def terminate(self): 127 def terminate(self):
127 self.proc.terminate() 128 if self.proc:
129 self.proc.terminate()
128 130
129 def wait(self): 131 # Returns True if has terminated
130 return self.proc.wait() is not None 132 def wait(self, timeout=None):
133 if self.proc:
134 return self.proc.wait(timeout=timeout) is not None
135 else:
136 return True
131 137
132 def has_terminated(self): 138 def has_terminated(self):
133 return self.proc.poll() is not None 139 return not self.proc or (self.proc.poll() is not None)
134 140

mercurial