View Single Post
Old 11-04-2013, 01:31 PM   #7
aleyx
Addict
aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.aleyx can self-interpret dreams as they happen.
 
Posts: 250
Karma: 20386
Join Date: Sep 2010
Location: France
Device: Bookeen Diva, Kobo Clara BW
Quote:
Originally Posted by Ladyrixx View Post
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

Last edited by aleyx; 11-21-2013 at 02:05 PM.
aleyx is offline   Reply With Quote