Skip to content

Commit 6039a3f

Browse files
committed
fix output() so it gives the output instead of a url to the output
1 parent 1599035 commit 6039a3f

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

boaapi/boa_client.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
#
1818
import xmlrpc.client
1919
import traceback
20-
from boaapi.util import parse_job
21-
from boaapi.util import CookiesTransport
20+
from boaapi.util import CookiesTransport, parse_job, fetch_url
2221

2322
BOA_PROXY = "http://boa.cs.iastate.edu/boa/?q=boa/api"
2423

@@ -391,7 +390,7 @@ def output(self, job):
391390
try:
392391
if job.exec_status != "Finished":
393392
return "Job is currently running"
394-
return self.server.job.output(job.id)
393+
return fetch_url(self.server.job.output(job.id))
395394
except xmlrpc.client.Fault as e:
396395
raise BoaException(e).with_traceback(e.__traceback__)
397396

boaapi/util.py

+11
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
import http.client
1819
import xmlrpc
20+
from urllib.parse import urlsplit
1921
from boaapi.job_handle import JobHandle
2022

2123
class CookiesTransport(xmlrpc.client.Transport):
@@ -45,3 +47,12 @@ def parse_response(self, response):
4547

4648
def parse_job(client, job):
4749
return JobHandle(client, job['id'], job['submitted'], job['input'], job['compiler_status'], job['hadoop_status'])
50+
51+
def fetch_url(url):
52+
base_url = urlsplit(url)
53+
conn = http.client.HTTPConnection(base_url.hostname, base_url.port if base_url.port != None else (443 if base_url.scheme == 'https' else 80))
54+
conn.request("GET", url)
55+
r1 = conn.getresponse()
56+
if r1.status == 301:
57+
return fetch_url(r1.getheader('Location'))
58+
return r1.read()

0 commit comments

Comments
 (0)