[Sugar-devel] Need help with 'shutil'
Tony Anderson
tony_anderson at usa.net
Sat May 28 08:55:55 EDT 2016
Hi Ütkarsh,
I suppose shutil is a more elegant way to do it. I have become dependent
on subprocess as a 'swiss army knife'. It lets you issue any
shell command.
from subprocess import call, Popen, Pipe #generally covers all cases
cmd = 'zip -r my_folder.zip my_folder
call(cmd,cwd=root,shell=True)
If you use shutil, make sure that the resulting file is a zip file and
not a archive file (tarball).
Tony
On 05/28/2016 02:09 PM, Ütkarsh Tiwari wrote:
> Hi,
> I am trying to zip the contents of a directory using shutil but I
> am facing some issues.
>
> I want to zip the contents present inside 'root/my_folder/' directory
> to 'root/my_folder.zip'. I am unable to figure what exact commands
> shall I specify in "shutil.make_archive()" to get this done. Please
> help.
>
> Thanks,
> Utkarsh Tiwari
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
More information about the Sugar-devel
mailing list