View Single Post
Old 11-05-2013, 03:47 AM   #14
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
That's indeed a lot leaner, especially since numeric_version is already a tuple, so version comparison is pretty straightforward.

Thanks Kovid!

Code:
#!/usr/bin/env python
## -*- coding: utf-8 -*-
if sys.version_info[0] > 2:
        import urllib.request as u
else:
        import urllib as u
from calibre.constants import numeric_version

if numeric_version < tuple(map(int, u.urlopen('http://calibre-ebook.com/downloads/latest_version').read()[:-1].split("."))):
        sys.exit(0)
else:
        sys.exit(1)
EDIT: newer version of update code here

Last edited by aleyx; 11-19-2013 at 04:58 PM.
aleyx is offline   Reply With Quote