Jump to content

nikipore

Member
  • Posts

    40
  • Joined

  • Last visited

Recent Profile Visitors

840 profile views

nikipore's Achievements

Member

Member (4/5)

5

Reputation

  1. @clenden I'd suggest to drill into the cause of your problem by debugging intermediary results with either one of the two methods: print statements (only works on the command line) writing to a temporary file (see above how to do that) The most likely cause I can think of is that the places.sqlite you are scanning is not the one associated to the Firefox profile you are actually using. What FF version are you on, btw?
  2. I'd suggest to use a fixed path like ~/Library/Application Support/Alfred2/Workflow Data/Python/python to point to the Python interpreter of your choice. This can be as simple as a softlink. And I would recommend to everyone to use a virtualenv install which is standard and lightweight. No need to install another Python, just re-use whatever Python you are using (system, MacPorts, brew, ...).
  3. The query was implemented such that it matches any string where the letters m-a-m-e appear in this order. I now changed this to words (separated by space). I pushed the new package to github. Feel free to give it a test drive.
  4. Please replace the icon method as shown below. This should catch your error. Please let me know if that helps; I will commit that patch to git, then. def icon(db, faviconid): if not faviconid: return data = db.execute(u'select data from moz_favicons where id=%d' % faviconid).fetchone() if not data: return icon = os.path.join(_CACHE, 'icon-%d.png' % faviconid) if (not os.path.exists(icon)) or ((time.time() - os.path.getmtime(icon)) > _CACHE_EXPIRY): open(icon, 'wb').write(data[0]) return icon
  5. Would you please temporarily replace the last block by the code below (the second and third lines have been inserted) and check /tmp/alfred.txt whether your places.sqlite file is identified correctly and exists? (profile, query) = alfred.args() import os open('/tmp/alfred.txt', 'w').write('profile=%s\nplaces=%s\nexists=%s' % (profile, places(profile), os.access(places(profile), os.R_OK))) db = sqlite3.connect(places(profile)) alfred.write(alfred.xml(results(db, query), maxresults=_MAX_RESULTS))
  6. Mike, sorry for answering half a year later, but this forum's amazing activity in the birth phase of Alfred 2 workflows was just too much for me to follow, so I kind of pulled the plug. I'm on Mountain Lion too (10.8.5), and the workflow still works perfectly for me on FF 24. Are other Python workflows functioning? Where is your places.sqlite? Cheers, Jan
  7. Thanks for the suggestion. I'll look into that when I find the time (which could take a couple of weeks). EDIT I just uploaded a modified version which should work for both SIP addresses and normal phone numbers. It replaces a leading + in phone numbers by the country prefix. It is preconfigured to the most common (pretty much everyone but U.S.) setting 00 and can be changed in the bash script.
  8. I suggest to introduce a "streaming" mode which sets up the communication Alfred <-> subprocess via stdin and stdout of the subprocess. It would be optimal if the encoding was specified explicitly, I propose normalized UTF-8 (not Mac UTF-8). Since the stdout route subprocess -(stdout)-> Alfred is already there, this would symmetrize the communication.
  9. Thanks for the feature request. Not quite sure whether it's really possible to pass every conceivable string as a command-line parameter. By "streaming" I mean that Alfred could feed {query} on the stdin of the subprocess; streaming via stdout is the way the communication from the subprocess into Alfred is set up already. I'll maybe add the streaming part as an alternative suggestion to your feature request. In Python, the communication on behalf on the subprocess would look as follows: query = sys.stdin.read() Up to decoding and normalizing the binary stream (which could then even be encoded as properly normalized UTF-8), that would be the whole story. Clean and easy, no escaping needed at all.
  10. This one's for you: http://www.alfredforum.com/topic/836-firefox-bookmarks-and-input-history/
  11. @johnjddoe: I can confirm that 2n-1 and 2n backslashes (n>0) within double quotes arrive in Python as n backslashes. Annoying indeed. I think we should file an issue to request a proper unescaping (if possible at all). Maybe the cleanest way out is to offer a streaming mode where the script harvests UTF-8 (either Mac style or normalized) on stdin and yields UTF-8 on stdout.
  12. I escape backlashes in Alfred and unescape them in python-alfred, and that approach also treats backslashes correctly. Which characters or character sequences are left which aren't treated correctly?
  13. Sure: Just use a single quote '. That doesn't even trigger the Python script without double quotes around {query}. Disagreed. I think the best practice is to take care that any string arrives in Python just as the user entered it in Alfred (straight from the horse's mouth). If you've got that worked out, you wouldn't want to change that any more. Of course, you're free to interpret that string at will and as it suits your specific application.
  14. Awesome, Robin. More of these, please!
  15. I poked a bit more at the various options and can confirm once more that leaving the double quotes away is a bad idea. But the world isn't as simple as neither of us thought: Actually, the correct implementation seems to be to tick all escape options, use /bin/bash, escape the {query} with double quotes: python yourscript.py "{query}" arg2 arg3 ... and then unescape semicolon, round brackets, and space in the code. This at least works for all characters which Alfred offers to escape to begin with. I didn't test (and I'm not very interested in, because I lose testabiity that way) inline Python code.
×
×
  • Create New...