3.3 datagrid.copy Example

This example fetches the specified source file to the destination. A recursive copy is then attempted if setRecursive(True) is set. The default is a single file copy. A multicast also is attempted if setMulticast(True) is set. The default is to do a unicast copy.The following example copies a file from the data grid to a resource, then read the lines of the file:

1      datagrid = DataGrid()
2      datagrid.copy("grid:///images/myFile","myLocalFile")
3      text = open("myLocalFile").readlines()

This is an example to recursively copy a directory and its sub directories from the data grid to a resource:

 
4      datagrid = DataGrid()
5      datagrid.setRecursive(True)
6      datagrid.copy("grid:///testStore/testFiles","/home/tester/myLocalFiles")

Here’s an example to copy down a file from the job deployment area to a resource and then read the lines of the file:


7     datagrid = DataGrid()
8     datagrid.copy("grid:///!myJob/myFile","myLocalFile")
9    text = open("myLocalFile").readlines()

Here are the same examples without using the shortcut characters. This shows the job “myJob” is under the “jobs” directory under the Datagrid root:

10     datagrid = DataGrid()
11     datagrid.copy("grid:///jobs/myJob/myFile","myLocalFile")
12     text = open("myLocalFile").readlines()