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

Commit

Permalink
Merge branch 'VPS-SEA/HostsUtl-Desktop-Dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
huhamhire committed Dec 14, 2013
2 parents 1612f8f + d0752c1 commit 6da705c
Show file tree
Hide file tree
Showing 22 changed files with 384 additions and 282 deletions.
145 changes: 89 additions & 56 deletions _build.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# _build.py : Tools to make packages for different platforms
#
# Copyleft (C) 2013 - huhamhire hosts team <develop@huhamhire.com>
# Copyleft (C) 2013 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
Expand All @@ -20,9 +20,9 @@
import sys
import shutil

from gui.hostsutil import __version__
from hoststool import __version__

SCRIPT = "hostsutil.py"
SCRIPT = "hoststool.py"

SCRIPT_DIR = os.getcwd() + '/'
RELEASE_DIR = "../release/"
Expand All @@ -31,10 +31,10 @@
VERSION = __version__
DESCRIPTION = "HostsUtl - Hosts Setup Utility"
AUTHOR = "Hamhire Hu"
AUTHOR_EMAIL ="develop@huhamhire.com",
AUTHOR_EMAIL = "hosts@huhamhire.com",
LICENSE = "Public Domain, Python, BSD, GPLv3 (see LICENSE)",
URL = "https://hosts.huhamhire.com",
CLASSIFIERS = [
CLASSIFIERS = [
"Development Status :: 4 - Beta",
"Environment :: MacOS X",
"Environment :: Win32 (MS Windows)",
Expand Down Expand Up @@ -62,46 +62,67 @@
"Topic :: CommonUtil",
]
DATA_FILES = [
("lang", [
"lang/en_US.qm",
"lang/zh_CN.qm",
"lang/zh_TW.qm",
]
),
("theme", [
"theme/default.qss",
]
),
"LICENSE",
"README.md",
"network.conf",
("gui/lang", [
"gui/lang/en_US.qm",
"gui/lang/zh_CN.qm",
"gui/lang/zh_TW.qm",
]),
("gui/theme", [
"gui/theme/default.qss",
]),
(".", [
"LICENSE",
"README.md",
"network.conf",
]),
]

if sys.argv > 1:
tar_flag = 0
includes = []
excludes = []
file_path = lambda rel_path: SCRIPT_DIR + rel_path
if sys.argv[1] == "py2tar":
# Pack up script package for Linux users
file_path = lambda rel_path: SCRIPT_DIR + rel_path
includes = [
"*.py", "lang/*.qm", "theme/*.qss", "LICENSE", "README.md",
"network.conf"]
excludes = ["_*.py", ".gitattributes"]
"*.py",
"gui/lang/*.qm",
"gui/theme/*.qss",
"*/*.py",
"LICENSE",
"README.md",
"network.conf",
]
excludes = [
"_build.py",
"_pylupdate4.py",
"_pyuic4.py",
".gitattributes",
".gitignore",
]
ex_files = []
prefix = "HostsUtl-x11-gpl-"
tar_flag = 1

elif sys.argv[1] == "py2source":
# Pack up source package for Linux users
file_path = lambda rel_path: SCRIPT_DIR + rel_path
includes = ["*"]
excludes = [".gitattributes"]
excludes = [
".gitattributes",
".gitignore",
"hostslist.data",
]
ex_files = []
prefix = "HostsUtl-source-gpl-"
tar_flag = 1
else:
prefix = "Error"
ex_files = []

if tar_flag:
import glob
import tarfile

TAR_NAME = prefix + VERSION + ".tar.gz"
RELEASE_PATH = RELEASE_DIR + TAR_NAME
if not os.path.exists(RELEASE_DIR):
Expand All @@ -116,23 +137,26 @@
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_path = os.path.join(prefix + VERSION,
src_file[rel_len:])
tar.add(src_file, tar_path)
print src_file
print "compressing: %s" % src_file
tar.close()
exit(1)

