def handle(self, *args, **options): domain = since = None if len(args) == 1: domain = args[0] elif len(args) == 2: domain = args[0] since = string_to_datetime(args[1]) else: raise CommandError('Usage: %s\n%s' % (self.args, self.help)) succeeded = [] failed = [] error_messages = defaultdict(lambda: 0) for form in iter_problem_forms(domain, since): print "%s\t%s\t%s\t%s\t%s" % ( form._id, form.received_on, form.xmlns, form.xpath('form/meta/username'), form.problem.strip()) if not options["dryrun"]: try: reprocess_form_cases(form) except Exception, e: failed.append(form._id) error_messages[str(e)] += 1 else: succeeded.append(form._id)
def handle(self, *args, **options): domain = since = None if len(args) == 1: domain = args[0] elif len(args) == 2: domain = args[0] since = string_to_datetime(args[1]) else: raise CommandError('Usage: %s\n%s' % (self.args, self.help)) succeeded = [] failed = [] error_messages = defaultdict(lambda: 0) for form in iter_problem_forms(domain, since): print "%s\t%s\t%s\t%s\t%s" % (form._id, form.received_on, form.xmlns, form.xpath('form/meta/username'), form.problem.strip()) if not options["dryrun"]: try: reprocess_form_cases(form) except Exception, e: failed.append(form._id) error_messages[str(e)] += 1 else: succeeded.append(form._id)
def handle(self, *args, **options): forms = all_forms_without_domains() headers = [ 'id', 'xmlns', 'username', 'received_on', 'domain', '# matched domains' ] if not options["cleanup"]: print ','.join(headers) for f in forms: domains = guess_domain(f) domain = domains[0] if domains else '' if not options["cleanup"]: print ",".join([ f._id, f.xmlns or '', f.metadata.username or '', f.received_on.isoformat(), domain, str(len(domains)) ]) else: if len(domains) == 1: f.domain = domain reprocess_form_cases(f) print 'added form %s to domain %s' % (f._id, domains[0]) else: print 'form %s failed because there were %s matching domains: %s' % ( f._id, len(domains), ', '.join(domains))
def handle(self, *args, **options): if len(args) == 1: id = args[0] else: raise CommandError('Usage: %s\n%s' % (self.args, self.help)) reprocess_form_cases(XFormError.get(id))