Skip to content

Commit 96a06bd

Browse files
authored
Merge pull request #97 from fosslight/develop
Fix error when it fails to create venv for Pypi
2 parents 3d9c227 + 195340f commit 96a06bd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/fosslight_dependency/_package_manager.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,8 @@ def check_and_run_license_scanner(platform, license_scanner_bin, file_dir):
255255
license_name = ""
256256
return license_name
257257
else:
258-
ret = os.system(run_license_scanner)
259-
if ret != 0:
260-
logger.info("=> (No error) This is the information that the license was not found.")
258+
ret = subprocess.run(run_license_scanner, shell=True, stderr=subprocess.PIPE)
259+
if ret.returncode != 0 or ret.stderr:
261260
return ""
262261

263262
fp = open(tmp_output_file_name, "r", encoding='utf8')

src/fosslight_dependency/package_manager/Pypi.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,13 @@ def create_virtualenv(self):
110110
cmd = cmd_separator.join(cmd_list)
111111

112112
try:
113-
cmd_ret = subprocess.call(cmd, shell=True)
114-
if cmd_ret != 0:
113+
cmd_ret = subprocess.run(cmd, shell=True, stderr=subprocess.PIPE)
114+
if cmd_ret.returncode != 0:
115+
ret = False
116+
err_msg = f"return code({cmd_ret.returncode})"
117+
elif cmd_ret.stderr.decode('utf-8').rstrip().startswith('ERROR:'):
115118
ret = False
116-
err_msg = f"return code({cmd_ret})"
119+
err_msg = f"stderr msg({cmd_ret.stderr})"
117120
except Exception as e:
118121
ret = False
119122
err_msg = e
@@ -234,6 +237,7 @@ def parse_oss_information(self, f_name):
234237
sheet_list = []
235238
comment = ''
236239
try:
240+
oss_init_name = ''
237241
with open(f_name, 'r', encoding='utf-8') as json_file:
238242
json_data = json.load(json_file)
239243

@@ -267,7 +271,7 @@ def parse_oss_information(self, f_name):
267271
license_name, dn_loc, homepage, '', '', comment])
268272

269273
except Exception as ex:
270-
logger.error(f"Failed to parse oss information: {ex}")
274+
logger.warning(f"Fail to parse oss information: {oss_init_name}({ex})")
271275

272276
return sheet_list
273277

0 commit comments

Comments
 (0)