How to use the kobo.admin function in kobo

To help you get started, we’ve selected a few kobo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github release-engineering / kobo / kobo / admin / commands / cmd_start_cli_command.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the command.")

        name = args[0]
        directory = kwargs.pop("dir")
        if not directory:
            directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "cli@cmd___project_name__.py.template")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / commands / cmd_start_worker.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the project.")

        name = args[0]
        directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "worker")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / commands / cmd_start_cli.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the project.")

        name = args[0]
        directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "cli")
        except kobo.admin.TemplateError, ex:
            self.parser.error(ex)

        print "Use `kobo-admin start-cli-command` to add additional commands."
github release-engineering / kobo / kobo / admin / commands / cmd_start_worker_task.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the task.")

        name = args[0]
        directory = kwargs.pop("dir")
        if not directory:
            directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "task___project_name__.py.template")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / commands / cmd_start_cli_command.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the command.")

        name = args[0]
        directory = kwargs.pop("dir")
        if not directory:
            directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "cli@cmd___project_name__.py.template")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / commands / cmd_start_client.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the project.")

        name = args[0]
        directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "client")
        except kobo.admin.TemplateError, ex:
            self.parser.error(ex)

        print "Edit config file to finish setup."
        print "Use `kobo-admin start-client-command` to add additional commands."
github release-engineering / kobo / kobo / admin / commands / cmd_start_hub.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the project.")

        name = args[0].replace("-", "_")
        directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "hub")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)

        # code from django/core/management/commands/startproject.py
        # Create a random SECRET_KEY hash, and put it in the main settings.
        main_settings_file = os.path.join(directory, name, 'settings.py')
        settings_contents = open(main_settings_file, 'r').read()
        fp = open(main_settings_file, 'w')
        django_alphabet = "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)"
        secret_key = kobo.shortcuts.random_string(50, alphabet=django_alphabet)
        settings_contents = re.sub(r"(?<=SECRET_KEY = ')'", secret_key + "'", settings_contents)
        fp.write(settings_contents)
        fp.close()
github release-engineering / kobo / kobo / admin / commands / cmd_start_client_command.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the command.")

        name = args[0]
        directory = kwargs.pop("dir")
        if not directory:
            directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "client@cmd___project_name__.py.template")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / commands / cmd_start_worker.py View on Github external
def run(self, *args, **kwargs):
        if len(args) < 1:
            self.parser.error("Please specify a name of the project.")

        name = args[0]
        directory = os.getcwd()

        try:
            kobo.admin.copy_helper(name, directory, "worker")
        except kobo.admin.TemplateError as ex:
            self.parser.error(ex)
github release-engineering / kobo / kobo / admin / __init__.py View on Github external
def main():
    """Main method for kobo-admin script."""
    # Register plugins for commands
    KoboAdminCommandContainer.register_module(kobo.admin.commands, prefix="cmd_")

    command_container = KoboAdminCommandContainer()
    parser = kobo.cli.CommandOptionParser(
        command_container = command_container,
    )
    parser.run()
    return 0