From: biao716.wang Date: Tue, 16 Aug 2022 08:24:07 +0000 (+0900) Subject: Add postscripts-maxruntime option to set the max run time for post scripts X-Git-Tag: accepted/tools/devbase/tools/20250527.103804~40 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8f59197e809a7acc02b01fffce5b2373beea660d;p=tools%2Fmic.git Add postscripts-maxruntime option to set the max run time for post scripts example: sudo mic create auto test.ks --postscripts-maxruntime=500 mean the max run time for post scripts is 500 minutes. without this option, default max run time is 120 minutes. Change-Id: I4fb90477307e75901b17e7ae92777e984fdd8743 Signed-off-by: biao716.wang --- diff --git a/mic/cmd_create.py b/mic/cmd_create.py index ce18ed5..3d84fca 100755 --- a/mic/cmd_create.py +++ b/mic/cmd_create.py @@ -151,7 +151,10 @@ def main(parser, args, argv): if args.skip_set_hosts: configmgr.create['skip_set_hosts']=args.skip_set_hosts - if args.runtime: + if args.postscripts_maxruntime: + configmgr.create['postscripts_maxruntime']=int(args.postscripts_maxruntime) + +if args.runtime: configmgr.set_runtime(args.runtime) if args.use_mic_in_bootstrap: diff --git a/mic/conf.py b/mic/conf.py index d68d086..23653dd 100755 --- a/mic/conf.py +++ b/mic/conf.py @@ -80,6 +80,7 @@ class ConfigMgr(object): "tpk_install": None, "use_mic_in_bootstrap": False, "skip_set_hosts": False, + "postscripts_maxruntime": 120, }, 'chroot': { "saveto": None, diff --git a/mic/imager/baseimager.py b/mic/imager/baseimager.py index 43ac5f9..7a93c13 100644 --- a/mic/imager/baseimager.py +++ b/mic/imager/baseimager.py @@ -39,8 +39,6 @@ from mic.chroot import kill_proc_inchroot from mic.archive import get_archive_suffixes from mic.conf import configmgr from mic.utils.grabber import myurlgrab -# post script max run time -MAX_RUN_TIME = 120 class BaseImageCreator(object): @@ -1314,9 +1312,8 @@ class BaseImageCreator(object): while p.poll() == None: msger.info(p.stdout.readline().strip()) end_time = time.time() - if (end_time - start_time)/60 > MAX_RUN_TIME: - raise CreatorError( - "Your post script is executed more than "+MAX_RUN_TIME+"mins, please check it!") + if (end_time - start_time)/60 > configmgr.create['postscripts_maxruntime']: + raise CreatorError("Your post script is executed more than %d mins, please check it!" % configmgr.create['postscripts_maxruntime']) if p.returncode != 0: raise CreatorError("Failed to execute %%post script " "with '%s'" % (s.interp)) diff --git a/tools/mic b/tools/mic index 968118d..98b72cf 100755 --- a/tools/mic +++ b/tools/mic @@ -142,6 +142,7 @@ def create_parser(parser): default=None, help='Copy tpk file to /usr/apps/.preload-tpk') parent_parser.add_argument('--rpm-debug', action='store_true', dest='rpm_debug', help='Set debug mode for rpm install') parent_parser.add_argument('--skip-set-hosts', action='store_true', dest='skip_set_hosts', default=False, help='choose to skip set hosts by mic') + parent_parser.add_argument('--postscripts-maxruntime', dest='postscripts_maxruntime', default=120, help='max run time for post scripts') parser.set_defaults(alias="cr")