Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tree: 5be3c5e31f
Fetching contributors…

Cannot retrieve contributors at this time

43 lines (39 sloc) 1.171 kB
import serial
import subprocess
import time
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=0.25)
nuclear_time = 3600 # nuclear timeout in seconds
nuke = 0
disabled_sites = '/var/banhammer.txt'
#reload_config = "squid3 -k reconfigure"
reload_config = "echo \"reconfigure\""
#Sites to block
banhammer = """^.*reddit.com
^.*news.ycombinator.com
^.*somethingawful.com
"""
while(1):
line = ser.readline()
if(line.find("disable_procrastination") != -1):
myfile = open(disabled_sites, 'w')
myfile.write(banhammer)
myfile.close()
print "Disable"
subprocess.call(reload_config, shell=True)
if(line.find("enable_procrastination") != -1):
open(disabled_sites, 'w').close()
print "Enable"
subprocess.call(reload_config, shell=True)
if(line.find("boom") != -1):
myfile = open(disabled_sites, 'w')
myfile.write(banhammer)
myfile.close()
print "Nuclear"
subprocess.call(reload_config, shell=True)
nuke += nuclear_time
while nuke >= 0:
print nuke
ser.write(str(nuke))
ser.write('\n')
nuke -= 1
time.sleep(1)
Jump to Line
Something went wrong with that request. Please try again.