def delTypeInSettings(typeToDelete,typeComboBox1,typeComboBox2): l = getTypeVideosList() if typeToDelete in l: db = DBConnector() db.deleteDoc("settings/"+typeToDelete) typeComboBox1["values"] = getTypeVideosList() typeComboBox2["values"] = getTypeVideosList()
def clean_Op(log,*args): log.set("start cleaning the DB") try: db = DBConnector() vids = db.readCollaction("videos") for v in vids: if ivaluaetFanction(vids[v]['avgRating'],vids[v]['ratedNum'], args[0].get(), args[1].get()): db.deleteDoc("videos/"+v) except Exception as e: print(e) log.set(e.__str__()) return log.set("FINISHED cleaning the DB")
def commitSettingButtonFunction(typeToAddOrChange, keywordListInEntry, typeComboBox1, typeComboBox2,logView): db = DBConnector() if typeToAddOrChange is None or typeToAddOrChange=='' or typeToAddOrChange.isspace(): logView.set("cant add or change type ") return if not strOnlydigAndAlpha(typeToAddOrChange): logView.set("type can only contains chars and numbers ") return if keywordListInEntry is None or len(keywordListInEntry) == 0 or keywordListInEntry[0] == '': logView.set("cant add type with empty key words ") return for w in keywordListInEntry: if not strOnlydigAndAlpha(w): logView.set("key words only contains chars and numbers ") return try: task = threading.Thread(target=db.uploadDataToDoc, args=["settings/" + typeToAddOrChange, {"onlyForCreate": "a"}]) task.start() task.join() keywords_json_fb = db.readCollaction("settings/" + typeToAddOrChange + "/keywords") keywords_fb = keywords_json_fb.keys() # adding new key word for the type for kw in keywordListInEntry: if kw not in keywords_fb: data = { 'lastTaskUrl': '' } db.uploadDocToCollection("settings/" + typeToAddOrChange + "/keywords", kw, data) # removing thing that are not in the entry fro fb for kw in keywords_fb: if kw not in keywordListInEntry: db.deleteDoc("settings/" + typeToAddOrChange + "/keywords/" + kw) typeComboBox1["values"] = getTypeVideosList() typeComboBox2["values"] = getTypeVideosList() logView.set("changes commited") except Exception as e: logView.set("something want wrong" , e.__str__())