Skip to content

Commit 86ae621

Browse files
authored
Add exception for checking version
2 parents e1a72f4 + 9f85e69 commit 86ae621

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/fosslight_util/set_log.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def init_check_latest_version(pkg_version="", main_package_name=""):
2727
except TypeError:
2828
logger.warning('Cannot check the lastest version on PIP')
2929
logger.warning('You could use already installed version\n')
30+
except Exception as error:
31+
logger.debug('Cannot check the latest version:' + str(error))
3032

3133

3234
def init_log(log_file, create_file=True, stream_log_level=logging.INFO,
@@ -60,9 +62,14 @@ def init_log(log_file, create_file=True, stream_log_level=logging.INFO,
6062
"OS": platform.system()+" "+platform.release(),
6163
}
6264
if main_package_name != "":
63-
pkg_version = pkg_resources.get_distribution(main_package_name).version
64-
init_check_latest_version(pkg_version, main_package_name)
65-
_result_log["Tool Info"] = main_package_name + " v" + pkg_version
65+
pkg_info = main_package_name
66+
try:
67+
pkg_version = pkg_resources.get_distribution(main_package_name).version
68+
init_check_latest_version(pkg_version, main_package_name)
69+
pkg_info = main_package_name + " v" + pkg_version
70+
except Exception as error:
71+
logger.debug('Cannot check the version:' + str(error))
72+
_result_log["Tool Info"] = pkg_info
6673
if path_to_analyze != "":
6774
_result_log["Path to analyze"] = path_to_analyze
6875

0 commit comments

Comments
 (0)