示例#1
0
    def post_update(cls, cron):

        config = Config()

        # When `cron` is True, we want to bypass question and just recreate
        # YML and environment files from new templates
        if cron is True:
            current_dict = config.get_template()
            current_dict.update(config.get_dict())
            config.set_config(current_dict)
            Template.render(config, force=True)
            sys.exit(0)

        message = ('After an update, it is strongly recommended to run\n'
                   '`python3 run.py --setup` to regenerate environment files.')
        CLI.framed_print(message, color=CLI.COLOR_INFO)
        response = CLI.yes_no_question('Do you want to proceed?')
        if response is True:
            current_dict = config.build()
            Template.render(config)
            config.init_letsencrypt()
            Setup.update_hosts(current_dict)
            question = 'Do you want to (re)start containers?'
            response = CLI.yes_no_question(question)
            if response is True:
                Command.start()
示例#2
0
def run(force_setup=False):

    if sys.version_info[0] == 2:
        CLI.colored_print("╔═══════════════════════════════════════════════════════════════╗", CLI.COLOR_ERROR)
        CLI.colored_print("║ DEPRECATION: Python 2.7 has reached the end of its life on    ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ January 1st, 2020. Please upgrade your Python as Python 2.7   ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ is not maintained anymore.                                    ║", CLI.COLOR_ERROR)
        CLI.colored_print("║ A future version of KoBoInstall will drop support for it.     ║", CLI.COLOR_ERROR)
        CLI.colored_print("╚═══════════════════════════════════════════════════════════════╝", CLI.COLOR_ERROR)

    if not platform.system() in ["Linux", "Darwin"]:
        CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR)
    else:
        config = Config()
        current_config = config.get_config()
        if config.first_time:
            force_setup = True

        if force_setup:
            current_config = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            config.init_letsencrypt()
            Setup.update_hosts(current_config)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(current_config)

        Command.start()
示例#3
0
def run(force_setup=False):
    if not platform.system() in ['Linux', 'Darwin']:
        CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR)
    else:
        config = Config()
        dict_ = config.get_dict()
        if config.first_time:
            force_setup = True

        if force_setup:
            dict_ = config.build()
            Template.render(config)

            support = Support()
            support.copy_support_scripts()

            # # config.init_letsencrypt()
            # # Setup.update_hosts(dict_)
        else:
            print("Running smoothly")
            # if config.auto_detect_network():
            #     Template.render(config)
            #     Setup.update_hosts(dict_)

        Command.start()
示例#4
0
def run(force_setup=False):

    if sys.version_info[0] == 2:
        message = (
            'DEPRECATION: Python 2.7 has reached the end of its life on '
            'January 1st, 2020. Please upgrade your Python as Python 2.7 is '
            'not maintained anymore.\n\n'
            'A future version of KoBoInstall will drop support for it.')
        CLI.framed_print(message)

    if not platform.system() in ['Linux', 'Darwin']:
        CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR)
    else:
        config = Config()
        dict_ = config.get_dict()
        if config.first_time:
            force_setup = True

        if force_setup:
            dict_ = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            config.init_letsencrypt()
            Setup.update_hosts(dict_)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(dict_)

        Command.start()
示例#5
0
    def build(cls, image=None):
        """
        Builds kpi/kobocat images with `--no-caches` option
        Pulls latest `kobotoolbox/koboform_base` as well

        :param image: str
        """
        config_object = Config()
        config = config_object.get_config()

        if config_object.dev_mode or config_object.staging_mode:

            def build_image(image_):
                frontend_command = ["docker-compose",
                                    "-f", "docker-compose.frontend.yml",
                                    "-f", "docker-compose.frontend.override.yml",
                                    "build", "--force-rm", "--no-cache",
                                    image_]

                if config.get("docker_prefix", "") != "":
                    frontend_command.insert(-4, "-p")
                    frontend_command.insert(-4, config.get("docker_prefix"))

                CLI.run_command(frontend_command, config.get("kobodocker_path"))

            pull_base_command = ["docker",
                                 "pull",
                                 "kobotoolbox/koboform_base"]

            CLI.run_command(pull_base_command, config.get("kobodocker_path"))

            if image is None or image == "kf":
                config["kpi_dev_build_id"] = "{prefix}{timestamp}".format(
                    prefix="{}.".format(config.get("docker_prefix"))
                    if config.get("docker_prefix") else "",
                    timestamp=str(int(time.time()))
                )
                config_object.write_config()
                Template.render(config_object)
                build_image("kpi")

            if image is None or image == "kc":
                config["kc_dev_build_id"] = "{prefix}{timestamp}".format(
                    prefix="{}.".format(config.get("docker_prefix"))
                    if config.get("docker_prefix") else "",
                    timestamp=str(int(time.time()))
                )
                config_object.write_config()
                Template.render(config_object)
                build_image("kobocat")
