示例#1
0
 def get_custom_conf_path(cls):
     if not CommonUtil.check_platform()[0] == "Windows":
         path = os.path.expanduser('~/.custom.hosts')
         if not os.path.isfile(path):
             path = os.path.expanduser('~/custom.hosts')
         if os.path.isfile(path):
             return path
     return None
示例#2
0
 def get_custom_conf_path(cls):
     if not CommonUtil.check_platform()[0] == "Windows":
         path = os.path.expanduser('~/.custom.hosts')
         if not os.path.isfile(path):
             path = os.path.expanduser('~/custom.hosts')
         if os.path.isfile(path):
             return path
     return None
示例#3
0
 def set_platform(self):
     """
     Set the information of current operating system platform.
     """
     system, hostname, path, encode, flag = CommonUtil.check_platform()
     self.platform = system
     self.hostname = hostname
     self.hosts_path = path
     self.plat_flag = flag
     if encode == "win_ansi":
         self.sys_eol = "\r\n"
     else:
         self.sys_eol = "\n"
示例#4
0
 def set_platform(self):
     """
     Set the information of current operating system platform.
     """
     system, hostname, path, encode, flag = CommonUtil.check_platform()
     self.platform = system
     self.hostname = hostname
     self.hosts_path = path
     self.plat_flag = flag
     if encode == "win_ansi":
         self.sys_eol = "\r\n"
     else:
         self.sys_eol = "\n"
示例#5
0
 def set_platform(cls):
     """
     Set the information about current operating system.
     Modified from tui.hostsutil.HostsUtil.set_platform()
     """
     system, hostname, path, encode, flag = CommonUtil.check_platform()
     cls.platform = system
     cls.hostname = hostname
     cls.hosts_path = path
     if encode == "win_ansi":
         cls.sys_eol = "\r\n"
     else:
         cls.sys_eol = "\n"
示例#6
0
 def set_platform(self):
     """
     Set the information about current operating system.
     """
     system, hostname, path, encode, flag = CommonUtil.check_platform()
     color = "GREEN" if flag else "RED"
     self.platform = system
     self.statusinfo[1][1] = system
     self.hostname = hostname
     self.hosts_path = path
     self.statusinfo[1][2] = color
     if encode == "win_ansi":
         self.sys_eol = "\r\n"
     else:
         self.sys_eol = "\n"
示例#7
0
 def set_platform(self):
     """
     Set the information about current operating system.
     """
     system, hostname, path, encode, flag = CommonUtil.check_platform()
     color = "GREEN" if flag else "RED"
     self.platform = system
     self.statusinfo[1][1] = system
     self.hostname = hostname
     self.hosts_path = path
     self.statusinfo[1][2] = color
     if encode == "win_ansi":
         self.sys_eol = "\r\n"
     else:
         self.sys_eol = "\n"
示例#8
0
    def launch_tui(cls):
        """
        Start a Text-based User Interface (TUI) session of
        `Hosts Setup Utility`.

        .. note:: This is a `classmethod`.
        """

        # Set code page for Windows
        system = CommonUtil.check_platform()[0]
        cp = "437"
        if system == "Windows":
            chcp = os.popen("chcp")
            cp = chcp.read().split()[-1]
            chcp.close()
            os.popen("chcp 437")

        main = tui.HostsUtil()
        main.start()

        # Restore the default code page for Windows
        if system == "Windows":
            os.popen("chcp " + cp)
示例#9
0
    def launch_tui(cls):
        """
        Start a Text-based User Interface (TUI) session of
        `Hosts Setup Utility`.

        .. note:: This is a `classmethod`.
        """

        # Set code page for Windows
        system = CommonUtil.check_platform()[0]
        cp = "437"
        if system == "Windows":
            chcp = os.popen("chcp")
            cp = chcp.read().split()[-1]
            chcp.close()
            os.popen("chcp 437")

        main = tui.HostsUtil()
        main.start()

        # Restore the default code page for Windows
        if system == "Windows":
            os.popen("chcp " + cp)
示例#10
0
        for name_format in excludes:
            ex_files.extend(glob.glob(file_path(name_format)))
        for name_format in includes:
            files = glob.glob(file_path(name_format))
            for src_file in files:
                if src_file not in ex_files:
                    tar_path = os.path.join(prefix + VERSION,
                                            src_file[rel_len:])
                    tar.add(src_file, tar_path)
                    print "compressing: %s" % src_file
        tar.close()
        exit(1)

from util import CommonUtil

system = CommonUtil.check_platform()[0]
if system == "Windows":
    # Build binary executables for Windows
    import struct
    import zipfile
    from distutils.core import setup
    import py2exe

    # Set working directories
    WORK_DIR = SCRIPT_DIR + "work/"
    DIR_NAME = "HostsTool"
    DIST_DIR = WORK_DIR + DIR_NAME + '/'
    WIN_OPTIONS = {
        "includes": ["sip"],
        "excludes": ["_scproxy", "_sysconfigdata"],
        "dll_excludes": ["MSVCP90.dll"],
示例#11
0
        for name_format in excludes:
            ex_files.extend(glob.glob(file_path(name_format)))
        for name_format in includes:
            files = glob.glob(file_path(name_format))
            for src_file in files:
                if src_file not in ex_files:
                    tar_path = os.path.join(prefix + VERSION,
                                            src_file[rel_len:])
                    tar.add(src_file, tar_path)
                    print "compressing: %s" % src_file
        tar.close()
        exit(1)

from util import CommonUtil

system = CommonUtil.check_platform()[0]
if system == "Windows":
    # Build binary executables for Windows
    import struct
    import zipfile
    from distutils.core import setup
    import py2exe

    # Set working directories
    WORK_DIR = SCRIPT_DIR + "work/"
    DIR_NAME = "HostsTool"
    DIST_DIR = WORK_DIR + DIR_NAME + '/'
    WIN_OPTIONS = {
        "includes": ["sip"],
        "excludes": ["_scproxy", "_sysconfigdata"],
        "dll_excludes": ["MSVCP90.dll"],