-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from intezer/feature/wait-interval
Feature/wait interval
- Loading branch information
Showing
11 changed files
with
190 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = '1.1.1' | ||
__version__ = '1.2.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,77 @@ | ||
import requests | ||
|
||
|
||
def _parse_erroneous_response(response: requests.Response): | ||
try: | ||
data = response.json() | ||
return data.get('error', '') | ||
except ValueError: | ||
return '' | ||
|
||
|
||
class IntezerError(Exception): | ||
pass | ||
|
||
|
||
class ServerError(IntezerError): | ||
def __init__(self, message: str, response: requests.Response): | ||
self.response = response | ||
detailed_error = _parse_erroneous_response(response) | ||
if detailed_error: | ||
message = '{}. Error:{}'.format(message, detailed_error) | ||
super().__init__(message) | ||
|
||
|
||
class AnalysisHasAlreadyBeenSent(IntezerError): | ||
def __init__(self): | ||
super(AnalysisHasAlreadyBeenSent, self).__init__('Analysis already been sent') | ||
|
||
|
||
class IndexHasAlreadyBeenSent(IntezerError): | ||
def __init__(self): | ||
super(IndexHasAlreadyBeenSent, self).__init__('Index already been sent') | ||
super().__init__('Index already been sent') | ||
|
||
|
||
class AnalysisDoesNotExistError(IntezerError): | ||
def __init__(self): | ||
super(AnalysisDoesNotExistError, self).__init__('Analysis was not found') | ||
super().__init__('Analysis was not found') | ||
|
||
|
||
class HashDoesNotExistError(IntezerError): | ||
def __init__(self): | ||
super(HashDoesNotExistError, self).__init__('Hash was not found') | ||
class HashDoesNotExistError(ServerError): | ||
def __init__(self, response: requests.Response): | ||
super().__init__('Hash was not found', response) | ||
|
||
|
||
class ReportDoesNotExistError(IntezerError): | ||
def __init__(self): | ||
super(ReportDoesNotExistError, self).__init__('Report was not found') | ||
super().__init__('Report was not found') | ||
|
||
|
||
class AnalysisIsAlreadyRunning(IntezerError): | ||
def __init__(self): | ||
super(AnalysisIsAlreadyRunning, self).__init__('Analysis already running') | ||
class AnalysisIsAlreadyRunning(ServerError): | ||
def __init__(self, response: requests.Response): | ||
super().__init__('Analysis already running', response) | ||
|
||
|
||
class InsufficientQuota(IntezerError): | ||
def __init__(self): | ||
super(InsufficientQuota, self).__init__('Insufficient quota') | ||
class InsufficientQuota(ServerError): | ||
def __init__(self, response: requests.Response): | ||
super().__init__('Insufficient quota', response) | ||
|
||
|
||
class GlobalApiIsNotInitialized(IntezerError): | ||
def __init__(self): | ||
super(GlobalApiIsNotInitialized, self).__init__('Global API is not initialized') | ||
super().__init__('Global API is not initialized') | ||
|
||
|
||
class AnalysisIsStillRunning(IntezerError): | ||
def __init__(self): | ||
super(AnalysisIsStillRunning, self).__init__('Analysis is still running') | ||
super().__init__('Analysis is still running') | ||
|
||
|
||
class InvalidApiKey(IntezerError): | ||
def __init__(self): | ||
super(InvalidApiKey, self).__init__('Invalid api key') | ||
class InvalidApiKey(ServerError): | ||
def __init__(self, response: requests.Response): | ||
super().__init__('Invalid api key', response) | ||
|
||
|
||
class IndexFailed(IntezerError): | ||
def __init__(self): | ||
super(IndexFailed, self).__init__('Index operation failed') | ||
class IndexFailed(ServerError): | ||
def __init__(self, response: requests.Response): | ||
super().__init__('Index operation failed', response) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
requests>=2.22.0,<3 | ||
responses==0.10.12 | ||
pytest==5.3.5 | ||
responses==0.10.14 | ||
pytest==5.4.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.