我的第二个作品,Hosts助手,自动/手动更新Hosts文件
Tofloor
poster avatar
Dream
deepin
2017-07-14 19:17
Author








用linux差不多2个月了,发现更新hosts还是挺麻烦的,虽然网上有一些自动更新的脚本,但是我还是喜欢用带界面的软件,所以自己花了几天时间写了这个hosts助手,可以手动更新,也可以自动更新。
用tkinter写的界面,为了达到美观实用的效果还是挺磨人的,一直在网上找资料,对linux的认识又增进了不少。皇天不负有心人,终于做出了自己比较满意的成品,特地献给各位。
附件:Hosts助手.py.tar.gz
步骤:1、首先获得hosts文件的读写权限,命令:sudo chmod 777 /etc/hosts
2、需要安装python3的tkinter模块,命令: sudo apt-get install python3-tk
3、将附件文件解压出来,打开终端,在终端中输入命令:python3  绝对路径/Hosts助手.py    注意!一定要是绝对路径
4、成功,以后可以从启动器打开

Reply Favorite View the author
All Replies
2 / 4
To page
avatar
RedPanda
deepin
2017-07-15 04:30
#21
https://bbs.deepin.org/post/142516
好吧,其实可以把那一大段放到外面的,看来不仅软件界面要美化,代码也要美化,毕竟这社区里大神多 ...

其实是我的强迫症犯了。。。看多了python的那套“优美代码”的理论后遗症。。。
Reply View the author
avatar
RedPanda
deepin
2017-07-15 04:31
#22
https://bbs.deepin.org/post/142516
好吧,其实可以把那一大段放到外面的,看来不仅软件界面要美化,代码也要美化,毕竟这社区里大神多 ...

话说加\r也不行吗?
Reply View the author
avatar
Dream
deepin
2017-07-15 04:43
#23
https://bbs.deepin.org/post/142516
话说加\r也不行吗?

我用的pycharm,如果加\r的话,那行会很长,最后还是要被叠起来
Reply View the author
avatar
.Andy
deepin
2017-07-15 04:59
#24
一直手动更新的路过
Reply View the author
avatar
RedPanda
deepin
2017-07-15 05:05
#25
https://bbs.deepin.org/post/142516
我用的pycharm,如果加\r的话,那行会很长,最后还是要被叠起来

好吧。。。
Reply View the author
avatar
182******97
deepin
2017-07-15 11:10
#26

可以 fastboot 刷twrp 用aroma filemanager 修改
Reply View the author
avatar
182******97
deepin
2017-07-15 11:12
#27
https://bbs.deepin.org/post/142516
https://github.com/huhamhire/huhamhire-hosts 试试这个

404,kidding me?
Reply View the author
avatar
182******97
deepin
2017-07-15 11:13
#28
收藏了收藏了
Reply View the author
avatar
wtz
deepin
2017-07-15 16:33
#29
赞赞赞!
终于看到各种绿色工具开始在Linux上流行了!
Reply View the author
avatar
wtz
deepin
2017-07-15 16:36
#30
使用前要先chmod 777?
这个有点可怕……可以用polkit动态提权么?
Reply View the author
avatar
xiaoyangerbani
deepin
2017-07-15 19:01
#31
为什么要一直更新hosts呢,配置一下xx-net,get一切文明上网
Reply View the author
avatar
fiora
deepin
2017-07-15 19:16
#32
https://bbs.deepin.org/post/142516
为什么要一直更新hosts呢,配置一下xx-net,get一切文明上网

xx-net太慢了
Reply View the author
avatar
itwuhu
deepin
2017-07-15 19:16
#33
本帖最后由 itwuhu 于 2017-7-15 11:18 编辑

楼主,请原谅我是一枚小白;这hosts助手修改后 会有什么用途呢?
我可否理解为与windows 系统下的hosts一样的作用呢?
Reply View the author
avatar
Dream
deepin
2017-07-15 21:16
#34
https://bbs.deepin.org/post/142516
使用前要先chmod 777?
这个有点可怕……可以用polkit动态提权么?

没研究过这个,在网上查了一下,看起来好复杂,中文资料也少,放弃了。你如果真的觉得改成777不安全的话,你把那个hosts文件的所属组或者所有者改一下吧。
Reply View the author
avatar
Dream
deepin
2017-07-15 21:19
#35
https://bbs.deepin.org/post/142516
楼主,请原谅我是一枚小白;这hosts助手修改后 会有什么用途呢?
我可否理解为与windows 系统下的hosts一样 ...

改了hosts你就可以访问谷歌,非死不可等网站了
Reply View the author
avatar
itwuhu
deepin
2017-07-15 21:48
#36
https://bbs.deepin.org/post/142516
改了hosts你就可以访问谷歌,非死不可等网站了

您这套工具已经具备翻越谷歌的条件啦!!
Reply View the author
avatar
itwuhu
deepin
2017-07-15 22:04
#37
本帖最后由 itwuhu 于 2017-7-15 14:10 编辑

为嘛我运行一直都不成功呢?
我将hosts助手.py.tar.gz存放到 etc/下面;麻烦楼主看下;原谅我是一枚小白






Reply View the author
avatar
Dream
deepin
2017-07-15 22:45
#38
https://bbs.deepin.org/post/142516
您这套工具已经具备翻越谷歌的条件啦!!

只要hosts文件正常更新,一般都是可以的
Reply View the author
avatar
Dream
deepin
2017-07-15 22:49
#39
https://bbs.deepin.org/post/142516
为嘛我运行一直都不成功呢?
我将hosts助手.py.tar.gz存放到 etc/下面;麻烦楼主看下;原谅我是一枚小白

不要把 Hosts助手.py 文件放到根目录或/etc下,那里你没有权限操作,把它放到你有权限的文件夹下,你用命令:cd ~    切换到的目录是你的个人目录,你把它放到这里面任何一个位置都行
Reply View the author
avatar
Dream
deepin
2017-07-15 22:58
#40
https://bbs.deepin.org/post/142516
为嘛我运行一直都不成功呢?
我将hosts助手.py.tar.gz存放到 etc/下面;麻烦楼主看下;原谅我是一枚小白

这些文件夹下面都能放
Reply View the author
2 / 4
To page