Quote:
Originally Posted by Ladyrixx
I don't suppose you could share that? My Python is pretty much non-existent.
|
I will as soon as I get back from work ^^
Meaning, as soon as I get that monster SQL statement to actually work, instead of giving me either too much or no records. Grr.
EDIT:
So, here it is:
calibre-check.py:
Code:
#!/usr/bin/env python
## -*- coding: utf-8 -*-
import subprocess, tempfile, sys, os
if sys.version_info[0] > 2:
import urllib.request as u
else:
import urllib as u
from distutils.version import LooseVersion as ver
local_version = tempfile.TemporaryFile()
subprocess.call(["calibre-debug", '-c', "import calibre; print (calibre.__version__)"], stdout=local_version)
local_version.seek(0)
local_version = ver(local_version.read()[:-1])
remote_version = ver(u.urlopen('http://calibre-ebook.com/downloads/latest_version').read()[:-1])
if local_version < remote_version:
sys.exit(0)
else:
sys.exit(1)
In English: Get Calibre's version string, then get the online version; if the online version is higher, return 0, else return 1.
I'm sure someone can put it in a one-liner and integrate it to the current updater one-liner.
Or maybe integrate that (or a variation) to linux_installer.
Then, calibre-update.sh:
Code:
#!/bin/bash
if python calibre-check.py; then
sudo python -c "import sys; py3 = sys.version_info[0] > 2; u = __import__('urllib.request' if py3 else 'urllib', fromlist=1); exec(u.urlopen('http://status.calibre-ebook.com/linux_installer').read()); main(install_dir='/opt')"
else
echo "Calibre is up-to-date"
fi
Putting calibre-update.sh in a cron running Friday night every few hours would be the next step.
EDIT: newer version of update code
here