Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
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)
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."
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)
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)
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."
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()
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)
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)
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