Skip to content

Commit 2a43a3e

Browse files
author
pg
committed
add generic json command executor for external bs
commit_hash:0833419ebee283a1fb0e0a41f615b0bf7b61f548
1 parent 0b6a2c9 commit 2a43a3e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

build/scripts/generic_cmd.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
import sys
3+
import json
4+
import base64
5+
import subprocess
6+
7+
8+
if __name__ == '__main__':
9+
p = sys.argv.index('--')
10+
ctx = base64.b64decode(sys.argv[p + 1].encode()).decode()
11+
kv = {}
12+
13+
for x in sys.argv[1:p]:
14+
k, v = x.split('=')
15+
ctx = ctx.replace(f'$({k})', v)
16+
kv[k] = v
17+
18+
cmd = json.loads(ctx)
19+
20+
args = cmd['cmd_args']
21+
cwd = cmd.get('cwd', kv['B'])
22+
23+
env = dict(**os.environ)
24+
env['ARCADIA_ROOT_DISTBUILD'] = kv['S']
25+
env.update(cmd['env'])
26+
27+
out = subprocess.check_output(args, env=env, cwd=cwd)
28+
29+
if stdout := cmd.get('stdout'):
30+
with open(stdout, 'wb') as f:
31+
f.write(out)

0 commit comments

Comments
 (0)