Skip to content

Commit

Permalink
play around with a command-line query script, displaying statistics f…
Browse files Browse the repository at this point in the history
…rom all nodes.
  • Loading branch information
ivh committed Sep 12, 2011
1 parent 5029b6a commit a746f2a
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 22 deletions.
Empty file added __init__.py
Empty file.
22 changes: 0 additions & 22 deletions other/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
from lxml.builder import E
from lxml import etree as e
from lxml.etree import XPath
import string as s

text_list=XPath("//text()")
parser=e.XMLParser(remove_blank_text=True)

# XML schemata
xsl_job2html_url='http://vamdc.fysast.uu.se:8080/DSAcat/TAP/uws-job-to-html.xsl'
xsl_job2html = e.parse(xsl_job2html_url)
job2html= e.XSLT(xsl_job2html)

xsl_data2html_url='http://vamdc.fysast.uu.se:8080/DSAcat/TAP/uws-results-to-html.xsl'
xsl_data2html = e.parse(xsl_data2html_url)
data2html= e.XSLT(xsl_data2html)

xsl_xsams_url='http://vamdc.fysast.uu.se:8080/DSAcat/xsams-0.1.xsd'
xsl_xsams= e.parse(xsl_xsams_url)


#import XsamsPyxb as xsams # this requires pyxb to be installed
37 changes: 37 additions & 0 deletions other/query_preview.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env python

import sys
import requests
from multiprocessing import Pool
from vamdc.other.registry import getNodeList

try:
QUERY = sys.argv[1]
except:
print "Please give the complete query string as an argument, in double quotes."
sys.exit(1)

PARAMS = {\
'QUERY':QUERY,
'FORMAT':'XSAMS',
'LANG':'VSS2'
}

def headreq(nodes):
return requests.head(nodes['url']+'sync',params=PARAMS,timeout=5)

def run():
nodes = getNodeList()
n = len(nodes)
pool = Pool(processes=n)

pardict = {'url':[node['url']+'sync' for node in nodes],
'params':(PARAMS,)*n,
'timeout':(5,)*n
}

res = pool.map(headreq,nodes)
print res

if __name__ == '__main__':
run()
File renamed without changes.

0 comments on commit a746f2a

Please sign in to comment.