Jump to content

ZotQuery: an Alfred workflow for Zotero


Recommended Posts

Ran z:config, seemed to run fine. All three files are in the folder 

 

Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/

 

folder.

 

But when I run z:cache, this this the error that I keep getting 

 

[iNFO: alfred.workflow.input.keyword] Processing output 'alfred.workflow.action.script' with arg ''

[ERROR: alfred.workflow.action.script] Code 1: 15:59:19 workflow.py:1199 ERROR    [Errno 2] No such file or directory: u'/Users/username/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/paths.json'

Traceback (most recent call last):

  File "alfred-workflow.zip/workflow/workflow.py", line 1197, in run

    func(self)

  File "_update-caches.py", line 57, in main

    zotero_path = z.get_path('database_path')

  File "/Users/username/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.3A30B125-FCA4-4055-8B87-EEED9D5E7204/zq_utils.py", line 66, in get_path

    with open(wf.datafile(u"paths.json"),'r') as f:

IOError: [Errno 2] No such file or directory: u'/Users/username/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/paths.json'

[iNFO: alfred.workflow.action.script] Processing output 'alfred.workflow.output.notification' with arg '<?xml version="1.0" encoding="utf-8"?>

<items><item valid="no"><title>Error in workflow 'com.hackademic.zotquery'</title><subtitle>[Errno 2] No such file or directory: u'/Users/username/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/paths.json'</subtitle><icon>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns</icon></item></items>'

 

Is there something I'm missing here?

Link to comment
[ERROR: alfred.workflow.action.script] Code 1: 16:50:55 workflow.py:1199 ERROR    [Errno 2] No such file or directory: u''
Traceback (most recent call last):
  File "alfred-workflow.zip/workflow/workflow.py", line 1197, in run
    func(self)
  File "_update-caches.py", line 59, in main
    shutil.copyfile(zotero_path, clone_database)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 82, in copyfile
    with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: u''

Here's what I'm getting now. 

Link to comment

I actually can't get z:bug to run. here's what I get 

Starting debug for 'ZotQuery'

[ERROR: alfred.workflow.input.scriptfilter] Code 1: 19:58:46 workflow.py:1199 ERROR    [Errno 2] No such file or directory: u'/Users/username/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/zotero_db.json'
Traceback (most recent call last):
  File "alfred-workflow.zip/workflow/workflow.py", line 1197, in run
    func(self)
  File "filters.py", line 13, in main
    zf = ZotFilter(query, scope)
  File "/Users/username/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.6B4E65CA-8A43-44BC-8908-5F11F8189D88/zq_filters.py", line 33, in __init__
    with open(self.wf.datafile("zotero_db.json"), 'r') as f:
IOError: [Errno 2] No such file or directory: u'/Users/username/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/zotero_db.json'
Link to comment

Ok. Well, ZotQuery is unable to locate any of your Zotero data, which is why it cant create the json database, which is why it isn't working. 

 

Which version of Zotero do you have installed? Zotero Standalone or Zotero for Firefox? We are going to need to find where your Zotero data is lurking to get things working.

Link to comment
  • 5 weeks later...

 

This gives me the ability to cite while writing and let pandoc/LaTeX sort out the reference style. But it only works semi-fluidly in BibDesk at the moment because Zotero doesn’t export MMD or pandoc citekeys or MMD referenced links for the bibliography. The zotero-better-bibtex (ZBB) add-on for Zotero by Emiliano heyns (friflaj) [2] does come tantilisingly close in exporting LaTeX citekeys and BibTex bibliographies from Zotero. I’ve tried to hack around with a fork of ZBB but the json is a bit too much for me at the moment.

 

 

What would you need ZBB to do to help you out?

Link to comment
UPDATE: I've just posted version 8.0 to Packal.

 

This version is almost exclusively an "under-the-hood" update. ZotQuery now runs from one central script (zotquery.py), and the entire code base has been refactored. On the one hand, this should allow for much better readability of the code (for those interested in such esoteric matters); but, on the other hand, this should also squash a few bugs. For one, I refactored the code to automatically detect your Zotero paths, so this should hopefully work better now. 

 

