Every line of 'django startapp' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
75 def main(): 76 77 if not settings.configured: 78 settings.configure(**DEFAULT_SETTINGS) 79 django.setup() 80 failures = DiscoverRunner(failfast=False).run_tests(["simple_history.tests"]) 81 failures |= DiscoverRunner(failfast=False).run_tests( 82 ["simple_history.registry_tests"] 83 ) 84 sys.exit(failures)
12 def start_project(): 13 """ 14 Copy a project template, replacing boilerplate variables. 15 16 """ 17 usage = "usage: %prog [options] project_name [base_destination_dir]" 18 parser = optparse.OptionParser(usage=usage) 19 parser.add_option('-t', '--template-dir', dest='src_dir', 20 help='project template directory to use', 21 default=TEMPLATE_DIR) 22 options, args = parser.parse_args() 23 if len(args) not in (1, 2): 24 parser.print_help() 25 sys.exit(1) 26 project_name = args[0] 27 28 src = options.src_dir 29 if len(args) > 1: 30 base_dest_dir = args[1] 31 else: 32 base_dest_dir = '' 33 dest = os.path.join(base_dest_dir, project_name) 34 35 # Get any boilerplate replacement variables: 36 replace = {} 37 for var, help, default in utils.get_boilerplate(src, project_name): 38 help = help or var 39 if default is not None: 40 prompt = '%s [%s]: ' % (help, default) 41 else: 42 prompt = '%s: ' % help 43 value = None 44 while not value: 45 value = raw_input(prompt) or default 46 replace[var] = value 47 48 # Put in the rest of the replacement variables 49 REPO_PATH = os.path.join(os.getcwd(), replace['myproject']) 50 replace.update({ 51 '$REPO_PATH': REPO_PATH, 52 '$PROJECT_NAME': replace['myproject'], 53 '$PROJECT_PATH': os.path.join(REPO_PATH, replace['myproject']), 54 '_gitignore': '.gitignore', 55 }) 56 utils.copy_template(src, dest, replace) 57 subprocess.call(['python', os.path.join(dest, 'bin/bootstrap.py'), 'dev'])
38 def run_from_argv(self, argv): 39 """ 40 Override the default run_from_argv because we just want to pass the command line args to Testacular. 41 """ 42 current_path = os.path.dirname(os.path.abspath(__file__)) 43 # Move up three directories (from the current file) to the root of the project 44 for _ in range(3): 45 current_path = os.path.dirname(current_path) 46 config_file = os.path.join(current_path, self._get_default_site(), self.testacular_config_file) 47 48 if not os.path.exists(config_file): 49 sys.stderr.write("Error: %s not found. Please run:\n" % config_file) 50 sys.stderr.write(" python manage.py makeangularsite\n") 51 sys.exit(1) 52 53 sys.stdout.write("\n") 54 sys.stdout.write("Starting Testacular Server (http://vojtajina.github.com/testacular)\n") 55 sys.stdout.write("-------------------------------------------------------------------\n") 56 57 # Add testacular command and use argv from the command line 58 args = ['testacular', 'start', config_file] 59 args.extend(argv[2:]) 60 os.execvp('testacular', args)