def app_install(app, fobj, request, filename, overwrite=None):
 did_mkdir = False
 if (filename[(-4):] == '.w2p'):
  extension = 'w2p'
 elif (filename[(-7):] == '.tar.gz'):
  extension = 'tar.gz'
 else:
  extension = 'tar'
 upname = apath(('../deposit/%s.%s' % (app, extension)), request)
 try:
  write_file(upname, fobj.read(), 'wb')
  path = apath(app, request)
  if (not overwrite):
   os.mkdir(path)
   did_mkdir = True
  w2p_unpack(upname, path)
  if (extension != 'tar'):
   os.unlink(upname)
  fix_newlines(path)
  return upname
 except Exception:
  if did_mkdir:
   rmtree(path)
  return False

def app_install ( app , fobj , request , filename , overwrite = None ) : did_mkdir = False if ( filename [ ( - 4 ) : ] == '.w2p' ) : extension = 'w2p' elif ( filename [ ( - 7 ) : ] == '.tar.gz' ) : extension = 'tar.gz' else : extension = 'tar' upname = apath ( ( '../deposit/%s.%s' % ( app , extension ) ) , request ) try : write_file ( upname , fobj . read ( ) , 'wb' ) path = apath ( app , request ) if ( not overwrite ) : os . mkdir ( path ) did_mkdir = True w2p_unpack ( upname , path ) if ( extension != 'tar' ) : os . unlink ( upname ) fix_newlines ( path ) return upname except Exception : if did_mkdir : rmtree ( path ) return False
installs an application: - identifies file type by filename - writes fobj contents to the .