MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / run_scan_plain

Function run_scan_plain

src/scancode/cli_test_utils.py:23–80  ·  view source on GitHub ↗

Run a scan as a plain subprocess. Return rc, stdout, stderr.

(
    options,
    cwd=None,
    test_mode=True,
    expected_rc=0,
    env=None,
    retry=True,
)

Source from the content-addressed store, hash-verified

21
22
23def run_scan_plain(
24 options,
25 cwd=None,
26 test_mode=True,
27 expected_rc=0,
28 env=None,
29 retry=True,
30):
31 """
32 Run a scan as a plain subprocess. Return rc, stdout, stderr.
33 """
34
35 from commoncode.command import execute
36
37 options = add_windows_extra_timeout(options)
38
39 if test_mode and '--test-mode' not in options:
40 options.append('--test-mode')
41
42 if not env:
43 env = dict(os.environ)
44
45 scmd = 'scancode'
46 scan_cmd = os.path.join(scancode_root_dir, scmd)
47 rc, stdout, stderr = execute(
48 cmd_loc=scan_cmd,
49 args=options,
50 cwd=cwd,
51 env=env,
52 )
53
54 if retry and rc != expected_rc:
55 # wait and rerun in verbose mode to get more in the output
56 time.sleep(1)
57 if '--verbose' not in options:
58 options.append('--verbose')
59 result = rc, stdout, stderr = execute(
60 cmd_loc=scan_cmd,
61 args=options,
62 cwd=cwd,
63 env=env,
64 )
65
66 if rc != expected_rc:
67 opts = get_opts(options)
68 error = f'''
69Failure to run:
70rc: {rc}
71scancode {opts}
72stdout:
73{stdout}
74
75stderr:
76{stderr}
77''' % locals()
78 assert rc == expected_rc, error
79
80 return rc, stdout, stderr

Calls 5

executeFunction · 0.90
get_optsFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected