Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/fosslight_source/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

Options:
Mandatory
-p <source_path>\t\t Path to analyze source
-p <source_path>\t Path to analyze source

Optional
-h\t\t\t\t Print help message
-v\t\t\t\t Print FOSSLight Source Scanner version
-j\t\t\t\t Generate raw result of scanners in json format
-m\t\t\t\t Print additional information for scan result on separate sheets
-o <output_path>\t\t Output path
\t\t\t\t (If you want to generate the specific file name, add the output path with file name.)
-f <format>\t\t\t Output file format (excel, csv, opossum, yaml)
-s <scanner>\t\t Select which scanner to be run (scancode, scanoss, all)"""
-h\t\t\t Print help message
-v\t\t\t Print FOSSLight Source Scanner version
-j\t\t\t Generate raw result of scanners in json format
-m\t\t\t Print additional information for scan result on separate sheets
-o <output_path>\t Output path (Path or file name)
-f <format>\t\t Output file format (excel, csv, opossum, yaml)
-s <scanner>\t Select which scanner to be run (scancode, scanoss, all)
-t <float>\t\t Stop scancode scanning if scanning takes longer than a timeout in seconds."""

_HELP_MESSAGE_CONVERT = """
Usage: fosslight_convert [option1] <arg1> [option2] <arg2>...
Expand Down
15 changes: 10 additions & 5 deletions src/fosslight_source/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ def main():

scanned_result = []
license_list = []
time_out = 120

try:
opts, args = getopt.getopt(argv, 'hvmjs:p:o:f:')
opts, args = getopt.getopt(argv, 'hvmjs:p:o:f:t:')
for opt, arg in opts:
if opt == "-h":
print_help_msg_source()
Expand All @@ -70,6 +71,8 @@ def main():
format = arg
elif opt == "-s":
selected_scanner = arg.lower()
elif opt == "-t":
time_out = arg
except Exception:
print_help_msg_source()

Expand All @@ -90,13 +93,15 @@ def main():
if selected_scanner == 'scancode':
success, _result_log["Scan Result"], scanned_result, license_list = run_scan(path_to_scan, output_file_name,
write_json_file, -1, True,
print_matched_text, format, True)
print_matched_text, format, True,
time_out)
elif selected_scanner == 'scanoss':
scanned_result = run_scanoss_py(path_to_scan, output_file_name, format, True, write_json_file)
elif selected_scanner == 'all' or selected_scanner == '':
success, _result_log["Scan Result"], scanned_result, license_list = run_all_scanners(path_to_scan, output_file_name,
write_json_file, -1,
print_matched_text, format, True)
print_matched_text, format, True,
time_out)
else:
print_help_msg_source()
sys.exit(1)
Expand Down Expand Up @@ -167,7 +172,7 @@ def create_report_file(start_time, scanned_result, license_list, selected_scanne


def run_all_scanners(path_to_scan, output_file_name="", _write_json_file=False, num_cores=-1,
need_license=False, format="", called_by_cli=True):
need_license=False, format="", called_by_cli=True, time_out=120):
"""
Run Scancode and scanoss.py for the given path.

Expand All @@ -192,7 +197,7 @@ def run_all_scanners(path_to_scan, output_file_name="", _write_json_file=False,
success, _result_log["Scan Result"], scancode_result, license_list = run_scan(path_to_scan, output_file_name,
_write_json_file, num_cores,
True, need_license,
format, called_by_cli)
format, called_by_cli, time_out)
scanoss_result = run_scanoss_py(path_to_scan, output_file_name, format, called_by_cli, _write_json_file)

for file_in_scancode_result in scancode_result:
Expand Down
7 changes: 5 additions & 2 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@


def run_scan(path_to_scan, output_file_name="",
_write_json_file=False, num_cores=-1, return_results=False, need_license=False, format="", called_by_cli=False):
_write_json_file=False, num_cores=-1, return_results=False, need_license=False, format="",
called_by_cli=False, time_out=120):
if not called_by_cli:
global logger

Expand Down Expand Up @@ -67,12 +68,14 @@ def run_scan(path_to_scan, output_file_name="",

if os.path.isdir(path_to_scan):
try:
time_out = float(time_out)
rc, results = cli.run_scan(path_to_scan, max_depth=100,
strip_root=True, license=True,
copyright=True, return_results=True,
processes=num_cores,
output_json_pp=output_json_file,
only_findings=True, license_text=True)
only_findings=True, license_text=True,
timeout=time_out)

if not rc:
msg = "Source code analysis failed."
Expand Down