irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

manual_cleanup.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import shutil
4 
5 from irods import lib
6 from irods.test import session
7 from irods.configuration import IrodsConfig
8 from irods.test import settings
9 
10 test_user_list = ['alice', 'bobby', 'otherrods', 'zonehopper', 'admin']
11 test_resc_list = ['AnotherResc', 'TestResc', 'pt', 'leaf']
12 
13 # make admin session
14 irods_config = IrodsConfig()
15 admin_name = irods_config.client_environment['irods_user_name']
16 zone_name = irods_config.client_environment['irods_zone_name']
17 env_dict = lib.make_environment_dict(admin_name, settings.ICAT_HOSTNAME, zone_name, use_ssl=settings.USE_SSL)
18 sess = session.IrodsSession(env_dict, settings.PREEXISTING_ADMIN_PASSWORD, False)
19 
20 # clean trash
21 sess.run_icommand('irmtrash -M')
22 
23 # remove test stuff
24 for user_name in test_user_list:
25  # get permission on user's collection
26  sess.run_icommand('ichmod -rM own {admin_name} /{zone_name}/home/{user_name}'.format(**locals()))
27 
28  # remove test data in user's home collection
29  out, _, _ = sess.run_icommand('ils /{zone_name}/home/{user_name}'.format(**locals()))
30  entries = out.split()
31  if len(entries) > 1:
32  for entry in entries[1:]:
33  # collection
34  if entry.startswith('/'):
35  sess.run_icommand('irm -rf {entry}'.format(**locals()))
36  # data object
37  elif entry != 'C-':
38  sess.run_icommand('irm -f /{zone_name}/home/{user_name}/{entry}'.format(**locals()))
39 
40  # remove user
41  sess.run_icommand('iadmin rmuser {user_name}'.format(**locals()))
42 
43 # remove parent-child relationships
44 sess.run_icommand('iadmin rmchildfromresc pt leaf')
45 
46 # remove resources
47 for resource in test_resc_list:
48  sess.run_icommand('iadmin rmresc {resource}'.format(**locals()))
49 
50 # remove local files
51 shutil.rmtree('/tmp/federation_test_stuff', ignore_errors=True)
irods.configuration.IrodsConfig
Definition: configuration.py:22
irods.configuration
Definition: configuration.py:1