Can list projects on xnat central with pyxnat but not my own xnat, any ideas?

68 views
Skip to first unread message

John McLean

unread,
Oct 20, 2016, 1:03:41 PM10/20/16
to xnat_discussion
Hi,

When I use pyxnat to get a list of projects on xnat central, it works. However, when trying to do this on my own server, I get an empty outcome. Code and result below. Any ideas what might be going on?

Strictly speaking my server id is: https://ins-xnat.mvls.gla.ac.uk/xnat_gu. I've been looking at using the 'verify' option within Interface, but not exactly sure of the syntax. I tried: 

xnat_gu = Interface(server="http://ins-xnat.mvls.gla.ac.uk/xnat_gu", verify=False,

but that didn't make a difference.

Anyway, my code and result is below:

from pyxnat import Interface
xnat_gu = Interface(server="http://ins-xnat.mvls.gla.ac.uk/xnat_gu", 
                user='myusername',
                password='mypassword',
                cachedir='/tmp')
xnat_gu.select.projects().get()

The output from my jupyter terminal is as follows:

Moore, Charlie

unread,
Oct 20, 2016, 1:25:39 PM10/20/16
to xnat_di...@googlegroups.com

When I try and access your server over https it loads, but when using http, it doesn’t. If the calls you listed at the bottom are indeed doing http calls, they might be failing in the same way. I don’t know many details about pyxnat (I’m guessing verify=false is saying to not worry about https?), but it sounds like it could be an http/https issue to me.

 

Thanks,

Charlie

--
You received this message because you are subscribed to the Google Groups "xnat_discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xnat_discussi...@googlegroups.com.
To post to this group, send email to xnat_di...@googlegroups.com.
Visit this group at https://groups.google.com/group/xnat_discussion.
For more options, visit https://groups.google.com/d/optout.

 


The materials in this message are private and may contain Protected Healthcare Information or other information of a sensitive nature. If you are not the intended recipient, be advised that any unauthorized use, disclosure, copying or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this email in error, please immediately notify the sender via telephone or return mail.

John McLean

unread,
Oct 21, 2016, 6:02:22 AM10/21/16
to xnat_discussion, moo...@wustl.edu
Thanks Charlie, I'm focussing on the ssl aspects of my server now. Long overdue for some TLC.

I followed the following link.


When using the https calls, this got me past the security errors that were being flagged up.

I now have a new error to concern myself with. See code and error output below. I think I should probably just bite the bullet and sort of my SSL certificates which may make all of these nasty errors go away.

from pyxnat import Interface
# import urllib3
import requests
import certifi
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# urllib3.disable_warnings()
xnat_gu = Interface(server="https://ins-xnat.mvls.gla.ac.uk:443/xnat_gu", verify=False,
                user='myusername',
                password='mypassword',
                cachedir='/tmp')
xnat_gu.select.projects().get()

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-5-a01131c2bd47> in <module>()
     10                 password='mypassword',
     11                 cachedir='/tmp')
---> 12 xnat_gu.select.projects().get()

/home/tempie/anaconda2/lib/python2.7/site-packages/pyxnat/core/select.pyc in projects(self, id_filter)
    251                 Name pattern to filter the returned projects.
    252         """
--> 253         self._intf._get_entry_point()
    254 
    255         return globals()['Projects'](

/home/tempie/anaconda2/lib/python2.7/site-packages/pyxnat/core/interfaces.pyc in _get_entry_point(self)
    251             except Exception as e:
    252                 if not '/data/JSESSION' in str(e):
--> 253                     raise e
    254 
    255         return self._entry

AttributeError: 'Response' object has no attribute 'keys'

Dom McIntyre

unread,
Nov 11, 2016, 1:53:03 PM11/11/16
to xnat_discussion, moo...@wustl.edu
Have you managed to get past this problem? It doesn't look like a certificate issue to me.
From the pyxnat source:
            verify: True, False, or path to file containing certificate for your site
             
Added to the requests Session, as documented here:
              http
://docs.python-requests.org/en/latest/user/advanced/#ssl-cert-verification
             
Simplifies handling self-certified sites, or sites where there is an issue
             
with certification

If you don't have a valid certificate with a chain back to a trusted CA, by default the login will fail, as verify defaults to True. If you set it to False, you should get a torrent of warnings to the effect of C:\...\requests\packages\urllib3\connectionpool.py:838: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/security.html  InsecureRequestWarning), but the login will succeed and the API will function; the SilenceInsecureRequestWarning setting you're using just silences the warnings, it doesn't alter the https communications. If you're using a self-signed certificate, you can supply the path to that as the value of verify, and it will be treated as a trusted certificate - this is a more desirable method than just using verify=false. TLDR, just verify=false should get you a responsive pyxnat.Interface.

The only way I can deliberately trigger the specific error you see is by editing interfaces.py to set DEBUG to True (which means a line of code using response.keys() will be executed) and then trying to log in with an incorrect password; that causes some debug code to be run which tries to print response.keys(), which triggers the attribute error (so you wouldn't see that if you turned DEBUG off again). That code is only run if the requests.get() response is bad. What version of xnat is running on your server? If it's pre-1.5, I can see something in the code which might cause this to happen, and again I think it would not fail if you turned DEBUG off.

John McLean

unread,
Dec 19, 2016, 6:28:17 AM12/19/16
to xnat_di...@googlegroups.com, moo...@wustl.edu
Thanks Dom for your input. Sorry for the delay in my reply. I've been away from XNAT admin for a while. I'll look through your comments and revisit this to see if I can resolve the problem. Thanks again.

John

--
You received this message because you are subscribed to a topic in the Google Groups "xnat_discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/xnat_discussion/WieRHNZIJCI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to xnat_discussion+unsubscribe@googlegroups.com.
To post to this group, send email to xnat_discussion@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages