Forum Discussion
Steve_Brown_882
Feb 16, 2011Historic F5 Account
pyControl download_file
Has anyone used the config sync download file functionality in python. I have gotten the command to work as follows, but I am not really sure what I need to do to get the resulting data into a file on...
L4L7_53191
Feb 21, 2011Nimbostratus
Wow, this twisted my brain for a few minutes, but fortunately it turned out to be pretty easy. So here's what is going on: one of the attributes that's being set on the response data is named 'return', which is obviously a python keyword! To get the data, do this:
The return data is base64 encoded so we'll need to decode it to see anything useful.
import base64
ret = cs.download_file(file_name='/var/tmp/foo.txt',chunk_size=65536,file_offset=0)
Now, if you look at that 'ret' object, you'll see that it's got two attributes set: ret.file_offset, and ret.return. To get a that second guy, do this:
fdata = getattr(ret,'return').file_data
print base64.b64decode(fdata)
So once you do the b64decode you can write it out like a normal file, etc.
Hope this helps,
-Matt
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects