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

27 lines
708 B
Python

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