def handle(self, server, inpath, *args, **options): if not os.path.exists(inpath): raise CommandError("No such file: {0}".format(inpath)) sfm = from_django_conf(server) restore(sfm, inpath, doctype_mappingstr=options.get('doctypes'), dryrun=options.get('dryrun'))
def main(): parser = ArgumentParser() parser.add_argument('--dryrun', default=False, action='store_true', help='Don\'t actually restore the documents. Just run through the backup file.') parser.add_argument('--doctypes', metavar='MAPPING', action='store', help='A string describing how to translate doctypes during the restore process.') parser.add_argument('--docids', metavar='DOCID_RANGE', action='store', help='A string describing which docids to restore. E.g. 1-10,20,30-31 would restore 13 documents.') parser.add_argument('--url', metavar='URL', type=str, default='http://127.0.0.1:8080', action='store', help='URL of the Superfastmatch server.') parser.add_argument('inpath', metavar='INPATH', action='store', help='Backup file to read.') args = parser.parse_args() if os.path.exists(args.inpath) == False: print >>sys.stderr, "Unable to find {inpath}.".format(**vars(args)) sys.exit(1) sfm = Client(args.url, parse_response=True) restore(sfm, args.inpath, docid_rangestr=args.docids, doctype_mappingstr=args.doctypes, dryrun=args.dryrun)