Ejemplo n.º 1
0
    def handle(self, *args, **options):
        if options["interactive"]:
            answer = None
            while not answer or answer not in "yn":
                answer = six.moves.input("Include sample games? (y or n): ")
                if not answer:
                    answer = "y"
                    break
                else:
                    answer = answer[0].lower()
        else:
            answer = 'n'
        self.core_project_template_path = os.path.join(
            os.path.dirname(otree.__file__), 'project_template')
        if answer == "y":
            project_template_path = (
                "https://github.com/oTree-org/oTree/archive/master.zip")
        else:
            project_template_path = self.core_project_template_path
        if options.get('template', None) is None:
            options['template'] = project_template_path
        super(Command, self).handle(*args, **options)

        self.modify_project_files(options)
        try:
            pypi_updates_cli()
        except:
            pass
        print('Created project folder.')
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        if options["interactive"]:
            answer = None
            while not answer or answer not in "yn":
                answer = six.moves.input("Include sample games? (y or n): ")
                if not answer:
                    answer = "y"
                    break
                else:
                    answer = answer[0].lower()
        else:
            answer = 'n'
        self.core_project_template_path = os.path.join(
                os.path.dirname(otree.__file__), 'project_template')
        if answer == "y":
            project_template_path = (
                "https://github.com/oTree-org/oTree/archive/master.zip")
        else:
            project_template_path = self.core_project_template_path
        if options.get('template', None) is None:
            options['template'] = project_template_path
        super(Command, self).handle(*args, **options)

        self.modify_project_files(options)
        try:
            pypi_updates_cli()
        except:
            pass
        print('Created project folder.')
Ejemplo n.º 3
0
def execute_from_command_line(arguments, script_file):

    try:
        subcommand = arguments[1]
    except IndexError:
        subcommand = 'help'  # default

    # Workaround for Python 2 & windows. For some reason, runserver
    # complains if the script you are using to initialize celery does not end
    # on '.py'. That's why we require a manage.py file to be around.

    # originally this was written for a problem with billiard/celery,
    # but now for runserver.
    # See https://github.com/celery/billiard/issues/129 for more details.
    cond = (
        platform.system() == 'Windows' and
        not script_file.lower().endswith('.py') and
        subcommand not in NO_SETTINGS_COMMANDS
    )

    if cond:

        scriptdir = os.path.dirname(os.path.abspath(script_file))
        managepy = os.path.join(scriptdir, 'manage.py')
        if not os.path.exists(managepy):
            error_lines = []

            error_lines.append(
                "It seems that you do not have a file called 'manage.py' in "
                "your current directory. This is a requirement when using "
                "otree on windows."
            )
            error_lines.append("")
            error_lines.append("")
            error_lines.append(
                "Please download the file {url} and save it as 'manage.py' in "
                "the directory {directory}".format(
                    url=MANAGE_URL, directory=scriptdir))
            raise CommandError("\n".join(error_lines))
        args = [sys.executable] + [managepy] + arguments[1:]
        process = subprocess.Popen(args,
                                   stdin=sys.stdin,
                                   stdout=sys.stdout,
                                   stderr=sys.stderr)
        return_code = process.wait()
        sys.exit(return_code)

    # only monkey patch when is necesary
    if "version" in arguments or "--version" in arguments:
        sys.stdout.write(otree_and_django_version() + '\n')
        try:
            pypi_updates_cli()
        except:
            pass
    else:
        utility = OTreeManagementUtility(arguments)
        utility.execute()
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     if options.get('template', None) is None:
         options['template'] = self.get_default_template()
     super(Command, self).handle(*args, **options)
     try:
         pypi_updates_cli()
     except:  # noqa
         pass  # noqa
     print('Created app folder.')
Ejemplo n.º 5
0
def execute_from_command_line(arguments, script_file):

    try:
        subcommand = arguments[1]
    except IndexError:
        subcommand = 'help'  # default

    # Workaround for Python 2 & windows. For some reason, runserver
    # complains if the script you are using to initialize celery does not end
    # on '.py'. That's why we require a manage.py file to be around.
    # originally this was written for a problem with billiard/celery,
    # but now for runserver.
    # See https://github.com/celery/billiard/issues/129 for more details.
    cond = (platform.system() == 'Windows'
            and not script_file.lower().endswith('.py')
            and subcommand not in NO_SETTINGS_COMMANDS)

    if cond:

        scriptdir = os.path.dirname(os.path.abspath(script_file))
        managepy = os.path.join(scriptdir, 'manage.py')
        if not os.path.exists(managepy):
            error_lines = []

            error_lines.append(
                "It seems that you do not have a file called 'manage.py' in "
                "your current directory. This is a requirement when using "
                "otree on windows.")
            error_lines.append("")
            error_lines.append("")
            error_lines.append(
                "Please download the file {url} and save it as 'manage.py' in "
                "the directory {directory}".format(url=MANAGE_URL,
                                                   directory=scriptdir))
            raise CommandError("\n".join(error_lines))
        args = [sys.executable] + [managepy] + arguments[1:]
        process = subprocess.Popen(args,
                                   stdin=sys.stdin,
                                   stdout=sys.stdout,
                                   stderr=sys.stderr)
        return_code = process.wait()
        sys.exit(return_code)

    # only monkey patch when is necesary
    if "version" in arguments or "--version" in arguments:
        sys.stdout.write(otree_and_django_version() + '\n')
        try:
            pypi_updates_cli()
        except:
            pass
    else:
        utility = OTreeManagementUtility(arguments)
        utility.execute()