I wrote a python cgi script that receives the book file + some text from an html form. The scripts saves the file without a problem (in a temp dir: /opt/bibliotecha/tmp_bookcase/), however I am trying to use calibredb tool to add it to calibre library, but I am not succeeding.
I isolated the problematic part into the following script;
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import cgi
import cgitb; cgitb.enable()
print "Content-type: text/html"
print
import os, subprocess
tmp_upload_path = "/opt/bibliotecha/tmp_bookcase/"
tmp_path_book = tmp_upload_path + "Vila-Matas,Enrique-Dublinesque(NewDirections,2012).epubVila-Matas,Enrique-Dublinesque(NewDirections,2012).epub"
subprocess.call(["calibredb", "add", tmp_path_book])
If I call the script from the terminal, it does what is supposed to do.
If I call the script from the browser, I get the following message:
No write acces to /var/www/.config/calibre using a temporary dir instead
I believe the error might have to do with the fact that when the script is called from the browser it users a different user and group. But how could calibre don't complain about that?
I found a thread that seems to address the same problem https://bugs.launchpad.net/calibre/+bug/1299635 and they mention the environment on runs calibre in is the having to be the same in php (in their case) and the console.
but I don't really get the calibre environment, never heard about it.
Any hints?? :D
a