CMS 3D CMS Logo

Classes | Functions | Variables
query Namespace Reference

Classes

class  DDOptionParser
 

Functions

def sendMessage (host, port, dbsInst, userInput, page, limit, xml=0, case='on', iface='dd', details=0, cff=0, debug=0)
 

Variables

 args
 
 dbsInst
 
 host
 
 input
 
 optManager
 
 opts
 
 port
 
 result
 

Function Documentation

def query.sendMessage (   host,
  port,
  dbsInst,
  userInput,
  page,
  limit,
  xml = 0,
  case = 'on',
  iface = 'dd',
  details = 0,
  cff = 0,
  debug = 0 
)
   Send message to server, message should be an well formed XML document.

Definition at line 52 of file query.py.

References createfilelist.int, join(), edm.print(), python.rootplot.root2matplotlib.replace(), and str.

52 def sendMessage(host,port,dbsInst,userInput,page,limit,xml=0,case='on',iface='dd',details=0,cff=0,debug=0):
53  """
54  Send message to server, message should be an well formed XML document.
55  """
56  if xml: xml=1
57  else: xml=0
58  if cff: cff=1
59  else: cff=0
60  input=urllib.quote(userInput)
61  if debug:
62  httplib.HTTPConnection.debuglevel = 1
63  print("Contact",host,port)
64  _port=443
65  if host.find("http://")!=-1:
66  _port=80
67  if host.find("https://")!=-1:
68  _port=443
69  host=host.replace("http://","").replace("https://","")
70  if host.find(":")==-1:
71  port=_port
72  prefix_path=""
73  if host.find("/")!=-1:
74  hs=host.split("/")
75  host=hs[0]
76  prefix_path='/'.join(hs[1:])
77  if host.find(":")!=-1:
78  host,port=host.split(":")
79  port=int(port)
80 # print "\n\n+++",host,port
81  if port==443:
82  http_conn = httplib.HTTPS(host,port)
83  else:
84  http_conn = httplib.HTTP(host,port)
85  if details: details=1
86  else: details=0
87  path='/aSearch?dbsInst=%s&html=0&caseSensitive=%s&_idx=%s&pagerStep=%s&userInput=%s&xml=%s&details=%s&cff=%s&method=%s'%(dbsInst,case,page,limit,input,xml,details,cff,iface)
88  if prefix_path:
89  path="/"+prefix_path+path[1:]
90  http_conn.putrequest('POST',path)
91  http_conn.putheader('Host',host)
92  http_conn.putheader('Content-Type','text/html; charset=utf-8')
93  http_conn.putheader('Content-Length',str(len(input)))
94  http_conn.endheaders()
95  http_conn.send(input)
96 
97  (status_code,msg,reply)=http_conn.getreply()
98  data=http_conn.getfile().read()
99  if debug or msg!="OK":
100  print()
101  print(http_conn.headers)
102  print("*** Send message ***")
103  print(input)
104  print("************************************************************************")
105  print("status code:",status_code)
106  print("message:",msg)
107  print("************************************************************************")
108  print(reply)
109  return data
110 
111 #
112 # main
113 #
def replace(string, replacements)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
#define str(s)
def sendMessage(host, port, dbsInst, userInput, page, limit, xml=0, case='on', iface='dd', details=0, cff=0, debug=0)
Definition: query.py:52

Variable Documentation

query.args

Definition at line 119 of file query.py.

query.dbsInst

Definition at line 117 of file query.py.

query.host
query.input

Definition at line 132 of file query.py.

query.optManager

Definition at line 118 of file query.py.

query.opts

Definition at line 119 of file query.py.

query.port
query.result

Definition at line 138 of file query.py.