Coder Social home page Coder Social logo

mtapi's People

Contributors

dependabot[bot] avatar georgyo avatar jonthornton avatar mattsahn avatar mmeyer724 avatar nathan9 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mtapi's Issues

Feature: upper case route if route is non-numeric

What are your thoughts on having the route be upper cased for all non-numeric routes.

/by-route/G and /by-route/g would return the same data set. As is, the lower cased route returns an empty list.

Where can I find stops.txt on mta.info?

Hey Jon,

I'm hoping to use this for an MTA-related SMS project I'm working on. I've got the server up and running but I'm unable to find stops.txt on mta.info. Any suggestions or links as to where it might be? I'll keep looking.

Thanks!
ZS

Could I Run MTAPI app on Raspberry PI?

Dear developers, I got your code running on the EC2 at AWS. Runs great for my purposes. I happen to have a pre-existing account at AWS and so I get charged more than I want for a hobby activity.
Are there any processors like Raspberry Pi that your code might run on?
I'm sorry this looks like an issue, but it's merely a request for a suggestion.
Thanks in advance.
Regards

Not Pulling Feeds For ACBD

Hey there,

I'm wondering why I can't get the route of the ACBD trains. Specifically, I'm looking for 125th st in Harlem, but I don't see it as an available route. Any chance this can get fixed?

Thanks,
Dan

KeyError: 'MTA_KEY' line 57 in app.py

Hi,

I am building a subway clock using your MTA API code, and using the tutorial from https://github.com/boscacci/Arduino-Subway-Clock. I'm setting up the code for my AWS server, but keep running into this particular issue that I can't resolve.

Specifically getting this error from my SSH:

ubuntu@ip-xxx-xx-x-xxx:~/MTAPI$ python3 app.py
Traceback (most recent call last):
File "/home/ubuntu/MTAPI/app.py", line 57, in
app.config['MTA_KEY'],
KeyError: 'MTA_KEY'

I get the same error after running the command:

flask run --host=0.0.0.0 --port=8080

Do you have any advice for this? THANKS!

Stations.json

Hey So I was wondering what exactly the format is for the Json file and how individual train lines are saved.
Like lets say 72nd street has the 1, 2 and 3 trains arriving at it. How could you parse the Json file to see that 72nd street is a stop on all three of the lines?

Thanks!

Project dependencies may have API risk issues

Hi, In MTAPI, inappropriate dependency versioning constraints can cause risks.

Below are the dependencies and version constraints that the project is using

atomicwrites==1.3.0
attrs==19.1.0
Click==7.0
configparser==4.0.2
contextlib2==0.5.5
Flask==1.1.1
funcsigs==1.0.2
importlib-metadata==0.22
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==0.23
more-itertools==5.0.0
packaging==19.1
pathlib2==2.3.4
pluggy==0.13.0
protobuf==3.15.0
py==1.10.0
pyparsing==2.4.2
pytest==5.1.2
pytz==2019.2
scandir==1.10.0
six==1.12.0
wcwidth==0.1.7
Werkzeug==0.15.6
zipp==0.6.0

The version constraint == will introduce the risk of dependency conflicts because the scope of dependencies is too strict.
The version constraint No Upper Bound and * will introduce the risk of the missing API Error because the latest version of the dependencies may remove some APIs.

After further analysis, in this project,
The version constraint of dependency protobuf can be changed to >=2.6.0,<=3.0.0a3.
The version constraint of dependency pytz can be changed to >=2011d,<=2013d.
The version constraint of dependency pytz can be changed to >=2011b,<=2022.1.

The above modification suggestions can reduce the dependency conflicts as much as possible,
and introduce the latest version as much as possible without calling Error in the projects.

The invocation of the current project includes all the following methods.

