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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
#!/bin/env python
#/*******************************************************************/
#/* XDMF */
#/* eXtensible Data Model and Format */
#/* */
#/* Id : $Id: NdgmCp.py,v 1.2 2009-01-23 20:48:53 clarke Exp $ */
#/* Date : $Date: 2009-01-23 20:48:53 $ */
#/* Version : $Revision: 1.2 $ */
#/* */
#/* Author: */
#/* Jerry A. Clarke */
#/* clarke@arl.army.mil */
#/* US Army Research Laboratory */
#/* Aberdeen Proving Ground, MD */
#/* */
#/* Copyright @ 2002 US Army Research Laboratory */
#/* All Rights Reserved */
#/* See Copyright.txt or http://www.arl.hpc.mil/ice for details */
#/* */
#/* This software is distributed WITHOUT ANY WARRANTY; without */
#/* even the implied warranty of MERCHANTABILITY or FITNESS */
#/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
#/* for more information. */
#/* */
#/*******************************************************************/
from __future__ import print_function
import os
import sys
import string
import Xdmf
from NdgmLs import *
class NdgmCp :
def __init__( self, From, To ) :
self.Host = None
self.From = From
self.FromIsFile = 1
self.To = To
self.ToIsFile = 1
l = string.split( From, ':' )
if len(l) > 1 :
self.FromIsFile = 0
host, name = string.split( From, ':' )
if len( host ) > 0 :
if string.upper( host ) == 'NDGM' :
host = None
self.Host = host
self.From = name
l = string.split( To, ':' )
if len(l) > 1 :
self.ToIsFile = 0
host, name = string.split( To, ':' )
if len( host ) > 0 :
if string.upper( host ) == 'NDGM' :
host = None
self.Host = host
self.To = name
if self.To == '.' :
self.To = self.From
self.Conn = NdgmLs( self.Host )
self.Conn.Ls()
self.Entries = self.Conn.Format()
def Get( self ) :
if self.FromIsFile :
self.FromLength = os.path.getsize( self.From )
else :
for entry in self.Entries :
entry = string.split( entry )
if self.From == entry[0] :
self.FromStart = int( entry[1] )
self.FromEnd = int( entry[2] )
self.FromLength = self.FromEnd - self.FromStart
print ('Source Data is %d bytes' % self.FromLength)
def Put( self ) :
if self.ToIsFile :
if self.FromIsFile :
Cmd = 'cp ' + self.From + ' ' + self.To
print (Cmd)
os.system( Cmd )
else :
From = str(self.FromStart) + ':' + str(self.FromEnd)
Cmd = 'ice ndgm_cat ' + From + ' ' + self.To
print (Cmd)
os.system( Cmd )
else :
Found = 0
for entry in self.Entries :
entry = string.split( entry )
if self.To == entry[0] :
Found = 1
self.ToStart = int( entry[1] )
self.ToEnd = int( entry[2] )
self.ToLength = self.ToEnd - self.ToStart
break
if Found :
pass
else :
Xdmf.XdmfAddNdgmEntry( self.To, self.FromLength )
self.Conn.Ls()
self.Entries = self.Conn.Format()
for entry in self.Entries :
entry = string.split( entry )
if self.To == entry[0] :
Found = 1
self.ToStart = int( entry[1] )
self.ToEnd = int( entry[2] )
self.ToLength = self.ToEnd - self.ToStart
break
if self.FromIsFile :
From = self.From
else :
From = str(self.FromStart) + ':' + str(self.FromEnd)
Cmd = 'ice ndgm_cat ' + From + ' ' + str( self.ToStart )
print (Cmd)
os.system( Cmd )
if __name__ == '__main__' :
argc = len( sys.argv )
n = NdgmCp( sys.argv[ argc - 2 ] , sys.argv[ argc - 1 ] )
n.Get()
n.Put()
|