Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Server

Notices

Reply
 
Thread Tools Search this Thread
Old 09-16-2021, 02:07 PM   #1
CubGeek
Connoisseur
CubGeek began at the beginning.
 
Posts: 52
Karma: 10
Join Date: Sep 2021
Location: Upstate NY, USA
Device: iPad Pro, Kindle basic
Question 'calibredb add' throws python error when calibre-server is running

Raspberry Pi 4 (8gb)
Raspbery Pi OS 64-bit (no, not ArchLinuxARM)
Calibre installed from the repos (yes, I know they're woefully out of date)

Code:
$ calibredb --verison
calibredb (Calibre 3.39.1)

$ python -c "import os; print(os.uname())"
('Linux', 'raspberrypi', '5.10.63-v8+', '#1453 SMP PREEMPT Tue Sep 14 15:00:30 BST 2021', 'aarch64')

$ python --version
Python 2.7.16

$ python3 --version
Python 3.7.3

$ cat /etc/default/locale
#  File generated by update-locale
LANG=en_US.UTF-8
I was able to get the server installed, created libraries, and I was then able to import books (mostly epubs from Humble Bundles). I then started the calibre-server and I can see, read, and download books through the web interface. And, once I enabled --with-auth and set up a user, I can now edit metadata through the web interface.

However, I’d like to be able to add books to the server without stopping the server then restarting it afterwards. It seems, according to the messages I’ve seen and the manual that calibredb can do this. So, I’m currently trying to figure out how. Looking at the manual page for calibredb, I saw how to list the library_id for each of the libraries on the content server:

Code:
$ calibredb —with-library 'http://localhost:8080/#-' list —username MyUser —password MyPass
cookbooks
fiction
non-fiction
technical
Okay, so now I’ve got a library_id and I attempt to put it into a command:
Code:
calibredb add /path-to-books-to-add-to-library/cookbooks/* —with-library 'http://localhost:8080/#cookbooks' —username MyUser —password MyPass
This result in the following
Code:
Traceback (most recent call last):
File “/usr/bin/calibredb”, line 20, in <module>
     sys.exit(main())
File “/usr/lib/calibre/calibre/db/cli/main.py”, line 255, in main
     return run_cmd(cmd, opts, args[1:], DBCtx(opts))
File “/usr/lib/calibre/calibre/db/cli/main.py”, line 55, in run_cmd
     ret = m.main(opts, args, dbctx)
File “/usr/lib/calibre/calibre/db/cli/cmd_add.py”, line 366, in main
     identifiers, lcodes, opts.filters
File “/usr/lib/calibre/calibre/db/cli/cmd_add.py”, line 164, in do_add
     oidentifiers, olanguages
File “/usr/lib/calibre/calibre/db/cli/main.py”, line 191, in run
     return self.remote_run(name, m, args)
File “/usr/lib/calibre/calibre/db/cli/main.py”, line 213, in remote_run
     res = self.br.open_novisit(rq)
File “/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py”, line 199, in open_novisit
     return self._mech_open(url, data, visit=False, timeout=timeout)
File “/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py”, line 230, in _mech_open
     response = UserAgentBase.open(self, request, data)
File “/usr/lib/python2.7/dist-packages/mechanize/_opener.py”, line 193, in open
     response = urlopen(self, req, data)
File “/usr/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py”, line 344, in _open
    ’_open’, req)
File “/usr/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py”, line 332, in _call_chain
     result = func(args)
File “/usr/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py”, line 1142, in http_open
     return self.do_open(httplib.HTTPConnection, req)
File “/usr/lib/python2.7/dist-packages/mechanize/_urllib2_fork.py”, line 1115, in do_open
     h.request(req.get_method(), req.get_selector(), req.data, headers)
File “/usr/lib/python2.7/httplib.py”, line 1058, in request
     self._send_request(method, url, body, headers)
File “/usr/lib/python2.7/httplib.py”, line 1098, in _send_request
     self.endheaders(body)
File “/usr/lib/python2.7/httplib.py”, line 1054, in endheaders
     self._send_output(message_body)
File “/usr/lib/python2.7/httplib.py”, line 890, in _send_output
     msg += message_body
UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0x9e in position 0: invalid start byte
However, if I stop the server, add the books (substituting the path to the library for the http-and-library_id path), and then start the server again, it works flawlessly:
Code:
$ sudo systemctl stop calibre-server

$ calibredb add /path-to-books-to-add-to-library/cookbooks/* --with-library ~/calibre-library/cookbooks --username MyUser --password MyPass
Added book ids: 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26

$ sudo systemctl start calibre-server
The books are added and I can then see/download/read/edit metadata.

Searching, I saw this post by KovidGoyal that showed an equal sign between the --with-library and the http-and-library_id path and no single quotes like when I got the library_id listing. So, I gave that a shot.

Code:
calibredb add /path-to-books-to-add-to-library/cookbooks/* —with-library=http://localhost:8080/#cookbooks —username MyUser —password MyPass
Similar results. I can add books if I stop the server, add them and then start the server again. But using calibredb (which the manual says is used to connect to a server that's running) throws an error. What am I missing or have misconfigured?
CubGeek is offline   Reply With Quote
Old 09-16-2021, 10:36 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 44,572
Karma: 24495948
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Your version of calibre is too old.
kovidgoyal is online now   Reply With Quote
Advert
Old 09-17-2021, 12:01 PM   #3
CubGeek
Connoisseur
CubGeek began at the beginning.
 
Posts: 52
Karma: 10
Join Date: Sep 2021
Location: Upstate NY, USA
Device: iPad Pro, Kindle basic
Quote:
Originally Posted by kovidgoyal View Post
Your version of calibre is too old.
Ah. The functionality of calibredb to interface with a currently-running instance of calibre-server was added in versions after the one available in the repos.

Good to know that. Thank you.

While it's unfortunate that the ARM repos are so out-of-date, I do appreciate the software and the effort that's gone into creating it. As well as your respose here. Thanks! While i wait for repos to get updated to something approximating "current" i'll set up a cron job to stop the server, the one to import books, and then one to restart the server.

best wishes!
CubGeek is offline   Reply With Quote
Reply

Tags
arm64, calibredb, python error, raspberry pi 4


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Python error when accessing content server with calibredb drawson1 Library Management 1 06-19-2018 01:08 PM
calibredb cannot add with content server running apiontek Calibre 10 08-04-2017 05:50 AM
Calibre-server / Linux don't see calibreDB update when it's running aurigod Calibre 13 11-25-2015 03:44 AM
Running calibre-server with auto add Hiryu Library Management 21 12-05-2014 07:15 PM
Add a book from another computer running calibre server gandor62 Library Management 2 06-29-2011 12:24 PM


All times are GMT -4. The time now is 07:55 AM.


MobileRead.com is a privately owned, operated and funded community.