/usr/share/arc/examples/sdk/partial_copy.py is in nordugrid-arc-python 5.0.5-1ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 29 30 | import arc
import sys
if len(sys.argv) != 2:
sys.stdout.write("Usage: python partial_copy.py filename\n")
sys.exit(1)
desired_size = 512
usercfg = arc.UserConfig()
url = arc.URL(sys.argv[1])
handle = arc.DataHandle(url,usercfg)
point = handle.__ref__()
point.SetSecure(False) # GridFTP servers generally do not have encrypted data channel
info = arc.FileInfo("")
point.Stat(info)
sys.stdout.write("Name: %s\n"%str(info.GetName()))
fsize = info.GetSize()
if fsize > desired_size:
point.Range(fsize-desired_size,fsize-1)
databuffer = arc.DataBuffer()
point.StartReading(databuffer)
while True:
n = 0
length = 0
offset = 0
( r, n, length, offset, buf) = databuffer.for_write(True)
if not r: break
sys.stdout.write("BUFFER: %d : %d : %s\n"%(offset, length, str(buf)))
databuffer.is_written(n)
point.StopReading()
|