##// END OF EJS Templates
Use logging during sync. Log list response processing
neko259 -
r1605:25856b69 default
parent child Browse files
Show More
@@ -1,4 +1,5 b''
1 1 import re
2 import logging
2 3 import xml.etree.ElementTree as ET
3 4
4 5 import httplib2
@@ -25,6 +26,8 b' class Command(BaseCommand):'
25 26 ' number of posts in one')
26 27
27 28 def handle(self, *args, **options):
29 logger = logging.getLogger('boards.sync')
30
28 31 url = options.get('url')
29 32
30 33 list_url = url + 'api/sync/list/'
@@ -50,11 +53,11 b' class Command(BaseCommand):'
50 53 else:
51 54 raise Exception('Invalid global ID')
52 55 else:
53 print('Running LIST request...')
56 logger.info('Running LIST request...')
54 57 h = httplib2.Http()
55 58 xml = GlobalId.objects.generate_request_list()
56 59 response, content = h.request(list_url, method="POST", body=xml)
57 print('Processing response...')
60 logger.info('Processing response...')
58 61
59 62 root = ET.fromstring(content)
60 63 status = root.findall('status')[0].text
@@ -71,20 +74,23 b' class Command(BaseCommand):'
71 74 else:
72 75 version = 1
73 76 if not exists or global_id.post.version < version:
77 logger.debug('* Processed (+) post {}'.format(global_id))
74 78 ids_to_sync.append(global_id)
75 print('Starting sync...')
79 else:
80 logger.debug('* Processed (-) post {}'.format(global_id))
81 logger.info('Starting sync...')
76 82
77 83 if len(ids_to_sync) > 0:
78 84 limit = options.get('split_query', len(ids_to_sync))
79 85 for offset in range(0, len(ids_to_sync), limit):
80 86 xml = GlobalId.objects.generate_request_get(ids_to_sync[offset:offset+limit])
81 87 h = httplib2.Http()
82 print('Running GET request...')
88 logger.info('Running GET request...')
83 89 response, content = h.request(get_url, method="POST", body=xml)
84 print('Processing response...')
90 logger.info('Processing response...')
85 91
86 92 SyncManager.parse_response_get(content, file_url)
87 93 else:
88 print('Nothing to get, everything synced')
94 logger.info('Nothing to get, everything synced')
89 95 else:
90 96 raise Exception('Invalid response status')
General Comments 0
You need to be logged in to leave comments. Login now