vspinu / zotelo

Manage zotero collections from emacsemacs.
121 stars 8 forks source link

zotelo-update-database NS_ERROR_FAILURE #10

Closed ArthurTu closed 11 years ago

ArthurTu commented 11 years ago

I am using zotelo with emacs on cygwin.

I added a fix to zotelo source code to handle to file name convertion, and expected it to work.

After zotelo-update-database, error occured.

 zotelo message [Sun Apr 28 18:34:02 2013]
 Executing command: 

 (moz-command (format zotelo--export-collection-js 'C:\cygwin\home\Arthur\test.bib' 2))

 translated as:

var zotelo_filename=('C:\cygwin\home\Arthur\test.bib');
var zotelo_id = 2;
var zotelo_translator_id = '9cb70025-a888-4a29-a210-93ec52da40d4';
var zotelo_prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('extensions.zotero.');
var zotelo_file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
var zotelo_recColl = zotelo_prefs.getBoolPref('recursiveCollections');
zotelo_file.initWithPath(zotelo_filename);
//split
var zotelo_zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
var zotelo_collection = true;
var zotelo_translator = new zotelo_zotero.Translate('export');
if (zotelo_id != 0){ //not all collections
    zotelo_collection = zotelo_zotero.Collections.get(zotelo_id);
    zotelo_translator.setCollection(zotelo_collection);
};
//split
if(zotelo_collection){
    zotelo_translator.setLocation(zotelo_file);
    zotelo_translator.setTranslator(zotelo_translator_id);
    zotelo_prefs.setBoolPref('recursiveCollections', true);
    zotelo_translator.translate();
    zotelo_prefs.setBoolPref('recursiveCollections', zotelo_recColl);
    zotelo_out=':MozOK:';
}else{
    zotelo_out='Collection with the id ' + zotelo_id + ' does not exist.';
};
//split
zotelo_out;

Updating 'test.bib' ...

 zotelo message [Sun Apr 28 18:34:02 2013]
 Moz-command finished

 zotelo message [Sun Apr 28 18:34:02 2013]
 Moz-command finished

 zotelo message [Sun Apr 28 18:34:02 2013]
 Moz-command finished
if: MozError: 
!!! [Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFileOutputStream.init]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://zotero/content/xpcom/translation/translate_firefox.js :: Zotero.Translate.IO.Write :: line 833"  data: no]

Details:

  name: NS_ERROR_FAILURE
  QueryInterface:
    function QueryInterface() {
        [native code]
    }
  message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIFileOutputStream.init]
  result: 2147500037
  filename: chrome://zotero/content/xpcom/translation/translate_firefox.js
  lineNumber: 833
  columnNumber: 0
  location: JS frame :: chrome://zotero/content/xpcom/translation/translate_firefox.js :: Zotero.Translate.IO.Write :: line 833
  inner: null
  data: null
  initialize:
    function initialize() {
        [native code]
    }
vspinu commented 11 years ago

You should be able to execute the translated code in firebug console:

var zotelo_filename=('C:\cygwin\home\Arthur\test.bib');
var zotelo_id = 2;
var zotelo_translator_id = '9cb70025-a888-4a29-a210-93ec52da40d4';
var zotelo_prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('extensions.zotero.');
var zotelo_file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
var zotelo_recColl = zotelo_prefs.getBoolPref('recursiveCollections');
zotelo_file.initWithPath(zotelo_filename);
//split
var zotelo_zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
var zotelo_collection = true;
var zotelo_translator = new zotelo_zotero.Translate('export');
if (zotelo_id != 0){ //not all collections
    zotelo_collection = zotelo_zotero.Collections.get(zotelo_id);
    zotelo_translator.setCollection(zotelo_collection);
};
//split
if(zotelo_collection){
    zotelo_translator.setLocation(zotelo_file);
    zotelo_translator.setTranslator(zotelo_translator_id);
    zotelo_prefs.setBoolPref('recursiveCollections', true);
    zotelo_translator.translate();
    zotelo_prefs.setBoolPref('recursiveCollections', zotelo_recColl);
    zotelo_out=':MozOK:';
}else{
    zotelo_out='Collection with the id ' + zotelo_id + ' does not exist.';
};
//split
zotelo_out;

You can run this in firebug or moz-repl console on some non-cygwin path and see if it has to do with cygwin or it is some firefox or zotero bug. I have not way to investigate this issue and I would appreciate if you can figure it out.

ArthurTu commented 11 years ago

Fixed in my pull request. This is the output of the correct code. Do notice the escape of backslashes in zotelo_filename.

 zotelo message [Sun Apr 28 19:25:12 2013]
 Executing command: 

 (moz-command (format zotelo--export-collection-js 'C:\\cygwin\\home\\Arthur\\test.bib' 2))

 translated as:

var zotelo_filename=('C:\\cygwin\\home\\Arthur\\test.bib');
var zotelo_id = 2;
var zotelo_translator_id = '9cb70025-a888-4a29-a210-93ec52da40d4';
var zotelo_prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefService).getBranch('extensions.zotero.');
var zotelo_file = Components.classes['@mozilla.org/file/local;1'].createInstance(Components.interfaces.nsILocalFile);
var zotelo_recColl = zotelo_prefs.getBoolPref('recursiveCollections');
zotelo_file.initWithPath(zotelo_filename);
//split
var zotelo_zotero = Components.classes['@zotero.org/Zotero;1'].getService(Components.interfaces.nsISupports).wrappedJSObject;
var zotelo_collection = true;
var zotelo_translator = new zotelo_zotero.Translate('export');
if (zotelo_id != 0){ //not all collections
    zotelo_collection = zotelo_zotero.Collections.get(zotelo_id);
    zotelo_translator.setCollection(zotelo_collection);
};
//split
if(zotelo_collection){
    zotelo_translator.setLocation(zotelo_file);
    zotelo_translator.setTranslator(zotelo_translator_id);
    zotelo_prefs.setBoolPref('recursiveCollections', true);
    zotelo_translator.translate();
    zotelo_prefs.setBoolPref('recursiveCollections', zotelo_recColl);
    zotelo_out=':MozOK:';
}else{
    zotelo_out='Collection with the id ' + zotelo_id + ' does not exist.';
};
//split
zotelo_out;

Updating 'test.bib' ...

 zotelo message [Sun Apr 28 19:25:12 2013]
 Moz-command finished

 zotelo message [Sun Apr 28 19:25:12 2013]
 Moz-command finished

 zotelo message [Sun Apr 28 19:25:12 2013]
 Moz-command finished

 zotelo message [Sun Apr 28 19:25:12 2013]
 Moz-command finished
'test.bib' updated successfully (BibTeX)