Commit 5d67b16a authored by Seblu's avatar Seblu

Move install stuff into image

c_install function are moved to image
parent a58a65a5
......@@ -301,24 +301,9 @@ def c_install(args):
image, repo = next(get_images([args.pattern], repoman, min=1, max=1))
# Print setup information
arrow(u"Installing %s v%s" % (image.name, image.version))
# install start time
t0 = time.time()
# run parser scripts with parser parser argument
image.run_parser({"parser": subparser})
# call parser again, with extended attributes
arrow("Parsing arguments")
# Catch exception in custom argparse action
try:
args = args.parser.parse_args()
except Exception as e:
raise ISError("Parsing error", e)
# run setup scripts
if not args.dry_run:
image.run_setup({"namespace": args})
# compute building time
t1 = time.time()
dt = int(t1 - t0)
arrow(u"Install time: %s" % datetime.timedelta(seconds=dt))
# let's go
dt = image.run(args.parser, subparser, run_setup=not args.dry_run)
arrow(u"Install time: %s" % datetime.timedelta(seconds=dt))
def c_list(args):
'''
......
......@@ -944,6 +944,40 @@ class PackageImage(Image):
arrow(u"Extracting payload %s in %s" % (payname, dest))
self.payload[payname].extract(dest, force=force)
def run(self, parser, extparser, load_modules=True, run_parser=True,
run_setup=True):
'''
Run images scripts
parser is the whole command line parser
extparser is the parser extensible by parser scripts
if load_modules is true load image modules
if run_parser is true run parser scripts
if run_setup is true run setup scripts
'''
# register start time
t0 = time.time()
# load image modules
if load_modules:
self.load_modules(lambda: self.select_scripts("lib"))
# run parser scripts to extend extparser
# those scripts should only extand the parser or produce error
if run_parser:
self.run_parser({"parser": extparser})
# call parser (again), with full options
arrow("Parsing command line")
# Catch exception in custom argparse action
try:
args = parser.parse_args()
except Exception as e:
raise ISError("Argument parser", e)
# run setup scripts
if run_setup:
self.run_setup({"namespace": args})
# return the building time
return int(time.time() - t0)
def run_parser(self, global_dict):
'''
Run parser scripts
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment