##// END OF EJS Templates
Added limit option to sync command
neko259 -
r1551:a596995d default
parent child Browse files
Show More
@@ -20,6 +20,9 b' class Command(BaseCommand):'
20 parser.add_argument('url', type=str, help='Server root url')
20 parser.add_argument('url', type=str, help='Server root url')
21 parser.add_argument('--global-id', type=str, default='',
21 parser.add_argument('--global-id', type=str, default='',
22 help='Post global ID')
22 help='Post global ID')
23 parser.add_argument('--split-query', type=int,
24 help='Split GET query into separate by the given'
25 ' number of posts in one')
23
26
24 def handle(self, *args, **options):
27 def handle(self, *args, **options):
25 url = options.get('url')
28 url = options.get('url')
@@ -68,12 +71,14 b' class Command(BaseCommand):'
68 print()
71 print()
69
72
70 if len(ids_to_sync) > 0:
73 if len(ids_to_sync) > 0:
71 xml = GlobalId.objects.generate_request_get(ids_to_sync)
74 limit = options.get('split_query', len(ids_to_sync))
72 # body = urllib.parse.urlencode(data)
75 for offset in range(0, len(ids_to_sync), limit):
73 h = httplib2.Http()
76 xml = GlobalId.objects.generate_request_get(ids_to_sync[offset:offset+limit0])
74 response, content = h.request(get_url, method="POST", body=xml)
77 # body = urllib.parse.urlencode(data)
78 h = httplib2.Http()
79 response, content = h.request(get_url, method="POST", body=xml)
75
80
76 SyncManager.parse_response_get(content, file_url)
81 SyncManager.parse_response_get(content, file_url)
77 else:
82 else:
78 print('Nothing to get, everything synced')
83 print('Nothing to get, everything synced')
79 else:
84 else:
General Comments 0
You need to be logged in to leave comments. Login now