Added: Use ssh key for 8_upload script.

This commit is contained in:
kaetemi 2011-11-15 14:55:57 +01:00
parent bf9c288583
commit 72b8643d54

View file

@ -57,7 +57,7 @@ printLog(log, "")
Psftp = findFileMultiDir(log, ToolDirectories + WindowsExeDllCfgDirectories, UploadPsftpTool) Psftp = findFileMultiDir(log, ToolDirectories + WindowsExeDllCfgDirectories, UploadPsftpTool)
printLog(log, "PSFTP " + Psftp) printLog(log, "PSFTP " + Psftp)
def downloadVersionTag(server, user, dir): def downloadVersionTag(server, user, sshkey, dir):
if os.path.isfile("upload.tag"): if os.path.isfile("upload.tag"):
os.remove("upload.tag") os.remove("upload.tag")
if os.path.isfile("upload.batch"): if os.path.isfile("upload.batch"):
@ -67,7 +67,7 @@ def downloadVersionTag(server, user, dir):
ub.write("get upload.tag upload.tag\n") ub.write("get upload.tag upload.tag\n")
ub.write("quit\n") ub.write("quit\n")
ub.close() ub.close()
subprocess.call([ Psftp, "-b", "upload.batch", user + "@" + server ]) subprocess.call([ Psftp, "-b", "upload.batch", "-i", sshkey, user + "@" + server ])
os.remove("upload.batch") os.remove("upload.batch")
if os.path.isfile("upload.tag"): if os.path.isfile("upload.tag"):
ft = open("upload.tag") ft = open("upload.tag")
@ -122,8 +122,8 @@ def listDirectoryUpload(ft, ub, udb, dir):
printLog(log, "listDirectoryUpload: file not dir or file?!" + fileFull) printLog(log, "listDirectoryUpload: file not dir or file?!" + fileFull)
return nft return nft
def uploadSftp(server, user, dir_to, dir_from, addcmd): def uploadSftp(server, user, sshkey, dir_to, dir_from, addcmd):
ft = downloadVersionTag(server, user, dir_to) ft = downloadVersionTag(server, user, sshkey, dir_to)
if isDirectoryNeeded(ft, dir_from): if isDirectoryNeeded(ft, dir_from):
if os.path.isfile("upload_dir.batch"): if os.path.isfile("upload_dir.batch"):
os.remove("upload_dir.batch") os.remove("upload_dir.batch")
@ -146,8 +146,8 @@ def uploadSftp(server, user, dir_to, dir_from, addcmd):
ub.close() ub.close()
udb.write("quit\n") udb.write("quit\n")
udb.close() udb.close()
subprocess.call([ Psftp, "-be", "-b", "upload_dir.batch", user + "@" + server ]) subprocess.call([ Psftp, "-be", "-b", "upload_dir.batch", "-i", sshkey, user + "@" + server ])
subprocess.call([ Psftp, "-b", "upload.batch", user + "@" + server ]) subprocess.call([ Psftp, "-b", "upload.batch", "-i", sshkey, user + "@" + server ])
os.remove("upload_dir.batch") os.remove("upload_dir.batch")
os.remove("upload.batch") os.remove("upload.batch")
os.remove("upload.tag") os.remove("upload.tag")
@ -156,23 +156,23 @@ def uploadSftp(server, user, dir_to, dir_from, addcmd):
printLog(log, ">>> Upload patch <<<") printLog(log, ">>> Upload patch <<<")
for target in UploadPatch: for target in UploadPatch:
uploadSftp(target[0], target[1], target[3], ClientPatchDirectory + "/patch", [ ]) uploadSftp(target[0], target[1], target[2], target[3], ClientPatchDirectory + "/patch", [ ])
printLog(log, ">>> Upload data_shard <<<") printLog(log, ">>> Upload data_shard <<<")
for target in UploadShard: for target in UploadShard:
uploadSftp(target[0], target[1], target[3], DataShardDirectory, [ "rm *.packed_sheets", "rm primitive_cache/*.binprim" ]) uploadSftp(target[0], target[1], target[2], target[3], DataShardDirectory, [ "rm *.packed_sheets", "rm primitive_cache/*.binprim" ])
printLog(log, ">>> Upload data_common <<<") printLog(log, ">>> Upload data_common <<<")
for target in UploadCommon: for target in UploadCommon:
uploadSftp(target[0], target[1], target[3], DataCommonDirectory, [ ]) uploadSftp(target[0], target[1], target[2], target[3], DataCommonDirectory, [ ])
printLog(log, ">>> Upload data_leveldesign/leveldesign <<<") printLog(log, ">>> Upload data_leveldesign/leveldesign <<<")
for target in UploadLeveldesign: for target in UploadLeveldesign:
uploadSftp(target[0], target[1], target[3], LeveldesignDirectory, [ ]) uploadSftp(target[0], target[1], target[2], target[3], LeveldesignDirectory, [ ])
printLog(log, ">>> Upload data_leveldesign/primitives <<<") printLog(log, ">>> Upload data_leveldesign/primitives <<<")
for target in UploadPrimitives: for target in UploadPrimitives:
uploadSftp(target[0], target[1], target[3], PrimitivesDirectory, [ ]) uploadSftp(target[0], target[1], target[2], target[3], PrimitivesDirectory, [ ])
log.close() log.close()
if os.path.isfile("8_upload.log"): if os.path.isfile("8_upload.log"):