去年写了一个快速切换 hosts 的软件 SwitchHosts!,这一年里接到很多反馈意见,综合考虑了大家的意见以及自己能投入的时间之后,我终于在它的 v0.1 版发布马上一周年之际发布了 v0.2 版。
新版本 SwitchHosts! 的截图见下面:
这次升级主要的改进有:
- 改进界面;
- 添加在线方案,允许用户引入网络上的 hosts 方案;
- 支持方案导入及导出,方便分享自己的配置方案;
- 优化语法高亮控件,修复渲染长 hosts 时闪屏的问题;
- 修复程序在中文目录下无法运行的问题;
- 支持 hosts 排序(拖拽排序);
希望大家喜欢这个新版本,也欢迎继续提意见!:-)
(2015-12-20 更新:SwitchHosts! 第三版已发布。)
评论:
制作成exe文件可以使用py2exe或<a href="http://www.pyinstaller.org/" rel="nofollow">pyInstaller</a>,我用的是pyInstaller。
比如你的pyInstaller目录在 D:toolspyinstaller-2.0,SwitchHosts!源码在 D:studioSwitchHosts,那么只需要在命令行下使用类似下面的命令就可以打包成绿色exe了:
D:toolspyinstaller-2.0> pyinstaller.py -w -F --icon=D:studioSwitchHostsuiimgicon_0.ico --name=SwitchHosts --out=D:studioSwitchHostsdist D:studioSwitchHostssrcSwitchHosts.py
在 Win 7 下没有权限问题么?还是用之前都要手动获取 hosts 文件权限?
PS: 一年前我开发过一个Python应用程序,底层逻辑用py棒极了,可是前台展示却成了问题。当时我是用的Qt GUI,真的很受限制。wx一开始考虑过,但是总觉得不够漂亮就没去用。现在想通了,既然大家都往web里钻,当时真的应该做成个webapp的
其中,直接运行SwitchHosts.py的提示为:
Traceback (most recent call last):
File "SwitchHosts.py", line 127, in
main()
File "SwitchHosts.py", line 123, in main
sh.run()
File "SwitchHosts.py", line 56, in run
taskbar_icon=self.taskbar_icon,
File "/home/dukeant/SwitchHosts/src/libs/MainFrame.py", line 71, in __init__
title or self.default_title, pos, size, style)
File "/home/dukeant/SwitchHosts/src/libs/ui.py", line 147, in __init__
self.m_textCtrl_content = self.makeTextCtrl(bSizer6)
File "/home/dukeant/SwitchHosts/src/libs/ui.py", line 224, in makeTextCtrl
txt_ctrl.SetMaxLength(0)
AttributeError: 'HostsCtrl' object has no attribute 'SetMaxLength'
用pyinstaller打包的命令为:
python pyinstaller.py -w -F --icon=/home/dukeant/SwitchHosts/src/img/logo.ico --name=SwitchHosts --out=/home/dukeant/SwitchHosts/src/dist /home/dukeant/SwitchHosts/src/SwitchHosts.py
运行打包生成的程序,报错为:
Traceback (most recent call last):
File "", line 127, in
File "", line 123, in main
File "", line 56, in run
File "/home/dukeant/SwitchHosts/src/dist/build/pyi.linux2/SwitchHosts/out00-PYZ.pyz/libs.MainFrame", line 71, in __init__
File "/home/dukeant/SwitchHosts/src/dist/build/pyi.linux2/SwitchHosts/out00-PYZ.pyz/libs.ui", line 147, in __init__
File "/home/dukeant/SwitchHosts/src/dist/build/pyi.linux2/SwitchHosts/out00-PYZ.pyz/libs.ui", line 224, in makeTextCtrl
AttributeError: 'HostsCtrl' object has no attribute 'SetMaxLength'
(dukeant是我自己的账户名)
不知道哪里出了问题,求教!
我用一个txt去存放配置文件,结果URL无法访问的问题
但是我在浏览器里面又能正常打开,请问这是什么问题。有没有对在线配置方案有更加具体的介绍呢?
,HostsX有这个
https://smarthosts.googlecode.com/svn/trunk/hosts
https://raw.githubusercontent.com/zxdrive/imouto.host/master/imouto.host.txt
这2个hosts可以在浏览器打开,但新建在线方案时总是提示URL无法访问。
是不支持https,还是不支持中文内容?
<blockquote>在下载在线URL之前,SwitchHosts!会先尝试快速地判断一下这个URL是否存在,因为如果直接去打开URL,并且这个URL刚好打不开的话,用户就会等待很久。
判断URL是否存在的方法是<a href="https://github.com/oldj/SwitchHosts/blob/master/src/libs/common_operations.py#L126" rel="nofollow">httpExist(url)</a>,它实际上是向站点的域名(根目录)发一个HEAD请求。你给的第一个链接没问题,但第二个链接的域名(https://raw.githubusercontent.com)不能直接访问,会返回404状态,所以SwitchHosts!以为这个链接无法访问。
</blockquote>
简单来说是一个代码上的缺陷,我会在下一个版本修复,感谢反馈!
顺便问一下,你用的是Windows版还是Mac版啊?
这两天用SwitchHosts时遇到了点问题,一直提示hosts未能成功切换,以前都是正常的,过完年回来就不行了。
版本是0.1.6.1755
0.1.6.1755 已经很久不维护了,现在最新的版本是 3.2.3 ,可以在 <a href="https://github.com/oldj/SwitchHosts/releases" rel="nofollow">这儿</a> 下载,备用下载地址:<a href="https://pan.baidu.com/share/link?shareid=150951&uk=3607385901" target="_blank" rel="nofollow noopener noreferrer">百度网盘</a> 。