Jun-25-2019, 05:49 PM
The zipfile itself should be outside of "server1".
To zip the directory "server1", you have to loop over the files.
To zip the directory "server1", you have to loop over the files.
!/usr/bin/python3 import os, zipfile server1 = "test" log_file_name = "logfile" zip_file = zipfile.ZipFile(log_file_name + ".zip", "w") for dirname, subdirs, files in os.walk(server1): for filename in files: zip_file.write(os.path.join(dirname, filename)) zip_file.close()