Re.'Compressing folders in Windows using Python'

2006-01-02 Thread sri2097
Hi all,This is in reply to the 'Compressing folders in Windows using
Python' query I raised y'day.

I figured out that windows does not allow command line zipping so I
started looking for alternatives.

I found some modules in Perl which does zipping. I guess it goes by the
name 'gzip'. I plan to write the zipping feature in Perl and import it
into Python.

Thanx a lot for all those who took time to answer my query. If you find
any loophole in the above approach feel free to drop me mail...

Srikar

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Peter Hansen
sri2097 wrote:
 Hi all,This is in reply to the 'Compressing folders in Windows using
 Python' query I raised y'day.
 
 I figured out that windows does not allow command line zipping so I
 started looking for alternatives.
 
 I found some modules in Perl which does zipping. I guess it goes by the
 name 'gzip'. I plan to write the zipping feature in Perl and import it
 into Python.

Cool!  When you're done, check out 
http://docs.python.org/lib/module-gzip.html and see how yours compares 
with the standard one... ;-)

-Peter

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Ravi Teja
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/299412

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Tim N. van der Leeuw
Isn't it much easier to figure out how python built-in module 'zipfile'
works?

Pseudo-code would be something like:

#UNTESTED
import zipfile
import os
import os.path

zf = zipfile.ZipFile('myzipfilename.zip', 'w', zipfile.ZIP_DEFLATED)
for root, dirs, files in os.walk('compressthisdir'):
for f in riles:
fullname = os.join(root, f)
zf.write(fullname)
zf.close()


Cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Re.'Compressing folders in Windows using Python'

2006-01-02 Thread Tim N. van der Leeuw
Using gzip means you can compress only 1 file per gzip; so you'll have
to invent something like tar to put all your files in your directories
together into 1 file and then apply gzip on that file to get it
compressed...

Using the zipfile module should allow you to create a standard
winzip-compatible archive that puts all files directly into 1
compressed archive.

cheers,

--Tim

-- 
http://mail.python.org/mailman/listinfo/python-list


Compressing folders in Windows using Python.

2006-01-01 Thread sri2097
Hi,
I'm trying to zip a particular fiolder and place the zipped folder into
a target folder using python. I have used the following command in
'ubuntu'.

zip_command = 'zip -qr %s %s' % (target, ' '.join(source))

I execute this using os.command(zip_command). It works fine...

But when I run this script in Windows XP, I get an error while
executing the above zip command. What command is there to zip files in
Windows? Or is there any other problem ?

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread Steven D'Aprano
On Sun, 01 Jan 2006 04:07:11 -0800, sri2097 wrote:

 Hi,
 I'm trying to zip a particular fiolder and place the zipped folder into
 a target folder using python. I have used the following command in
 'ubuntu'.
 
 zip_command = 'zip -qr %s %s' % (target, ' '.join(source))
 
 I execute this using os.command(zip_command). It works fine...
 
 But when I run this script in Windows XP, I get an error while
 executing the above zip command. 

Would you like to tell us what error you get?

No no, I'll just guess... your disk is full... am I close?

*wink*

 What command is there to zip files in Windows? Or is there any other problem ?

What happens if you call up a Windows command prompt and type zip at the
prompt?



-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread Heiko Wundram
Steven D'Aprano wrote:
 But when I run this script in Windows XP, I get an error while
 executing the above zip command.
 
 Would you like to tell us what error you get?

I presume the error he's seeing is something along the line of:

zip: Bad command or filename.

That's basically because there is no commandline builtin for zipping up
files on Windows, and I don't know of WinZIP or any of the InfoZIP derived
GUIs installing a command-line zipper.

What might help you though (and keep you platform-independent):

http://www.python.org/doc/2.4.2/lib/module-zipfile.html

--- Heiko.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread Heiko Wundram
Heiko Wundram wrote:
 That's basically because there is no commandline builtin for zipping up
 files on Windows, and I don't know of WinZIP or any of the InfoZIP derived
 GUIs installing a command-line zipper.

btw. the zip command isn't builtin on Unix either. It's only available if
you installed the corresponding InfoZIP package(s). I know pretty much
every Linux-distribution comes preinstalled with it (because of stuff like
ark, a KDE-frontend for archivers, requiring it), but you shouldn't rely on
that either.

--- Heiko.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread bren[at]gillatt.org
Heiko Wundram wrote:
 Steven D'Aprano wrote:
 
But when I run this script in Windows XP, I get an error while
executing the above zip command.

Would you like to tell us what error you get?
 
 
 I presume the error he's seeing is something along the line of:
 
 zip: Bad command or filename.
 
 That's basically because there is no commandline builtin for zipping up
 files on Windows, and I don't know of WinZIP or any of the InfoZIP derived
 GUIs installing a command-line zipper.
 
 What might help you though (and keep you platform-independent):
 
 http://www.python.org/doc/2.4.2/lib/module-zipfile.html
 
 --- Heiko.

Go and get something like 7-ZIP and put a path environment variable in.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread Christian Tismer
sri2097 wrote:
 Hi,
 I'm trying to zip a particular fiolder and place the zipped folder into
 a target folder using python. I have used the following command in
 'ubuntu'.
 
 zip_command = 'zip -qr %s %s' % (target, ' '.join(source))
 
 I execute this using os.command(zip_command). It works fine...
 
 But when I run this script in Windows XP, I get an error while
 executing the above zip command. What command is there to zip files in
 Windows? Or is there any other problem ?

zip is not a built-in command for windows.
You might use winzip or something else, there is
a bunch of different compression tools available.

ciao - chris

-- 
Christian Tismer :^)   mailto:[EMAIL PROTECTED]
tismerysoft GmbH : Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
14109 Berlin : PGP key - http://wwwkeys.pgp.net/
work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Compressing folders in Windows using Python.

2006-01-01 Thread Tim N. van der Leeuw

Christian Tismer wrote:
 sri2097 wrote:
  Hi,
  I'm trying to zip a particular fiolder and place the zipped folder into
  a target folder using python. I have used the following command in
  'ubuntu'.
 
  zip_command = 'zip -qr %s %s' % (target, ' '.join(source))
 
  I execute this using os.command(zip_command). It works fine...
 
  But when I run this script in Windows XP, I get an error while
  executing the above zip command. What command is there to zip files in
  Windows? Or is there any other problem ?

 zip is not a built-in command for windows.
 You might use winzip or something else, there is
 a bunch of different compression tools available.

 ciao - chris


Something else to watch for -- Spaces in filenames. Uncommon on
unix/linux, but very common on windows. Put some double-quotes around
the filenames in your zip_command:

zip_command = 'zip -qr %s %s' % (target, ' '.join(source))


AFAIK there are built-in zip modules available in Python? They might be
a better alternative to calling an external zip command?

(Winzip btw, has a seperate download for a command-line capable version
of the compressor)

cheers,

--Tim


 --
 Christian Tismer :^)   mailto:[EMAIL PROTECTED]
 tismerysoft GmbH : Have a break! Take a ride on Python's
 Johannes-Niemeyer-Weg 9A :*Starship* http://starship.python.net/
 14109 Berlin : PGP key - http://wwwkeys.pgp.net/
 work +49 30 802 86 56  mobile +49 173 24 18 776  fax +49 30 80 90 57 05
 PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
   whom do you want to sponsor today?   http://www.stackless.com/

-- 
http://mail.python.org/mailman/listinfo/python-list