File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 157157 "RM_COLL201_AN" : 663 ,
158158 "OPEN_COLLECTION201_AN" : 712 ,
159159
160+ "GET_LIBRARY_FEATURES_AN" : 801 ,
161+
160162 # 1000 - 1059 - NETCDF API calls
161163 "NC_OPEN_AN" : 1000 ,
162164 "NC_CREATE_AN" : 1001 ,
Original file line number Diff line number Diff line change @@ -69,6 +69,17 @@ class MultipleResultsFound(QueryException):
6969 pass
7070
7171
72+ class NotImplementedInIRODSServer (RuntimeError ):
73+ def __init__ (self , feature_description , required_iRODS_version = ()):
74+ super (NotImplementedInIRODSServer ,self ).__init__ (feature_description + ': Not supported by the connected iRODS server.' )
75+ self .required_iRODS_version = required_iRODS_version
76+ def __str__ (self ):
77+ nv = self .required_iRODS_version
78+ return '{}{}' .format (self .args , ' [requires iRODS version: {nv}]' .format (** locals ()) if nv else '' )
79+ def __repr__ (self ):
80+ return self .__class__ .__name__ + str (self )
81+
82+
7283class iRODSExceptionMeta (type ):
7384 codes = {}
7485 positive_code_error_message = "For {name}, a positive code of {attrs[code]} was declared."
Original file line number Diff line number Diff line change 2121from irods .manager .user_manager import UserManager , GroupManager
2222from irods .manager .resource_manager import ResourceManager
2323from irods .manager .zone_manager import ZoneManager
24- from irods .message import iRODSMessage
25- from irods .exception import NetworkException
24+ from irods .message import ( iRODSMessage , STR_PI )
25+ from irods .exception import ( NetworkException , NotImplementedInIRODSServer )
2626from irods .password_obfuscation import decode
2727from irods import NATIVE_AUTH_SCHEME , PAM_AUTH_SCHEMES
2828from . import DEFAULT_CONNECTION_TIMEOUT
@@ -61,6 +61,17 @@ class NonAnonymousLoginWithoutPassword(RuntimeError): pass
6161
6262class iRODSSession (object ):
6363
64+ def library_features (self ):
65+ irods_version_needed = (4 ,3 ,1 )
66+ if self .server_version < irods_version_needed :
67+ raise NotImplementedInIRODSServer ('library_features' , irods_version_needed )
68+ message = iRODSMessage ('RODS_API_REQ' , int_info = api_number ['GET_LIBRARY_FEATURES_AN' ])
69+ with self .pool .get_connection () as conn :
70+ conn .send (message )
71+ response = conn .recv ()
72+ msg = response .get_main_message ( STR_PI )
73+ return json .loads (msg .myStr )
74+
6475 @property
6576 def env_file (self ):
6677 return self ._env_file
Original file line number Diff line number Diff line change 1+ #! /usr/bin/env python
2+ from __future__ import absolute_import
3+ import os
4+ import sys
5+ import unittest
6+
7+ import irods .test .helpers as helpers
8+
9+ class TestLibraryFeatures (unittest .TestCase ):
10+
11+ def setUp (self ):
12+ self .sess = helpers .make_session ()
13+
14+ def tearDown (self ):
15+ """Close connections."""
16+ self .sess .cleanup ()
17+
18+ def test_library_features__issue_556 (self ):
19+ if self .sess .server_version < (4 , 3 , 1 ):
20+ self .skipTest ('Do not test library features before iRODS 4.3.1' )
21+
22+ features = self .sess .library_features ()
23+
24+ # Test that returned features are in the form of a Python dict object.
25+ self .assertIsInstance (features , dict )
26+
27+ # Test that features is populated by at least one item.
28+ self .assertTrue (features )
29+
30+ if __name__ == '__main__' :
31+ # let the tests find the parent irods lib
32+ sys .path .insert (0 , os .path .abspath ('../..' ))
33+ unittest .main ()
You can’t perform that action at this time.
0 commit comments