Skip to content

Commit 947f98a

Browse files
authored
remove some options (#41)
* remove some options Signed-off-by: Ethan Lee <[email protected]> * options removing Signed-off-by: Ethan Lee <[email protected]> * checking bug - restore -d Signed-off-by: Ethan Lee <[email protected]> * check bug restore -t Signed-off-by: Ethan Lee <[email protected]> * restore all option Signed-off-by: Ethan Lee <[email protected]> * restore check_notice Signed-off-by: Ethan Lee <[email protected]> * check bug notice Signed-off-by: Ethan Lee <[email protected]> * add test_tox.py android.log Signed-off-by: Ethan Lee <[email protected]> * add test.tox Signed-off-by: Ethan Lee <[email protected]> * add android source (simple) Signed-off-by: Ethan Lee <[email protected]> * modify test_tox.py Signed-off-by: Ethan Lee <[email protected]> * change the permission of android_sample Signed-off-by: Ethan Lee <[email protected]> * modify test_tox.py Signed-off-by: Ethan Lee <[email protected]> * delete some files Signed-off-by: Ethan Lee <[email protected]> * delete android_12_simple folder Signed-off-by: Ethan Lee <[email protected]> * modify test_tox.py Signed-off-by: Ethan Lee <[email protected]> * Modify android_binary_analysis, check_notice Signed-off-by: Ethan Lee <[email protected]> --------- Signed-off-by: Ethan Lee <[email protected]>
1 parent 42e27c7 commit 947f98a

File tree

106 files changed

+792384
-55
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+792384
-55
lines changed

src/fosslight_android/android_binary_analysis.py

Lines changed: 19 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
get_path_by_using_find
3232
)
3333
from .check_package_file import check_packaging_files
34-
from .check_notice_file import (
35-
run_notice_html_checklist,
34+
from .check_notice_file import (
35+
run_notice_html_checklist,
3636
find_bin_in_notice,
3737
read_notice_file,
3838
create_additional_notice,
39-
divide_notice_files_by_binary
39+
divide_notice_files_by_binary
4040
)
4141
from ._binary_db_controller import get_oss_info_from_db
4242
from ._common import (
@@ -72,7 +72,6 @@
7272
platform_version = "" # Android Version. ex- 7.0.0.r1 -> 7.0
7373

7474
# Define Const Variables
75-
NOTICE_HTML_FILE_NAME = ""
7675
ANDROID_LOG_FILE_NAME = "android.log"
7776
num_cores = 1
7877
now = ""
@@ -343,7 +342,7 @@ def find_notice_value(notice_zip_dest_file=""):
343342
notice_file_comment = "Notice file not found."
344343

345344
try:
346-
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path), NOTICE_HTML_FILE_NAME)
345+
notice_file_list, notice_files = read_notice_file(os.path.abspath(build_out_notice_file_path))
347346
if notice_file_list:
348347
if notice_files:
349348
for notice_file in notice_files:
@@ -793,14 +792,11 @@ def create_and_copy_notice_zip(notice_files_list, zip_file_path):
793792
return final_destination_file_name
794793

795794

796-
def main():
797-
global android_log_lines, ANDROID_LOG_FILE_NAME, NOTICE_HTML_FILE_NAME, python_script_dir, num_cores, now, logger, final_bin_info
798-
find_empty_path = False
799-
_create_additial_notice = False
800-
notice_check_ok = False
801-
base_binary_txt = ""
802-
auto_fill_oss_name = True
803-
_NOTICE_CHECKLIST_TYPE = False
795+
def main():
796+
global android_log_lines, ANDROID_LOG_FILE_NAME, python_script_dir, num_cores, now, logger, final_bin_info
797+
find_empty_path = False
798+
notice_check_ok = False
799+
auto_fill_oss_name = True
804800
analyze_source = False
805801
path_to_exclude = []
806802
RESULT_FILE_EXTENSION = ".xlsx"
@@ -820,17 +816,12 @@ def main():
820816
parser = argparse.ArgumentParser(description='FOSSLight Android', prog='fosslight_android', add_help=False)
821817
parser.add_argument('-h', '--help', action='store_true', required=False)
822818
parser.add_argument('-v', '--version', action='store_true', required=False)
823-
parser.add_argument('-s', '--source', type=str, required=False)
824-
parser.add_argument('-b', '--binary', type=str, required=False)
825-
parser.add_argument('-n', '--notice', type=str, required=False)
826-
parser.add_argument('-t', '--toadd', action='store_true', required=False)
827-
parser.add_argument('-m', '--more', action='store_true', required=False)
828-
parser.add_argument('-c', '--check', type=str, required=False)
819+
parser.add_argument('-s', '--source', type=str, required=False)
820+
parser.add_argument('-m', '--more', action='store_true', required=False)
829821
parser.add_argument('-a', '--android', type=str, required=False)
830822
parser.add_argument('-f', '--find', action='store_true', required=False)
831823
parser.add_argument('-i', '--ignore', action='store_true', required=False)
832-
parser.add_argument('-p', '--packaging', type=str, required=False)
833-
parser.add_argument('-d', '--divide', type=str, required=False)
824+
parser.add_argument('-p', '--packaging', type=str, required=False)
834825
parser.add_argument('-r', '--remove', type=str, required=False)
835826
parser.add_argument('-e', '--exclude', nargs="*", required=False, default=[])
836827

