55from subprocess import Popen , PIPE
66
77
8- # Put file to hpss
98def hpss_put (hpss , file , keep = True ):
9+ """
10+ Put a file to the HPSS archive.
11+ """
1012
1113 logging .info ('Transferring file to HPSS: %s' % (file ))
1214 path , name = os .path .split (file )
@@ -36,8 +38,10 @@ def hpss_put(hpss, file, keep=True):
3638 os .remove (file )
3739
3840
39- # Get file from hpss
4041def hpss_get (hpss , file ):
42+ """
43+ Get ia file from the HPSS archive.
44+ """
4145
4246 logging .info ('Transferring from HPSS: %s' % (file ))
4347 path , name = os .path .split (file )
@@ -63,3 +67,22 @@ def hpss_get(hpss, file):
6367 # Back to original working directory
6468 if path != '' :
6569 os .chdir (cwd )
70+
71+ def hpss_chgrp (hpss , group , recurse = False ):
72+ """
73+ Change the group of the HPSS archive.
74+ """
75+ if recurse :
76+ cmd = 'hsi chgrp -R {} {}' .format (group , hpss )
77+ else :
78+ cmd = 'hsi chgrp {} {}' .format (group , hpss )
79+
80+ p1 = Popen (shlex .split (cmd ), stdout = PIPE , stderr = PIPE )
81+ (stdout , stderr ) = p1 .communicate ()
82+ status = p1 .returncode
83+ if status != 0 :
84+ logging .error ('Changing group of HPSS archive {} to {}' .format ())
85+ logging .debug ('stdout:\n %s' , stdout )
86+ logging .debug ('stderr:\n %s' , stderr )
87+ raise Exception
88+
0 commit comments