def send_file_without_wait( file_path, dynamic_unpacking, static_unpacking): # type: (str, bool, bool) -> None api.set_global_api('<api_key>') analysis = Analysis(file_path=file_path, dynamic_unpacking=dynamic_unpacking, static_unpacking=static_unpacking) analysis.send() analysis.wait_for_completion() pprint(analysis.result())
def test_send_analysis_by_file_sent_analysis_without_wait_and_get_status_finish( self): # Arrange with responses.RequestsMock() as mock: mock.add('POST', url=self.full_url + '/analyze', status=201, json={'result_url': 'a/sd/asd'}) mock.add('GET', url=self.full_url + '/analyses/asd', status=200, json={'result': 'report'}) analysis = Analysis(file_path='a') with patch(self.patch_prop, mock_open(read_data='data')): # Act analysis.send() analysis.wait_for_completion() # Assert self.assertEqual(analysis.status, consts.AnalysisStatusCode.FINISH)
def run(self): result = {} try: intezer_sdk.consts.USER_AGENT = "IntelOwl" # run analysis analysis = Analysis(file_hash=self.observable_name) analysis.send(wait=False) analysis.wait_for_completion( interval=self.poll_interval, sleep_before_first_check=True, timeout=timedelta(seconds=self.timeout), ) result.update(analysis.result(), hash_found=True) except (intezer_errors.HashDoesNotExistError, intezer_errors.InsufficientQuota): result.update(hash_found=False) except intezer_errors.IntezerError as e: raise AnalyzerRunException(e) return result
def analysis_by_hash_without_wait(file_hash): # type: (str) -> None api.set_global_api('<api_key>') analysis = Analysis(file_hash=file_hash) analysis.send() analysis.wait_for_completion() pprint(analysis.result())