def __init__(self, program): super(Icon, self).__init__() self.icon_state_map = { STATE_CONNECTED: wx.Icon(static_path('enabled.png'), wx.BITMAP_TYPE_PNG), STATE_DISCONNECTED: wx.Icon(static_path('disabled.png'), wx.BITMAP_TYPE_PNG), None: wx.Icon(static_path('unknown.png'), wx.BITMAP_TYPE_PNG) } self.create_menu() self.program = program
def remove_tap(): # Only remove tap if there is a single tap running. # XXX Does this work on non-english Windows? if '1 matching device(s) found.' in _get_tap_status(): l.info('removing single tap device') subprocess.call([static_path('tap/tapinstall'), 'remove', TAP_NAME], startupinfo=subprocess_sui) else: l.info('several tap devices found - not removing any of them')
def run(self): if onWindows: ensure_tap_installed() executable = static_path('openvpn/openvpn') else: executable = 'openvpn' self.p = subprocess.Popen([executable, '--config', 'user.ovpn'], cwd=var_path('user'), stdout=subprocess.PIPE, startupinfo=subprocess_sui) while True: line = self.p.stdout.readline() if line == '': break line = line.strip() l.debug(line) if "Initialization Sequence Completed" in line: if self.on_connected: self.on_connected()
def _get_tap_status(): return subprocess.check_output([static_path('tap/tapinstall'), 'status', '*%s*' % TAP_NAME], startupinfo=subprocess_sui)
def install_tap(): subprocess.call([static_path('tap/tapinstall'), 'install', static_path('tap/OemWin2k.inf'), TAP_NAME], startupinfo=subprocess_sui)