The calling methods from the protobuf
google.protobuf.symbol_database.Default
google.protobuf.reflection.GeneratedProtocolMessageType
google.protobuf.descriptor.FileDescriptor
The calling methods from the pytz
pytz.timezone
The calling methods from the all methods
self.threader.start_timer
getattr
stations.values
flask.jsonify
logging.getLogger
mtaproto.nyct_subway_pb2.NyctTripDescriptor.Direction.Name
datetime.datetime.now.total_seconds
mtapi.mtapi.Mtapi.get_by_point
argparse.ArgumentParser.add_argument
route.upper
threading.Thread
logging.getLogger.error
time.sleep
str
_make_envelope
s.serialize
threading.RLock
min
self.timer_thread.is_alive
enumerate
mtaproto.feedresponse.TripStop
mtaproto.gtfs_realtime_pb2.FeedHeader.RegisterExtension
self._pb_data.ParseFromString
mtaproto.feedresponse.Trip
pytz.timezone
route.upper.upper
distance
self._update
join
datetime.datetime.fromtimestamp
google.protobuf.symbol_database.Default.RegisterEnumDescriptor
self.update_lock.release
mtapi._mtapithreader._MtapiThreader
mtapi.mtapi.Mtapi
iter
row.transfers.add
station_id.stations.add_train
flask.Flask.run
datetime.timedelta
self.is_expired
self.threader.restart_if_dead
google.protobuf.descriptor.EnumValueDescriptor
google.protobuf.descriptor.Descriptor
station.keys.join.md5.hexdigest
mtaproto.feedresponse.FeedResponse
f
route_id.routes.add
google.protobuf.descriptor.EnumDescriptor
google.protobuf.reflection.GeneratedProtocolMessageType
x.encode
argparse.ArgumentParser
csv.writer.writerow
stops.pop
k.self._stations.serialize.update
station_id.stations.keys
google.protobuf.descriptor.FileDescriptor
id.stations.clear_train_data
csv.writer
self.update_thread.start
x.encode.decode
functools.reduce
mtapi.mtapi.Mtapi.get_routes
google.protobuf.symbol_database.Default.RegisterFileDescriptor
self.clear_train_data
id_string.split
logging.getLogger.info
self.routes.add
app.config.from_pyfile
sum
id.stations.sort_trains
map
main
mtaproto.feedresponse.Trip.is_valid
row.stations.add
trip.route_id.upper
Exception
print
route.islower
operator.itemgetter
functools.wraps
collections.defaultdict
self._Station
urllib.request.Request.add_header
flask.abort
flask.Flask.route
json.load
google.protobuf.descriptor.FieldDescriptor
json.dump
k.self._stations.serialize.sort
contextlib.closing
bool
flask.redirect
urllib.request.Request
mtapi.mtapi.Mtapi.get_by_route
logging.getLogger.warn
self.start_timer
k.self._stops_to_stations.self._stations.serialize
k.self._stations.serialize
self.timer_thread.start
mtaproto.nyct_subway_pb2.gtfs__realtime__pb2.FeedMessage
mtaproto.gtfs_realtime_pb2.TripDescriptor.RegisterExtension
station.keys
mtapi.mtapi.Mtapi.last_update
os.path.isfile
self._stations.copy.deepcopy.values
exit
urllib.request.urlopen
self.update_lock.acquire
station.values
mtapi.mtapi.Mtapi.get_by_id
google.protobuf.symbol_database.Default.RegisterMessage
flask.json.JSONEncoder.default
_b
self._routes.keys
argparse.ArgumentParser.parse_args
obj.isoformat
app.config.from_envvar
itertools.islice
len
threading.Lock
math.sqrt
open
datetime.datetime.now
set
direction.self.trains.append
list
self.mtapi._update
app.config.update
self._load_mta_feed
float
copy.deepcopy
mtaproto.gtfs_realtime_pb2.TripUpdate.StopTimeUpdate.RegisterExtension
isinstance
csv.DictReader
logging.basicConfig
flask.Flask
hashlib.md5
google.protobuf.symbol_database.Default
sorted
r.read
station.md5.hexdigest
self._build_stops_index
self._direction

@developer
Could please help me check this issue?
May I pull a request to fix it?
Thank you very much.

Request some guidance

Dear Developers, I've been trying to get things working with MTAPI. I've worked my way through a bunch of stuff, my own problems, and this may be one of those too. Using the python3 app.py, I keep getting a failure as shown below. My deepest suspicion is that my lack of knowledge has got the better of me. Here's below the response I get . I can't find any way to confront that ERROR and fix it. I've looked as well as I can on the internet, and because I can't find anything, I'm betting it's something I'm not doing.
Any help to debug this problem of mine is appreciated. Settings.cfg is also pasted in.(And, btw, running Ubuntu instance at AWS EC2)
Thanks

