Skip to content

Commit

Permalink
Use old string format to support older versions of python 3 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
chkp-aviadl authored Mar 3, 2020
1 parent 88291e0 commit 845bbcf
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 3 additions & 3 deletions python/api/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,18 @@ def main(service, resource, client_key, verbose):
logger.debug('success!')
token = token_res.content
logger.debug('now, let\'s query reputation')
rep_res = requests.post(f'https://rep.checkpoint.com/{service}-rep/service/v2.0/query?resource={resource}',
rep_res = requests.post('https://rep.checkpoint.com/{}-rep/service/v2.0/query?resource={}'.format(service, resource),
json={
'request': [{'resource': resource}]
}, headers={'Client-Key': client_key, 'token': token})
if rep_res.status_code != 200:
raise StatusCodeException(rep_res.status_code)
logger.debug('success!')
logger.debug(f'your response is:\n{json.dumps(rep_res.json(), indent=2)}\n')
logger.debug('your response is:\n{}\n'.format(json.dumps(rep_res.json(), indent=2)))
response = rep_res.json()['response'][0]
risk = response['risk']
classification = response['reputation']['classification']
logger.info(f'{resource} is {classification} with risk {risk}/100')
logger.info('{} is {} with risk {}/100'.format(resource, classification, risk))


if __name__ == '__main__':
Expand Down
5 changes: 1 addition & 4 deletions python/api/utils/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import sys


class StatusCodeException(Exception):
def __init__(self, status_code: int, *args: object) -> None:
super().__init__(*args)
self.status_code = status_code

def __str__(self) -> str:
return f"Operation failed with status {self.status_code}"
return "Operation failed with status {}".format(self.status_code)
2 changes: 1 addition & 1 deletion python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="reputation-service-API-client",
version="1.0.0",
version="1.0.1",
author="Check Point Software Technologies LTD.",
author_email="[email protected]",
description="Reputation Service python example",
Expand Down

0 comments on commit 845bbcf

Please sign in to comment.