Anyways, go and update. I would also re-run z:config just to ensure everything is squared away for the new version (I've changed the structure of the JSON cache file, for example).

 

stephen

Link to comment

Thanks for the update! I'm running into a problem with the bibtex keys zotquery generates. Someone I have to cite a lot has a last name with ’ (O’Toole). I use pandoc and it will not run if my cite keys have that kind of character in them. Would it be possible to tweak your code so it does not include ’ when it generates the cite key? I can fix it with find and replace, but a more permanent solution is preferable. If this is not something you want to implement can you please give an idea of where in your code I might be able to make this change?  Thanks!  

Link to comment
Do simple single quotes work with Pandoc? For example, if this "O’Toole" breaks Pandoc, does this work: "O'Toole"? If so, it's an easy fix. I confess tho that I'm a bit surprised the Pandoc is breaking under such minor conditions. It appears that this was fixed long ago (see here for example). 

But a problem is a problem, so I've just posted version 8.0.1 to Packal. It fixes only this issue, but it does fix it. It replace smart apostrophes with "dumb" (i.e. ASCII) ones.

 

Hope that helps,

stephen

Link to comment

 

Do simple single quotes work with Pandoc? For example, if this "O’Toole" breaks Pandoc, does this work: "O'Toole"? If so, it's an easy fix. I confess tho that I'm a bit surprised the Pandoc is breaking under such minor conditions. It appears that this was fixed long ago (see here for example). 
But a problem is a problem, so I've just posted version 8.0.1 to Packal. It fixes only this issue, but it does fix it. It replace smart apostrophes with "dumb" (i.e. ASCII) ones.
 
Hope that helps,
stephen

 

 

 

Awesome!  Thanks for being so responsive. But I am running into an issue with the new version:

bird:user.workflow.07F575B3-FF6C-430E-B6ED-B7824069EEA0 Chris$ python zotquery.py --filter "none" "debug"
Traceback (most recent call last):
  File "zotquery.py", line 91, in <module>
    import html2text
ImportError: No module named html2text

I reinstalled 8 to confirm that it was still working. Please let me know if there's any other information I can give you that would be helpful. I'm not sure whether this is something unique to my setup. 

Link to comment

I am getting this error with 8.0.2:

 

[ERROR: alfred.workflow.input.scriptfilter] Code 1: Traceback (most recent call last):

  File "zotquery.py", line 91, in <module>

    import html2text

ImportError: No module named html2text

 

 

By the way, is it possible to exclude items from group libraries in ZotQuery 8?

Link to comment

Dear Stephen,

 

many thanks for your wonderful workflow. It looks fantastic and a handy addition to the existing toolset Zotero offers. I'm super keen to see it work but unfortunately am either doing something terribly wrong or have a system setting that prevents me from creating a workable set-up. The first time I installed it I skipped the set-up phase, which made the workflow find and cache all articles but nothing would happen when I 'entered' the found article or wanted to take any other sort of action on it. Next, I tried the z:config command to correct my former error, which led to no activity. I make it to the configuration choice, then nothing else happens. I deleted the first-run.txt file, as recommended elsewhere in this forum, but to no avail. Now I've deleted and re-installed both the workflow and Alfred in its entirety, but still the z:config command will not lead to any questions - my com.hackademic.zotquery folder contains three files (first-run.txt, prefs.json, settings.json) which are all empty. Do you possibly have an inkling of how I could now make it work?

 

Many thanks for your advice,

Erwin

 

[OS X 10.9.3, Alfred v2.3 (264)]

Link to comment

To all, sorry for the delay (on vacation), and sorry for the bug. I have been working with a different system for dependencies, but I'm not finished and the code wasn't properly refactored. However, I've updated to version 8.0.3 which should import all dependencies without problems. Please upgrade and let me know if it works. 

 

stephen

Link to comment

This problem may be unique to me. I tried to remove everything (including the com.hackademic.zotquery folder in application support) and reinstall the workflow, but for some reason it's not asking me about my sqlite so I get :

Starting debug for 'ZotQuery'

[ERROR: alfred.workflow.action.script] Code 1: 15:16:48 workflow.py:1263 ERROR    local variable 'default_path' referenced before assignment
Traceback (most recent call last):
  File "/Users/Chris/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.39A8D121-FA1B-447E-86CB-E48415514B69/workflow/workflow.py", line 1261, in run
    func(self)
  File "zotquery.py", line 1495, in main
    print z_configurator.config()
  File "zotquery.py", line 520, in config
    return self.set_zot_paths()
  File "zotquery.py", line 570, in set_zot_paths
    """.format(self.ui_scpt, default_path)
UnboundLocalError: local variable 'default_path' referenced before assignment
15:16:53 workflow.py:1263 ERROR    [Errno 2] No such file or directory: u'/Users/Chris/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/paths.json'
Traceback (most recent call last):
  File "/Users/Chris/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.39A8D121-FA1B-447E-86CB-E48415514B69/workflow/workflow.py", line 1261, in run
    func(self)
  File "zotquery.py", line 1489, in main
    z_cacher = ZotCache(_force, _personal_only)
  File "zotquery.py", line 170, in __init__
    self.zot_db = self.get_path('database_path')
  File "zotquery.py", line 207, in get_path
    with open(self.wf_obj.datafile("paths.json"), 'r') as file_obj:
IOError: [Errno 2] No such file or directory: u'/Users/Chris/Library/Application Support/Alfred 2/Workflow Data/com.hackademic.zotquery/paths.json'
Link to comment

It looks like there was a bug in the config script. I have a fallback if ZotQuery cannot find all the necessary Zotero paths where you select the relevant folder or file within a dialog box. That had a small bug which I didn't catch because the script always can automatically grab my data. I just uploaded version 8.0.4 to Packal. Try that out.

stephen

Link to comment
[ERROR: alfred.workflow.action.script] Code 0: execution error: Expected expression but found end of line. (-2741)
execution error: Expected expression but found end of line. (-2741)
354:356: syntax error: A end of line can’t go after this “)”. (-2740)

Getting that now. 

Link to comment

Hello, 

I followed the configuration directions, but that didn't generate the database files: 

 

https://dl.dropboxusercontent.com/u/18116710/Screenshots/Screenshot_2014-05-28_14.59.42.png

 

When I set the configuration or I use "database caching" I get: 

 

https://dl.dropboxusercontent.com/u/18116710/Screenshots/Screenshot_2014-05-28_15.01.9.png

 

I am using Maverick, an standalone version of Zotero (4.0.2), and ZotQuery (8.0.3)

 

Any ideas?

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...