i wanna copy a file to my test device to a specific folder e.g. /data/test/ which is mounted on my /dev/sda7 partition which is only 10GB.
Now it can happen that the partition is full or almost full so that my new file will not fit. Now if this happens i get this error from “Put File” : | FAIL |11:50:22 OSError: Failure
For now i have a (stupid but working) solution to just remove all files in /data/test using “Execute Command” from the SSHLibrary before copying over new file - and i also use TRY CATCH to handle exceptions.
But well i thought a better way would be to have a function to check for free disk space in /data/test before starting the file copy and looks like it’s not a big deal do to this using python but is there something in RF to get free disk space or do i have to do it in python and then use it along RF
I don’t know of an RF library that would do that for you (does not mean there is none).
Moreover, such RF library would likely get the disk size of the machine hosting the tests, not the device you want to SSH copy files to.
I believe your best bet would be to execute some command specific to your device OS through SSHLibrary Execute Command, then parse the STDOUT of this command to work out if you have enough space.
i’m not running the test locally but remote.
I need to copy over a file size ~3GB to my device thus i use SSHLibrary Put File command - and for now /data/test/ contains only test data which can/will be cleared - so my current solution where i just rm -f all files in /data/test using Execute Command is working fine.
I just thought of doing a “check” if there is sufficient space available for my file i want to transfer before doing this to avoid the “OSError: Failure” when the disk is full. This happend because some pre-tasks failed and old test data was not removed from /data/test/ - which i now fixed.
I also read about the python way using shutil - but this is also working locally - so i would need to run it on my remote device - and i think going the regexp way is also fine.