home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1478 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  2.5 KB  |  69 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. __license__ = 'GPL v3'
  6. __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
  7. __docformat__ = 'restructuredtext en'
  8. from calibre.constants import iswindows, islinux, isfreebsd
  9.  
  10. class LinuxNetworkStatus(object):
  11.     
  12.     def __init__(self):
  13.         
  14.         try:
  15.             import dbus
  16.             bus = dbus.SystemBus()
  17.             proxy = bus.get_object('org.freedesktop.NetworkManager', '/org/freedesktop/NetworkManager')
  18.             self.manager = dbus.Interface(proxy, 'org.freedesktop.DBus.Properties')
  19.         except:
  20.             self.manager = None
  21.  
  22.  
  23.     
  24.     def __call__(self):
  25.         if self.manager is None:
  26.             return True
  27.         
  28.         try:
  29.             connections = self.manager.Get('org.freedesktop.NetworkManager', 'ActiveConnections')
  30.             return len(connections) > 0
  31.         except:
  32.             self.manager is None
  33.             return True
  34.  
  35.  
  36.  
  37.  
  38. class WindowsNetworkStatus(object):
  39.     
  40.     def __init__(self):
  41.         plugins = plugins
  42.         import calibre.constants
  43.         self.winutil = plugins['winutil'][0]
  44.  
  45.     
  46.     def __call__(self):
  47.         if self.winutil is None:
  48.             return True
  49.         return self.winutil.internet_connected()
  50.  
  51.  
  52.  
  53. class DummyNetworkStatus(object):
  54.     
  55.     def __call__(self):
  56.         return True
  57.  
  58.  
  59. if iswindows:
  60.     pass
  61. elif islinux or isfreebsd:
  62.     pass
  63.  
  64. _network_status = DummyNetworkStatus()
  65.  
  66. def internet_connected():
  67.     return _network_status()
  68.  
  69.