-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbild.py
More file actions
executable file
·48 lines (39 loc) · 1.11 KB
/
bild.py
File metadata and controls
executable file
·48 lines (39 loc) · 1.11 KB
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
#!/usr/bin/env python
import urllib
import os
import signal
# bootstrap by downloading bilder.py if not found
if not os.path.exists("bilder.py"):
print "bootstrapping; downloading bilder.py"
urllib.urlretrieve(
"https://raw.githubusercontent.com/parrt/bild/master/src/python/bilder.py",
"bilder.py")
# assumes bilder.py is in current directory
from bilder import *
def compile():
javac("src", "out")
def launch_proxy():
global server_pid
require(compile)
server_pid = java("cs601.proxy.ProxyServer", cp="out", background=True)
print "Server PID ", server_pid
def test(url):
print "testing "+url
rmdir("/tmp/wo")
rmdir("/tmp/w")
errcode = wget(url, trgdir="/tmp/wo", level=1)
errcode = wget(url, trgdir="/tmp/w", level=1, proxy="http://localhost:8080")
output = diff("/tmp/wo", "/tmp/w", recursive=True)
if output is not None and len(output)>0:
print output
def tests():
launch_proxy()
try:
test("http://www.cs.usfca.edu/index.html")
#test("http://www.github.com")
finally:
print "Killing Server PID ", server_pid
os.kill(server_pid, signal.SIGABRT)
def all():
tests()
processargs(globals())