<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://textserver.lsi.upc.edu/wiki/index.php?action=history&amp;feed=atom&amp;title=Batch_Results_Retrieval_in_Python</id>
		<title>Batch Results Retrieval in Python - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://textserver.lsi.upc.edu/wiki/index.php?action=history&amp;feed=atom&amp;title=Batch_Results_Retrieval_in_Python"/>
		<link rel="alternate" type="text/html" href="http://textserver.lsi.upc.edu/wiki/index.php?title=Batch_Results_Retrieval_in_Python&amp;action=history"/>
		<updated>2026-08-13T04:32:40Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.26.2</generator>

	<entry>
		<id>http://textserver.lsi.upc.edu/wiki/index.php?title=Batch_Results_Retrieval_in_Python&amp;diff=120&amp;oldid=prev</id>
		<title>Padro at 11:30, 21 January 2016</title>
		<link rel="alternate" type="text/html" href="http://textserver.lsi.upc.edu/wiki/index.php?title=Batch_Results_Retrieval_in_Python&amp;diff=120&amp;oldid=prev"/>
				<updated>2016-01-21T11:30:36Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class='diff diff-contentalign-left'&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;col class='diff-marker' /&gt;
				&lt;col class='diff-content' /&gt;
				&lt;tr style='vertical-align: top;' lang='en'&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan='2' style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Revision as of 11:30, 21 January 2016&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l4&quot; &gt;Line 4:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 4:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;########################################################################&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;########################################################################&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;#160; Example client to &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;submit &lt;/del&gt;a batch request to TextServer &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;#160; Example client to &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;retrieve the results of &lt;/ins&gt;a batch request to TextServer &amp;#160;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;# SERVICENAME service, and wait for the job to be finished.&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;#&amp;#160; Input must be a ZIP file containing one or more text files to analyze&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt;&amp;#160;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;#160; Output will be a ZIP file containing results for each input file in&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;#&amp;#160; Output will be a ZIP file containing results for each input file in&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# the requested format (XML, json, conll)&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;&amp;#160;&lt;/td&gt;&lt;td style=&quot;background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;# the requested format (XML, json, conll)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Padro</name></author>	</entry>

	<entry>
		<id>http://textserver.lsi.upc.edu/wiki/index.php?title=Batch_Results_Retrieval_in_Python&amp;diff=109&amp;oldid=prev</id>
		<title>Padro: Created page with &quot;&lt;syntaxhighlight lang=&quot;python&quot; line=&quot;1&quot; &gt; #! /usr/bin/python  ######################################################################## # #  Example client to submit a batch re...&quot;</title>
		<link rel="alternate" type="text/html" href="http://textserver.lsi.upc.edu/wiki/index.php?title=Batch_Results_Retrieval_in_Python&amp;diff=109&amp;oldid=prev"/>
				<updated>2016-01-21T11:26:03Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot; &amp;gt; #! /usr/bin/python  ######################################################################## # #  Example client to submit a batch re...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot; line=&amp;quot;1&amp;quot; &amp;gt;&lt;br /&gt;
#! /usr/bin/python&lt;br /&gt;
&lt;br /&gt;
########################################################################&lt;br /&gt;
#&lt;br /&gt;
#  Example client to submit a batch request to TextServer &lt;br /&gt;
# SERVICENAME service, and wait for the job to be finished.&lt;br /&gt;
#&lt;br /&gt;
#  Input must be a ZIP file containing one or more text files to analyze&lt;br /&gt;
#  Output will be a ZIP file containing results for each input file in&lt;br /&gt;
# the requested format (XML, json, conll)&lt;br /&gt;
#&lt;br /&gt;
########################################################################&lt;br /&gt;
&lt;br /&gt;
# import required libraries&lt;br /&gt;
import urllib2&lt;br /&gt;
# You may need to install &amp;quot;poster&amp;quot; python module for these two:&lt;br /&gt;
from poster.encode import multipart_encode&lt;br /&gt;
from poster.streaminghttp import register_openers&lt;br /&gt;
import xml.etree.ElementTree&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
# Register the streaming http handlers with urllib2&lt;br /&gt;
register_openers()&lt;br /&gt;
&lt;br /&gt;
# set query elements&lt;br /&gt;
user = raw_input('TextServer Username: ')&lt;br /&gt;
tkid = raw_input('TextServer Job Token ID: ')&lt;br /&gt;
outfname = raw_input('Output ZIP file: ')&lt;br /&gt;
&lt;br /&gt;
# service URL&lt;br /&gt;
TextServer_URL = &amp;quot;http://frodo.lsi.upc.edu:8080/TextWS/textservlet/ws&amp;quot;&lt;br /&gt;
&lt;br /&gt;
# prepare request to poll for completion and retrieve results&lt;br /&gt;
datagen, headers = multipart_encode({'username' : user,&lt;br /&gt;
                                     'tokenID' : tkid&lt;br /&gt;
                                     })&lt;br /&gt;
request = urllib2.Request(TextServer_URL + &amp;quot;/resultRetrieve&amp;quot;, &lt;br /&gt;
                          datagen, &lt;br /&gt;
                          headers)&lt;br /&gt;
&lt;br /&gt;
try:&lt;br /&gt;
  # send request to check for results&lt;br /&gt;
  print &amp;quot;Polling server for job completion...&amp;quot;&lt;br /&gt;
  resp =  urllib2.urlopen(request).read()&lt;br /&gt;
  &lt;br /&gt;
except urllib2.HTTPError, e:&lt;br /&gt;
  if (e.code == 503 and e.read()[0:8] == &amp;quot;[TS-125]&amp;quot; ) :&lt;br /&gt;
    # http status 503, textserver code TS-125 means the job is not finished yet. &lt;br /&gt;
    print &amp;quot;Job not finished yet&amp;quot; &lt;br /&gt;
  else :      &lt;br /&gt;
    # some actual error happened. abort&lt;br /&gt;
    print e, &amp;quot;-&amp;quot;, e.read()&lt;br /&gt;
  exit()&lt;br /&gt;
    &lt;br /&gt;
&lt;br /&gt;
# no error, save results to output file&lt;br /&gt;
outf=open(outfname, 'w+')&lt;br /&gt;
print &amp;gt;&amp;gt;outf, resp&lt;br /&gt;
outf.close()&lt;br /&gt;
print &amp;quot;Job finished. Results saved to&amp;quot;,outfname&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Padro</name></author>	</entry>

	</feed>