def handle_uploaded_file(afile): path = '/tmp/'+afile.name with open(path, 'wb+') as destination: for chunk in afile.chunks(): destination.write(chunk) data = getData(path) if data != None: ind = random.randint(999,99999) nombre = data[0][:30] icon = extractIcon(path,ind) versionName = data[2][:20] version = data[3] d = open(path,"rb").read(512) thash = sha256(d) sha = thash.hexdigest() print sha aux = apks.objects.filter(sha=sha) if len(aux) > 0: raise Exception('aplicacion duplicada') a = apks(sha=sha,nombre=nombre,icon=icon,descripcion="",ruta=data[0]+"_"+str(ind)+"/"+afile.name,versionName=versionName,version=version,pool=999,ind=ind,relativo="") a.save() os.mkdir(settings.UPLOAD_POOL+"/"+data[0]+"_"+str(ind)) copy(path,settings.UPLOAD_POOL+"/"+data[0]+"_"+str(ind)) os.remove(path)
def create_db(): repo_index = 0 amm = 0 lapk = list_apks() #calcular la cantidad total de aplicaciones for k in lapk: amm += len(k) for k in lapk: for i in k: theAPKdata = get_data(i) if theAPKdata: ruta = i.replace(POOL[repo_index], "") mkl = apks.objects.filter(ruta=ruta) if len(mkl): if mkl[0].relativo != get_relatives(i): print 'cambiando relativos para',mkl[0].nombre mkl[0].relativo = get_relatives(i) mkl[0].save() continue nombre = theAPKdata[0][:30] version = theAPKdata[3] icon = extract_icon(i, version) versionName = theAPKdata[2][:20] data = open(i, "rb").read() thash = sha256(data) sha = thash.hexdigest() try: aux = apks.objects.filter(sha=sha) if len(aux) > 0: move_or_delete(i) print 'aplicacion duplicada', i, 'movida a', settings.TRASHCAN else: if POOL[repo_index] == POOL[-1]: tpool = '999' else: tpool = str(repo_index) a = apks(sha=sha, nombre=nombre, icon=icon, descripcion="", ruta=i.replace(POOL[repo_index], ""), versionName=versionName, version=version, pool=tpool, relativo=get_relatives(i)) a.save() except: move_or_delete(i) print "No se puede insertar " + nombre + " archivo: " + i + ' movida a ' + settings.TRASHCAN else: print "No se puede obtener los datos de: " + i + ' movida a ' + settings.TRASHCAN move_or_delete(i) #print ">> " + str(ind) + '/' + str(amm) repo_index += 1
def handle_uploaded_file(afile): path = '/tmp/' + afile.name with open(path, 'wb+') as destination: for chunk in afile.chunks(): destination.write(chunk) data = get_data(path) if data != None: ind = data[3] nombre = data[0][:30] icon = extract_icon(path, ind) versionName = data[2][:20] version = data[3] d = open(path, "rb").read(512) thash = sha256(d) sha = thash.hexdigest() aux = apks.objects.filter(sha=sha) if len(aux) > 0: raise Exception('aplicacion duplicada') a = apks(sha=sha, nombre=nombre, icon=icon, descripcion="", ruta=data[0] + "_" + str(ind) + "/" + afile.name, versionName=versionName, version=version, pool=999, ind=ind, relativo="") a.save() os.mkdir(settings.UPLOAD_POOL + "/" + data[0] + "_" + str(ind)) copy(path, settings.UPLOAD_POOL + "/" + data[0] + "_" + str(ind)) os.remove(path) else: raise Exception('no se obtuvieron datos')
def createDB(): ind = 0 r = 0 for k in listAPKs(): for i in k: theAPKdata = getData(i) if theAPKdata: nombre = theAPKdata[0][:30] icon = extractIcon(i,ind) versionName = theAPKdata[2][:20] version = theAPKdata[3] ind += 1 try: a = apks(nombre=nombre,icon=icon,descripcion="",ruta=i.replace(POOL[r],""),versionName=versionName,version=version,pool=str(r),ind=ind,relativo=getRelatives(i)) a.save() except: print ("Can not insert "+nombre+" file: "+i) else: print ("Can not get data from file: "+i) r += 1
def createDB(): ind = 0 r = 0 amm = 0 lapk = listAPKs() for k in lapk: amm += len(k) for k in lapk: for i in k: theAPKdata = getData(i) if theAPKdata: nombre = theAPKdata[0][:30] icon = extractIcon(i,ind) versionName = theAPKdata[2][:20] version = theAPKdata[3] ind += 1 data = open(i,"rb").read(512) thash = sha256(data) sha = thash.hexdigest() try: aux = apks.objects.filter(sha=sha) if len(aux) > 0: print 'aplicacion duplicada',i else: a = apks(sha=sha,nombre=nombre,icon=icon,descripcion="",ruta=i.replace(POOL[r],""),versionName=versionName,version=version,pool=str(r),ind=ind,relativo=getRelatives(i)) a.save() except: print ("Can not insert "+nombre+" file: "+i) else: print ("Can not get data from file: "+i) print ">> "+str(ind)+'/'+str(amm) r += 1
def create_db(): repo_index = 0 amm = 0 lapk = list_apks() #calcular la cantidad total de aplicaciones for k in lapk: amm += len(k) for k in lapk: for i in k: theAPKdata = get_data(i) if theAPKdata: ruta = i.replace(POOL[repo_index], "") mkl = apks.objects.filter(ruta=ruta) if len(mkl): if mkl[0].relativo != get_relatives(i): print 'cambiando relativos para', mkl[0].nombre mkl[0].relativo = get_relatives(i) mkl[0].save() continue nombre = theAPKdata[0][:30] version = theAPKdata[3] icon = extract_icon(i, version) versionName = theAPKdata[2][:20] data = open(i, "rb").read() thash = sha256(data) sha = thash.hexdigest() try: aux = apks.objects.filter(sha=sha) if len(aux) > 0: move_or_delete(i) print 'aplicacion duplicada', i, 'movida a', settings.TRASHCAN else: if POOL[repo_index] == POOL[-1]: tpool = '999' else: tpool = str(repo_index) a = apks(sha=sha, nombre=nombre, icon=icon, descripcion="", ruta=i.replace(POOL[repo_index], ""), versionName=versionName, version=version, pool=tpool, relativo=get_relatives(i)) a.save() except: move_or_delete(i) print "No se puede insertar " + nombre + " archivo: " + i + ' movida a ' + settings.TRASHCAN else: print "No se puede obtener los datos de: " + i + ' movida a ' + settings.TRASHCAN move_or_delete(i) #print ">> " + str(ind) + '/' + str(amm) repo_index += 1