1313import re
1414import tarfile
1515import subprocess
16+ import uuid
1617from contextlib import redirect_stdout
1718
1819class Terminal ():
@@ -1434,11 +1435,12 @@ def index(self, local_loc, remote_loc, isVerbose=False):
14341435 st_dict ['created_time' ] = []
14351436 st_dict ['accessed_time' ] = []
14361437 st_dict ['mode' ] = []
1437- # st_dict['inode'] = []
1438+ st_dict ['inode' ] = []
14381439 st_dict ['device' ] = []
14391440 st_dict ['n_links' ] = []
14401441 st_dict ['uid' ] = []
14411442 st_dict ['gid' ] = []
1443+ st_dict ['uuid' ] = []
14421444 st_dict ['file_remote' ] = []
14431445
14441446 for file in file_list :
@@ -1455,11 +1457,12 @@ def index(self, local_loc, remote_loc, isVerbose=False):
14551457 st_dict ['created_time' ].append (st .st_ctime )
14561458 st_dict ['accessed_time' ].append (st .st_atime )
14571459 st_dict ['mode' ].append (st .st_mode )
1458- # st_dict['inode'].append(st.st_ino)
1460+ st_dict ['inode' ].append (st .st_ino )
14591461 st_dict ['device' ].append (st .st_dev )
14601462 st_dict ['n_links' ].append (st .st_nlink )
14611463 st_dict ['uid' ].append (st .st_uid )
14621464 st_dict ['gid' ].append (st .st_gid )
1465+ st_dict ['uuid' ].append (self .gen_uuid (st ))
14631466 st_dict ['file_remote' ].append (rfilepath )
14641467 st_list .append (st )
14651468
@@ -1626,7 +1629,7 @@ def copy(self, tool="copy", isVerbose=False, **kwargs):
16261629 stdout , stderr = process .communicate ()
16271630 returncode = process .communicate ()
16281631
1629- print ( " DSI submitted Conduit job. " )
1632+ print ( " DSI submitted Conduit data movement job. " )
16301633
16311634 # Database Movement
16321635 if isVerbose :
@@ -1638,21 +1641,57 @@ def copy(self, tool="copy", isVerbose=False, **kwargs):
16381641 stdout , stderr = process .communicate ()
16391642 returncode = process .communicate ()
16401643
1641- print ( " DSI submitted Conduit job. " )
1644+ print ( " DSI submitted Conduit data movement job. " )
16421645
16431646 except subprocess .CalledProcessError as e :
16441647 print (f"Command failed with error: { e .stderr } " )
1648+ elif tool == "pfcp" :
1649+ env = os .environ .copy ()
1650+
1651+ if not os .path .exists (self .remote_location ):
1652+ if isVerbose :
1653+ print ( " mkdir " + self .remote_location )
1654+ path = Path (self .remote_location )
1655+ try :
1656+ path .mkdir (parents = True )
1657+ except Exception :
1658+ print (f"Unable to create folder { abspath } . Do you have access rights?" )
1659+ raise
1660+
1661+ try :
1662+ #subprocess.call(["pfcp", "-r", self.local_location, self.remote_location], env=env, shell=True)
16451663
1664+ # File Movement
1665+ if isVerbose :
1666+ print ( "pfcp -R " + self .local_location + " " + os .path .join (self .remote_location , self .project_name ) )
1667+ cmd = ['pfcp' ,'-R' ,self .local_location , os .path .join (self .remote_location , self .project_name )]
1668+ process = subprocess .Popen (cmd , stdin = subprocess .DEVNULL , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , encoding = 'latin-1' )
1669+
1670+ stdout , stderr = process .communicate ()
1671+ returncode = process .communicate ()
1672+
1673+ print ( " DSI submitted pfcp data movement job. " )
16461674
1675+ # Database Movement
1676+ if isVerbose :
1677+ print ( " pfcp " + str (self .project_name + ".db" ) + " " + os .path .join (self .remote_location , self .project_name , self .project_name + ".db" ) )
1678+
1679+ cmd = ['pfcp' , str (self .project_name + ".db" ), os .path .join (self .remote_location , self .project_name , self .project_name + ".db" )]
1680+ process = subprocess .Popen (cmd , stdin = subprocess .DEVNULL , stdout = subprocess .PIPE , stderr = subprocess .PIPE , text = True , encoding = 'latin-1' )
1681+
1682+ stdout , stderr = process .communicate ()
1683+ returncode = process .communicate ()
1684+
1685+ print ( " DSI submitted pfcp data movement job. " )
1686+ except subprocess .CalledProcessError as e :
1687+ print (f"Command failed with error: { e .stderr } " )
16471688 elif tool == "ftp" :
16481689 True
16491690 elif tool == "git" :
16501691 True
16511692 else :
16521693 raise TypeError (f"Data movement format not supported:, Type: { tool } " )
16531694
1654-
1655-
16561695
16571696 def dircrawl (self ,filepath ):
16581697 """
@@ -1683,6 +1722,22 @@ def get(self, project_name = "Project"):
16831722 '''
16841723 True
16851724
1725+ def gen_uuid (self , st ):
1726+ '''
1727+ Generates a unique file identifier using the os.stat data object as the input
1728+
1729+ '''
1730+ inode = st .st_ino
1731+ ctime = st .st_ctime
1732+ unique_str = f"{ inode } -{ ctime } "
1733+
1734+ file_uuid = uuid .uuid5 (uuid .NAMESPACE_URL , unique_str )
1735+ print (f"UUID:{ file_uuid } " )
1736+ return file_uuid
1737+
1738+
1739+
1740+
16861741class TarFile ():
16871742 def __init__ (self , tar_name , local_files , local_tmp_dir = 'tmp' ):
16881743 self .tar_name = tar_name
0 commit comments