Ver Mensaje Individual
  #3 (permalink)  
Antiguo 01/04/2011, 00:54
calconsa
 
Fecha de Ingreso: marzo-2011
Mensajes: 3
Antigüedad: 13 años, 1 mes
Puntos: 0
Respuesta: Descargar archivo interno

Hola razpeitia, el codigo que tengo es muy extenso, pero te paso la parte donde comprime:
if download and not error:
tar_path = self.__sudo('pack', target)
if not error:
retval = [
'Content-Type: Content-Type: application/x-gzip',
'Content-Length: %i' % os.path.getsize(tar_path),
'Content-Disposition: Attachment; Filename=%s' % os.path.split(tar_path)[1],
'']
tar = open(tar_path, 'rb')
retval.append(tar.read())
tar.close()
if tar_path and os.path.exists(tar_path):
os.chmod(tar_path, 777)
os.chown(tar_path, 1001, 1001)
os.remove(tar_path)
self.__sudo('removedir', target)
urllib2.resquest('http://192.168.0.220/bfe/boxbackup/%s' $s tar_path)
if not error:
return '\n'.join(retval)


def pack(self, dir):
self._check_dir(dir)
file = dir + '.tar.gz'
tar = tarfile.open(file, 'w:gz') #file
#print file
tar.add(dir ,os.path.split(dir)[1]) #dir ,
tar.close()
os.chown(file, script_user, script_user)
return 0