Hi all,
i have made some “ugly” code any maybe you can help me to made it “nice”.
So my use case is that i have to download an image from a server to client-1 and then copy this file from my client-1 to another client-2.
The download from my server is done using “jfrog-cli” a tool which use checksums so i know that the download from server → client-1 is fine.
Now i use SSHLibrary to copy this file from client-1 to client-2 by “Put File…” and because my image is ~4GB i need to be sure the copying went fine.
For this i just do a sha1sum to the image on client-1 - then copy the file over to client-2 and use sha1sum via Execute Command on client-2. Then i just compare the sha1 sum’s using “Should be Equal as Strings”.
btw: sha1 is totaly sufficent for my needs - i could also use MD5 - i just want to know that during the 4GB copying nothing went bad.
This is my code:
${image_on_client-1}= Run Process sha1sum ${PATH_ON_HOST}${image_file}
shell=True
${image_on_client-2}= Remote Execute Command sha1sum
${PATH_ON_TARGET}${image_file}
${foo}= Split String ${image_on_client-1.stdout}
${bar}= Split String ${image_on_client-2}[0]
Should Be Equal As Strings ${foo}[0] ${bar}[0]
So this is working fine using the Split String. But is it possible to have the “Split String” somehow embedded to the “Should Be Equal as String” keyword?
E.g. like this
Should Be Equals As Strings (Split String ${image_on_client-1.stdout} Split String ${image_on_client-2}[0])
You should know that if you execute “sha1sum” the stdout will have the sha1sum (which i’m intrested in) and the full path of the image file seperated by a space. That’s why “Split String” will give me a list of 2 values (value [0] with the sha value i want, and value [1] with the full path i don’t care about)
Any help is welcome.
Br,
Camil
P.S.
Do not wonder about “Remote Execute Command” i made this keyword as an extension to “Execute Command” and put it as a Resource - the code is here:
Remote Execute Command
Set Log Level DEBUG
[Arguments] ${command} ${return_val}=${LIST_OF_RC}
${return_val} = Create List @{return_val}
${stdout} ${stderr} ${rc}= Execute Command ${command} return_stdout=True
return_stderr=True return_rc=True
${rc_as_String}= Convert To String ${rc}
List Should Contain Value ${return_val} ${rc_as_String}
[Return] ${stdout} ${rc_as_String}