示例#6
0
    def build(cls, image=None):
        """
        Builds kpi/kobocat images with `--no-caches` option
        Pulls latest `kobotoolbox/koboform_base` as well

        :param image: str
        """
        config = Config()
        dict_ = config.get_dict()

        if config.dev_mode or config.staging_mode:

            def build_image(image_):
                frontend_command = [
                    'docker-compose',
                    '-f',
                    'docker-compose.frontend.yml',
                    '-f',
                    'docker-compose.frontend.override.yml',
                    '-p', config.get_prefix('frontend'),
                    'build', '--force-rm', '--no-cache',
                    image_
                ]

                CLI.run_command(frontend_command, dict_['kobodocker_path'])

            if image is None or image == 'kf':
                dict_['kpi_dev_build_id'] = '{prefix}{timestamp}'.format(
                    prefix=config.get_prefix('frontend'),
                    timestamp=str(int(time.time()))
                )
                config.write_config()
                Template.render(config)
                build_image('kpi')

            if image is None or image == 'kc':
                pull_base_command = ['docker',
                                     'pull',
                                     'kobotoolbox/koboform_base']

                CLI.run_command(pull_base_command, dict_['kobodocker_path'])

                dict_['kc_dev_build_id'] = '{prefix}{timestamp}'.format(
                    prefix=config.get_prefix('frontend'),
                    timestamp=str(int(time.time()))
                )
                config.write_config()
                Template.render(config)
                build_image('kobocat')
示例#7
0
    def update(cls):
        config_object = Config()
        config = config_object.get_config()

        Setup.update_kobodocker(config)
        CLI.colored_print("KoBoToolbox has been updated", CLI.COLOR_SUCCESS)

        # update itself
        git_command = ['git', 'pull', 'origin', Config.KOBO_INSTALL_BRANCH]
        CLI.run_command(git_command)
        CLI.colored_print("KoBoInstall has been updated", CLI.COLOR_SUCCESS)

        CLI.colored_print(
            "╔═════════════════════════════════════════════════════╗",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "║ After an update, it's strongly recommended to run   ║",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "║ `./run.py --setup` to regenerate environment files. ║",
            CLI.COLOR_WARNING)
        CLI.colored_print(
            "╚═════════════════════════════════════════════════════╝",
            CLI.COLOR_WARNING)

        CLI.colored_print("Do you want to proceed?", CLI.COLOR_SUCCESS)
        CLI.colored_print("\t1) Yes")
        CLI.colored_print("\t2) No")
        response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE)
        if response == Config.TRUE:
            current_config = config_object.build()
            Template.render(config_object)
            config_object.init_letsencrypt()
            Setup.update_hosts(current_config)

            CLI.colored_print("Do you want to (re)start containers?",
                              CLI.COLOR_SUCCESS)
            CLI.colored_print("\t1) Yes")
            CLI.colored_print("\t2) No")
            response = CLI.get_response([Config.TRUE, Config.FALSE],
                                        Config.TRUE)
            if response == Config.TRUE:
                Command.start()
示例#8
0
def run(force_setup=False):

    if not platform.system() in ["Linux", "Darwin"]:
        CLI.colored_print("Not compatible with this OS", CLI.COLOR_ERROR)
    else:
        config = Config()
        current_config = config.get_config()
        if not current_config:
            force_setup = True

        if force_setup:
            current_config = config.build()
            Setup.run(current_config)
            Template.render(config)
            Setup.update_hosts(current_config)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(current_config)

        Command.start()
示例#9
0
def run(force_setup=False):

    if not platform.system() in ['Linux', 'Darwin']:
        CLI.colored_print('Not compatible with this OS', CLI.COLOR_ERROR)
    else:
        config = Config()
        dict_ = config.get_dict()
        if config.first_time:
            force_setup = True

        if force_setup:
            dict_ = config.build()
            Setup.clone_kobodocker(config)
            Template.render(config)
            Setup.update_hosts(dict_)
        else:
            if config.auto_detect_network():
                Template.render(config)
                Setup.update_hosts(dict_)

        config.validate_passwords()
        Command.start(force_setup=force_setup)
示例#10
0
    def post_update(cls, cron):

        config_object = Config()

        # When `cron` is True, we want to bypass question and just recreate
        # YML and environment files from new templates
        if cron is True:
            current_config = config_object.get_config_template()
            current_config.update(config_object.get_config())
            config_object.set_config(current_config)
            Template.render(config_object, force=True)
            sys.exit(0)

        CLI.colored_print("╔═════════════════════════════════════════════════════╗",
                          CLI.COLOR_WARNING)
        CLI.colored_print("║ After an update, it's strongly recommended to run   ║",
                          CLI.COLOR_WARNING)
        CLI.colored_print("║ `./run.py --setup` to regenerate environment files. ║",
                          CLI.COLOR_WARNING)
        CLI.colored_print("╚═════════════════════════════════════════════════════╝",
                          CLI.COLOR_WARNING)

        CLI.colored_print("Do you want to proceed?", CLI.COLOR_SUCCESS)
        CLI.colored_print("\t1) Yes")
        CLI.colored_print("\t2) No")
        response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE)
        if response == Config.TRUE:
            current_config = config_object.build()
            Template.render(config_object)
            config_object.init_letsencrypt()
            Setup.update_hosts(current_config)

            CLI.colored_print("Do you want to (re)start containers?",
                              CLI.COLOR_SUCCESS)
            CLI.colored_print("\t1) Yes")
            CLI.colored_print("\t2) No")
            response = CLI.get_response([Config.TRUE, Config.FALSE], Config.TRUE)
            if response == Config.TRUE:
                Command.start()