From c48b6b4e83f1130b8b2e229f4bb317d386bc6b79 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Fri, 26 Aug 2022 08:45:20 +0900 Subject: [PATCH 1/3] Change FOSSLight to 3D Font for help msg --- src/fosslight_util/help.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/fosslight_util/help.py b/src/fosslight_util/help.py index 0348b9f..ca3a7e4 100644 --- a/src/fosslight_util/help.py +++ b/src/fosslight_util/help.py @@ -6,17 +6,16 @@ import pkg_resources _HELP_MESSAGE_COMMON = """ - _______ _______ _______ _______ ___ ___ __ - | || || || || | |___| | | _ - | ___|| _ || _____|| _____|| | ___ | |____ __| |__ - | |___ | | | || |_____ | |_____ | | | | _______ | _ ||__ __| - | ___|| |_| ||_____ ||_____ || |___ | || _ || | | | | | - | | | | _____| | _____| || || || |_| || | | | | |__ - |___| |_______||_______||_______||_______||___||____ ||__| |__| |____| - | | - ____| | - |_______| - """ + ____ _____ ____ ____ __ __ __ + /\ _`\ /\ __`\ /\ _`\ /\ _`\ /\ \ __ /\ \ /\ \__ + \ \ \L\_\ \ \ \/\ \ \ \,\L\_\ \ \,\L\_\ \ \ \ /\_\ __ \ \ \___ \ \ ,_\ + \ \ _\/ \ \ \ \ \ \/_\__ \ \/_\__ \ \ \ \ __ \/\ \ /'_ `\ \ \ _ `\ \ \ \/ + \ \ \/ \ \ \_\ \ /\ \L\ \ /\ \L\ \ \ \ \L\ \ \ \ \ /\ \L\ \ \ \ \ \ \ \ \ \_ + \ \_\ \ \_____\ \ `\____\ \ `\____\ \ \____/ \ \_\ \ \____ \ \ \_\ \_\ \ \__\ + \/_/ \/_____/ \/_____/ \/_____/ \/___/ \/_/ \/___L\ \ \/_/\/_/ \/__/ + /\____/ + \_/__/ +""" class PrintHelpMsg(): From 7c39b7fc030212f1cc22387fa6bf50a595ffa77e Mon Sep 17 00:00:00 2001 From: Jiyeong Seok Date: Tue, 30 Aug 2022 18:04:31 +0900 Subject: [PATCH 2/3] Fix to sigalrm error for windows Signed-off-by: Jiyeong Seok --- src/fosslight_util/download.py | 46 +++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/fosslight_util/download.py b/src/fosslight_util/download.py index 11fc09a..953e1db 100755 --- a/src/fosslight_util/download.py +++ b/src/fosslight_util/download.py @@ -18,18 +18,33 @@ import fosslight_util.constant as constant from fosslight_util.set_log import init_log import signal +import time +import threading +import platform logger = logging.getLogger(constant.LOGGER_NAME) compression_extension = {".tar.bz2", ".tar.gz", ".tar.xz", ".tgz", ".tar", ".zip", ".jar", ".bz2"} SIGNAL_TIMEOUT = 600 +class Alarm(threading.Thread): + def __init__(self, timeout): + threading.Thread.__init__(self) + self.timeout = timeout + self.setDaemon(True) + + def run(self): + time.sleep(self.timeout) + logger.error("download timeout! (%d sec)", SIGNAL_TIMEOUT) + os._exit(1) + + class TimeOutException(Exception): pass def alarm_handler(signum, frame): - logger.warning("git clone timeout! (%d sec)", SIGNAL_TIMEOUT) + logger.warning("download timeout! (%d sec)", SIGNAL_TIMEOUT) raise TimeOutException() @@ -37,7 +52,7 @@ def print_help_msg(): print("* Required : -s link_to_download") print("* Optional : -t target_directory") print("* Optional : -d log_file_directory") - sys.exit() + sys.exit(0) def main(): @@ -121,14 +136,21 @@ def get_ref_to_checkout(checkout_to, ref_list): def download_git_clone(git_url, target_dir, checkout_to=""): - signal.signal(signal.SIGALRM, alarm_handler) - signal.alarm(SIGNAL_TIMEOUT) + if platform.system() != "Windows": + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(SIGNAL_TIMEOUT) + else: + alarm = Alarm(SIGNAL_TIMEOUT) + alarm.start() try: Path(target_dir).mkdir(parents=True, exist_ok=True) repo = git.clone_repository(git_url, target_dir, bare=False, repository=None, remote=None, callbacks=None) - signal.alarm(0) + if platform.system() == "Windows": + signal.alarm(0) + else: + del alarm except Exception as error: logger.warning("git clone - failed:"+str(error)) return False @@ -148,9 +170,12 @@ def download_git_clone(git_url, target_dir, checkout_to=""): def download_wget(link, target_dir, compressed_only): success = False downloaded_file = "" - - signal.signal(signal.SIGALRM, alarm_handler) - signal.alarm(SIGNAL_TIMEOUT) + if platform.system() == "Windows": + signal.signal(signal.SIGALRM, alarm_handler) + signal.alarm(SIGNAL_TIMEOUT) + else: + alarm = Alarm(SIGNAL_TIMEOUT) + alarm.start() try: Path(target_dir).mkdir(parents=True, exist_ok=True) @@ -171,7 +196,10 @@ def download_wget(link, target_dir, compressed_only): logger.info("wget:"+link) downloaded_file = wget.download(link) - signal.alarm(0) + if platform.system() == "Windows": + signal.alarm(0) + else: + del alarm shutil.move(downloaded_file, target_dir) downloaded_file = os.path.join(target_dir, downloaded_file) From 54a90bfbb96d8bba0791204ff40c12c815d6ba79 Mon Sep 17 00:00:00 2001 From: Jaekwon Bang Date: Wed, 31 Aug 2022 10:15:13 +0900 Subject: [PATCH 3/3] Restore to the original help msg --- src/fosslight_util/help.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/fosslight_util/help.py b/src/fosslight_util/help.py index ca3a7e4..e9f050c 100644 --- a/src/fosslight_util/help.py +++ b/src/fosslight_util/help.py @@ -6,15 +6,16 @@ import pkg_resources _HELP_MESSAGE_COMMON = """ - ____ _____ ____ ____ __ __ __ - /\ _`\ /\ __`\ /\ _`\ /\ _`\ /\ \ __ /\ \ /\ \__ - \ \ \L\_\ \ \ \/\ \ \ \,\L\_\ \ \,\L\_\ \ \ \ /\_\ __ \ \ \___ \ \ ,_\ - \ \ _\/ \ \ \ \ \ \/_\__ \ \/_\__ \ \ \ \ __ \/\ \ /'_ `\ \ \ _ `\ \ \ \/ - \ \ \/ \ \ \_\ \ /\ \L\ \ /\ \L\ \ \ \ \L\ \ \ \ \ /\ \L\ \ \ \ \ \ \ \ \ \_ - \ \_\ \ \_____\ \ `\____\ \ `\____\ \ \____/ \ \_\ \ \____ \ \ \_\ \_\ \ \__\ - \/_/ \/_____/ \/_____/ \/_____/ \/___/ \/_/ \/___L\ \ \/_/\/_/ \/__/ - /\____/ - \_/__/ + _______ _______ _______ _______ ___ ___ __ + | || || || || | |___| | | _ + | ___|| _ || _____|| _____|| | ___ | |____ __| |__ + | |___ | | | || |_____ | |_____ | | | | _______ | _ ||__ __| + | ___|| |_| ||_____ ||_____ || |___ | || _ || | | | | | + | | | | _____| | _____| || || || |_| || | | | | |__ + |___| |_______||_______||_______||_______||___||____ ||__| |__| |____| + | | + ____| | + |_______| """