[IMP] runbot: add a mode parameter to readfile

When using the read_method in a "python job", it's sometimes needed to
read a file in binary mode.

With this commit, the mode can be specified when calling the method.
This commit is contained in:
Christophe Monniez 2019-06-11 14:55:18 +02:00
parent 799f3aed22
commit 800691a14c

View File

@ -890,12 +890,13 @@ class runbot_build(models.Model):
new_step = step_ids[next_index] # job to do, state is job_state (testing or running) new_step = step_ids[next_index] # job to do, state is job_state (testing or running)
return {'active_step': new_step.id, 'local_state': new_step._step_state()} return {'active_step': new_step.id, 'local_state': new_step._step_state()}
def read_file(self, file): def read_file(self, file, mode='r'):
file_path = self._path(file) file_path = self._path(file)
try: try:
with open(file_path, 'r') as f: with open(file_path, mode) as f:
return f.read() return f.read()
except: except Exception as e:
self._log('readfile', 'exception: %s' % e)
return False return False
def build_type_label(self): def build_type_label(self):