def handle(self, *args, **options): self.action = options['action'] self.check_only = options['check_only'] self.only = options['only'] self.soft_mode = options['soft_mode'] start = time.time() anonymizer = Anonymizer(soft_mode=self.soft_mode, only=self.only) self.stdout.write('Check pass successfully') self.stdout.write(f'{"=-" * 25}=') if self.check_only is True: return if self.action is None or self.action == 'anonymize': if ((self.only is None) or (self.only is not None and self.only in Anonymizer.anonym_models)) and len( anonymizer.anonym_models) > 0: self.stdout.write('Anonymizing started') anonymizer.anonymize(only=self.only) self.stdout.write('Anonymizing finished') if self.action is None or self.action == 'clean': if ((self.only is None) or (self.only is not None and self.only in Anonymizer.clean_models )) and len(anonymizer.clean_models) > 0: self.stdout.write('Cleaning started') anonymizer.clean(only=self.only) self.stdout.write('Cleaning finished') end = time.time() - start self.stdout.write(f'{"=-" * 25}=') self.stdout.write(f'Total time (sec.): {end:.2f}')
def handle(self, *args, **options): start = time.time() anonymizer = Anonymizer(soft_mode=options['soft_mode']) if options['action'] is None or options['action'] == 'anonymize': anonymizer.anonymize() if options['action'] is None or options['action'] == 'clean': anonymizer.clean() end = time.time() print('=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=') print('Total time (sec.): {}'.format(end - start))
def handle(self, *args, **options): print 'Anonymizer found next DB settings:' for db in settings.DATABASES: print '{} -- NAME: {}, HOST: {}'.format( db, settings.DATABASES[db]['NAME'], settings.DATABASES[db]['HOST'] or 'localhsot') start = time.time() anonymizer = Anonymizer(soft_mode=options['soft_mode']) if options['action'] is None or options['action'] == 'anonymize': anonymizer.anonymize() if options['action'] is None or options['action'] == 'clean': anonymizer.clean() end = time.time() print '=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=' print 'Total time (sec.): {}'.format(end - start)