diff --git a/TODO b/TODO index e55f1a7..f8ea182 100644 --- a/TODO +++ b/TODO @@ -20,8 +20,13 @@ [CHANGES] +None + [BUG FIXES] +- Fixed bug that caused program to exit after a failed + file transfer even when -a was specified. + TODO ---- diff --git a/tsshbatch.py b/tsshbatch.py index 554e4ea..9a458a3 100755 --- a/tsshbatch.py +++ b/tsshbatch.py @@ -20,7 +20,7 @@ CMDINCL = PROGENV + "CMDS" HOSTINCL = PROGENV + "HOSTS" -CVSID = "$Id: tsshbatch.py,v 1.209 2014/12/09 17:20:20 tundra Exp $" +CVSID = "$Id: tsshbatch.py,v 1.210 2014/12/09 18:16:46 tundra Exp $" VERSION = CVSID.split()[2] CPRT = "(c)" PROGDATE = "2011-2014" @@ -365,17 +365,34 @@ if destination[-1] != PATHSEP: destination += PATHSEP - if GET: - destination += host + HOSTSEP + os.path.basename(srcfile) - PrintStdout(iTXFILE % (host + ":" + srcfile, destination)) - sftp.get(srcfile, destination) - os.chmod(destination, sftp.stat(srcfile).st_mode) + try: - else: - destination += os.path.basename(srcfile) - PrintStdout(iTXFILE % (srcfile, host + ":" + destination)) - sftp.put(srcfile, destination) - sftp.chmod(destination, os.stat(srcfile).st_mode) + if GET: + destination += host + HOSTSEP + os.path.basename(srcfile) + PrintStdout(iTXFILE % (host + ":" + srcfile, destination)) + sftp.get(srcfile, destination) + os.chmod(destination, sftp.stat(srcfile).st_mode) + + else: + destination += os.path.basename(srcfile) + PrintStdout(iTXFILE % (srcfile, host + ":" + destination)) + sftp.put(srcfile, destination) + sftp.chmod(destination, os.stat(srcfile).st_mode) + + except: + + PrintReport([host, eFXERROR % str(sys.exc_info()[1])], HANDLER=PrintStderr) + + # Do we continue after failed file transfers or not? + if ABORTONFXERROR: + try: + sftp.close() + ssh.close() + + except: + pass + + ErrorExit("") sftp.close() ssh.close() @@ -384,15 +401,15 @@ PrintReport([host, eFXERROR % str(sys.exc_info()[1])], HANDLER=PrintStderr) - try: - sftp.close() - ssh.close() - - except: - pass - - # Do we continue or not? + # Do we continue after failed connection attempts or not? if ABORTONFXERROR: + try: + sftp.close() + ssh.close() + + except: + pass + ErrorExit("") # End of 'HostFileTransfer()' @@ -1032,7 +1049,7 @@ # Apply any relevant variable dereferencing host = VarSub(host) - print Put_Transfer_List + if Get_Transfer_List: HostFileTransfer(host, UNAME, PWORD, Get_Transfer_List, GET=True)