Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (25 sloc) 864 Bytes
import subprocess
import os
import zipfile
def subprocess_execute(cmd,print_info=True):
''' Function to use subprocess to execute a shell command and return outputs.
if print_info:
print('... cmd to execute:')
print('... result:')
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(result, error) = process.communicate()
rc = process.wait()
if rc != 0:
print("Error: failed to execute command:", cmd)
return result.decode('utf-8')
def zipdir(path, zip_name=''):
''' Function to zip a folder.
zipf = zipfile.ZipFile('', 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk(path):
for file in files:
zipf.write(os.path.join(root, file))
You can’t perform that action at this time.