Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TAR & conf_file exlusivity #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions oct_turrets/start_turret.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def from_config(config_path):
"""
config = validate_conf(config_path)
cfg_path = os.path.dirname(config_path)
module_file = os.path.join(cfg_path, config['script'])
module_dir = config['script_dir'] if 'script_dir' in config else cfg_path
module_file = os.path.join(module_dir, config['script'])
module = load_file(module_file)
return module, config

Expand All @@ -72,9 +73,12 @@ def start(args):
dir_name = "{}-{}".format(os.path.basename(args.tar).split('.')[0], unique_id)
dir_name = os.path.join(tempfile.gettempdir(), dir_name)
module, config = from_tar(args.tar, unique_id, dir_name)
if args.config_file is not None:
_, config = from_config(args.config_file)
is_tar = True
else:
module, config = from_config(args.config)
module, config = from_config(args.config_file)
dir_name = None

Turret = get_turret_class(config.get('turret_class'))
turret = Turret(config, module, unique_id)
Expand All @@ -91,9 +95,8 @@ def start(args):
def main():

parser = argparse.ArgumentParser(description='Give parameters for start a turret instance')
group = parser.add_mutually_exclusive_group()
group.add_argument('--config-file', type=str, default=None, help='path for json configuration file')
group.add_argument('--tar', type=str, default=None, help='Path for the tarball to use')
parser.add_argument('--config-file', type=str, default=None, help='path for json configuration file')
parser.add_argument('--tar', type=str, default=None, help='Path for the tarball to use')
args = parser.parse_args()

if args.config_file is None and args.tar is None:
Expand Down