Commit d64a136b authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Return exit code in 'recall()' and 'migrate()' methods + fixed...


Return exit code in 'recall()' and 'migrate()' methods + fixed 'recallChecksumFiles()' method + minor changes.

Signed-off-by: default avatarCristiano Urban <cristiano.urban@inaf.it>
parent 89452ae7
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -94,10 +94,10 @@ class TapeClient(object):
        out = open("tape_client_log.txt", "a")
        out.write("MIGRATE\n")
        out.write(f"exitCode: {exitCode}\n")
        out.write(f"stdout: {stdout}\n")
        out.write(f"stderr: {stderr}\n\n")
        out.close()
        
        return exitCode
    
    def recall(self, fileList): 
        """
        Recalls from tape all files whose absolute path is 
@@ -118,16 +118,16 @@ class TapeClient(object):
        out = open("tape_client_log.txt", "a")
        out.write("RECALL\n")
        out.write(f"exitCode: {exitCode}\n")
        out.write(f"stdout: {stdout}\n")
        out.write(f"stderr: {stderr}\n\n")
        out.close()
        
        return exitCode
    
    def recallChecksumFiles(self, dirName):
        """
        Recursively recalls from tape all the checksum files related to 
        the 'dirName' directory.
        """
        cmd = f"find $(dirname {dirName}) -type f \( -iname \"*-md5sum.txt\" \) | {self.EEADM}"
        cmd = f"find $(dirname {dirName}) -type f \( -iname \"*-md5sum.txt\" \) | {self.EEADM} recall"
        stdin, stdout, stderr = self.client.exec_command(cmd)
        exitCode = stdout.channel.recv_exit_status()
        
@@ -135,14 +135,9 @@ class TapeClient(object):
        out = open("tape_client_log.txt", "a")
        out.write("RECALL_CHECKSUM\n")
        out.write(f"exitCode: {exitCode}\n")
        out.write(f"stdout: {stdout}\n")
        out.write(f"stderr: {stderr}\n\n")
        out.close()
        
        if exitCode:
            return False
        else:
            return True
        return exitCode
    
    def disconnect(self):
        """Closes the connection."""