def showHistory(listbox_history): histories=database.show_data() showBrowsingHistory(listbox_history) if histories: for history in histories: listbox_history.insert(END, "Date : "+history[0]) listbox_history.insert(END, "Title : "+history[1]) listbox_history.insert(END, "Link : "+history[2]) listbox_history.insert(END, 280*'_') else: listbox_history.insert(END, "History is emptry.")
def download_csv(listbox_history): file = filedialog.asksaveasfile(defaultextension="*.*", filetypes=[('history', '.csv'),]) if file: try: with open(file.name, 'w', newline='') as file: writer = csv.writer(file) writer.writerow(["Date", "Title", "Link"]) histories=database.show_data() for history in histories: writer.writerow([history[0],history[1], history[2]]) showBrowsingHistory(listbox_history,"success") listbox_history.insert(END, "Successfully downloaded.") except: showBrowsingHistory(listbox_history,"failed") listbox_history.insert(END, "Failed To Download CSV file.")
def addsale(): def addProdu(): a = e6.get() b = variable.get() c = e2.get() d = e3.get() reslt = database.insert_data_sale(a, b, c, d) if reslt: messagebox.showinfo("Information", "Record Inserted") newwi = Toplevel(newwin) options = ["Select Product Id"] variable = StringVar(newwi) variable.set(options[0]) res = database.show_data() for data in res: prod_id = data[0] options.append(prod_id) l6 = Label(newwi, text="Sale Id") l6.grid(row=1, column=2, sticky=W) e6 = Entry(newwi) e6.grid(row=1, column=3) l1 = Label(newwi, text="Product Id") l1.grid(row=2, column=2, sticky=W) e1 = OptionMenu(newwi, variable, *options) e1.grid(row=2, column=3, sticky=W) l2 = Label(newwi, text="Qty Sold") l2.grid(row=3, column=2, sticky=W) e2 = Entry(newwi) e2.grid(row=3, column=3) l3 = Label(newwi, text="Sale Per Unit Price") l3.grid(row=4, column=2, sticky=W) e3 = Entry(newwi) e3.grid(row=4, column=3) btn_add_p = Button(newwi, text="Add", command=addProdu) btn_add_p.grid(row=6, column=4, sticky=W, padx=3, pady=3)
def crwal(page, location): option = webdriver.ChromeOptions() option.add_argument("-incognito") driver = webdriver.Chrome() driver.get(page) time.sleep(8) #cookiebtn=driver.find_element_by_xpath("//div[@class='close-cookie']") #cookiebtn.click() time.sleep(2) btn = driver.find_element_by_xpath( "//a[@class='dq b9 ai cs dr ds dt du dv dw dx dy dz e0 e1']") btn.click() time.sleep(15) change = driver.find_element_by_xpath( "//button[@class='btn btn--primary']") change.click() time.sleep(2) change = driver.find_element_by_xpath( "//button[@class='btn btn--primary']") change.click() time.sleep(2) change = driver.find_element_by_xpath( "//button[@class='btn btn--primary']") change.click() time.sleep(5) #zone=driver.find_elements_by_xpath("//div[@class='as eu at bj ff cl']") #zone[2].click() zone = driver.find_elements_by_xpath( "//span[@class='ff cl ft fu fv ai ao fw fg gl fx gm br']") zone = zone[1].text l = zone.split() zone = "" for i in l: zone += i if (zone.lower() == "travelzones"): zone = "tz" if zone[-1] == 's': zone = zone[:-1] if zone.lower() == "hexcluster": zone = "uberboundaries" if zone.lower() == "gautengprovincezone": zone = "gpzones" if zone.lower() == "middlesuperoutputarea": zone = "msoa" print(zone) downloadbtn = driver.find_element_by_xpath( "//button[@class='d9 ao b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf bg as da at db hi hj hk hl dg dh di dj dk hm bu bv bw ca hh ci hn ho hp']" ) downloadbtn.click() time.sleep(3) change = driver.find_elements_by_xpath("//li[@class='tabs__item']") change[1].click() table = driver.find_elements_by_xpath( "//table[@class='table table--striped table--small flush--bottom']/tbody/tr/td" ) if len(table) != 0: print(len(table)) change = table[0].find_elements_by_xpath("//a/small") change[4].click() text_area = driver.find_element_by_id('firstName') text_area.send_keys("Iuahuiwfiawnxui") text_area = driver.find_element_by_id('lastName') text_area.send_keys("Wxhjvfgpd") text_area = driver.find_element_by_id('email') text_area.send_keys("*****@*****.**") text_area = driver.find_element_by_id('role') text_area.send_keys("Analyst") text_area = driver.find_element_by_id('plannedUsage') text_area.send_keys("Analysis") purpose = driver.find_element_by_xpath( "//div[@class='er an ca ag ah dp cs fg g1 g2 gl fx gm br']") purpose.click() purpose = driver.find_elements_by_xpath( "//div[@class='bt de dc dd df d2 cl']/div/ul/li") purpose[0].click() change = driver.find_element_by_xpath("//button[@type='submit']") change.click() #close_button=driver.find_element_by_xpath("//button[@aria-label='Close']") #close_button.click() file = str( location) + "-" + zone.lower() + "-2019-1-All-MonthlyAggregate.csv" file1 = str(location) + "-" + zone.lower( ) + "s-2019-1-All-MonthlyAggregate.csv" print("Downloading") #time.sleep(30) download_wait(file, file1) print("DATA IS DOWNLOADED SUCCESSFULLY") driver.quit() print("Processing...") database.show_data(file, file1, location) else: driver.quit() delete_file(file, file1)
heading = Label(win, text="Product List", justify=CENTER) l1 = Label(win, text="Product ID") l2 = Label(win, text="Product Name") l3 = Label(win, text="Qty on hand") l4 = Label(win, text="Product Unit Price") l5 = Label(win, text="Re-oder") heading.grid(row=1, column=4, sticky=W, padx=20, pady=20) l1.grid(row=4, column=1, sticky=W, pady=2, padx=2) l2.grid(row=4, column=2, sticky=W, pady=2, padx=2) l3.grid(row=4, column=3, sticky=W, pady=2, padx=2) l4.grid(row=4, column=4, sticky=W, pady=2, padx=2) l5.grid(row=4, column=5, sticky=W, pady=2, padx=2) result = database.show_data() rows = 5 for data in result: pro = Label(win, text=data[0]) pro.grid(row=rows, column=1, sticky=W, pady=2, padx=2) name = Label(win, text=data[1]) name.grid(row=rows, column=2, sticky=W, pady=2, padx=2) qty = Label(win, text=data[2]) qty.grid(row=rows, column=3, sticky=W, pady=2, padx=2) unit = Label(win, text=data[3]) unit.grid(row=rows, column=4, sticky=W, pady=2, padx=2) reoder = Label(win, text=data[4]) reoder.grid(row=rows, column=5, sticky=W) rows += 1 btn_add = Button(win, text="Add Product", command=addProduct)
def test_db_command(bot, update): show_data()
def show(): (result1, result2) = show_data() url_data = {} #print "resss", result1, result2 return {'url_data': ['url1', 'neutral'], 'word_data': ['mani', 4]}