File: gfal2_python_listdir.py

package info (click to toggle)
gfal2-bindings 1.13.0-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 688 kB
  • sloc: cpp: 2,574; python: 1,050; sh: 109; makefile: 92
file content (26 lines) | stat: -rwxr-xr-x 571 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Example : list the content of a directory with gfal 2.0
#

import sys
import os
import gfal2


## main func
if __name__ == '__main__':
	# comment for usage
	if(len(sys.argv) < 2):
		print("\nUsage\t %s [gfal_folder] \n"%(sys.argv[0]))
		print("    Example: %s lfn:/grid/dteam/ "%(sys.argv[0]))
		print("             %s srm://myserver.com/myhome/ \n"%(sys.argv[0]))
		os._exit(1)

	ctx = gfal2.creat_context()		
	my_dir = ctx.listdir(sys.argv[1])
	for d in my_dir:
		print(d)
	
	# no closedir needed, done automatically