Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/04/2011, 08:28
Avatar de razpeitia
razpeitia
Moderador
 
Fecha de Ingreso: marzo-2005
Ubicación: Monterrey, México
Mensajes: 7.321
Antigüedad: 19 años, 1 mes
Puntos: 1360
Respuesta: Descargar archivo interno

Código Python:
Ver original
  1. if download and not error:
  2.     tar_path = self.__sudo('pack', target)
  3.     if not error:
  4.         retval = [
  5.                 'Content-Type: Content-Type: application/x-gzip',
  6.                 'Content-Length: %i' % os.path.getsize(tar_path),
  7.                 'Content-Disposition: Attachment; Filename=%s' % os.path.split(tar_path)[1],
  8.                 '']
  9.         tar = open(tar_path, 'rb')
  10.         retval.append(tar.read())
  11.         tar.close()
  12.         if tar_path and os.path.exists(tar_path):
  13.             os.chmod(tar_path, 777)
  14.             os.chown(tar_path, 1001, 1001)
  15.             os.remove(tar_path)
  16.         self.__sudo('removedir', target)
  17.         urllib2.resquest('http://192.168.0.220/bfe/boxbackup/%s' $s tar_path) #eror de sintaxis
  18.         if not error:
  19.             return '\n'.join(retval)
  20.  
  21.  
  22. def pack(self, dir):
  23.     self._check_dir(dir) #dir es un metodo buitl-in de python usa otro nombre
  24.     file = dir + '.tar.gz' #lo mismo con file
  25.     tar = tarfile.open(file, 'w:gz') #file
  26.     #print file
  27.     tar.add(dir ,os.path.split(dir)[1]) #dir ,
  28.     tar.close()
  29.     os.chown(file, script_user, script_user)
  30.     return 0

Realmente no puedo ayudarte mucho sin saber que es lo hacen tus demás funciones, si tu código es muy extenso subelo a un repo o a pastebin.com