$ python3 app.py
2022-12-03 22:27:28,675 - mtapi.mtapi - INFO - updating...
2022-12-03 22:27:29,219 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,220 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,223 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,224 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,239 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,240 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,241 - mtapi.mtapi - INFO - Stop R60 not found
2022-12-03 22:27:29,586 - mtapi.mtapi - ERROR - Couldn't connect to MTA server: Unexpected end-group tag.
2022-12-03 22:27:29,747 - mtapi._mtapithreader - INFO - Starting update thread...

  • Serving Flask app "app" (lazy loading)
  • Environment: production
    WARNING: This is a development server. Do not use it in a production deployment.
    Use a production WSGI server instead.
  • Debug mode: on
    2022-12-03 22:27:29,757 - werkzeug - INFO - * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

Settings.cfg
MTA_KEY ='*********************'
STATIONS_FILE = './data/stations.json'
CROSS_ORIGIN =' '
MAX_TRAINS=10
MAX_MINUTES=30
CACHE_SECONDS=60
THREADED=True
DEBUG = True

503 Error on all API feeds...

My API Key works on the feeds listed on the http://datamine.mta.info/list-of-feeds site, however it doesn't seem to work with the feed urls in the mtapi.py file.

Any idea what the difference between these two feeds might be? Out of curiosity, how did you find the api-endpoint.mta.info urls in the first place? I can't seem to find them referenced anywhere.

Segmentation fault python app.py

I followed the steps to start the server but it fails immediately with a segmentation fault error:

segmentation fault python app.py

I enabled the faulthandler to find out where it exactly happens and found the following:

`(.venv) โžœ MTAPI git:(master) โœ— python app.py
Test
Fatal Python error: Segmentation fault

Current thread 0x00007ff84e659340 (most recent call first):
File "/Users/arascovan/repos/MTAPI/mtaproto/gtfs_realtime_pb2.py", line 1179 in
File "", line 228 in _call_with_frames_removed
File "", line 850 in exec_module
File "", line 680 in _load_unlocked
File "", line 986 in _find_and_load_unlocked
File "", line 1007 in _find_and_load
File "/Users/arascovan/repos/MTAPI/mtaproto/nyct_subway_pb2.py", line 16 in
File "", line 228 in _call_with_frames_removed
File "", line 850 in exec_module
File "", line 680 in _load_unlocked
File "", line 986 in _find_and_load_unlocked
File "", line 1007 in _find_and_load
File "", line 228 in _call_with_frames_removed
File "", line 1058 in _handle_fromlist
File "/Users/arascovan/repos/MTAPI/mtaproto/feedresponse.py", line 1 in
File "", line 228 in _call_with_frames_removed
File "", line 850 in exec_module
File "", line 680 in _load_unlocked
File "", line 986 in _find_and_load_unlocked
File "", line 1007 in _find_and_load
File "/Users/arascovan/repos/MTAPI/mtapi/mtapi.py", line 9 in
File "", line 228 in _call_with_frames_removed
File "", line 850 in exec_module
File "", line 680 in _load_unlocked
File "", line 986 in _find_and_load_unlocked
File "", line 1007 in _find_and_load
File "/Users/arascovan/repos/MTAPI/app.py", line 16 in
[1] 21952 segmentation fault python app.py`

epoch timestamp in addition to 8601

Hello! Thank you for this great project!

Would you be willing to accept a PR or add the functionality to also include a unix timestamp/epoch timestamp in addition to the datetime?

For example a current response:

                {
                    "route": "N",
                    "time": "2023-02-26T22:07:06-05:00"
                },

What I propose:

                {
                    "route": "N",
                    "time": "2023-02-26T22:07:06-05:00"
                    "ts": 1677467226
                },

For my project it's much easier to work with an epoch timestamp than having to parse/load the datetime.

HTTP Error code: 255 - Is this an issue with python3.10?

Making note of a weird error in my aws instance, throwing me an error with import mapping innit.py

Think it might be because python 3.10 has a change re collections to collections.abc ?

Possible code fix might be:

try:
from collections.abc import Mapping
except ImportError:
from collections import Mapping

TypeError

Hello, when I run the script it is giving me a type error:

Traceback (most recent call last):
File "app.py", line 62, in
threaded=app.config['THREADED'])
File "/home/pi/Desktop/MTAPI-master/mtapi/mtapi.py", line 84, in init
self._stations = json.load(f)
File "/usr/lib/python3.5/json/init.py", line 268, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/usr/lib/python3.5/json/init.py", line 312, in loads
s.class.name))
TypeError: the JSON object must be str, not 'bytes'

I deleted the folder and re-did all the installation. Thanks for creating this, it really comes in handy!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.