def setUp(self): logger.info("Resetting progressd ...") progressd.reset() logger.info("Logging in as admin") logger.info("Report count: %d" % len(Report.objects.all())) self.client = Client() self.assertTrue(self.client.login(username="******", password="******"))
def setUp(self): logger.info('Resetting progressd ...') progressd.reset() logger.info('Logging in as admin') logger.info('Report count: %d' % len(Report.objects.all())) self.client = Client() self.assertTrue(self.client.login(username='******', password='******'))
def handle(self, *args, **options): if not options['force']: msg = ('You have requested to reset portal, this will delete\n' 'everything from the database and start from scratch.\n' 'Are you sure?\n' "Type 'yes' to continue, or 'no' to cancel: ") confirm = raw_input(msg) else: confirm = 'yes' if confirm != 'yes': self.stdout.write('Aborting.') return # Iterating keys in buffers and save data based on options for name in self.buffer_names: if not options['drop_' + name]: self.save_data(name) # lets clear it self.stdout.write('Resetting database ... ', ending='') management.call_command('reset_db', interactive=False, router='default') self.stdout.write('done.') management.call_command('clean', applications=False, report_id=None, clear_cache=True, clear_logs=True) management.call_command('clean_pyc', path=settings.PROJECT_ROOT) # some chain of migration dependencies requires this first # https://code.djangoproject.com/ticket/24524 management.call_command('migrate', 'preferences', interactive=False) # now we can do the full migrate (previously syncdb) management.call_command('migrate', interactive=False) self.stdout.write('Loading initial data ... ', ending='') initial_data = glob.glob(os.path.join(settings.INITIAL_DATA, '*.json')) initial_data.sort() if not options['drop_users']: # filter out default admin user fixture and reload previous users initial_data = [f for f in initial_data if 'admin_user' not in f] if initial_data: management.call_command('loaddata', *initial_data) for name in self.buffer_names: self.load_data(name) # if we don't have a settings fixture, create new default item if not SystemSettings.objects.all(): SystemSettings().save() management.call_command('reload', report_id=None) if (not options['drop_users'] and (self.buffers['users']['buffer'] is None or len(AppfwkUser.objects.all()) == 0)): self.stdout.write('WARNING: No users added to database. ' 'If you would like to include the default ' 'admin user, rerun this command with the ' "'--drop-users' option.") # reset progressd cache self.stdout.write('Resetting progressd ...', ending='') try: from steelscript.appfwk.apps.jobs.progress import progressd progressd.reset() except RvbdException: self.stdout.write(' unable to connect to progressd, skipping ...', ending='') self.stdout.write(' done.')
def handle(self, *args, **options): if not options["force"]: msg = ( "You have requested to reset portal, this will delete\n" "everything from the database and start from scratch.\n" "Are you sure?\n" "Type 'yes' to continue, or 'no' to cancel: " ) confirm = raw_input(msg) else: confirm = "yes" if confirm != "yes": self.stdout.write("Aborting.") return # Iterating keys in buffers and save data based on options for name in self.buffer_names: if not options["drop_" + name]: self.save_data(name) # lets clear it self.stdout.write("Resetting database ... ", ending="") management.call_command("reset_db", interactive=False, router="default") self.stdout.write("done.") management.call_command("clean", applications=False, report_id=None, clear_cache=True, clear_logs=True) management.call_command("clean_pyc", path=settings.PROJECT_ROOT) management.call_command("syncdb", interactive=False) self.stdout.write("Loading initial data ... ", ending="") initial_data = glob.glob(os.path.join(settings.INITIAL_DATA, "*.json")) initial_data.sort() if not options["drop_users"]: # filter out default admin user fixture and reload previous users initial_data = [f for f in initial_data if "admin_user" not in f] if initial_data: management.call_command("loaddata", *initial_data) for name in self.buffer_names: self.load_data(name) # if we don't have a settings fixture, create new default item if not SystemSettings.objects.all(): SystemSettings().save() management.call_command("reload", report_id=None) if not options["drop_users"] and ( self.buffers["users"]["buffer"] is None or len(AppfwkUser.objects.all()) == 0 ): self.stdout.write( "WARNING: No users added to database. " "If you would like to include the default " "admin user, rerun this command with the " "'--drop-users' option." ) # reset progressd cache self.stdout.write("Resetting progressd ...", ending="") try: from steelscript.appfwk.apps.jobs.progress import progressd progressd.reset() except RvbdException: self.stdout.write(" unable to connect to progressd, skipping ...", ending="") self.stdout.write(" done.")