Example #1
0
def build_extra_vars(
    name,
    timezone,
    language,
    language_name,
    wifi_pwd,
    edupi,
    edupi_resources,
    nomad,
    mathews,
    wikifundi_languages,
    aflatoun_languages,
    kalite_languages,
    packages,
    admin_account,
    root_partition_size,
    disk_size,
):
    """ extra-vars friendly format of the ansiblecube configuration """

    extra_vars = {
        # predefined defaults we want to superseed whichever in ansiblecube
        "installer_version": get_version_str(),
        "mirror": mirror,
        "catalogs": CATALOGS,
        "kernel_version": get_content("raspbian_image").get("kernel_version"),
        "root_partition_size": root_partition_size,
        "disk_size": disk_size,
        "project_name": name,
        "timezone": timezone,
        "language": language,
        "language_name": language_name,
        "kalite_languages": kalite_languages,
        "wikifundi_languages": wikifundi_languages,
        "aflatoun_languages": aflatoun_languages,
        "edupi": edupi,
        "edupi_has_resources": bool(edupi_resources),
        "nomad": nomad,
        "mathews": mathews,
        "packages": packages,
        "custom_branding_path": "/tmp",
        "admin_account": "admin",
        "admin_password": "******",
    }

    if wifi_pwd:
        extra_vars.update({"wpa_pass": wifi_pwd})

    if admin_account is not None:
        extra_vars.update(
            {
                "admin_account": admin_account["login"],
                "admin_password": admin_account["pwd"],
            }
        )
        secret_keys = ["admin_password"]
    else:
        secret_keys = []

    return extra_vars, secret_keys
Example #2
0
def get_parser():
    parser = argparse.ArgumentParser(description='p4c-bm arguments')
    parser.add_argument('source', metavar='source', type=str,
                        help='A source file to include in the P4 program.')
    parser.add_argument('--json', dest='json', type=str,
                        help='Dump the JSON representation to this file.',
                        required=False)
    parser.add_argument('--pd', dest='pd', type=str,
                        help='Generate PD C/C++ code for this P4 program'
                        ' in this directory. Directory must exist.',
                        required=False)
    parser.add_argument('--pd-from-json', action='store_true',
                        help='Generate PD from a JSON file, not a P4 file',
                        default=False)
    parser.add_argument('--p4-prefix', type=str,
                        help='P4 name use for API function prefix',
                        default="prog", required=False)
    parser.add_argument('--field-aliases', type=str,
                        help='Path to file containing field aliases. '
                        'In this file, each line contains a mapping with this '
                        'format: "<alias> <full name of field>"',
                        required=False)
    parser.add_argument('--p4-v1.1', action='store_true',
                        help='Run the compiler on a p4 v1.1 program',
                        default=False, required=False)
    parser.add_argument('--version', '-v', action='version',
                        version=version.get_version_str())
    parser.add_argument('--primitives', action='append', default=[],
                        help="A JSON file which contains additional primitive \
                        declarations")
    return parser
Example #3
0
def get_parser():
    parser = argparse.ArgumentParser(description='p4c-bm arguments')
    parser.add_argument('source',
                        metavar='source',
                        type=str,
                        help='A source file to include in the P4 program.')
    parser.add_argument('--json',
                        dest='json',
                        type=str,
                        help='Dump the JSON representation to this file.',
                        required=False)
    parser.add_argument('--pd',
                        dest='pd',
                        type=str,
                        help='Generate PD C/C++ code for this P4 program'
                        ' in this directory. Directory must exist.',
                        required=False)
    parser.add_argument('--pd-from-json',
                        action='store_true',
                        help='Generate PD from a JSON file, not a P4 file',
                        default=False)
    parser.add_argument('--p4-prefix',
                        type=str,
                        help='P4 name use for API function prefix',
                        default="prog",
                        required=False)
    parser.add_argument('--field-aliases',
                        type=str,
                        help='Path to file containing field aliases. '
                        'In this file, each line contains a mapping with this '
                        'format: "<alias> <full name of field>"',
                        required=False)
    parser.add_argument('--p4-v1.1',
                        action='store_true',
                        help='Run the compiler on a p4 v1.1 program',
                        default=False,
                        required=False)
    parser.add_argument('--version',
                        '-v',
                        action='version',
                        version=version.get_version_str())
    parser.add_argument('--primitives',
                        action='append',
                        default=[],
                        help="A JSON file which contains additional primitive \
                        declarations")
    parser.add_argument('--plugin',
                        dest='plugin_list',
                        action="append",
                        default=[],
                        help="list of plugins to generate templates")
    parser.add_argument('--openflow-mapping-dir',
                        help="Directory of openflow mapping files")
    parser.add_argument('--openflow-mapping-mod',
                        help="Openflow mapping module name -- not a file name")
    parser.add_argument('--keep-pragmas',
                        action='store_true',
                        help="Propagate pragmas to JSON file when applicable",
                        default=False)
    return parser
Example #4
0
from util import check_user_inputs
from version import get_version_str
from util import CLILogger, b64decode
from util import get_free_space_in_dir
from util import get_adjusted_image_size
from backend.catalog import get_catalogs
from run_installation import run_installation
from util import human_readable_size, get_cache
from backend.util import sd_has_single_partition, is_admin

import tzlocal
import humanfriendly

CANCEL_TIMEOUT = 5
logger = CLILogger()
logger.std("Kiwix Hotspot {v}".format(v=get_version_str()))


def set_config(config, args):
    def get_choices(option):
        return [x for x in parser._actions if x.dest == option][-1].choices

    def setif(key, value):
        if getattr(args, key, None) is None:
            setattr(args, key, value)

    if not isinstance(config, dict):
        return

    # direct arguments
    for key, arg_key in {
Example #5
0
# Copyright 2013-present Barefoot Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# Antonin Bas ([email protected])
#
#

# -*- coding: utf-8 -*-

from version import get_version_str

__author__ = 'Antonin Bas'
__email__ = '*****@*****.**'
__version__ = get_version_str()

del get_version_str
Example #6
0
    runpy.run_module("cli")
elif sys.argv[1] == "image":
    sys.argv.pop(1)
    runpy.run_module("image")
elif sys.argv[1] == "wipe":
    sys.argv.pop(1)
    from wipe import main

    main()
elif sys.argv[1] == "cache":
    sys.argv.pop(1)
    from cache import main

    main()
else:
    parser = argparse.ArgumentParser(description="Kiwix Hotspot creation tool")
    parser.add_argument("--version",
                        help="display version and exit",
                        action="store_true")
    sub_parser = parser.add_subparsers()
    sub_parser.add_parser("cli", help="run it on the console")
    sub_parser.add_parser("image", help="prepare a master image")
    sub_parser.add_parser("cache",
                          help="manage cache folder to reclaim disk space")
    sub_parser.add_parser("wipe", help="wipe an SD-card clean")
    args = parser.parse_args()

    if args.version:
        print("Kiwix Hotspot:", get_version_str())
        sys.exit(0)
Example #7
0
# Copyright 2013-present Barefoot Networks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#
# Antonin Bas ([email protected])
#
#

# -*- coding: utf-8 -*-

from version import get_version_str

__author__ = "Antonin Bas"
__email__ = "*****@*****.**"
__version__ = get_version_str()

del get_version_str