This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
2,793 additions
and
2,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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), ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Oops, something went wrong.