Skip to main content

Tom reshared this.


OHGO Wrapper


One of the problems I have with a lot of my Open Source projects is the code tends to be difficult to use in other projects because the classes end up blending into each other until it makes zero sense to pull out any of the code. So, for a project I'm working on I made concerted effort to abstract the code enough to be useful to other people.

This is a wrapper for the Ohio Department of Transportation's OHGO API. The API is a JSON REST API that provides access to traffic cameras, weather sensors, incidents, closures, and delays in the state of Ohio. I found a fantastic guidethat goes through the basic process of organizing a wrapper. And I was able to turn it into a useful package that I published on pypi.

Getting started with the wrapper is simple, for example this is how you grab images from a traffic camera (after you install via pip):
from ohgo import OHGOClient

client = OHGOClient('your-api-key')
cameras = client.get_cameras() # -> Returns a list of first 500 cameras in Ohio, pass in a QueryParams object with page_all=True to get all cameras

# Or if you prefer to get a specific group of cameras we can filter it further
from ohgo.models import QueryParams
from ohgo.types import Region
params = QueryParams(region=Region.COLUMBUS) # -> Returns a list of cameras in Columbus
cameras = client.get_cameras(params)

# Now we can get the image from the camera
camera = cameras
[0]image = client.get_images(camera) # -> Returns a list of PIL images from the camera
Something I didn't know before this, is that we can overload functions in python3 (so they behave differently depending on the arguments passed in). So, I used that to make the get_image and get_images functions behave differently depending on if you pass in a Camera, CameraView, or a DigitalSign object.

That guide also led me to the Quicktype website which lets you pass in JSON, and it will generate a Python class for you (or nearly any other language) that matches the provided JSON.

I also wanted to build a small demo for the wrapper, so I made a Mastodon api compatible bot that posts a random traffic camera image every hour which you can find here: @ohgo@tomkahe.com

OHGO Wrapper Source Code

OHGO Wrapper PyPi

OHGO Mastodon Bot Source Code

Tom reshared this.




Tom reshared this.


One of the best aspects of itch.io is the massive library of homebrew games for ancient computers and consoles.

And a lot of these games are free too.

You can find new games for practically everything: NES, C64, CoCo, DOS, GBC. It’s riveting stuff.

This entry was edited (2 months ago)

Tom reshared this.


Echoes of Wisdom started as a Zelda dungeon editor game polygon.com/zelda/455109/echoe…

Tom reshared this.