Skip to content

Commit 47b1a0b

Browse files
authored
Merge pull request #34 from fosslight/msg
Update message format when module-info.json cannot be read
2 parents 962dea9 + b3e04c5 commit 47b1a0b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/fosslight_android/android_binary_analysis.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,27 @@ def get_module_json_obj_by_installed_path(module_name, binary_name_with_path, bi
173173
def read_module_info_from_build_output_file():
174174
global module_info_json_obj
175175

176+
success = True
177+
176178
# Only in case upper 7.0.0 versions have a module-info.mk at build/core/tasks.
177179
# Lower versions sould copy module-info.mk to build/core/tasks than build it again.
178-
if not os.path.isfile(os.path.join(build_out_path, MODULE_INFO_FILE_NAME)):
179-
logger.warn("BUILD OUTPUT PATH :", build_out_path)
180-
logger.warn("Can't find a module-info.json file at build output path.")
180+
module_info_json_file = os.path.join(build_out_path, MODULE_INFO_FILE_NAME)
181+
if not os.path.isfile(module_info_json_file):
182+
logger.warn(f"BUILD OUTPUT PATH :{build_out_path}")
183+
logger.warn(f"Can't find a module-info.json file at build output path.:{module_info_json_file}")
181184
logger.warn("Please copy module-info.mk file to build/core/tasks than build it again.")
182-
sys.exit(1)
183-
185+
success = False
184186
try:
185-
module_f = os.path.join(build_out_path, MODULE_INFO_FILE_NAME)
186-
f = open(module_f, 'r')
187+
logger.info(f"READ module-info.json :{module_info_json_file}")
188+
f = open(module_info_json_file, 'r')
187189
module_info_json_obj = json.loads(f.read())
188190
f.close()
191+
except Exception as error:
192+
success = False
193+
logger.warn(f"[ERROR] Failed to read:{error}")
189194

190-
except IOError:
191-
logger.warn("[ERROR] Cannot read ", MODULE_INFO_FILE_NAME)
195+
if not success:
196+
sys.exit(1)
192197

193198

194199
def set_env_variables_from_result_log():

0 commit comments

Comments
 (0)