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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if __name__ == "__main__":
setup(
name='fosslight_source',
version='1.4.6',
version='1.4.7',
package_dir={"": "src"},
packages=find_packages(where='src'),
description='FOSSLight Source',
Expand Down
File renamed without changes.
21 changes: 10 additions & 11 deletions src/fosslight_source/convert_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
import yaml
from ._parsing_scancode_file_item import parsing_file_item
from fosslight_util.write_excel import write_excel_and_csv
from .help import print_help_msg_convert
from ._help import print_help_msg_convert

logger = logging.getLogger(constant.LOGGER_NAME)
_PKG_NAME = "fosslight_source"
_ERROR_PREFIX = "* Error : "


def convert_json_to_excel(scancode_json, excel_name):
Expand Down Expand Up @@ -52,40 +51,40 @@ def convert_json_to_excel(scancode_json, excel_name):
file_list, key=lambda row: (''.join(row.licenses)))
sheet_list["SRC_" + file_name] = [scan_item.get_row_to_print() for scan_item in file_list]
except Exception as ex:
pass
logger.warning("Error parsing "+file+":"+str(ex))

success_to_write, writing_msg = write_excel_and_csv(excel_name, sheet_list)
logger.warn("* Writing excel :"+str(success_to_write)+ " "+writing_msg)
logger.info("Writing excel :"+str(success_to_write)+ " "+writing_msg)
if success_to_write:
_result_log["OSS Report"] = excel_name+".xlsx"

except Exception as ex:
success = False
msg = _ERROR_PREFIX+str(ex)
logger.warning(str(ex))

scan_result_msg = str(success)+" "+msg
_result_log["Scan Result"] = scan_result_msg.strip()

try:
_str_final_result_log = yaml.safe_dump(_result_log, allow_unicode=True, sort_keys=True)
logger.warn("\n"+_str_final_result_log)
logger.info(_str_final_result_log)
except Exception as ex:
logger.warn(_ERROR_PREFIX+"Failed to print result log. "+ str(ex))
logger.warning("Failed to print result log.: "+ str(ex))

return file_list


def get_detected_licenses_from_scancode(scancode_json_file):
file_list = []
try:
logger.warn("Start parsing " + scancode_json_file)
logger.info("Start parsing " + scancode_json_file)
with open(scancode_json_file, "r") as st_json:
st_python = json.load(st_json)
rc, file_list, msg= parsing_file_item(st_python["files"])
logger.warn("|---"+msg)
logger.info("|---"+msg)
except Exception as error:
logger.warn(_ERROR_PREFIX+"Parsing -"+str(error))
logger.warn("|---Number of files detected: " + str(len(file_list)))
logger.warning("Parsing "+scancode_json_file+":"+str(error))
logger.info("|---Number of files detected: " + str(len(file_list)))
return file_list


Expand Down
18 changes: 9 additions & 9 deletions src/fosslight_source/run_scancode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
from fosslight_util.timer_thread import TimerThread
from ._parsing_scancode_file_item import parsing_file_item
from fosslight_util.write_excel import write_excel_and_csv
from .help import print_help_msg_source
from ._help import print_help_msg_source

logger = logging.getLogger(constant.LOGGER_NAME)
warnings.filterwarnings("ignore", category=FutureWarning)
_PKG_NAME = "fosslight_source"
_ERROR_PREFIX = "* Error : "


def main():
Expand Down Expand Up @@ -99,7 +98,7 @@ def run_scan(path_to_scan, output_file_name="",
output_json_pp=output_json_file,
only_findings=True)
if not rc:
msg += _ERROR_PREFIX+"Source code analysis failed.\n"
msg += "Source code analysis failed."
success = False
if results:
sheet_list = {}
Expand All @@ -114,15 +113,16 @@ def run_scan(path_to_scan, output_file_name="",

success_to_write, writing_msg = write_excel_and_csv(
output_file, sheet_list)
logger.warn("* Writing excel :"+str(success_to_write)+ " "+writing_msg)
logger.info("Writing excel :"+str(success_to_write)+ " "+writing_msg)
if success_to_write:
_result_log["OSS Report"] = output_file +".xlsx"
except Exception as ex:
success = False
msg = _ERROR_PREFIX + str(ex)+"\n"
msg = str(ex)
logger.error("Analyze "+path_to_scan+":"+msg)
else:
success = False
msg = _ERROR_PREFIX+"Check the path to scan. :" + path_to_scan+"\n"
msg = "Check the path to scan. :" + path_to_scan

if not return_results:
result_list = []
Expand All @@ -131,10 +131,10 @@ def run_scan(path_to_scan, output_file_name="",
_result_log["Output Directory"] = output_dir
try:
_str_final_result_log = yaml.safe_dump(_result_log, allow_unicode=True, sort_keys=True)
logger.warn("\n"+_str_final_result_log)
logger.info(_str_final_result_log)
except Exception as ex:
logger.warn(_ERROR_PREFIX+"Failed to print result log. "+ str(ex))
return success, _str_final_result_log, result_list
logger.warning("Failed to print result log. "+ str(ex))
return success, _result_log["Scan Result"], result_list


if __name__ == '__main__':
Expand Down