Merge pull request #25 from alternak/main
Add option to disable SSL verification
This commit is contained in:
commit
a503c964cf
1 changed files with 9 additions and 1 deletions
|
@ -4,6 +4,7 @@ import logging
|
|||
import sys
|
||||
import datetime
|
||||
from collections import defaultdict
|
||||
import urllib3
|
||||
|
||||
# Trying to deal with python's isnumeric() function
|
||||
# not recognizing negative numbers
|
||||
|
@ -25,6 +26,7 @@ parser.add_argument("-s", "--album-separator", default=" ", type=str, help="Sepa
|
|||
parser.add_argument("-c", "--chunk-size", default=2000, type=int, help="Maximum number of assets to add to an album with a single API call")
|
||||
parser.add_argument("-C", "--fetch-chunk-size", default=5000, type=int, help="Maximum number of assets to fetch with a single API call")
|
||||
parser.add_argument("-l", "--log-level", default="INFO", choices=['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG'], help="Log level to use")
|
||||
parser.add_argument("-i", "--ignore-ssl", action="store_true", help="Set to true to ignore SSL verification")
|
||||
args = vars(parser.parse_args())
|
||||
# set up logger to log in logfmt format
|
||||
logging.basicConfig(level=args["log_level"], stream=sys.stdout, format='time=%(asctime)s level=%(levelname)s msg=%(message)s')
|
||||
|
@ -40,6 +42,7 @@ album_levels = args["album_levels"]
|
|||
# Album Levels Range handling
|
||||
album_levels_range_arr = ()
|
||||
album_level_separator = args["album_separator"]
|
||||
ignore_ssl = args["ignore_ssl"]
|
||||
logging.debug("root_path = %s", root_paths)
|
||||
logging.debug("root_url = %s", root_url)
|
||||
logging.debug("api_key = %s", api_key)
|
||||
|
@ -49,12 +52,16 @@ logging.debug("unattended = %s", unattended)
|
|||
logging.debug("album_levels = %s", album_levels)
|
||||
#logging.debug("album_levels_range = %s", album_levels_range)
|
||||
logging.debug("album_level_separator = %s", album_level_separator)
|
||||
logging.debug("ignore_ssl = %s", ignore_ssl)
|
||||
|
||||
# Verify album levels
|
||||
if is_integer(album_levels) and album_levels == 0:
|
||||
parser.print_help()
|
||||
exit(1)
|
||||
|
||||
if ignore_ssl:
|
||||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||
|
||||
# Verify album levels range
|
||||
if not is_integer(album_levels):
|
||||
album_levels_range_split = album_levels.split(",")
|
||||
|
@ -93,7 +100,8 @@ requests_kwargs = {
|
|||
'x-api-key': api_key,
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
}
|
||||
},
|
||||
'verify' : not ignore_ssl
|
||||
}
|
||||
|
||||
# Yield successive n-sized
|
||||
|
|
Loading…
Reference in a new issue