/usr/share/spikeproxy/read_query.py is in spikeproxy 1.4.8-4.2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/usr/bin/env python
"""
read_query.py
Reads a query from a stored pickled file and displays it
This is going to be really slow because the imports do a lot of initializing.
Use this as an example if you want to script up somethign that needs to loop
or whatever.
"""
import os
import getopt
import dircache
import cPickle
#my imports
from spkproxy import header,body
from requestandresponse import RequestAndResponse
import daveutil
import sys
def usage():
print "Usage: read_query.py -f file [-r: print request] [-R: print response]"
sys.exit(1)
try:
(opts,args)=getopt.getopt(sys.argv[1:],"f:rR")
except getopt.GetoptError:
#print help
usage()
dorequest=0
doresponse=0
target=""
for o,a in opts:
if o in ["-f"]:
target=a
if o in ["-r"]:
dorequest=1
if o in ["-R"]:
doresponse=1
if target=="":
usage()
clientheader=header()
clientbody=body()
serverheader=header()
serverbody=body()
filename=target
fd=open(filename)
if fd==None:
print "Bad Filename: %s"%filename
sys.exit(1)
obj=cPickle.load(fd)
fd.close()
if dorequest:
print daveutil.constructRequest(obj.clientheader,obj.clientbody)
if doresponse:
print daveutil.constructResponse(obj.serverheader,obj.serverbody)
#DONE
|