Hello everyone.
I'm new to both Galaxy and python, so forgive me if my issue turns out to be silly. I'm developing a simple suite of tools that perform a series of REST calls and process the results. The simplest of them calls the service and expects a json file in return.
When I call the function from command line, it correctly writes the output on file (same path where galaxy should write, same user). However, when I call it through Galaxy, only an empty file is produced.
This is the tool xml file:
<tool id="rest-login" name="REST Login" version="0.1.0">
<description>Login in the platform</description>
<command interpreter="python">rest-auth.py $output -cmd=login -login_type=%authType.type
</command>
<inputs>
<conditional name="authType">
<param name="login_type" type="select" label="Log as guest or registered?">
<option value="guest">Guest</option>
<option value="registered">Registered User</option>
</param>
<!-- For now, unused -->
<when value="registered">
<param name="user" type="text" label="Username"></param>
<param name="password" type="text" label="Password"></param>
</when>
</conditional>
</inputs>
<outputs>
<data format="json" name="output" label="current_user" />
</outputs>
</tool>
While this is the code snippet that makes the call, given the output destination as argument:
def guest_login(output):
req = urllib2.Request('http://example.com/rest-service')
req.add_header('Accept', 'application/json')
res = urllib2.urlopen(req)
res_str = res.read().decode('utf8')
with open(output, 'w') as f_out :
json.dump(res_str,f_out)
f_out.close
Thanks in advance!
Luana