File: gfal2_get_turls.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 (28 lines) | stat: -rwxr-xr-x 574 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
27
28
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Example : get list of turls/replicas with gfal 2.0
#

import gfal2
import sys

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: %s [surl]" % sys.argv[0])
        sys.exit(1)

    surl = sys.argv[1]

    ctx = gfal2.creat_context()
    try:
        replicas = ctx.getxattr(surl, 'user.replicas') 
        print(replicas)
    except gfal2.GError as e:
        print("Could not get the replicas:")
        print("\t", e.message)
        print("\t Code", e.code)
        sys.exit(2)

    sys.exit(0)