VUIIS / dax

Distributed Automation for XNAT
MIT License
25 stars 24 forks source link

Create XnatChangePrearchiveProject #432

Closed duettwe closed 11 months ago

duettwe commented 11 months ago

This script takes the new project name and a txt file as input. Txt file would be a line by line list of sessions.

123456
234567
345678
...
789012

It's currently saying that I don't have privileges for this though.

duettwe commented 11 months ago

@baxpr - Is the privileges issue going to be resolved when this gets pulled?

baxpr commented 11 months ago

Oh - no. What's the problem? Are you using an account with admin priv?

duettwe commented 11 months ago

Just my ACCRE account

baxpr commented 11 months ago

XNAT account - which XNAT account?

duettwe commented 11 months ago
(dax_v2.10.0) [duettwe@hickory ~]$ python rename_project.py --newProj HeckersESOP --txt HeckersESOP.txt
Moving Session 210201 to project HeckersESOP
pyxnat._exec failure:
                    URI: https://xnat2.vanderbilt.edu/xnat/data/services/prearchive/move
                    status code: 500
                    headers: {'Date': 'Tue, 12 Sep 2023 14:41:44 GMT', 'Server': 'Noelios-Restlet-Engine/1.1.10', 'Accept-Ranges': 'bytes', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 'self'", 'Content-Type': 'text/html;charset=ISO-8859-1', 'Content-Length': '378', 'Set-Cookie': 'SESSION_EXPIRATION_TIME="1694529703828,2700000"; Version=1; Path=/xnat/', 'Connection': 'close'}
                    content: b'<html>\n<head>\n   <title>Status page</title>\n</head>\n<body>\n<h3>The user daxtest has insufficient privileges for the requested operation on the resource xnat:projectData.</h3><p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">here</a>.<br>\nPlease continue your visit at our <a href="/">home page</a>.\n</p>\n</body>\n</html>\n'

Traceback (most recent call last):
  File "rename_project.py", line 45, in <module>
    xnat._exec(request_uri,'POST',post_body,{'content-type': 'application/x-www-form-urlencoded'})
  File "/home/duettwe/.local/lib/python3.8/site-packages/dax/XnatUtils.py", line 301, in _exec
    result = super()._exec(
  File "/home/duettwe/.local/lib/python3.8/site-packages/pyxnat/core/interfaces.py", line 357, in _exec
    catch_error(response.content, '''pyxnat._exec failure:
  File "/home/duettwe/.local/lib/python3.8/site-packages/pyxnat/core/errors.py", line 84, in catch_error
    raise DatabaseError(full_response)
pyxnat.core.errors.DatabaseError: pyxnat._exec failure:
                    URI: https://xnat2.vanderbilt.edu/xnat/data/services/prearchive/move
                    status code: 500
                    headers: {'Date': 'Tue, 12 Sep 2023 14:41:44 GMT', 'Server': 'Noelios-Restlet-Engine/1.1.10', 'Accept-Ranges': 'bytes', 'X-Content-Type-Options': 'nosniff', 'X-XSS-Protection': '1; mode=block', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 'self'", 'Content-Type': 'text/html;charset=ISO-8859-1', 'Content-Length': '378', 'Set-Cookie': 'SESSION_EXPIRATION_TIME="1694529703828,2700000"; Version=1; Path=/xnat/', 'Connection': 'close'}
                    content: b'<html>\n<head>\n   <title>Status page</title>\n</head>\n<body>\n<h3>The user daxtest has insufficient privileges for the requested operation on the resource xnat:projectData.</h3><p>You can get technical details <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.1">here</a>.<br>\nPlease continue your visit at our <a href="/">home page</a>.\n</p>\n</body>\n</html>\n'
duettwe commented 11 months ago

It doesn't ask for an XNAT account.

baxpr commented 11 months ago

Needs to be authenticated before making the post request. Curl has -n option to use .netrc file, but I'm not sure about python requests library. Could open a JSESSION maybe?

duettwe commented 11 months ago

https://requests.readthedocs.io/en/latest/user/authentication/?highlight=.netrc#netrc-authentication

This seems to think it checks the netrc automatically? Or am I reading that entirely wrong?

duettwe commented 11 months ago

Changed the .netrc to use the admin account, worked great!

The only problem with these is the sessions being named like 210201-x-Heckers_210201. Wouldn't that create a new session under the 210201 subject with that name and put the examcard there?