actev_get_system.py 1.79 KB
Newer Older
1
"""Entry point module: get-system
2
3
4
5

This file should not be modified.
"""
import os
6
from diva_evaluation_cli.bin.private_src.implementation.get_system.system_types_definition import system_types
7

8
def entry_point(url, system_type, location=None, user=None, password=None, token=None, install_cli=False, name=False):
9
10
11
12
13
14
15
16
17
18
19
20
    """Private entry point.

    Downloads a credentialed, web-accessible content into src

    Args:
        url (str): Url to get the system
        location (str, optional): Path to store the system
        user (str, optional): Username to access the url
        password (str, optional): Password to access the url
        token (str, optional): Token to access the url
        install_cli (bool, optional): Information to know wether CLI has to be installed

21
22
    """
    try:
Alexandre Boyer's avatar
Alexandre Boyer committed
23
24
        command = system_types[system_type]()
        script = command.entry_point
25
    except:
26
        raise Exception("Unknown system type")
Alexandre Boyer's avatar
Alexandre Boyer committed
27

Alexandre Boyer's avatar
Alexandre Boyer committed
28
29
30
31
32
33
34
35
    if not location:
        location = "None"
    if not user:
        user = "None"
    if not password:
        password = "None"
    if not token:
        token = "None"
36
37
38
39
    if install_cli:
        install_cli = "True"
    else:
        install_cli = "False"
40
41
    if not name:
        name = ""
Alexandre Boyer's avatar
Alexandre Boyer committed
42

43
44
    # go into the right directory to execute the script
    path = os.path.dirname(__file__)
45
    script = os.path.join(path, '../implementation/get_system/get/' + script)
46
47
48
49
    script += " " + url + \
              " " + location + \
              " " + user + \
              " " + password + \
50
              " " + token + \
51
52
              " " + install_cli + \
              " " + name
Alexandre Boyer's avatar
Alexandre Boyer committed
53

54
55
56
57
    # execute the script
    # status is the exit status code returned by the program
    status = os.system(script)
    if status != 0:
58
        raise Exception("Error occured in %s" % command.entry_point)