2

So I have an overlay firefox extension with a python script I want to run when the user click a menu. My question is whether it is possible to run the script from the firefox extension? I did some research and found nsIProcess as a possible solution, but I couldn't get it to work with the code below. Any help is much appreciated.

replay: function(){
  var file = Components.classes["@mozilla.org/file/local;1"]
                 .createInstance(Components.interfaces.nsIFile);
  file.initWithPath("~/Library/Application Support/Firefox/Profiles/[profiles_name]/extensions/helloworld@xulschool.com/content/getInput.py");

  var process = Components.classes["@mozilla.org/process/util;1"]
                    .createInstance(Components.interfaces.nsIProcess);
  process.init(file);

  var args = [];
  process.run(false, args, args.length);
}

EDIT: So far I've managed to navigate to the python file without any problem, but when I try running it with process.run, I receive this error code:

NS_ERROR_FAILURE: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIProcess.run]

I have no idea what caused this. Could it be my python code?

user3842589
  • 21
  • 1
  • 3
  • It's possible. See this topic here he's working with py file and solution explains a bit about it: [Select A File Within Firefox Add-On Directory](http://stackoverflow.com/questions/24900845/select-a-file-within-firefox-add-on-directory/24906114#24906114) – Noitidart Jul 30 '14 at 05:46
  • 2
    This is essentially the same question as http://stackoverflow.com/q/24900845/484441 except for overlay add-ons instead of SDK add-ons. Remove the `require` calls, and replace the `self.data.url` with something like `chrome://myaddon/content/getInput.py` and you should be done – nmaier Jul 30 '14 at 09:44

0 Answers0