From 3225a293a4df8ff5c22f219733426293ae7fe57a Mon Sep 17 00:00:00 2001 From: Lucas Oskorep Date: Mon, 10 May 2021 11:59:18 -0500 Subject: [PATCH] adding in base repo with not implemented functions --- mta.py | 37 +++++++++++++++++++++++++++++++ mta_status_alerts.json | 1 + mta_test.py | 17 +++++++++++++++ testing.py | 49 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 mta.py create mode 100644 mta_status_alerts.json create mode 100644 mta_test.py create mode 100644 testing.py diff --git a/mta.py b/mta.py new file mode 100644 index 0000000..d7f0f24 --- /dev/null +++ b/mta.py @@ -0,0 +1,37 @@ +import requests +from typing import List + + +class MTA(object): + def __init__(self, api_key: str, train_lines=None, station_ids=None, timing_callbacks=None, alert_callbacks = None): + self.api_key = api_key + self.train_lines = train_lines if train_lines else [] + self.station_ids = station_ids if station_ids else [] + self.timing_callbacks = timing_callbacks if timing_callbacks else [] + self.alert_callbacks = alert_callbacks if alert_callbacks else [] + + def start_updates(self): + print("starting updates") + raise NotImplementedError("Have not implemented start updates yet") + + async def process_callbacks(self): + raise NotImplementedError("Have not implemented callback processing yet") + + + def add_train_line(self, train_line: str): + self.train_lines.append(train_line) + + def remove_train_line(self, train_line: str): + self.train_lines.remove(train_line) + + def add_station_id(self, station_id: str): + self.station_ids.append(station_id) + + def remove_station_id(self, station_id: str): + self.station_ids.remove(station_id) + + def add_callback(self, callback_func): + self.timing_callbacks.append(callback_func) + + def remove_callback(self, callback_func): + self.timing_callbacks.remove(callback_func) \ No newline at end of file diff --git a/mta_status_alerts.json b/mta_status_alerts.json new file mode 100644 index 0000000..16a50fc --- /dev/null +++ b/mta_status_alerts.json @@ -0,0 +1 @@ +{"lastUpdated": "2021-05-10T12:34:40-0400", "routeDetails": [{"route": "2", "color": "EE352E", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_2", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73533", "statusSummary": "Weekday Service", "statusDescription": "

[2] trains run between Wakefield-241 St and Flatbush Av-Brooklyn College.

", "priority": 3, "direction": "0", "creationDate": "2021-04-24T07:50:19-0400", "startDate": "2021-05-10T04:01:12-0400", "endDate": null}, {"id": "lmm:alert:73533", "statusSummary": "Weekday Service", "statusDescription": "

[2] trains run between Wakefield-241 St and Flatbush Av-Brooklyn College.

", "priority": 3, "direction": "1", "creationDate": "2021-04-24T07:50:19-0400", "startDate": "2021-05-10T04:01:12-0400", "endDate": null}]}, {"route": "3", "color": "EE352E", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_3", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73541", "statusSummary": "Weekday Service", "statusDescription": "

[3] trains run between Harlem-148 St and New Lots Av.

", "priority": 3, "direction": "0", "creationDate": "2021-04-24T07:51:06-0400", "startDate": "2021-05-10T04:03:11-0400", "endDate": null}, {"id": "lmm:alert:73541", "statusSummary": "Weekday Service", "statusDescription": "

[3] trains run between Harlem-148 St and New Lots Av.

", "priority": 3, "direction": "1", "creationDate": "2021-04-24T07:51:06-0400", "startDate": "2021-05-10T04:03:11-0400", "endDate": null}]}, {"route": "6X", "color": "00A65C", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_6X", "inService": "true", "routeType": "1", "statusDetails": null}, {"route": "1", "color": "EE352E", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_1", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73532", "statusSummary": "Weekday Service", "statusDescription": "

[1] trains run between \u200c\u200cVan Cortlandt Park-242 St and South Ferry.

", "priority": 3, "direction": "1", "creationDate": "2020-12-10T00:59:42-0500", "startDate": "2021-05-10T04:00:51-0400", "endDate": null}, {"id": "lmm:alert:73532", "statusSummary": "Weekday Service", "statusDescription": "

[1] trains run between \u200c\u200cVan Cortlandt Park-242 St and South Ferry.

", "priority": 3, "direction": "0", "creationDate": "2020-12-10T00:59:42-0500", "startDate": "2021-05-10T04:00:51-0400", "endDate": null}]}, {"route": "S", "color": null, "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_FS", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73543", "statusSummary": "Weekday Service", "statusDescription": "

[FS] trains run between Franklin Av and Prospect Park.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:07:08-0500", "startDate": "2021-05-10T04:03:37-0400", "endDate": null}, {"id": "lmm:alert:73543", "statusSummary": "Weekday Service", "statusDescription": "

[FS] trains run between Franklin Av and Prospect Park.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:07:08-0500", "startDate": "2021-05-10T04:03:37-0400", "endDate": null}]}, {"route": "FX", "color": "FF6319", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_FX", "inService": "true", "routeType": "1", "statusDetails": null}, {"route": "W", "color": "FCCC0A", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_W", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73555", "statusSummary": "Weekday Service", "statusDescription": "

[W] trains run between Astoria-Ditmars Blvd and Whitehall St-South Ferry.

Departing Astoria-Ditmars Blvd from 6:13 AM to 9:26 PM

Departing Whitehall St-South Ferry from 7:06 AM to 10:14 PM.

[W] trains do not operate late nights and weekends, take [N] or [R] service instead.

", "priority": 3, "direction": "0", "creationDate": "2021-04-21T08:17:11-0400", "startDate": "2021-05-10T04:58:38-0400", "endDate": null}, {"id": "lmm:alert:73555", "statusSummary": "Weekday Service", "statusDescription": "

[W] trains run between Astoria-Ditmars Blvd and Whitehall St-South Ferry.

Departing Astoria-Ditmars Blvd from 6:13 AM to 9:26 PM

Departing Whitehall St-South Ferry from 7:06 AM to 10:14 PM.

[W] trains do not operate late nights and weekends, take [N] or [R] service instead.

", "priority": 3, "direction": "1", "creationDate": "2021-04-21T08:17:11-0400", "startDate": "2021-05-10T04:58:38-0400", "endDate": null}]}, {"route": "SIR", "color": null, "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_SI", "inService": "true", "routeType": "1", "statusDetails": [{"id": "MTA NYCT_277781", "statusSummary": "Planned Work", "statusDescription": "SCHEDULED MAINTENANCE
May 10 - 12, Mon to Wed, 9 AM to 3 PM
[SIR] Trains board at the Tottenville-bound platform at Arthur Kill and Richmond Valley Stations




", "priority": 9, "direction": "0", "creationDate": "2021-05-10T00:00:00-0400", "startDate": "2021-05-10T00:00:00-0400", "endDate": "2021-05-12T23:59:00-0400"}, {"id": "lmm:alert:73523", "statusSummary": "Weekday Service", "statusDescription": "

On weekdays, [SIR] trains will operate to meet the S.I. Ferry, scheduled:

 

Every 20 minutes during the rush hour periods 

Every 30 minutes during the midday/off-peak period

Every hour from 10 PM (from St George)/12 AM (from Tottenville) to 5AM

 

On weekends, SIR trains will operate to meet the S.I. Ferry, scheduled:

 

Every 30 minutes from 7 AM to 11 PM

Every hour from 11 PM to 7 AM

", "priority": 3, "direction": "0", "creationDate": "2020-07-18T05:06:17-0400", "startDate": "2021-05-10T03:57:50-0400", "endDate": null}, {"id": "lmm:alert:73523", "statusSummary": "Weekday Service", "statusDescription": "

On weekdays, [SIR] trains will operate to meet the S.I. Ferry, scheduled:

 

Every 20 minutes during the rush hour periods 

Every 30 minutes during the midday/off-peak period

Every hour from 10 PM (from St George)/12 AM (from Tottenville) to 5AM

 

On weekends, SIR trains will operate to meet the S.I. Ferry, scheduled:

 

Every 30 minutes from 7 AM to 11 PM

Every hour from 11 PM to 7 AM

", "priority": 3, "direction": "1", "creationDate": "2020-07-18T05:06:17-0400", "startDate": "2021-05-10T03:57:50-0400", "endDate": null}]}, {"route": "Z", "color": "996633", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_Z", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73527", "statusSummary": "Weekday Service", "statusDescription": "

[Z] trains run between Jamaica Center-Parsons/Archer and Broad St AM and PM Rush hours.

Departing Jamaica Center-Parsons/Archer from 7:21 AM to 8:13 AM.

Departing Broad St from 4:55 PM to 5:45 PM.

[Z] trains do not operate evenings, late nights, and weekends; take [J] service instead.

", "priority": 3, "direction": "0", "creationDate": "2020-09-04T22:18:39-0400", "startDate": "2021-05-10T03:59:10-0400", "endDate": null}, {"id": "lmm:alert:73527", "statusSummary": "Weekday Service", "statusDescription": "

[Z] trains run between Jamaica Center-Parsons/Archer and Broad St AM and PM Rush hours.

Departing Jamaica Center-Parsons/Archer from 7:21 AM to 8:13 AM.

Departing Broad St from 4:55 PM to 5:45 PM.

[Z] trains do not operate evenings, late nights, and weekends; take [J] service instead.

", "priority": 3, "direction": "1", "creationDate": "2020-09-04T22:18:39-0400", "startDate": "2021-05-10T03:59:10-0400", "endDate": null}]}, {"route": "N", "color": "FCCC0A", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_N", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73536", "statusSummary": "Weekday Service", "statusDescription": "

[N] trains run between Astoria-Ditmars Blvd and Coney Island-Stillwell Av.

", "priority": 3, "direction": "1", "creationDate": "2021-02-01T19:42:07-0500", "startDate": "2021-05-10T04:02:19-0400", "endDate": null}, {"id": "lmm:alert:73536", "statusSummary": "Weekday Service", "statusDescription": "

[N] trains run between Astoria-Ditmars Blvd and Coney Island-Stillwell Av.

", "priority": 3, "direction": "0", "creationDate": "2021-02-01T19:42:07-0500", "startDate": "2021-05-10T04:02:19-0400", "endDate": null}]}, {"route": "L", "color": "A7A9AC", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_L", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73524", "statusSummary": "Weekday Service", "statusDescription": "

[L] trains run between 8 Av and Canarsie-Rockaway Pkwy.

", "priority": 3, "direction": "1", "creationDate": "2020-12-14T00:58:44-0500", "startDate": "2021-05-10T03:58:07-0400", "endDate": null}, {"id": "lmm:alert:73524", "statusSummary": "Weekday Service", "statusDescription": "

[L] trains run between 8 Av and Canarsie-Rockaway Pkwy.

", "priority": 3, "direction": "0", "creationDate": "2020-12-14T00:58:44-0500", "startDate": "2021-05-10T03:58:07-0400", "endDate": null}]}, {"route": "M", "color": "FF6319", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_M", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73553", "statusSummary": "Weekday Service", "statusDescription": "

[M] trains run between Forest Hills-71 Av and Middle Village-Metropolitan Av.

", "priority": 3, "direction": "0", "creationDate": "2020-12-06T01:12:29-0500", "startDate": "2021-05-10T04:57:10-0400", "endDate": null}, {"id": "lmm:alert:73553", "statusSummary": "Weekday Service", "statusDescription": "

[M] trains run between Forest Hills-71 Av and Middle Village-Metropolitan Av.

", "priority": 3, "direction": "1", "creationDate": "2020-12-06T01:12:29-0500", "startDate": "2021-05-10T04:57:10-0400", "endDate": null}]}, {"route": "R", "color": "FCCC0A", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_R", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73552", "statusSummary": "Weekday Service", "statusDescription": "

[R] trains run between Forest Hills-71 Av and Bay Ridge-95 St.

", "priority": 3, "direction": "1", "creationDate": "2021-04-11T01:58:40-0400", "startDate": "2021-05-10T04:56:42-0400", "endDate": null}, {"id": "lmm:alert:73552", "statusSummary": "Weekday Service", "statusDescription": "

[R] trains run between Forest Hills-71 Av and Bay Ridge-95 St.

", "priority": 3, "direction": "0", "creationDate": "2021-04-11T01:58:40-0400", "startDate": "2021-05-10T04:56:42-0400", "endDate": null}]}, {"route": "7X", "color": "B933AD", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_7X", "inService": "true", "routeType": "1", "statusDetails": null}, {"route": "Q", "color": "FCCC0A", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_Q", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73530", "statusSummary": "Weekday Service", "statusDescription": "

[Q] trains run between 96 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:06:24-0500", "startDate": "2021-05-10T04:00:14-0400", "endDate": null}, {"id": "lmm:alert:73530", "statusSummary": "Weekday Service", "statusDescription": "

[Q] trains run between 96 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:06:24-0500", "startDate": "2021-05-10T04:00:14-0400", "endDate": null}]}, {"route": "F", "color": "FF6319", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_F", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73610", "statusSummary": "Some Reroutes", "statusDescription": "

Some southbound [F] trains are running on the [A] line from W 4 St-Wash Sq to Jay St-MetroTech while we work to correct a signal malfunction at Delancey St-Essex St.

Expect delays in southbound [F] [A] service.

", "priority": 21, "direction": "0", "creationDate": "2021-05-10T12:30:54-0400", "startDate": "2021-05-10T12:30:54-0400", "endDate": null}, {"id": "lmm:alert:73558", "statusSummary": "Weekday Service", "statusDescription": "

[F] trains run between Jamaica-179 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:01:03-0500", "startDate": "2021-05-10T05:02:30-0400", "endDate": null}, {"id": "lmm:alert:73610", "statusSummary": "Some Reroutes", "statusDescription": "

Some southbound [F] trains are running on the [A] line from W 4 St-Wash Sq to Jay St-MetroTech while we work to correct a signal malfunction at Delancey St-Essex St.

Expect delays in southbound [F] [A] service.

", "priority": 21, "direction": "1", "creationDate": "2021-05-10T12:30:54-0400", "startDate": "2021-05-10T12:30:54-0400", "endDate": null}, {"id": "lmm:alert:73558", "statusSummary": "Weekday Service", "statusDescription": "

[F] trains run between Jamaica-179 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:01:03-0500", "startDate": "2021-05-10T05:02:30-0400", "endDate": null}]}, {"route": "G", "color": "6CBE45", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_G", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73526", "statusSummary": "Weekday Service", "statusDescription": "

[G] trains run between Church Av and Court Sq.

", "priority": 3, "direction": "0", "creationDate": "2020-12-10T01:00:39-0500", "startDate": "2021-05-10T03:58:44-0400", "endDate": null}, {"id": "lmm:alert:73526", "statusSummary": "Weekday Service", "statusDescription": "

[G] trains run between Church Av and Court Sq.

", "priority": 3, "direction": "1", "creationDate": "2020-12-10T01:00:39-0500", "startDate": "2021-05-10T03:58:44-0400", "endDate": null}]}, {"route": "D", "color": "FF6319", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_D", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73535", "statusSummary": "Weekday Service", "statusDescription": "

[D] trains run between Norwood-205 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "0", "creationDate": "2021-02-02T14:30:31-0500", "startDate": "2021-05-10T04:01:56-0400", "endDate": null}, {"id": "lmm:alert:73535", "statusSummary": "Weekday Service", "statusDescription": "

[D] trains run between Norwood-205 St and Coney Island-Stillwell Av.

", "priority": 3, "direction": "1", "creationDate": "2021-02-02T14:30:31-0500", "startDate": "2021-05-10T04:01:56-0400", "endDate": null}]}, {"route": "E", "color": "2850AD", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_E", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73528", "statusSummary": "Weekday Service", "statusDescription": "

[E] trains run between Jamaica Center-Parsons/Archer and World Trade Center.

", "priority": 3, "direction": "1", "creationDate": "2020-10-31T04:54:57-0400", "startDate": "2021-05-10T03:59:32-0400", "endDate": null}, {"id": "lmm:alert:73528", "statusSummary": "Weekday Service", "statusDescription": "

[E] trains run between Jamaica Center-Parsons/Archer and World Trade Center.

", "priority": 3, "direction": "0", "creationDate": "2020-10-31T04:54:57-0400", "startDate": "2021-05-10T03:59:32-0400", "endDate": null}]}, {"route": "J", "color": "996633", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_J", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73537", "statusSummary": "Weekday Service", "statusDescription": "

[J] trains run between Jamaica Center-Parsons/Archer and Broad St.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:02:39-0500", "startDate": "2021-05-10T04:02:42-0400", "endDate": null}, {"id": "lmm:alert:73609", "statusSummary": "Some Delays", "statusDescription": "

Broad St-bound [J] trains are running with delays because of a signal problem at 121 St.

", "priority": 14, "direction": "1", "creationDate": "2021-05-10T11:55:05-0400", "startDate": "2021-05-10T11:55:05-0400", "endDate": null}, {"id": "lmm:alert:73609", "statusSummary": "Some Delays", "statusDescription": "

Broad St-bound [J] trains are running with delays because of a signal problem at 121 St.

", "priority": 14, "direction": "0", "creationDate": "2021-05-10T11:55:05-0400", "startDate": "2021-05-10T11:55:05-0400", "endDate": null}, {"id": "lmm:alert:73537", "statusSummary": "Weekday Service", "statusDescription": "

[J] trains run between Jamaica Center-Parsons/Archer and Broad St.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:02:39-0500", "startDate": "2021-05-10T04:02:42-0400", "endDate": null}]}, {"route": "S", "color": null, "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_H", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73556", "statusSummary": "Weekday Service", "statusDescription": "

[H] trains run between Broad Channel and Rockaway Park-Beach 116 St.

", "priority": 3, "direction": "1", "creationDate": "2021-05-05T16:34:46-0400", "startDate": "2021-05-10T04:59:18-0400", "endDate": null}, {"id": "lmm:alert:73556", "statusSummary": "Weekday Service", "statusDescription": "

[H] trains run between Broad Channel and Rockaway Park-Beach 116 St.

", "priority": 3, "direction": "0", "creationDate": "2021-05-05T16:34:46-0400", "startDate": "2021-05-10T04:59:18-0400", "endDate": null}]}, {"route": "S", "color": "6D6E71", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_GS", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73550", "statusSummary": "Weekday Service", "statusDescription": "

[S] trains run between Times Sq-42 St and Grand Central-42 St.

Trains run between 6:00 AM and 12:00 AM Daily.

The [S] does not operate late nights, take [7] service instead.

", "priority": 3, "direction": "0", "creationDate": "2020-11-03T01:01:32-0500", "startDate": "2021-05-10T04:07:36-0400", "endDate": null}, {"id": "lmm:alert:73550", "statusSummary": "Weekday Service", "statusDescription": "

[S] trains run between Times Sq-42 St and Grand Central-42 St.

Trains run between 6:00 AM and 12:00 AM Daily.

The [S] does not operate late nights, take [7] service instead.

", "priority": 3, "direction": "1", "creationDate": "2020-11-03T01:01:32-0500", "startDate": "2021-05-10T04:07:36-0400", "endDate": null}]}, {"route": "B", "color": "FF6319", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_B", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73596", "statusSummary": "Weekday Service", "statusDescription": "

[B] trains run between 145 St and Brighton Beach.

", "priority": 3, "direction": "0", "creationDate": "2021-02-01T12:35:30-0500", "startDate": "2021-05-10T09:26:05-0400", "endDate": null}, {"id": "lmm:alert:73596", "statusSummary": "Weekday Service", "statusDescription": "

[B] trains run between 145 St and Brighton Beach.

", "priority": 3, "direction": "1", "creationDate": "2021-02-01T12:35:30-0500", "startDate": "2021-05-10T09:26:05-0400", "endDate": null}]}, {"route": "C", "color": "2850AD", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_C", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73557", "statusSummary": "Weekday Service", "statusDescription": "

[C] trains run between 168 St and Euclid Av.

", "priority": 3, "direction": "0", "creationDate": "2020-12-25T22:44:32-0500", "startDate": "2021-05-10T05:00:05-0400", "endDate": null}, {"id": "lmm:alert:73557", "statusSummary": "Weekday Service", "statusDescription": "

[C] trains run between 168 St and Euclid Av.

", "priority": 3, "direction": "1", "creationDate": "2020-12-25T22:44:32-0500", "startDate": "2021-05-10T05:00:05-0400", "endDate": null}]}, {"route": "A", "color": "2850AD", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_A", "inService": "true", "routeType": "1", "statusDetails": [{"id": "MTA NYCT_277833", "statusSummary": "Planned Work", "statusDescription": "TRACK WORK
Mon to Fri, 9 AM to 5 PM until Jun 18
(except May 31)
[A] Downtown trains stop at 163 St and 155 St




", "priority": 9, "direction": "1", "creationDate": "2021-05-10T00:00:00-0400", "startDate": "2021-05-10T00:00:00-0400", "endDate": "2021-06-18T23:59:00-0400"}, {"id": "lmm:alert:73547", "statusSummary": "Weekday Service", "statusDescription": "

[A] trains run between Inwood-207 St and Far Rockaway-Mott AvOzone Park-Lefferts Blvd.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:06:03-0500", "startDate": "2021-05-10T04:04:05-0400", "endDate": null}, {"id": "lmm:alert:73547", "statusSummary": "Weekday Service", "statusDescription": "

[A] trains run between Inwood-207 St and Far Rockaway-Mott AvOzone Park-Lefferts Blvd.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:06:03-0500", "startDate": "2021-05-10T04:04:05-0400", "endDate": null}, {"id": "lmm:alert:73611", "statusSummary": "Delays", "statusDescription": "

Some southbound [F] trains are running on the [A] line from W 4 St-Wash Sq to Jay St-MetroTech while we work to correct a signal malfunction at Delancey St-Essex St.

Expect delays in southbound [F] [A] service.

", "priority": 18, "direction": "0", "creationDate": "2021-05-10T12:30:54-0400", "startDate": "2021-05-10T12:30:54-0400", "endDate": null}, {"id": "lmm:alert:73611", "statusSummary": "Delays", "statusDescription": "

Some southbound [F] trains are running on the [A] line from W 4 St-Wash Sq to Jay St-MetroTech while we work to correct a signal malfunction at Delancey St-Essex St.

Expect delays in southbound [F] [A] service.

", "priority": 18, "direction": "1", "creationDate": "2021-05-10T12:30:54-0400", "startDate": "2021-05-10T12:30:54-0400", "endDate": null}]}, {"route": "6", "color": "00933C", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_6", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73567", "statusSummary": "Weekday Service", "statusDescription": "

[6] trains run between Pelham Bay Park and Brooklyn Bridge-City Hall.

[6X] trains run from Pelham Bay Park to Brooklyn Bridge-City Hall.

", "priority": 3, "direction": "0", "creationDate": "2020-12-08T01:00:26-0500", "startDate": "2021-05-10T06:11:32-0400", "endDate": null}, {"id": "lmm:alert:73567", "statusSummary": "Weekday Service", "statusDescription": "

[6] trains run between Pelham Bay Park and Brooklyn Bridge-City Hall.

[6X] trains run from Pelham Bay Park to Brooklyn Bridge-City Hall.

", "priority": 3, "direction": "1", "creationDate": "2020-12-08T01:00:26-0500", "startDate": "2021-05-10T06:11:32-0400", "endDate": null}]}, {"route": "7", "color": "B933AD", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_7", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73603", "statusSummary": "Weekday Service", "statusDescription": "

[7] trains run between 34 St-Hudson Yards and Flushing-Main St.

", "priority": 3, "direction": "0", "creationDate": "2020-12-10T01:01:10-0500", "startDate": "2021-05-10T10:30:42-0400", "endDate": null}, {"id": "lmm:alert:73603", "statusSummary": "Weekday Service", "statusDescription": "

[7] trains run between 34 St-Hudson Yards and Flushing-Main St.

", "priority": 3, "direction": "1", "creationDate": "2020-12-10T01:01:10-0500", "startDate": "2021-05-10T10:30:42-0400", "endDate": null}]}, {"route": "4", "color": "00933C", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_4", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73560", "statusSummary": "Weekday Service", "statusDescription": "

[4] trains run between Woodlawn and Crown Hts-Utica Av.

", "priority": 3, "direction": "0", "creationDate": "2020-12-10T01:02:13-0500", "startDate": "2021-05-10T05:10:52-0400", "endDate": null}, {"id": "lmm:alert:73560", "statusSummary": "Weekday Service", "statusDescription": "

[4] trains run between Woodlawn and Crown Hts-Utica Av.

", "priority": 3, "direction": "1", "creationDate": "2020-12-10T01:02:13-0500", "startDate": "2021-05-10T05:10:52-0400", "endDate": null}]}, {"route": "5", "color": "00933C", "mode": "subway", "agency": "MTASBWY", "routeId": "MTASBWY_5", "inService": "true", "routeType": "1", "statusDetails": [{"id": "lmm:alert:73559", "statusSummary": "Weekday Service", "statusDescription": "

[5] trains run between Eastchester-Dyre Av and Flatbush Av-Brooklyn College.

", "priority": 3, "direction": "0", "creationDate": "2021-04-24T07:52:11-0400", "startDate": "2021-05-10T05:07:18-0400", "endDate": null}, {"id": "lmm:alert:73559", "statusSummary": "Weekday Service", "statusDescription": "

[5] trains run between Eastchester-Dyre Av and Flatbush Av-Brooklyn College.

", "priority": 3, "direction": "1", "creationDate": "2021-04-24T07:52:11-0400", "startDate": "2021-05-10T05:07:18-0400", "endDate": null}]}]} \ No newline at end of file diff --git a/mta_test.py b/mta_test.py new file mode 100644 index 0000000..2e15a71 --- /dev/null +++ b/mta_test.py @@ -0,0 +1,17 @@ +import os +from dotenv import load_dotenv +from mta import MTA + +load_dotenv() + + +async def mta_callback(data): + print("We are inside of hte call back now boizzzz") + print(data) + + +api_key = os.getenv('MTA_API_KEY', '') +mtaController = MTA(api_key) +mtaController.add_callback(mta_callback) + +mtaController.start_updates() diff --git a/testing.py b/testing.py new file mode 100644 index 0000000..08dcf25 --- /dev/null +++ b/testing.py @@ -0,0 +1,49 @@ +import requests +import os +import json + +from dotenv import load_dotenv +from pprint import pprint + +load_dotenv() + +#endpoint definitions - should be loaded form the env if possible, woudl make it easily maintaine from docker +ACE_ENDPOINT = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2Fgtfs-ace" +SUBWAY_ALERTS = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/camsys%2Fsubway-alerts" +SUBWAY_ALERTS_JSON = "https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/camsys%2Fsubway-status.json" + + +def create_api_call_header(api_key): + return { + "x-api-key":api_key + } + + +def test_api_calls(): + print("Testing the api") + api_key = os.getenv('MTA_API_KEY', '') + r = requests.get( + SUBWAY_ALERTS_JSON, + headers=create_api_call_header(api_key) + ) + print(r) + print(r.status_code) + pprint(r.json()) + with open("mta_status_alerts.json", "w+") as f: + f.write(json.dumps(r.json())) + + + + r = requests.get( + ACE_ENDPOINT, + headers=create_api_call_header(api_key) + ) + print(r) + print(r.status_code) + print(r.content) + + # alerts_data = json.loads() + + +if __name__ == '__main__': + test_api_calls()