Skip to content

Commit 02e1907

Browse files
[green-dragon-migration] update the tasktool files to python3 (#147)
## In This PR * Update tasktool files to python3 and allow task tool to be able to run independently from source repo without having to rely on external systems (CI) to set PYTHONPATH This code has been tested on https://green.lab.llvm.org/
1 parent ea253d9 commit 02e1907

File tree

4 files changed

+21
-10
lines changed

4 files changed

+21
-10
lines changed

tasks/tasktool/bin/build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
import sys
33
import os.path
44
sys.path = ['%s/..' % os.path.dirname(os.path.realpath(__file__))] + sys.path

tasks/tasktool/bin/task

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
import sys
33
import os.path
44
sys.path = ['%s/..' % os.path.dirname(os.path.realpath(__file__))] + sys.path

tasks/tasktool/tasktool/build.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
import os
2+
import sys
3+
4+
sys.path.append(os.path.dirname(__file__))
5+
16
from pipes import quote
27
import json
38
import os

tasks/tasktool/tasktool/task.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
'''
22
Task runner.
33
'''
4+
5+
import os
6+
import sys
7+
8+
sys.path.append(os.path.dirname(__file__))
9+
410
import argparse
511
import copy
612
import json
@@ -150,8 +156,8 @@ def _rewrite_local_git_urls(buildconfig):
150156
Prefix all git repository urls in buildconfig that start with a slash
151157
(they reference local files) with a prefix of the local machine/user.
152158
'''
153-
hostname = utils.check_output(['hostname', '-f']).strip()
154-
user = utils.check_output(['whoami']).strip()
159+
hostname = utils.check_output(['hostname', '-f'], encoding='utf8').strip()
160+
user = utils.check_output(['whoami'], encoding='utf8').strip()
155161
for name, config in buildconfig.items():
156162
if not isinstance(config, dict):
157163
continue
@@ -294,7 +300,7 @@ def _make_buildscript(hook, buildconfig, keep_buildconfig=False):
294300
buildconfig_file.close()
295301
build = utils.check_output([hook, _userdir, buildconfig.taskfilename,
296302
buildconfig_filename,
297-
buildconfig.taskname], cwd=_hooksdir)
303+
buildconfig.taskname], cwd=_hooksdir, encoding='utf8')
298304
if not keep_buildconfig:
299305
os.unlink(buildconfig_filename)
300306

@@ -307,7 +313,7 @@ def _make_buildscript(hook, buildconfig, keep_buildconfig=False):
307313

308314
def _mk_submit_results(buildname):
309315
return utils.check_output(['./mk-submit-results', _userdir, buildname],
310-
cwd=_hooksdir)
316+
cwd=_hooksdir, encoding='utf8')
311317

312318

313319
def _command_try(args):
@@ -322,7 +328,7 @@ def _command_try(args):
322328
tempf.write(build)
323329
tempf.close()
324330
utils.check_call(['./exec-try-build', _userdir, tempf.name, buildname],
325-
cwd=_hooksdir)
331+
cwd=_hooksdir, encoding='utf8')
326332
os.unlink(tempf.name)
327333

328334

@@ -339,7 +345,7 @@ def _command_submit(args):
339345
tempf.write(build)
340346
tempf.close()
341347
utils.check_call(['./submit', _userdir, tempf.name, buildname],
342-
cwd=_hooksdir)
348+
cwd=_hooksdir, encoding='utf8')
343349
os.unlink(tempf.name)
344350

345351

@@ -368,7 +374,7 @@ def _command_jenkinsrun(args):
368374
repro_script = os.path.join(taskdir, 'repro_message.sh')
369375
if os.access(repro_script, os.X_OK):
370376
utils.check_call([repro_script, _userdir,
371-
buildconfig.taskfilename])
377+
buildconfig.taskfilename], encoding='utf8')
372378
sys.exit(retcode)
373379

374380

@@ -387,7 +393,7 @@ def _command_sshrun(args):
387393
run_file.close()
388394
try:
389395
utils.check_call(['./sshrun', argconfig.hostname, run_file.name],
390-
cwd=_hooksdir)
396+
cwd=_hooksdir, encoding='utf8')
391397
finally:
392398
os.unlink(run_file.name)
393399

0 commit comments

Comments
 (0)