Spotter-VM/build/usr/lib/python3.6/lxcbuild/app.py

27 lines
708 B
Python
Raw Normal View History

2019-09-20 10:13:41 +02:00
# -*- coding: utf-8 -*-
2019-09-20 15:43:01 +02:00
import json
2019-09-20 10:13:41 +02:00
import os
2019-09-20 15:43:01 +02:00
import sys
2019-09-20 10:13:41 +02:00
2019-09-20 15:43:01 +02:00
from .builder import ImageNotFoundError
2019-09-20 10:13:41 +02:00
from .packer import Packer
class App:
def __init__(self, metafile):
self.build_dir = os.path.dirname(metafile)
2019-09-20 15:43:01 +02:00
if os.path.basename(metafile) == 'meta':
self.name = os.path.basename(self.build_dir)
else:
self.name = os.path.splitext(metafile)[0]
2019-09-20 10:13:41 +02:00
with open(metafile, 'r') as f:
self.conf = json.load(f)
def pack(self):
packer = Packer()
2019-09-20 15:43:01 +02:00
try:
packer.pack_app(self)
except ImageNotFoundError as e:
print('Image {} not found, can\'t pack {}'.format(e, self.name))
sys.exit(1)