PyTransportNSWv2 2.0.1__tar.gz → 2.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/PKG-INFO +1 -1
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/TransportNSWv2/TransportNSWv2.py +18 -3
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/setup.py +1 -1
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/LICENSE +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/SOURCES.txt +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/TransportNSWv2.py +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/dependency_links.txt +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/requires.txt +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/top_level.txt +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/README.md +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/TransportNSWv2/__init__.py +0 -0
- {PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/setup.cfg +0 -0
@@ -12,6 +12,15 @@ import re
|
|
12
12
|
import json #For the output
|
13
13
|
import time
|
14
14
|
|
15
|
+
# Global API variable
|
16
|
+
api_calls = 0
|
17
|
+
|
18
|
+
def increment_api_counter(source):
|
19
|
+
global api_calls
|
20
|
+
api_calls += 1
|
21
|
+
#print(str(api_calls) + " " + source)
|
22
|
+
|
23
|
+
# Constants
|
15
24
|
ATTR_DUE_IN = 'due'
|
16
25
|
|
17
26
|
ATTR_ORIGIN_STOP_ID = 'origin_stop_id'
|
@@ -117,7 +126,10 @@ class TransportNSWv2(object):
|
|
117
126
|
error_code = 0
|
118
127
|
|
119
128
|
if not skip_api_calls:
|
129
|
+
# Make the call and increment the API counter
|
120
130
|
response = requests.get(url, headers=header, timeout=5)
|
131
|
+
increment_api_counter('stop_finder')
|
132
|
+
|
121
133
|
else:
|
122
134
|
# An earlier call resulted in an API key error so no point trying again
|
123
135
|
response.status_code = 401
|
@@ -195,7 +207,7 @@ class TransportNSWv2(object):
|
|
195
207
|
origin_transport_type = [origin_transport_type]
|
196
208
|
|
197
209
|
if isinstance(destination_transport_type, int):
|
198
|
-
|
210
|
+
destination_transport_type = [destination_transport_type]
|
199
211
|
|
200
212
|
if isinstance(alert_type, str):
|
201
213
|
alert_type = alert_type.split('|')
|
@@ -242,6 +254,7 @@ class TransportNSWv2(object):
|
|
242
254
|
# Otherwise store the response for the next steps
|
243
255
|
try:
|
244
256
|
response = requests.get(url, headers=header, timeout=10)
|
257
|
+
increment_api_counter('trip')
|
245
258
|
|
246
259
|
except Exception as ex:
|
247
260
|
raise TripError (f"Error '{str(ex)}' calling trip API for journey {name_origin} to {name_destination}")
|
@@ -426,7 +439,7 @@ class TransportNSWv2(object):
|
|
426
439
|
|
427
440
|
current_journey_index = next_journey_index
|
428
441
|
|
429
|
-
json_output='{"journeys_to_return": ' + str(journeys_to_return) + ', "journeys_with_data": ' + str(found_journeys) + ', "journeys": [' + json_output + ']}'
|
442
|
+
json_output='{"journeys_to_return": ' + str(journeys_to_return) + ', "journeys_with_data": ' + str(found_journeys) + ', "api_calls": ' + str(api_calls) + ', "journeys": [' + json_output + ']}'
|
430
443
|
return json_output
|
431
444
|
|
432
445
|
|
@@ -559,12 +572,14 @@ class TransportNSWv2(object):
|
|
559
572
|
header = {'Accept': 'application/json', 'Authorization': auth}
|
560
573
|
|
561
574
|
url_base_path = self._get_base_url(mode)
|
562
|
-
|
563
575
|
url_mode_list = self._get_mode_list(mode, agencyid)
|
576
|
+
|
564
577
|
if not url_mode_list is None:
|
565
578
|
for mode_url in url_mode_list:
|
566
579
|
url = url_base_path + mode_url
|
567
580
|
response = requests.get(url, headers=header, timeout=10)
|
581
|
+
increment_api_counter(url)
|
582
|
+
|
568
583
|
# Only try and process the results if we got a good return code
|
569
584
|
if response.status_code == 200:
|
570
585
|
# Search the feed and see if we can match realtimetripid to trip_id
|
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|
5
5
|
|
6
6
|
setuptools.setup(
|
7
7
|
name="PyTransportNSWv2",
|
8
|
-
version="2.0.
|
8
|
+
version="2.0.2",
|
9
9
|
author="andystewart999",
|
10
10
|
author_email="andy.stewart@live.com",
|
11
11
|
description="Get detailed per-trip transport information from TransportNSW",
|
File without changes
|
File without changes
|
{PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/TransportNSWv2.py
RENAMED
File without changes
|
{PyTransportNSWv2-2.0.1 → PyTransportNSWv2-2.0.2}/PyTransportNSWv2.egg-info/dependency_links.txt
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|