Re: Download .jpg from web

2005-01-06 Thread ralobao
You could try using: urlllib.urlretrieve ...it may be faster.

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


Re: ZipFile and file rigths

2005-07-10 Thread ralobao
You can use os.chmod to fix it.

Here the description:

os.chmod

Docstring:
chmod(path, mode)

Change the access permissions of a file.

Cheers,

perchef escreveu:
> hi,
>
> i have written this small code which allow me to unzip files using
> python :
>
> import zipfile
> import os
> import os.path
>
> pathDir="/home/toto/Desktop"
> pathZip= os.path.join(pathDir,"foobar.zip")
>
> if zipfile.is_zipfile(pathZip):
> zf = zipfile.ZipFile(pathZip)
>
> for file in zf.namelist():
>   newPath = os.path.join(pathDir,file)
>   print newPath
>   if not file.endswith('/') and not os.path.exists(newPath) :
>   newFile = open(newPath, 'wb')
>   newFile.write(zf.read(file))
>   newFile.flush()
>   newFile.close()
>   else :
>   os.makedirs(newPath)
>
> zf.close()
> else:
> print pathZip + " is not a zip file"
>
> it works well but i have a small problem : i can't see how i can deal
> with file rights.
> When I unzip files with this script all the unzipped files haven't the
> good rights.
> for example :
>with this script :
>-rw-r--r-- foo.exe
>with a traditional zip program (ie : stuffit ):
>-rwxr-xr-x foo.exe
> ZipInfo objects doesn't store informations about rights ?
> (http://www.python.org/doc/current/lib/zipinfo-objects.html#zipinfo-objects)
> 
> How can i fix this ?

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


Re: beginner question fibonacci

2005-07-17 Thread ralobao
The case is that Python in attribution commands solves first the right
side, so he atributes the vars.

So the a+b expression is executed first.

Joon escreveu:
> >>> # Fibonacci series:
> ... # the sum of two elements defines the next
> ... a, b = 0, 1
>  >>> while b < 10:
> ...   print b
> ...   a, b = b, a+b
> ...
> 1
> 1
> 2
> 3
> 5
> 8
>
>
>
>  >>> a, b = 0, 1
>  >>> while b < 10:
>   print b
>   a = b
>   b = a+b
> 
>   
> 1
> 2
> 4
> 8
> 
> Why a, b = b, a+b isn't a = b; b = a+b ?

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


Problem while trying to extract a directory from a zipfile.

2004-12-07 Thread ralobao
I have this code:

try:
file = zipfile.ZipFile(nome_arquivo)
Gauge.start() #inicia o Gauge
for element in file.namelist():
try:
newFile = open(diretorio + element,"wb")
except:
newFile = open(diretorio + element + '/',"w")
# Gauge
percent = percent + 10
Gauge.update(percent)
Gauge.set_text("Extraindo" + element)
# Extrai
newFile.write(file.read(element))
newFile.close()

But when i try to extract an zipfile with a directory in it the code
returns me an IOErro exception: "It is a directory"

Please how can i solve it ?
-- 
http://mail.python.org/mailman/listinfo/python-list