Git Product home page Git Product logo

bixi-checker's Introduction

Bixi Checker

A simple command-line script that I created to simplify checking the status of your favourite bixi stations. It can handle multiple stations per location, routes (start and end locations only), and custom names for stations.

Requires Python 3.0+.

Simple example

To check if there's a route from home to work:

$: bixi go home work
Nearest to home: 15 bikes
Nearest to work: 27 docks

Setup instructions

  1. Clone this repository.
  2. Copy bixiapi/conf.py.sample to bixiapi/conf.py. Important
  3. Find the IDs for the stations you're interested in. To simplify this process, there's a lookup feature included in this program, in the search mode. For example, to find all the bixi stations on Sherbrooke, just type ./bixi.py search sherbrooke and you'll get a list of ID-name pairs. This feature currently doesn't handle non-ASCII characters (it will soon).
  4. Add the desired station IDs and locations to conf.py. You only need to add a station ID to the stations dictionary if you want to give it a custom name (otherwise, it will show the official name, which is usually the intersection). Note that location names should not contain a space.
  5. Install the package (requires distutils): python setup.py install
  6. To find a suitable route from one location to another, simply type ./bixi.py START END where START is the name you gave to the location you are departing from and END is the name you gave to the location you are arriving at. The script will then look at each of the stations you listed for the starting location, in order, and will print out the first one with an available bike; similarly, for the ending location, it will print out the first one with an available dock. If no stations are available, it will tell you that instead.
  7. If you there is a route that you take frequently, you can add it to the route dictionary at the bottom. Simply enter the starting location and the ending location as a tuple (START, END).

Modes

  • search: bixi search QUERY
  • go: bixi go START_LOCATION END_LOCATION
  • route: bixi route ROUTE_NAME

API

As bixi.com doesn't seem to have an official API (just some dynamically-generated Javascript), I've created a Python module, bixiapi.py, that wraps around it. bixiapi exposes one method - the get_stations() method - which takes in the identifier for the desired city (either "montreal", "toronto", or "capitale") and returns a dictionary containing the information for all the stations in that city. Any required type conversion is taken care of (as the bixi.com website returns everything as a string).

The format looks like this:

{
    # Key: station ID (as used internally, but converted to an int)
    1: {
        'docks': 10, # converted to an int
        'bikes': 10, # converted to an int
        'name': 'Street 1 / Street 2',
        'longitude': -77.7, # converted to a float
        'latitude': 44.4, # converted to a float
        'installed': true, # converted to a bool
        'locked': false, # converted to a bool
        'temporary': false, # converted to a bool
        'sponsor_name': None, # either a string or None
        'sponsor_link': None, # either a string or None
        'sponsor_logo': None, # either a string or None
    },
    # ...
}

Usage example

from bixiapi import scraper

stations = bixiapi.get_stations('montreal')

for station_id, station_data in stations:
    print station_id
    print station_data['name']

License

MIT license.

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.