from util.common import CommonUtil
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 = "HostsUtl"
DIR_NAME = "HostsUtil"
DIST_DIR = WORK_DIR + DIR_NAME + '/'
WIN_OPTIONS = {
"includes": ["sip"],
Expand All @@ -147,23 +171,30 @@
shutil.rmtree(DIST_DIR)
# Build Executable
print " Building Executable ".center(78, '=')
EXE_NAME = SCRIPT.split(".")[0]
setup(
name = NAME,
version = VERSION,
options = {"py2exe": WIN_OPTIONS},
windows = [
name=NAME,
version=VERSION,
options={"py2exe": WIN_OPTIONS},
console=[
{"script": SCRIPT,
"dest_base": "command_line_tool",
},
],
windows=[
{"script": SCRIPT,
"icon_resources": [(1, "img/icons/hosts_utl.ico")]
"icon_resources": [(1, "res/img/icons/hosts_utl.ico")],
"dest_base": EXE_NAME,
},
],
description = DESCRIPTION,
author = AUTHOR,
author_email = AUTHOR_EMAIL,
license = LICENSE,
url = URL,
zipfile = None,
data_files = DATA_FILES,
classifiers = CLASSIFIERS,
description=DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
zipfile="lib/shared.zip",
data_files=DATA_FILES,
classifiers=CLASSIFIERS,
)
# Clean work directory after build
shutil.rmtree(SCRIPT_DIR + "build/")
Expand All @@ -173,6 +204,8 @@
PLAT = "x64"
elif struct.calcsize("P") * 8 == 32:
PLAT = "x86"
else:
PLAT = "unknown"
DIR_NAME = DIR_NAME + '-win-gpl-' + VERSION + '-' + PLAT
ZIP_NAME = DIR_NAME + ".zip"
ZIP_FILE = WORK_DIR + ZIP_NAME
Expand Down Expand Up @@ -206,7 +239,7 @@
DIST_DIR = APP_PATH + "/Contents/"
# Set build configuration
MAC_OPTIONS = {
"iconfile": "img/icons/hosts_utl.icns",
"iconfile": "res/img/icons/hosts_utl.icns",
"includes": ["sip", "PyQt4.QtCore", "PyQt4.QtGui"],
"excludes": [
"PyQt4.QtDBus",
Expand Down Expand Up @@ -239,24 +272,24 @@
shutil.rmtree(APP_PATH)
if not os.path.exists(WORK_DIR):
os.mkdir(WORK_DIR)
# Make daemon APP
# Make daemon APP
OSAC_CMD = "osacompile -o %s %sHostsUtl.scpt" % (APP_PATH, RES_DIR)
os.system(OSAC_CMD)
# Build APP
print " Building Application ".center(78, '=')
setup(
app = [SCRIPT],
name = NAME,
version = VERSION,
options = {"py2app": MAC_OPTIONS},
setup_requires = ["py2app"],
description = DESCRIPTION,
author = AUTHOR,
author_email = AUTHOR_EMAIL,
license = LICENSE,
url = URL,
data_files = DATA_FILES,
classifiers = CLASSIFIERS,
app=[SCRIPT],
name=NAME,
version=VERSION,
options={"py2app": MAC_OPTIONS},
setup_requires=["py2app"],
description=DESCRIPTION,
author=AUTHOR,
author_email=AUTHOR_EMAIL,
license=LICENSE,
url=URL,
data_files=DATA_FILES,
classifiers=CLASSIFIERS,
)
# Clean work directory after build
os.remove(DIST_DIR + "Resources/applet.icns")
Expand All @@ -279,7 +312,7 @@
os.remove(DMG_TMP)
if os.path.isfile(DMG_PATH):
os.remove(DMG_PATH)
# Prepare files in DMG package
# Prepare files in DMG package
os.mkdir(VDMG_DIR)
shutil.move(APP_PATH, VDMG_DIR)
os.symlink("/Applications", VDMG_DIR + " ")
Expand Down
2 changes: 1 addition & 1 deletion gui/__list_trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# __list_trans.py : Name of items from the function list to be localized
#
# Copyleft (C) 2014 - huhamhire hosts team <develop@huhamhire.com>
# Copyleft (C) 2014 - huhamhire hosts team <hosts@huhamhire.com>
# =====================================================================
# Licensed under the GNU General Public License, version 3. You should
# have received a copy of the GNU General Public License along with
Expand Down
2 changes: 1 addition & 1 deletion gui/_checkconn.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __init__(self, parent=None):
from.
"""
super(QSubChkConnection, self).__init__(parent)
self.link = parent.mirrors[parent._mirr_id]["test_url"]
self.link = parent.mirrors[parent.mirror_id]["test_url"]

def run(self):
"""Check connection - Public Method
Expand Down
2 changes: 1 addition & 1 deletion gui/_checkupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, parent=None):
from.
"""
super(QSubChkUpdate, self).__init__(parent)
self.url = parent.mirrors[parent._mirr_id]["update"] + parent.infofile
self.url = parent.mirrors[parent.mirror_id]["update"] + parent.infofile

def run(self):
"""Check update - Public Method
Expand Down
14 changes: 7 additions & 7 deletions gui/_make.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,17 @@ def __init__(self, parent=None):
"""
super(QSubMakeHosts, self).__init__(parent)
self.count = 0
self.make_cfg = parent._make_cfg
self.make_mode = parent._make_mode
make_path = parent._make_path
self.make_cfg = parent.make_cfg
self.make_mode = parent.make_mode
make_path = parent.make_path
self.hostname = parent.hostname
if parent._make_mode == "system":
self.eol = parent._sys_eol
if parent.make_mode == "system":
self.eol = parent.sys_eol
self.hosts_file = open("hosts", "wb")
elif parent._make_mode == "ansi":
elif parent.make_mode == "ansi":
self.eol = "\r\n"
self.hosts_file = open(unicode(make_path), "wb")
elif parent._make_mode == "utf-8":
elif parent.make_mode == "utf-8":
self.eol = "\n"
self.hosts_file = open(unicode(make_path), "wb")

Expand Down
3 changes: 2 additions & 1 deletion gui/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def __init__(self, parent=None):
from.
"""
super(QSubFetchUpdate, self).__init__(parent)
self.url = parent.mirrors[parent._mirr_id]["update"] + parent.filename
self.url = parent.mirrors[parent.mirror_id]["update"] + \
parent.filename
self.path = "./" + parent.filename
self.tmp_path = self.path + ".download"
self.filesize = parent._update["size"]
Expand Down
Loading

0 comments on commit 6da705c

Please sign in to comment.