Ejemplo n.º 1
0
    def __init__(
        self,
        mainjob,
        instance_name,
        parent=None,
        id=wx.ID_ANY,
        title=None,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.DEFAULT_FRAME_STYLE,
        version=None,
        working_path=None,
        taskbar_icon=None,
    ):
        u""""""

        self.mainjob = mainjob
        self.instance_name = instance_name
        self.version = version
        self.default_title = "SwitchHosts! %s" % self.version
        self.sudo_password = ""

        ui.Frame.__init__(self, parent, id, title or self.default_title, pos,
                          size, style)

        self.taskbar_icon = taskbar_icon or TaskBarIcon(self)
        if taskbar_icon:
            self.taskbar_icon.setMainFrame(self)

        self.latest_stable_version = "0"
        self.__sys_hosts_path = None
        self.local_encoding = co.getLocalEncoding()
        self.sys_type = co.getSystemType()

        if working_path:
            working_path = working_path.decode(self.local_encoding)
            self.working_path = working_path
            self.configs_path = os.path.join(self.working_path, "configs.json")
            self.hosts_path = os.path.join(self.working_path, "hosts")
            if not os.path.isdir(self.hosts_path):
                os.makedirs(self.hosts_path)

        self.active_fn = os.path.join(self.working_path, ".active")
        self.task_qu = Queue.Queue(4096)
        self.startBackThreads(2)
        self.makeHostsContextMenu()

        self.init2()
        self.initBind()

        self.task_qu.put(self.chkActive)
Ejemplo n.º 2
0
    def __init__(
        self,
        mainjob,
        instance_name,
        parent=None,
        id=wx.ID_ANY,
        title=None,
        pos=wx.DefaultPosition,
        size=wx.DefaultSize,
        style=wx.DEFAULT_FRAME_STYLE,
        version=None,
        working_path=None,
        taskbar_icon=None,
    ):
        u""""""

        self.mainjob = mainjob
        self.instance_name = instance_name
        self.version = version
        self.default_title = "SwitchHosts! %s" % self.version
        self.sudo_password = ""

        ui.Frame.__init__(self, parent, id, title or self.default_title, pos, size, style)

        self.taskbar_icon = taskbar_icon or TaskBarIcon(self)
        if taskbar_icon:
            self.taskbar_icon.setMainFrame(self)

        self.latest_stable_version = "0"
        self.__sys_hosts_path = None
        self.local_encoding = co.getLocalEncoding()
        self.sys_type = co.getSystemType()

        if working_path:
            working_path = working_path.decode(self.local_encoding)
            self.working_path = working_path
            self.configs_path = os.path.join(self.working_path, "configs.json")
            self.hosts_path = os.path.join(self.working_path, "hosts")
            if not os.path.isdir(self.hosts_path):
                os.makedirs(self.hosts_path)

        self.active_fn = os.path.join(self.working_path, ".active")
        self.task_qu = Queue.Queue(4096)
        self.startBackThreads(2)
        self.makeHostsContextMenu()

        self.init2()
        self.initBind()

        self.task_qu.put(self.chkActive)
Ejemplo n.º 3
0
import wx
from wx import stc
import ui
import urllib
import re
import traceback
import random
import Queue
import time
from Hosts import Hosts
from TaskbarIcon import TaskBarIcon
from BackThreads import BackThreads
import common_operations as co
import lang

sys_type = co.getSystemType()

if sys_type == "linux":
    # Linux
    try:
        import pynotify
	pynotify.init("SwitchHosts!")
    except ImportError:
        pynotify = None
elif sys_type == "mac":
    # Mac
    import gntp.notifier

    growl = gntp.notifier.GrowlNotifier(
        applicationName="SwitchHosts!",
        notifications=["New Updates", "New Messages"],
Ejemplo n.º 4
0
import simplejson as json
import wx
from wx import stc
import ui
import urllib
import re
import traceback
import random
import Queue
from Hosts import Hosts
from TaskbarIcon import TaskBarIcon
from BackThreads import BackThreads
import common_operations as co
import lang

sys_type = co.getSystemType()

if sys_type == "linux":
    # Linux
    try:
        import pynotify
    except ImportError:
        pynotify = None
elif sys_type == "mac":
    # Mac
    import gntp.notifier

    growl = gntp.notifier.GrowlNotifier(
        applicationName="SwitchHosts!",
        notifications=["New Updates", "New Messages"],
        defaultNotifications=["New Messages"],