Working but needs tidying

This commit is contained in:
Fred Boniface 2024-02-22 12:30:11 +00:00
parent 676beab6b3
commit 99fd2e3e8d
5 changed files with 13 additions and 13 deletions

Binary file not shown.

View File

@ -6,9 +6,7 @@ def humanYaml(pis_list):
manual_review = '' manual_review = ''
for pis in pis_list: for pis in pis_list:
if len(pis['services']) == 1: if len(pis['services']) == 1:
print(f"Only one valid service for {pis['pis']}")
crs = [] crs = []
print(pis)
try: try:
for stop in pis['services'][0]['stops']: for stop in pis['services'][0]['stops']:
crs.append(owlboard_connector.convert_tiploc_to_crs(stop)) crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
@ -17,13 +15,12 @@ def humanYaml(pis_list):
except Exception as err: except Exception as err:
print(err) print(err)
elif len(pis['services']) > 1: elif len(pis['services']) > 1:
print(f"More than one possible service for {pis['pis']}") manual_review += f'## THIS CODE REQUIRES MANUAL VERIFICATION\n'
manual_review += f'## THIS CODE REQUIRES MANUAL VERIFICATION'
manual_review += f' - code: "{pis["pis"]}"\n' manual_review += f' - code: "{pis["pis"]}"\n'
for service in pis["services"]: for service in pis["services"]:
crs = [] crs = []
for stop in service['stops']: for stop in service['stops']:
crs.append(owlboard_connector.convert_tiploc_to_crs(stop)) crs.append(owlboard_connector.convert_tiploc_to_crs(stop))
manual_review += f' stops:[{",".join(crs)}]\n' manual_review += f' stops: [{",".join(crs)}]\n'
return additional_pis + manual_review return additional_pis + manual_review

1
src/git/clone/data Submodule

@ -0,0 +1 @@
Subproject commit 5b2ea9a418a2cb7e0d6e65fe3ceacfb83ca026e1

View File

@ -10,7 +10,7 @@ HEADERS = {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'accept': 'application/json', 'accept': 'application/json',
} }
BRANCH_NAME = datetime.now().strftime("%Y%m%d-%H%M%S") BRANCH_NAME = 'auto-' + datetime.now().strftime("%Y%m%d-%H%M%S")
''' '''
@ -36,4 +36,6 @@ def commit_and_push_changes(text_to_append, commit_message):
repo.index.add(["pis/gw.yaml"]) repo.index.add(["pis/gw.yaml"])
repo.index.commit(commit_message) repo.index.commit(commit_message)
origin = repo.remote(name='origin') origin = repo.remote(name='origin')
origin_url_credentials = REPO_URL.replace('https://', f'https://{USER}:{TOKEN}@')
origin.set_url(origin_url_credentials)
origin.push(refspec=BRANCH_NAME) origin.push(refspec=BRANCH_NAME)

View File

@ -7,12 +7,12 @@
import requests, os import requests, os
#OB_PIS_BASE_URL = "https://owlboard.info/api/v2/pis/byCode/" OB_PIS_BASE_URL = "https://owlboard.info/api/v2/pis/byCode/"
#OB_TRN_BASE_URL = "https://owlboard.info/api/v2/timetable/train/" OB_TRN_BASE_URL = "https://owlboard.info/api/v2/timetable/train/"
#OB_TIP_BASE_URL = "https://owlboard.info/api/v2/ref/locationCode/tiploc/" OB_TIP_BASE_URL = "https://owlboard.info/api/v2/ref/locationCode/tiploc/"
OB_PIS_BASE_URL = "http://localhost:8460/api/v2/pis/byCode/" #OB_PIS_BASE_URL = "http://localhost:8460/api/v2/pis/byCode/"
OB_TRN_BASE_URL = "http://localhost:8460/api/v2/timetable/train/" #OB_TRN_BASE_URL = "http://localhost:8460/api/v2/timetable/train/"
OB_TIP_BASE_URL = "http://localhost:8460/api/v2/ref/locationCode/tiploc/" #OB_TIP_BASE_URL = "http://localhost:8460/api/v2/ref/locationCode/tiploc/"
OB_TEST_URL = OB_PIS_BASE_URL + "5001" OB_TEST_URL = OB_PIS_BASE_URL + "5001"
UUID = os.environ.get('DGP_OB_UUID') UUID = os.environ.get('DGP_OB_UUID')
HEADERS = { HEADERS = {
@ -62,6 +62,7 @@ def get_service_detail(trainUid, date):
'vstp': json_res.get('vstp', False) 'vstp': json_res.get('vstp', False)
} }
organised = organise_svc(svc_detail) organised = organise_svc(svc_detail)
print(res.text)
print(organised) print(organised)
return organised return organised
else: else:
@ -91,5 +92,4 @@ def convert_tiploc_to_crs(tiploc):
json_res = res.json() json_res = res.json()
if json_res: if json_res:
crs = json_res[0]['3ALPHA'] crs = json_res[0]['3ALPHA']
print(f"TIPLOC: {tiploc}, CRS: {crs}")
return crs.lower() return crs.lower()