From 9d4644bedfabc90fc471517a8b55d850536306e0 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Mon, 24 May 2021 16:34:51 +0200 Subject: [PATCH] fix --- src/risotto/image.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/risotto/image.py b/src/risotto/image.py index e85dda7..cda153e 100644 --- a/src/risotto/image.py +++ b/src/risotto/image.py @@ -16,14 +16,17 @@ except: from .utils import _ -DATASET_PATH = '' +DATASET_PATH = '/usr/share/risotto/' TMP_DIRECTORY = '/tmp' PACKER_TMP_DIRECTORY = join(TMP_DIRECTORY, 'packer') PACKER_FILE_NAME = 'recipe.json' IMAGES_DIRECTORY = join(TMP_DIRECTORY, 'images') -FUNCTIONS = b"""from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value +FUNCTIONS = b"""try: + from tiramisu3 import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value +except: + from tiramisu import valid_network_netmask, valid_ip_netmask, valid_broadcast, valid_in_network, valid_not_equal as valid_differ, valid_not_equal, calc_value # ============================================================= # fork of risotto-setting/src/risotto_setting/config/config.py def get_password(**kwargs): @@ -168,7 +171,6 @@ class Image: if not isdir(funcs_dir): continue for func in listdir(funcs_dir): - print(join(funcs_dir, func)) with open(join(funcs_dir, func), 'rb') as fh: functions += fh.read() func_name = join(packer_tmp_directory, 'func.py') @@ -251,14 +253,12 @@ class Image: def build_image(self, packer_dst_filename: str, - packer_tmp_directory: str, + tmp_directory: str, packer_configuration: dict, ) -> None: - tmp_directory = join(packer_tmp_directory, 'tmp') - makedirs(tmp_directory) packer_configuration['tmp_directory'] = tmp_directory recipe = {'variables': packer_configuration} - packer_filename = join(packer_tmp_directory, PACKER_FILE_NAME) + packer_filename = join(tmp_directory, PACKER_FILE_NAME) with open(packer_filename, 'r') as recipe_fd: for key, value in jload(recipe_fd).items(): recipe[key] = value @@ -271,7 +271,7 @@ class Image: ) proc.wait() if proc.returncode: - raise Exception(_(f'cannot build {application} with {packer_filename}')) + raise Exception(_(f'cannot build {packer_dst_filename} with {packer_filename}')) move(join(tmp_directory, 'image.img'), packer_dst_filename) move(join(tmp_directory, 'image.sha256'), f'{packer_dst_filename}.sha256') rmtree(tmp_directory)