LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
3 # | 3 # |
4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
7 # | 7 # |
8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 else: | 224 else: |
225 # Hacky way to go around 415 error code | 225 # Hacky way to go around 415 error code |
226 files_to_upload = {'a': 'b'} | 226 files_to_upload = {'a': 'b'} |
227 | 227 |
228 url = urlparse.urljoin(self.base_url, self._UrlPaths.CREATE) | 228 url = urlparse.urljoin(self.base_url, self._UrlPaths.CREATE) |
229 | 229 |
230 response = self._execute(url, data=data, files=files_to_upload) | 230 response = self._execute(url, data=data, files=files_to_upload) |
231 | 231 |
232 if response.status_code != self._SuccessCodes.CREATE: | 232 if response.status_code != self._SuccessCodes.CREATE: |
233 # The creation was not successful | 233 # The creation was not successful |
234 print('Raising exception') | |
235 raise XTMCloudException(response.status_code, | 234 raise XTMCloudException(response.status_code, |
236 response.text.decode('utf-8'), | 235 response.text.decode('utf-8'), |
237 'creating job') | 236 'creating job') |
238 | 237 |
239 data = json.loads(response.text.encode('utf-8')) | 238 data = json.loads(response.text.encode('utf-8')) |
240 | 239 |
241 return data['projectId'], data['jobs'] | 240 return data['projectId'], data['jobs'] |
242 | 241 |
243 def upload_files(self, files, project_id, overwrite=True): | 242 def upload_files(self, files, project_id, overwrite=True): |
244 """Upload a set of files to a project. | 243 """Upload a set of files to a project. |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 headers = {'content-type': 'application/json'} | 469 headers = {'content-type': 'application/json'} |
471 | 470 |
472 response = requests.post(url, data=request_body, headers=headers) | 471 response = requests.post(url, data=request_body, headers=headers) |
473 | 472 |
474 if response.status_code == 200: | 473 if response.status_code == 200: |
475 return json.loads(response.text)['token'].encode() | 474 return json.loads(response.text)['token'].encode() |
476 | 475 |
477 raise XTMCloudException(response.status_code, | 476 raise XTMCloudException(response.status_code, |
478 response.text.encode('utf-8'), | 477 response.text.encode('utf-8'), |
479 'generating token') | 478 'generating token') |
LEFT | RIGHT |