From 059a8b77e1656230e2540fdc3260c22946c80a97 Mon Sep 17 00:00:00 2001 From: Antoine Drochon Date: Mon, 7 Jun 2021 09:42:49 -0700 Subject: [PATCH] Fix log.WARN Option to set UA prefix Bump to 0.3.4 --- bin/akamai-etp | 6 +++--- bin/config.py | 1 + cli.json | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/akamai-etp b/bin/akamai-etp index e3875a0..c662ad3 100755 --- a/bin/akamai-etp +++ b/bin/akamai-etp @@ -35,7 +35,7 @@ from requests.compat import urljoin from akamai.edgegrid import EdgeGridAuth, EdgeRc from config import EdgeGridConfig -__version__ = "0.3.3" +__version__ = "0.3.4" #: Data collection delay, default is 30 minutes collection_delay_min = 30 @@ -62,7 +62,7 @@ session.auth = EdgeGridAuth( access_token=config.access_token ) -session.headers.update({'User-Agent': "Akamai-CLI etp/%s" % __version__}) +session.headers.update({'User-Agent': f"{config.ua_prefix} cli-etp/{__version__}"}) headers = {'content-type': "application/json;charset=UTF-8"} baseurl = '%s://%s' % ('https', config.host) extra_qs = None @@ -245,7 +245,7 @@ def fetch_events(config, output): # TODO: add a better/more resilient logic sleep_time = max(0, poll_interval_sec - (time.time() - timing_s)) if sleep_time == 0: - LOG.WARN("Potential data gaps") + LOG.warn("Potential data gaps") LOG.info("Sleeping for %.2f sec..." % sleep_time) stop_event.wait(sleep_time) start = int(time.time()) - (collection_delay_min * 60) - poll_interval_sec diff --git a/bin/config.py b/bin/config.py index 67ff3ba..5732ac5 100644 --- a/bin/config.py +++ b/bin/config.py @@ -102,6 +102,7 @@ def __init__(self, config_values, configuration, flags=None): help=' Location of the credentials file (default is ~/.edgerc)') parser.add_argument('--section', '-c', default='default', metavar='credentials_file_section', action='store', help=' Credentials file Section\'s name to use') + parser.add_argument('--user-agent-prefix', dest='ua_prefix', default='Akamai-CLI', help=argparse.SUPPRESS) if flags: for argument in flags.keys(): diff --git a/cli.json b/cli.json index 754e1fc..966ddc7 100755 --- a/cli.json +++ b/cli.json @@ -5,7 +5,7 @@ "commands": [ { "name": "etp", - "version": "0.3.3", + "version": "0.3.4", "description": "Akamai CLI for Enterprise Threat Protector" } ]