예제 #1
0
    def handle(self, server, outpath, doctype_rangestr=None, *args, **options):
        sfm = from_django_conf(server)
        
        if os.path.exists(outpath):
            raise CommandError("I have nothing against {0}, why would I overwrite it?".format(outpath))

        if doctype_rangestr is not None:
            parse_doctype_range(doctype_rangestr)
        backup(sfm, outpath, doctype_rangestr)
예제 #2
0
    def handle(self, server, outpath, doctype_rangestr=None, *args, **options):
        sfm = from_django_conf(server)

        if os.path.exists(outpath):
            raise CommandError(
                "I have nothing against {0}, why would I overwrite it?".format(
                    outpath))

        if doctype_rangestr is not None:
            parse_doctype_range(doctype_rangestr)
        backup(sfm, outpath, doctype_rangestr)
예제 #3
0
def main():
    parser = ArgumentParser()
    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('--overwrite', default=False, action='store_true',
                        help='Overwrite OUTFILE if it already exists.')
    parser.add_argument('--chunksize', metavar='BYTES', action='store', type=int, default=10000000,
                        help=('The approximate number of bytes (uncompressed) to store in each chunk. ' 
                              + 'Lower numbers trade performance for less memory usage. (default: 10M)'))
    parser.add_argument('doctypes', metavar='RANGE_STRING', action='store',
                        help='Range string of doctypes to backup, e.g. 1:4-7:10')
    parser.add_argument('outpath', metavar='OUTPATH', action='store',
                        help='File to write to.')
    args = parser.parse_args()

    if os.path.exists(args.outpath) and args.overwrite == False:
        print >>sys.stderr, "{outpath} already exists.".format(**vars(args))
        sys.exit(1)

    sfm = Client(args.url, parse_response=True)
    backup(sfm, args.outpath, args.doctypes, chunksize=args.chunksize)