forked from StevenBlack/hosts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makeHosts.py
118 lines (93 loc) · 3.55 KB
/
makeHosts.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python
# Script by gfyoung
# https://github.com/gfyoung
#
# This Python script will generate hosts files and update the readme file.
from __future__ import print_function
import sys
import argparse
import subprocess
def print_failure(msg):
"""
Print a failure message.
Parameters
----------
msg : str
The failure message to print.
"""
print("\033[91m" + msg + "\033[0m")
def update_hosts_file(*flags):
"""
Wrapper around running updateHostsFile.py
Parameters
----------
flags : varargs
Commandline flags to pass into updateHostsFile.py. For more info, run
the following command in the terminal or command prompt:
```
python updateHostsFile.py -h
```
"""
if subprocess.call([sys.executable, "updateHostsFile.py"] + list(flags)):
print_failure("Failed to update hosts file")
def update_readme_file():
"""
Wrapper around running updateReadme.py
"""
if subprocess.call([sys.executable, "updateReadme.py"]):
print_failure("Failed to update readme file")
def main():
parser = argparse.ArgumentParser(description="Creates custom hosts "
"file from hosts stored in "
"data subfolders.")
parser.parse_args()
update_hosts_file("-a", "-o",
"alternates/gambling",
"-e", "gambling")
update_hosts_file("-a", "-n", "-o",
"alternates/porn",
"-e", "porn")
update_hosts_file("-a", "-n", "-o",
"alternates/social",
"-e", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews",
"-e", "fakenews")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-gambling",
"-e", "fakenews", "gambling")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-porn",
"-e", "fakenews", "porn")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-social",
"-e", "fakenews", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/gambling-porn",
"-e", "gambling", "porn")
update_hosts_file("-a", "-n", "-o",
"alternates/gambling-social",
"-e", "gambling", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/porn-social",
"-e", "porn", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-gambling-porn",
"-e", "fakenews", "gambling", "porn")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-gambling-social",
"-e", "fakenews", "gambling", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-porn-social",
"-e", "fakenews", "porn", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/gambling-porn-social",
"-e", "gambling", "porn", "social")
update_hosts_file("-a", "-n", "-o",
"alternates/fakenews-gambling-porn-social",
"-e", "fakenews", "gambling", "porn", "social")
update_hosts_file("-a", "-n")
# Update the readme files.
update_readme_file()
if __name__ == "__main__":
main()