Jump to content

ZotQuery: an Alfred workflow for Zotero


Recommended Posts

Indeed, I forgot that before my last attempt. Did so in the mean time with the same old result:

Here an Alfred2 report from the console:

2014.01.11 23:43:37,789 Alfred 2[234]: [ERROR] Script XML Parse Error occured Error Domain=NSXMLParserErrorDomain Code=4 "The operation couldn’t be completed. (NSXMLParserErrorDomain error 4.)"
 

Edited by kithairon
Link to comment

I've had time to give the latest update a whirl. After deleting the former build, installing the latest build, editing the .json file, and updating the cache via z:cache. I'm getting the same results; Alfred returns a fallback search. The link below provides the output.log, debug.log, and a screenshot of what's showing up in my console when I attempted to execute the workflow. I should add that I'm eager to provide any assistance I possibly can in resolving this issue. The benefits this workflow will provide to Mac users (who also happen to do a lot of research/ academic writing) will be manifold and I'm happy to participate in testing. Thanks again smarg19 for making this workflow possible.  

 

https://www.dropbox.com/sh/d5zcnq45dbc9g8x/xkn40iQkSX

Link to comment

Dang. Sorry this isn't working. Can you open the action_update-caches.py file and copy lines 450-460 for me? I'm wondering if you have an older version (I test and change and upload and sometimes forget that I left the debugging code in the original). There was a moment where I had commented out the actual writing to file. If you have these lines, however, in the code in that area:

 

# Write final, formatted json to Alfred cache
cache = alp.cache(join='zotero_db.json')
cache_file = open(cache, 'w+')
cache_file.write(final_json.encode('utf-8'))
cache_file.close()
 
then the script is writing the cache. If that's the case, can you actually go to the cache folder (as your log states, it is here: /Users/matthewculbreath/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.zotquery/zotero_db.json) and take a screen shot. If the .json file is there, open it. Also, can you try some of the other queries. For each one (zot:t and zot:a in particular), after you run it, screenshot the output.log file (it rewrites each time, so you have to screencapture before you run another query.)
Link to comment
for jtem in att_res:

if item['id'] == jtem['item']:

item['attachments'].append(jtem['attachment'])

 

try:

final_json = json.dumps(db_res, sort_keys=False, indent=4, separators=(',', ': '))

 

# Write final, formatted json to Alfred cache

cache = alp.cache(join='zotero_db.json')

cache_file = open(cache, 'w+')

cache_file.write(final_json.encode('utf-8'))
Link to comment

Ok, here's a link to screenshots of how lines 450-460 appear in the script. I was unable to locate any cache file in - /Users/matthewculbreath/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/com.hackademic.zotquery/zotero_db.json

The com.hackademic.zotquery folder was present but appeared to be empty even when I tried to reveal any hidden items with XtraFinder. I looked again using Forklift's "Show Invisible Items" view and got the same result. I've included screenshots of these views as well. Let me know if I'm looking in the wrong place.  

 

https://www.dropbox.com/sh/w5dijv5xkonnvo6/uD9wWr9crc

Edited by culb0743
Link to comment

The problem isn't the API key. The query scripts search the zotero_db.json file, and the error says that it can't find it. In order to debug this, I think we'll need better communication. I'm going to DM you and see if we can do a Google Hangout. We'll need some real-time interaction. I'm stumped to be honest.

Link to comment

The problem is clearly in the action_update-caches.py script, since the error says that it can't find the cache. But your logs say that it is running properly, which should mean that it is creating the file. Does your workflow folder have a test_space.py script? It should. Try opening it, deleting whatever is in there (this is my debugging script) and paste this code in there and run it?

 

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import alp
import os
from _zotquery import get_zotero_db
 
zotero_path = get_zotero_db()
clone_database = os.path.join(alp.cache(), "zotquery.sqlite")
 
print zotero_path
print '- - -'
print clone_database
Edited by smarg19
Link to comment

Wait. When you run z:cache, what does the Notification say?

 

If it doesn't say "Final Success! Created JSON cache of Zotero database.", then re-install the new workflow on the GitHub page and try running z:cache again. 

Edited by smarg19
Link to comment

Delighted to see you working hard and to find updates this morning. Sorry to report though that I'm now getting a "Setup failed! Cannot locate and clone Zotero database" in Output. Have reinstalled the workflow, changed the .json file with my ID and key and run z:cache. Have also deleted contents of the test_space.py with what you posted in the thread – no difference. (My Zotero is fine, database accessible). Culb0743 is using OS 10.9, I'm still on 10.8.5. Let me know if you have any further ideas.

Link to comment

Hmm. This means that there is an error in these three lines:

zotero_path = get_zotero_db()
clone_database = os.path.join(alp.cache(), "zotquery.sqlite")
shutil.copyfile(zotero_path, clone_database)
 
My guess would be the first. Can you put this code in the test_space.py script and run it, then tell me exactly what the console reports:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import alp
import os
from _zotquery import get_zotero_db
 
zotero_path = get_zotero_db()
clone_database = os.path.join(alp.cache(), "zotquery.sqlite")
 
print clone_database
print '- - -'
print zotero_path
Link to comment

Here my console output after pasting your code into my test_space.py

2014.01.12 10:46:50,902 system_profiler[26763]: Error -50 (ffffffce) occurred reading DPCD register data in System Profiler.
2014.01.12 10:46:50,903 system_profiler[26763]: Error -50 (ffffffce) occurred reading DPCD register data in System Profiler.
2014.01.12 10:46:50,903 system_profiler[26763]: Error -50 (ffffffce) occurred reading HDCP register data in System Profiler.
2014.01.12 10:47:17,014 nvALT[226]: remote: 0 updates
 

Link to comment

kithairon. Those errors are truly odd. Typically, when a script has an error and you run it, the error is reported in a line number. For example:

Traceback (most recent call last):
  File "/Users/smargheim/Library/Application Support/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.E127B2CC-1F13-4485-AF32-4022D5E52A6F/test_space.py", line 10, in <module>
    print clone_database
NameError: name 'clone_database' is not defined

What you have copied doesn't report any line numbers and is truly vague (i.e., I'm guessing, system level). Are you certain you are attempting to execute the test_space.py script in a program that can run Python scripts, such as TextMate, Sublime Text, or CodeRunner (these are all the ones I've used in the past). If you're not, you can download a free version of Sublime Text via their website and run it there. 

 

I honestly cannot help you if these are the errors the script is producing, as these are not errors in the workflow, but in the system (i.e. on you Mac, not in the Alfred system). My guess is, tho, that these are errors in execution, not your Mac, and we can find a better way to debug.

 

- - -

@Shawn Rice, 

Thanks for Packal! I'm actually uploading an updated version now with better icons (each item type (article, book, chapter, conference, etc) now has its own +attachment icon, instead of a single attachment icon) as well as some bug fixes. For all interested in this workflow, please download from Packal and check for updates. I'm a tinkerer who is generally always looking to improve, so having an easy way to upgrade the workflow will be in your best interest.

Link to comment

One of the main reasons I wanted to make Packal was just so that people could have a canonical place to find workflows and easily find updates without having to constantly troll the forums. When I finish the update-workflow, then things should become much, much easier for everyone; sadly, that project needs to go on hold for at least a week or two so I can write a dissertation chapter or two. Damn important things getting in the way of more fun things.

Link to comment

Ain't that the truth. My grad classes start back up on Wednesday, and things will slow down on the tinkering/coding front then. Which is sad. But I'm just glad that I got this finished before then, because I'm going to use the hell out of this.

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...