deanishe Posted March 1, 2014 Share Posted March 1, 2014 (edited) Critical update to v3.1 on 2017-11-02 (Yahoo! Finance API is dead) Alfred-Convert v3 Yet another conversion workflow. Main features: Works offline, so super fast (occasional web access required to update exchange rates) Many hundreds of units supported 1000+ currencies supported, including cryptocurrencies Custom, user-defined units Auto-updates Downloading Download from GitHub. Usage The syntax is simple: the quantity, the unit you want to convert from then the unit you want to convert to. For example: conv 128 mph km conv 72in cm conv 100psi bar conv 20.5 m/s mph Please see the README on GitHub for full instructions. Supported units Currently, Alfred-Convert supports all the units understood by the underlying Pint library plus a handful of additional units and 1000+ currencies. You can see a list of the supported currencies on the GitHub page. Adding custom units You can also add your own custom units. Use convinfo to open the unit definition file and the documentation describing how the definition format. If you have a unit you think should be included by default, please create a corresponding GitHub issue or ask in this thread. Edited June 7, 2020 by deanishe Fix link to list of supported units gekkoh and cands 2 Link to comment
deanishe Posted August 9, 2014 Author Share Posted August 9, 2014 Updated to fix a problem with git/Xcode. You will no longer be prompted to install Xcode if git is not installed on your system. firezemissile 1 Link to comment
jepense Posted August 16, 2014 Share Posted August 16, 2014 I'm trying to learn your python workflow library and decided to try convert as a tutorial. However, if I write "conv x" in Alfred, it always goes to the fallback search (Google etc.). If I try to run the python script convert.py in Terminal, I get python convert.py 200m/s mph 09:41:50 convert.py:100 DEBUG query : 200m/s 09:41:50 background.py:215 DEBUG Calling [u'/usr/bin/python', '/Users/myusername/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.417268A9-C3A4-4777-B247-D481035658FF/workflow/background.pyc', u'update'] ... RuntimeError: Bad magic number in .pyc file 09:41:50 background.py:218 ERROR Failed to call task in background 09:41:50 convert.py:57 DEBUG quantity : 200.0 tail : m/s 09:41:50 convert.py:135 CRITICAL Invalid query : No destination unit specified <?xml version="1.0" encoding="utf-8"?> <items><item valid="no"><title>No destination unit specified</title><subtitle>For example: 2.5cm in | 178lb kg | 200m/s mph</subtitle><icon>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertCautionIcon.icns</icon></item></items>09:41:50 convert.py:153 DEBUG finished So something happens in background.py and then it doesn't parse the second units correctly. (But I'm actually more interested in understanding why Alfred doesn't tell an error occured but fell back to Google instead, since that happens also when I try to write something using the workflow library myself.) Link to comment
deanishe Posted August 16, 2014 Author Share Posted August 16, 2014 background.py is failing because Python's trying to run the compiled version, background.pyc, but it was created by a different version of Python to the one you're running it with. Deleting all the .pyc files will solve that. This is unrelated to the parsing issue. The reason it isn't working from the command line is that the script takes only one argument. You need to run python "200m/s mph" (note the quotation marks) to run it in Terminal.Hard to say exactly what's happening wrt error messages in Alfred. What does Alfred's debugger show when you run the script? There a fair bit of documentation for my library, which might be helpful. Link to comment
jepense Posted August 16, 2014 Share Posted August 16, 2014 Right, of course, I should've figured that out from the script in conv. Thanks! The problem with running the script from within Alfred was due to /usr/bin/python pointing to python 2.5 while in Terminal python pointed to 2.7 from python.org. I changed the default version and now it works as it should. Thanks! Link to comment
deanishe Posted August 16, 2014 Author Share Posted August 16, 2014 I'm not 100% sure, but I strongly suspect the library is not compatible with 2.5. Link to comment
deanishe Posted December 26, 2014 Author Share Posted December 26, 2014 Big update to version 2. See OP for details. Link to comment
ngiqkokk Posted November 26, 2015 Share Posted November 26, 2015 I'am having problems with conversions from or to cups. I used "conv 1cup cc" and get "conversion input not understood". Is there a problem with "cup" as a unit? Link to comment
deanishe Posted November 26, 2015 Author Share Posted November 26, 2015 Yeah, it's a bug. Thanks for finding it! Pint knows about cups, but the abbreviation for the Cuban peso is "CUP", and that's overriding the definition of cup as a measure of volume. The error you're getting is because the workflow can't convert pesos to cubic centimetres… I'll figure out a permanent solution for the next release within the next day or two. As a temporary workaround, and assuming you don't need to work with Cuban pesos right now, you could try this: Right-click on the workflow in Alfred Preferences and choose "Show in Finder" Open the currencies.json file (but NOT with TextEdit!) Delete the line that says "CUP": "Cuba Peso", (should be line 35) Open Alfred and enter conv workflow:delcache to clear the currency cache (which may still contain Cuban Pesos) Now "cup" should resolve to half a pint, and not Cuban pesos, so your conversion should work. Link to comment
ngiqkokk Posted November 26, 2015 Share Posted November 26, 2015 Great, thanks a lot. Works as advertised Link to comment
Scott Posted December 9, 2015 Share Posted December 9, 2015 I'm having trouble getting Convert to work. Anything I type (including the examples in the OP) just give the please wait subtext ("Convertifying..."). I've tried opening the debug window on the script, but nothing appears in the window. Other workflows I have installed work fine, including in debug - but none of them use python as far as I can tell. So I installed Searchio and it has the same problem. When I go to the workflow directory and execute the script manually, it works fine. Am I doing something stupid? Link to comment
deanishe Posted December 9, 2015 Author Share Posted December 9, 2015 Okay, that's pretty weird. I cant imagine what "stupid" thing you might be doing. First, we need to figure out if it's a problem with the workflow, the workflow library or your system. Which version of OS X are you using? Do any other Python workflows work that aren't written by me or based on my Alfred-Workflow library? Could you try running the script manually from the workflow directory using /usr/bin/python (instead of just python)? Link to comment
Scott Posted December 9, 2015 Share Posted December 9, 2015 OS X 10.11.1 Relative Dates and Searchio stick on the please wait subtest. Resolve URL displays invalid URL regardless of what is input. Netloc says the current network is active; I'm not sure exactly what it's supposed to do, so that one may be working. The python in my path is /usr/local/bin/python, which is version 2.6.4. Running convert.py manually using that fails. But the workflow specifies /usr/bin/python, which is version 2.7.10. Running that one manually returns XML with the correct answer (between a ton of DEBUG lines). Link to comment
deanishe Posted December 9, 2015 Author Share Posted December 9, 2015 (edited) I'm at a bit of a loss, to be honest. My workflows usually explicitly specify /usr/bin/python, and you say they work with that Python when run from a shell… I'm fairly certain that it's an issue with your system, rather than the workflow(s)/library, simply because nobody's had this problem before. Is there anything in the workflows' log files (use <keyword> workflow:openlog in Alfred)? Is there anything in the syslog in Console.app? Have you messed around with your launchd/system environment? Have you tried rebooting and/or repair permissions? Edited December 9, 2015 by deanishe Link to comment
Scott Posted December 10, 2015 Share Posted December 10, 2015 Looks like you're right, it was a problem with my system. I ran Disk Utility's First Aid (no more repair permissions as of El Capitan), no problems found. Rebooted and tried Convert again, this time it immediately asked me to choose the Update action. I did, and it's working fine now. Thanks for the help! Link to comment
Ligeard Posted December 24, 2015 Share Posted December 24, 2015 Hello, Thanks a lot for your workflow. I'm living in Europe, we use km/h and m/s. But I can't convert km/h in m/s (or m/s in km/h). Is it possible to add it? Thanks. Link to comment
deanishe Posted December 24, 2015 Author Share Posted December 24, 2015 (edited) It's already in there. Please refer to the documentation. Edited December 24, 2015 by deanishe Link to comment
Ligeard Posted December 24, 2015 Share Posted December 24, 2015 It's already in there. Please refer to the documentation. Oups! Sorry... I try with "km/h" but not with "kph". I find easily the currencies in the info file, but not the units. Thanks a lot Link to comment
Ligeard Posted December 24, 2015 Share Posted December 24, 2015 I try some conversions, it's very useful! Is it possible to have the result with scientific format too? (for example 1000 g, 10*3g) or with a space between 3 numbers to read more easily the result? Link to comment
deanishe Posted July 16, 2017 Author Share Posted July 16, 2017 (edited) Big update for version 3. Option to exclude units when copying Add per-dimensionality defaults Option to specify thousands separator Option to specify custom decimal separator Add cryptocurrencies Update Alfred-Workflow Update Pint Edited July 16, 2017 by deanishe cands 1 Link to comment
ErfahrungenCOM Posted October 3, 2017 Share Posted October 3, 2017 (edited) hi deanishe, great addon. little problem with this converting euro to php (philippine peso), example: conv 11 eur php can you help out please? screenshot: Edited October 3, 2017 by ErfahrungenCOM Link to comment
deanishe Posted October 17, 2017 Author Share Posted October 17, 2017 Update to v3.0.2. Works around an incompatibility of the pint library with non-ASCII paths discovered by @Canor. Link to comment
deanishe Posted October 17, 2017 Author Share Posted October 17, 2017 On 03/10/2017 at 6:57 PM, ErfahrungenCOM said: hi deanishe, great addon. little problem with this converting euro to php (philippine peso), example: conv 11 eur php can you help out please? screenshot: Sorry, I forgot to reply to your message. Use "PHP", not "php". Lowercase currencies only work as long as they don't conflict with built-in units. As far as pint (the library that does all the converting) is concerned, p is the prefix for "pico" and hp is "horsepower", so "php" means "picohorsepower". Link to comment
xilopaint Posted October 18, 2017 Share Posted October 18, 2017 On 7/16/2017 at 11:24 AM, deanishe said: Big update for version 3. Option to exclude units when copying Add per-dimensionality defaults Option to specify thousands separator Option to specify custom decimal separator Add cryptocurrencies Update Alfred-Workflow Update Pint Deanishe, sorry for hijacking the thread for a simple question. But what versioning criteria do you use to release a new major version? I have read about SemVer that a new major version should come out when "any backwards incompatible changes are introduced to the public API". What can this mean in terms of an Alfred Workflow? Would it be the case of a new version for Alfred 3 that becomes incompatible with Alfred 2? Can I release a new major version just because of significant new features? Link to comment
deanishe Posted October 18, 2017 Author Share Posted October 18, 2017 (edited) 1 hour ago, xilopaint said: any backwards incompatible changes are introduced to the public API". What can this mean in terms of an Alfred Workflow? I don’t think semver is particularly relevant: workflows don’t usually have a public API. 1 hour ago, xilopaint said: Can I release a new major version just because of significant new features? Sure. You can increment it on every release if you want. Google Chrome’s on version 64 already. As a rule, new major versions tend to be synonymous with paid upgrades, which isn’t relevant to free software. If your workflow is associated with an app, you might use the same major version as the app for workflow versions that work with that app version. Otherwise, I don’t think it matters much as long as the version numbers always go up… I tend to go with “significant rewrite/new features = new major version”, but only because that’s what I know from most apps. I haven’t actually tried to develop a concrete concept for versioning. Edited October 18, 2017 by deanishe xilopaint 1 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