|
24 | 24 | parser.add_argument("-p", "--product", help="Example: adaptation_detail", required=False) |
25 | 25 | parser.add_argument("-api_key", "--api_key", required=False) |
26 | 26 | parser.add_argument("-v", "--version", required=False) |
27 | | - # Convert log default to an actual boolean |
28 | 27 | parser.add_argument("-log", "--log", help="Example: False", required=False, default="True") |
29 | 28 | parser.add_argument("-connection_limit", "--connection_limit", help="Example: 100", |
30 | 29 | required=False, default="100") |
31 | | - parser.add_argument("-rate_limit", "--rate_limit", help="Example: 5000", required=False, default="20000") |
32 | | - parser.add_argument("-rate_period", "--rate_period", help="Example: 3600", required=False, default="1") |
| 30 | + parser.add_argument("-rate_limit", "--rate_limit", help="Example: 4990", required=False, default="4990") |
| 31 | + parser.add_argument("-rate_period", "--rate_period", help="Example: 60", required=False, default="60") |
33 | 32 | parser.add_argument("-o", "--output_dir", help="Example: /output", required=False) |
34 | 33 | parser.add_argument("-s", "--search_items", help="Example: 28,29", required=False,) |
35 | 34 | parser.add_argument("-l", "--location_type", help="Example: property", required=False) |
|
156 | 155 | sys.exit() |
157 | 156 |
|
158 | 157 | # Adjust the connection variables |
159 | | - connection_adjust = input("Adjust connection parameters (Y/N)? Defaults to 100 connections, with a rate limit " |
160 | | - "of 5000 calls per 60 seconds: ") |
161 | | - if connection_adjust.lower() == "y": |
162 | | - argument.connection_limit = input("Input new connection limit (default 100): ") |
163 | | - argument.rate_limit = input("Input new rate limit (default 5000): ") |
164 | | - argument.rate_period = input("Input new rate period in seconds (default 60): ") |
165 | | - else: |
166 | | - argument.connection_limit = 100 |
167 | | - argument.rate_limit = 5000 |
168 | | - argument.rate_period = 60 |
| 158 | + if not argument.connection_limit and not argument.rate_limit and not argument.rate_period: |
| 159 | + connection_adjust = input("Adjust connection parameters (Y/N)? Defaults to 100 connections, with a rate " |
| 160 | + "limit of 4990 calls per 60 seconds: ") |
| 161 | + if connection_adjust.lower() == "y": |
| 162 | + input_params = input("Input new connection limit (default 100): ") |
| 163 | + if input_params != '': |
| 164 | + argument.connection_limit = "providerid:{}".format(input_params) |
| 165 | + input_params = input("Input new rate limit (default 5000): ") |
| 166 | + if input_params != '': |
| 167 | + argument.rate_limit = "providerid:{}".format(input_params) |
| 168 | + input_params = input("Input new rate period in seconds (default 60): ") |
| 169 | + if input_params != '': |
| 170 | + argument.rate_period = "providerid:{}".format(input_params) |
| 171 | + else: |
| 172 | + argument.connection_limit = 100 |
| 173 | + argument.rate_limit = 4990 |
| 174 | + argument.rate_period = 60 |
169 | 175 |
|
170 | 176 | # Adjust the output directory |
171 | 177 | if not argument.output_dir: |
|
182 | 188 | if os.path.isfile(argument.search_items): |
183 | 189 | search_items = read_search_items_from_file(argument.search_items) |
184 | 190 | else: |
185 | | - for search_item in argument.search_items.strip().split(";"): |
| 191 | + items = argument.search_items.strip().split(";") |
| 192 | + if len(items) == 1: |
| 193 | + logging.warning("Could not find the file '{}'. Treating the input as a search_item instead. " |
| 194 | + "If this is unexpected, check the spelling or path of the input" |
| 195 | + .format(argument.search_items)) |
| 196 | + for search_item in items: |
186 | 197 | try: |
187 | 198 | search_items.append(ast.literal_eval(search_item)) |
188 | 199 | except (SyntaxError, ValueError): |
|
0 commit comments