home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1320 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  3.3 KB  |  80 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __license__ = 'GPL v3'
  5. __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
  6. import traceback
  7. from PyQt4.Qt import QThread, pyqtSignal, Qt, QUrl
  8. import mechanize
  9. from calibre.constants import __appname__, __version__, iswindows, isosx
  10. from calibre import browser
  11. from calibre.utils.config import prefs
  12. from calibre.gui2 import config, dynamic, question_dialog, open_url
  13. URL = 'http://status.calibre-ebook.com/latest'
  14.  
  15. class CheckForUpdates(QThread):
  16.     update_found = pyqtSignal(object)
  17.     INTERVAL = 86400
  18.     
  19.     def __init__(self, parent):
  20.         QThread.__init__(self, parent)
  21.  
  22.     
  23.     def run(self):
  24.         while True:
  25.             
  26.             try:
  27.                 br = browser()
  28.                 req = mechanize.Request(URL)
  29.                 req.add_header('CALIBRE_VERSION', __version__)
  30.                 if iswindows:
  31.                     pass
  32.                 elif isosx:
  33.                     pass
  34.                 
  35.                 req.add_header('CALIBRE_OS', 'oth')
  36.                 req.add_header('CALIBRE_INSTALL_UUID', prefs['installation_uuid'])
  37.                 version = br.open(req).read().strip()
  38.                 if version and version != __version__ and len(version) < 10:
  39.                     self.update_found.emit(version)
  40.             except:
  41.                 traceback.print_exc()
  42.  
  43.             self.sleep(self.INTERVAL)
  44.  
  45.  
  46.  
  47. class UpdateMixin(object):
  48.     
  49.     def __init__(self, opts):
  50.         if not opts.no_update_check:
  51.             self.update_checker = CheckForUpdates(self)
  52.             self.update_checker.update_found.connect(self.update_found, type = Qt.QueuedConnection)
  53.             self.update_checker.start()
  54.         
  55.  
  56.     
  57.     def update_found(self, version):
  58.         if iswindows:
  59.             pass
  60.         elif isosx:
  61.             pass
  62.         
  63.         os = 'linux'
  64.         url = 'http://calibre-ebook.com/download_%s' % os
  65.         self.status_bar.new_version_available(version, url)
  66.         if config.get('new_version_notification') and dynamic.get('update to version %s' % version, True):
  67.             if question_dialog(self, _('Update available'), _('%s has been updated to version %s. See the <a href="http://calibre-ebook.com/whats-new">new features</a>. Visit the download page?') % (__appname__, version)):
  68.                 if iswindows:
  69.                     pass
  70.                 elif isosx:
  71.                     pass
  72.                 
  73.                 url = 'http://calibre-ebook.com/download_' + 'linux'
  74.                 open_url(QUrl(url))
  75.             
  76.             dynamic.set('update to version %s' % version, False)
  77.         
  78.  
  79.  
  80.