@@ -841,18 +832,9 @@ def main():
841832
print_version(PKG_NAME)
842833
if args.source: # android source path
843834
os.chdir(args.source)
844-
android_src_path = args.source
845-
if args.binary: # Base model's binary.txt to exclude
846-
base_binary_txt = args.binary
847-
if args.notice:
848-
NOTICE_HTML_FILE_NAME = args.notice
849-
if args.toadd: # Create needtoadd-notice.html file.
850-
_create_additial_notice = True
835+
android_src_path = args.source
851836
if args.more: # Analyze source mode.
852-
analyze_source = True
853-
if args.check:
854-
_NOTICE_CHECKLIST_TYPE = True
855-
notice_check_ok = (args.check == "ok" or args.check == "OK")
837+
analyze_source = True
856838
if args.android:
857839
ANDROID_LOG_FILE_NAME = args.android
858840
if args.find: # Execute "find" command when source path is not found.
@@ -866,17 +848,10 @@ def main():
866848

867849
if args.packaging:
868850
check_packaging_files(args.packaging)
869-
return
870-
if args.divide:
871-
divide_notice_files_by_binary(args.divide, python_script_dir, now)
872-
return
851+
return
852+
873853
if args.remove: # Remove the inputted list from the binary list.
874-
remove_list_file = args.remove
875-
876-
if _NOTICE_CHECKLIST_TYPE:
877-
run_notice_html_checklist(base_binary_txt, notice_check_ok, NOTICE_HTML_FILE_NAME)
878-
return
879-
854+
remove_list_file = args.remove
880855
read_success, android_log_lines = read_file(ANDROID_LOG_FILE_NAME)
881856
if not read_success:
882857
logger.error("(-a option) Fail to read a file:" + ANDROID_LOG_FILE_NAME)
@@ -913,13 +888,11 @@ def main():
913888
logger.warning(f"Failed to write result to excel:{msg}")
914889
result_log["Output FOSSLight Report"] = f"{result_file}"
915890

916-
if _create_additial_notice:
917-
create_additional_notice(final_bin_info, python_script_dir)
918-
919891
# Print the result
920892
result_log["Output Directory"] = python_script_dir
921893
try:
922-
str_final_result_log = yaml.safe_dump(result_log, allow_unicode=True, sort_keys=True)
894+
#str_final_result_log = yaml.safe_dump(result_log, allow_unicode=True, sort_keys=True)
895+
str_final_result_log = yaml.safe_dump(result_log, allow_unicode=True)
923896
logger.info(str_final_result_log)
924897
except Exception as ex:
925898
logger.warning(f"Failed to print result log. : {ex}")

src/fosslight_android/check_notice_file.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,14 @@ def find_files_by_extension(path):
9696
return files
9797

9898

99-
def read_notice_file(notice_file_path, notice_html_file):
99+
#def read_notice_file(notice_file_path, notice_html_file):
100+
def read_notice_file(notice_file_path):
100101
final_notice_file = {}
101102
# NOTICE.html need to be skipped the errors related to decode
102103
encodings = ["latin-1", "utf-8", "utf-16"]
103104
notice_files = []
104-
105+
106+
'''
105107
if notice_html_file != "":
106108
notice_files = notice_html_file.split(",")
107109
else:
@@ -114,8 +116,21 @@ def read_notice_file(notice_file_path, notice_html_file):
114116
additional_notice_files = find_files_by_extension(notice_file_path)
115117
if len(additional_notice_files) > 0:
116118
notice_files.extend(additional_notice_files)
117-
notice_files = list(set(notice_files))
118-
119+
notice_files = list(set(notice_files))
120+
'''
121+
122+
if os.path.isfile(notice_file_path):
123+
notice_files.append(notice_file_path)
124+
if notice_file_path.endswith(".html") or notice_file_path.endswith(".xml") or notice_file_path.endswith(".txt"):
125+
notice_file_path = os.path.dirname(notice_file_path)
126+
127+
if os.path.isdir(notice_file_path):
128+
additional_notice_files = find_files_by_extension(notice_file_path)
129+
if len(additional_notice_files) > 0:
130+
notice_files.extend(additional_notice_files)
131+
notice_files = list(set(notice_files))
132+
133+
119134
for file_name in notice_files:
120135
file_list = {}
121136
file_content = ""

0 commit comments

Comments
 (0)