frankspin Posted August 23, 2014 Share Posted August 23, 2014 (edited) Download: https://github.com/fspinillo/alfred-uber/blob/master/workflow/UberTime.alfredworkflow?raw=true With the release of Uber's new public API, I wanted to build a workflow to check on the estimated pick up times based on criteria given. The workflow was built in Python 2.7, and is bundled with requests and Dean Jackson (deanishe) wonderful Workflow package. What the workflow does Stores your Uber server token in Apple's filevault Stores your home and work address Enter zipcode, address or city with country to get estimated times Get estimated times for your work address Get estimated times for your home address Setup Go to the Uber developer page and register an app Once registered, you'll have a server token. Launch Alfred, type in 'utoken', paste your token and hit enter. A notfication should pop up notifying you it was saved optional Set your home address by launching Alfred and entering 'usethome' Set your home address by launching Alfred and entering 'usetwork' Using the workflow Important: Addresses must be entered with the country. Example: Rome, Italy // San Francisco, CA // Paris, France If you just want to search based on any address, launch Alfred and enter 'utime' with the criteria. If you want to search for times based on your home address, launch Alfred and enter 'uhome' If you want to search for times based on your home address, launch Alfred and enter 'work' Edited October 9, 2014 by frankspin Link to comment
frankspin Posted August 23, 2014 Author Share Posted August 23, 2014 I haven't had the chance to try this on different machines, or ones that don't have requests already installed, so any feedback is appreciated! Link to comment
DJay Posted August 23, 2014 Share Posted August 23, 2014 Sounds great. Thx for sharing. Unfortunately I get this.. Of course I paste the token. Maybe it's because I use Uber in germany? Thanks again. Link to comment
frankspin Posted August 24, 2014 Author Share Posted August 24, 2014 Sounds great. Thx for sharing. Unfortunately I get this.. Of course I paste the token. Maybe it's because I use Uber in germany? Thanks again. This should work in Germany, I justed it out on my end. As for the error, I forgot to import a module. I just uploaded the fix to the github repo. Also make sure you run 'usethome'/'usetwork' if you're going to be using 'uhome' and 'uwork' so it can save your address. Link to comment
DJay Posted August 24, 2014 Share Posted August 24, 2014 Now I get this error Message. Is there a special format to save my address? At the moment I do i.e. Mainstreet 22, 12099 Berlin Link to comment
frankspin Posted August 24, 2014 Author Share Posted August 24, 2014 Now I get this error Message. Is there a special format to save my address? At the moment I do i.e. Mainstreet 22, 12099 Berlin Enter it as Mainstreet 22, 12099 Berlin, Germany I'll update the how-to to mentin it need the country. Link to comment
DJay Posted August 24, 2014 Share Posted August 24, 2014 Thx frankspin. Unfortunately any address I use, I get the still the same error. Link to comment
frankspin Posted August 24, 2014 Author Share Posted August 24, 2014 (edited) Thx frankspin. Unfortunately any address I use, I get the still the same error. Can you use the debug window when running it? Is it just for when you use uhome or does it work with utime? Only thing I can think of is region is causing an issue. I can poke around for Germany specific API url's and see if that fixes it. Edited August 24, 2014 by frankspin Link to comment
DJay Posted August 24, 2014 Share Posted August 24, 2014 Here we go. No difference using uhome uwork or utime. Starting debug for 'UberTime' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:19:16 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uhome.py", line 51, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:19:31 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uwork.py", line 52, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:19:50 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uhome.py", line 51, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:47 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:48 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:51 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:52 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:53 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:55 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:55 workflow.py:1256 ERROR list index out of range Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 28, in main lat = mapsData['results'][0]['geometry']['location']['lat'] IndexError: list index out of range [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:57 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:58 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' [ERROR: alfred.workflow.input.scriptfilter] Code 1: 16:21:59 workflow.py:1256 ERROR 'times' Traceback (most recent call last): File "/Users/Daniel/Dropbox/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.D7370CAE-1E41-41A7-956F-00BD4E747929/workflow/workflow.py", line 1254, in run func(self) File "uber.py", line 40, in main uberArray = uberData['times'] KeyError: 'times' Link to comment
frankspin Posted August 24, 2014 Author Share Posted August 24, 2014 It's not getting the latitude from Google Maps, which is why it's not able to build the array for Uber. What's interesting to me is I can use this just fine with the address you provided but it's not working your location. I've never really played with localization before and I don't have a VPN, but I'll see if I can get my region changed to test this out for your region. Thanks for your patience! Link to comment
frankspin Posted August 24, 2014 Author Share Posted August 24, 2014 (edited) Quick edit: I logged into a sever based in the Netherlands and sucessfully ran this without an issue via terminal. So I'm not entirely sure what is going on, trying to get other people to test this out for me to see. Additionally I noticed requests is not being called properly despite being where it needs to be. Looking into that too. Feedback from someone else and they're getting the same error as you, so it's something with it working on different machines Edited August 24, 2014 by frankspin Link to comment
DJay Posted August 24, 2014 Share Posted August 24, 2014 Thanks a lot for your passionate work. Link to comment
frankspin Posted August 25, 2014 Author Share Posted August 25, 2014 Confirmed with DJay this is now fully working, and requests is now properly being packaged in. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now