assemblyline-service-client 4.5.1.dev98__py3-none-any.whl → 4.5.1.dev102__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of assemblyline-service-client might be problematic. Click here for more details.
- assemblyline_service_client/VERSION +1 -1
- assemblyline_service_client/task_handler.py +14 -12
- {assemblyline_service_client-4.5.1.dev98.dist-info → assemblyline_service_client-4.5.1.dev102.dist-info}/METADATA +1 -1
- assemblyline_service_client-4.5.1.dev102.dist-info/RECORD +8 -0
- assemblyline_service_client-4.5.1.dev98.dist-info/RECORD +0 -8
- {assemblyline_service_client-4.5.1.dev98.dist-info → assemblyline_service_client-4.5.1.dev102.dist-info}/LICENCE.md +0 -0
- {assemblyline_service_client-4.5.1.dev98.dist-info → assemblyline_service_client-4.5.1.dev102.dist-info}/WHEEL +0 -0
- {assemblyline_service_client-4.5.1.dev98.dist-info → assemblyline_service_client-4.5.1.dev102.dist-info}/top_level.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
4.5.1.
|
|
1
|
+
4.5.1.dev102
|
|
@@ -177,7 +177,8 @@ class TaskHandler(ServerBase):
|
|
|
177
177
|
except Exception:
|
|
178
178
|
pass
|
|
179
179
|
|
|
180
|
-
def request_with_retries(self, method: str, url: str,
|
|
180
|
+
def request_with_retries(self, method: str, url: str,
|
|
181
|
+
get_api_response=True, max_retry=None, **kwargs) -> Optional[Any]:
|
|
181
182
|
if 'headers' in kwargs:
|
|
182
183
|
self.session.headers.update(kwargs['headers'])
|
|
183
184
|
kwargs.pop('headers')
|
|
@@ -344,7 +345,7 @@ class TaskHandler(ServerBase):
|
|
|
344
345
|
def get_task(self) -> ServiceTask:
|
|
345
346
|
self.status = STATUSES.WAITING_FOR_TASK
|
|
346
347
|
task = None
|
|
347
|
-
headers =
|
|
348
|
+
headers = {"Timeout": str(TASK_REQUEST_TIMEOUT)}
|
|
348
349
|
self.log.info(f"Requesting a task with {TASK_REQUEST_TIMEOUT}s timeout...")
|
|
349
350
|
r = self.request_with_retries('get', self._path('task'), headers=headers, timeout=TASK_REQUEST_TIMEOUT*2)
|
|
350
351
|
if r['task'] is False: # No task received
|
|
@@ -369,7 +370,8 @@ class TaskHandler(ServerBase):
|
|
|
369
370
|
file_path = None
|
|
370
371
|
self.log.info(f"[{sid}] Downloading file: {sha256}")
|
|
371
372
|
response = self.request_with_retries('get', self._path('file', sha256),
|
|
372
|
-
get_api_response=False, max_retry=3, headers=self.headers,
|
|
373
|
+
get_api_response=False, max_retry=3, headers=self.headers,
|
|
374
|
+
timeout=FILE_REQUEST_TIMEOUT)
|
|
373
375
|
if response is not None:
|
|
374
376
|
# Check if we got a 'good' response
|
|
375
377
|
if response.status_code == 200:
|
|
@@ -418,8 +420,8 @@ class TaskHandler(ServerBase):
|
|
|
418
420
|
new_tool_version = result.get('response', {}).get('service_tool_version', None)
|
|
419
421
|
if new_tool_version is not None and self.service_tool_version != new_tool_version:
|
|
420
422
|
self.service_tool_version = new_tool_version
|
|
421
|
-
self.session.headers.update({'
|
|
422
|
-
self.headers.update({'
|
|
423
|
+
self.session.headers.update({'Service-Tool-Version': self.service_tool_version})
|
|
424
|
+
self.headers.update({'Service-Tool-Version': self.service_tool_version})
|
|
423
425
|
|
|
424
426
|
data = dict(task=task.as_primitives(), result=result, freshen=True)
|
|
425
427
|
try:
|
|
@@ -429,19 +431,19 @@ class TaskHandler(ServerBase):
|
|
|
429
431
|
while not r['success'] and r['missing_files']:
|
|
430
432
|
for f_sha256 in r['missing_files']:
|
|
431
433
|
file_info = result_files[f_sha256]
|
|
432
|
-
headers =
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
headers = {
|
|
435
|
+
"Sha256": file_info['sha256'],
|
|
436
|
+
"Classification": file_info['classification'],
|
|
437
|
+
"Ttl": str(task.ttl),
|
|
438
|
+
"Is-Section-Image": str(file_info.get('is_section_image', False))
|
|
439
|
+
}
|
|
438
440
|
|
|
439
441
|
with open(file_info['path'], 'rb') as fh:
|
|
440
442
|
# Upload the file requested by service server
|
|
441
443
|
self.log.info(f"[{task.sid}] Uploading file {file_info['path']} [{file_info['sha256']}]")
|
|
442
444
|
try:
|
|
443
445
|
self.request_with_retries('put', self._path('file'), files=dict(file=fh),
|
|
444
|
-
headers=headers,timeout=FILE_REQUEST_TIMEOUT)
|
|
446
|
+
headers=headers, timeout=FILE_REQUEST_TIMEOUT)
|
|
445
447
|
except ServiceServerException as e:
|
|
446
448
|
if "does not match expected file hash" in str(e):
|
|
447
449
|
self.log.warning(f"File upload of '{file_info['path']}' failed.")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: assemblyline-service-client
|
|
3
|
-
Version: 4.5.1.
|
|
3
|
+
Version: 4.5.1.dev102
|
|
4
4
|
Summary: Assemblyline 4 - Service client
|
|
5
5
|
Home-page: https://github.com/CybercentreCanada/assemblyline-service-client/
|
|
6
6
|
Author: CCCS Assemblyline development team
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
assemblyline_service_client/VERSION,sha256=X78dpda2kBIKcnROwJjsv-VuIP-eDSqv5N2SzKgFUOQ,13
|
|
2
|
+
assemblyline_service_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
assemblyline_service_client/task_handler.py,sha256=xZ7BdEAzlUnJIAcz8zepi2cNe_sD6ziOCDmiBc9Rg6Q,23315
|
|
4
|
+
assemblyline_service_client-4.5.1.dev102.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
|
|
5
|
+
assemblyline_service_client-4.5.1.dev102.dist-info/METADATA,sha256=8JtxTCO34aH6uF2tfSYRC4S-cPVmGCm8U3GR4XAe5oM,1578
|
|
6
|
+
assemblyline_service_client-4.5.1.dev102.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
7
|
+
assemblyline_service_client-4.5.1.dev102.dist-info/top_level.txt,sha256=clNWHvn8nw0kR15l5TASxWxIQvKGKe5Pso3kVPMiJv0,28
|
|
8
|
+
assemblyline_service_client-4.5.1.dev102.dist-info/RECORD,,
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
assemblyline_service_client/VERSION,sha256=NxTYIb4TeI-fwiSdZ6FGC9h7rpr9cCfPxWcXtCxv7gU,12
|
|
2
|
-
assemblyline_service_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
-
assemblyline_service_client/task_handler.py,sha256=U6OmqDSbBY9p-JccwdFImZ436McK_PK-A5Pl6d54Kko,23233
|
|
4
|
-
assemblyline_service_client-4.5.1.dev98.dist-info/LICENCE.md,sha256=NSkYo9EH8h5oOkzg4VhjAHF4339MqPP2cQ8msTPgl-c,1396
|
|
5
|
-
assemblyline_service_client-4.5.1.dev98.dist-info/METADATA,sha256=bk3CtKSK_zIE3ieUYl3Snv3Swc8iYd7AXOyF1Dd2He8,1577
|
|
6
|
-
assemblyline_service_client-4.5.1.dev98.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
7
|
-
assemblyline_service_client-4.5.1.dev98.dist-info/top_level.txt,sha256=clNWHvn8nw0kR15l5TASxWxIQvKGKe5Pso3kVPMiJv0,28
|
|
8
|
-
assemblyline_service_client-4.5.1.dev98.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|