Skip to content
This repository has been archived by the owner on Aug 3, 2024. It is now read-only.

Commit

Permalink
Merge branch 'HostsUtl-Desktop-Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
huhamhire committed Dec 10, 2013
2 parents 5ba9aa9 + 12eab09 commit 1612f8f
Show file tree
Hide file tree
Showing 72 changed files with 2,793 additions and 2,435 deletions.
10 changes: 5 additions & 5 deletions _build.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import sys
import shutil

from hostsutl import __version__
from gui.hostsutil import __version__

SCRIPT = "hostsutl.py"
SCRIPT = "hostsutil.py"

SCRIPT_DIR = os.getcwd() + '/'
RELEASE_DIR = "../release/"
Expand Down Expand Up @@ -69,7 +69,7 @@
]
),
("theme", [
"theme/darkdefault.qss",
"theme/default.qss",
]
),
"LICENSE",
Expand Down Expand Up @@ -200,7 +200,7 @@
from setuptools import setup
# Set working directories
WORK_DIR = SCRIPT_DIR + "work/"
RES_DIR = SCRIPT_DIR + "mac_res/"
RES_DIR = SCRIPT_DIR + "res/"
APP_NAME = "HostsUtl.app"
APP_PATH = WORK_DIR + APP_NAME
DIST_DIR = APP_PATH + "/Contents/"
Expand Down Expand Up @@ -268,7 +268,7 @@
# Pack APP to DMG file
VDMG_DIR = WORK_DIR + "package_vdmg/"
DMG_TMP = WORK_DIR + "pack_tmp.dmg"
DMG_RES_DIR = RES_DIR + "dmg_resource/"
DMG_RES_DIR = RES_DIR + "dmg/"
VOL_NAME = "HostsUtl"
DMG_NAME = VOL_NAME + "-mac-gpl-" + VERSION + ".dmg"
DMG_PATH = WORK_DIR + DMG_NAME
Expand Down
15 changes: 15 additions & 0 deletions gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __init__.py:
#
# Copyleft (C) 2014 - huhamhire <[email protected]>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================

from hostsutil import HostsUtil

__all__ = ["HostsUtil"]
41 changes: 41 additions & 0 deletions gui/__list_trans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# __list_trans.py : Name of items from the function list to be localized
#
# Copyleft (C) 2014 - huhamhire hosts team <[email protected]>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING
# THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE.
# =====================================================================

__author__ = "huhamhire <[email protected]>"

from util_ui import _translate

# Name of items from the function list to be localized
# __list_trans (list): A list containing names of function list items
# for translator to translate.
__list_trans = [
_translate("Util", "google(cn)", None),
_translate("Util", "google(hk)", None),
_translate("Util", "google(us)", None),
_translate("Util", "google-apis(cn)", None),
_translate("Util", "google-apis(us)", None),
_translate("Util", "activation-helper", None),
_translate("Util", "facebook", None),
_translate("Util", "twitter", None),
_translate("Util", "youtube", None),
_translate("Util", "wikipedia", None),
_translate("Util", "institutions", None),
_translate("Util", "steam", None),
_translate("Util", "others", None),
_translate("Util", "adblock-hostsx", None),
_translate("Util", "adblock-mvps", None),
_translate("Util", "adblock-mwsl", None),
_translate("Util", "adblock-yoyo", None), ]
58 changes: 58 additions & 0 deletions gui/_checkconn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _checkconn.py:
#
# Copyleft (C) 2014 - huhamhire <[email protected]>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================

__author__ = "huhamhire <[email protected]>"

from PyQt4 import QtCore

import sys
sys.path.append("..")
from util import CommonUtil


class QSubChkConnection(QtCore.QThread):
"""A class to check connection with server
QSubChkConnection is a subclasse of PyQt4.QtCore.QThread. This class
contains methods to check the network connection with a specified mirror.
The instance of this class should be created in an individual thread. And
the object instance of HostsUtil class should be set as parent here.
Attribute:
trigger (obj): A PyQt4.QtCore.pyqtSignal object to emit suatus signal
to the main dialog. The meaning of the signal arguments is listed
here:
-1 -> checking..., 0 -> Failed, 1 -> OK.
"""
trigger = QtCore.pyqtSignal(int)

def __init__(self, parent=None):
"""Initialize a new instance of this class - Private Method
Get mirror settings from the main dialog to check the connection.
Args:
parent (obj): An instance of HostsUtil object to get settings
from.
"""
super(QSubChkConnection, self).__init__(parent)
self.link = parent.mirrors[parent._mirr_id]["test_url"]

def run(self):
"""Check connection - Public Method
Operations to check the network connection with a specified mirror.
"""
self.trigger.emit(-1)
status = CommonUtil.check_connection(self.link)
self.trigger.emit(status)
67 changes: 67 additions & 0 deletions gui/_checkupdate.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# _checkupdate.py:
#
# Copyleft (C) 2014 - huhamhire <[email protected]>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
# =====================================================================

__author__ = "huhamhire <[email protected]>"

import json
import socket
import urllib
from PyQt4 import QtCore

from util_ui import _translate


class QSubChkUpdate(QtCore.QThread):
"""A class to check update info of the latest data file
QSubChkConnection is a subclasse of PyQt4.QtCore.QThread. This class
contains methods to retrieve the metadata of the latest hosts data file.
The instance of this class should be created in an individual thread. And
the object instance of HostsUtil class should be set as parent here.
Attribute:
trigger (obj): A PyQt4.QtCore.pyqtSignal object to emit suatus signal
to the main dialog. The meaning of the signal is listed here:
(dict) -> (update_info)
update_info (dict): A dictionary containing metadata of the
latest hosts data file.
"""
trigger = QtCore.pyqtSignal(dict)

def __init__(self, parent=None):
"""Initialize a new instance of this class - Private Method
Get mirror settings from the main dialog to check the connection.
Args:
parent (obj): An instance of HostsUtil object to get settings
from.
"""
super(QSubChkUpdate, self).__init__(parent)
self.url = parent.mirrors[parent._mirr_id]["update"] + parent.infofile

def run(self):
"""Check update - Public Method
Operations to retrieve the metadata of the latest hosts data file.
"""
try:
socket.setdefaulttimeout(5)
urlobj = urllib.urlopen(self.url)
j_str = urlobj.read()
urlobj.close()
info = json.loads(j_str)
self.trigger.emit(info)
except:
info = {"version": unicode(_translate("Util", "[Error]", None))}
self.trigger.emit(info)
Loading

0 comments on commit 1612f8f

Please sign in to comment.