/usr/lib/python2.7/dist-packages/pbcommand/interactive_resolver.py is in python-pbcommand 0.2.17-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #!/usr/bin/env python
from __future__ import unicode_literals
import os
import sys
import warnings
from pbcommand.cli import get_default_argparser
from pbcommand.models import SymbolTypes
from pbcommand.pb_io import (load_tool_contract_from,
write_resolved_tool_contract)
from pbcommand.resolver import resolve_tool_contract
try:
from prompt_toolkit.filters import Always
from prompt_toolkit.shortcuts import get_input
except ImportError:
sys.stderr.write("interactive resolver requires 'prompt_toolkit' (pip install prompt_toolkit)\n")
raise
def run_main(tc):
""":type tc: ToolContract"""
print "Loaded tc {c}".format(c=tc)
if tc.task.nproc == SymbolTypes.MAX_NPROC:
nproc = get_input('Enter max nproc: ')
else:
# not quite right
nproc = 1
output_dir = get_input('Output Directory: ', enable_system_bindings=Always())
output_dir = os.path.abspath(output_dir)
input_files = []
for i, input_type in enumerate(tc.task.input_file_types):
in_path = get_input(" {i} file {p} path :".format(i=i, p=input_type))
if not os.path.exists(in_path):
warnings.warn("Unable to find {p}".format(p=in_path))
input_files.append(in_path)
tool_options = {}
rtc = resolve_tool_contract(tc, input_files, output_dir, '/tmp', int(nproc), tool_options)
print rtc
file_name = tc.task.task_id + "_resolved_tool_contract.json"
rtc_path = os.path.join(output_dir, file_name)
print "writing RTC to {f}".format(f=rtc_path)
write_resolved_tool_contract(rtc, rtc_path)
return rtc
def _run_main(args):
return run_main(load_tool_contract_from(args.tc_path))
def get_parser():
p = get_default_argparser("0.1.0", "Interactive tool for resolving Tool Contracts")
p.add_argument("tc_path", type=str, help='Path to Tool Contract')
p.set_defaults(func=_run_main)
return p
def main(argv=sys.argv):
p = get_parser()
args = p.parse_args(argv[1:])
args.func(args)
return 0
if __name__ == '__main__':
sys.exit(main())
|