def __init__(self, support_email): title = u"404" header_image = Div( A(Img(src=u"/static/images/luminotes_title_full.png", width=u"206", height=u"69"), href=u"/", alt=u"Luminotes personal wiki notebook"), class_=u"error_header", ) Page.__init__( self, title, header_image, Div( H2(title), P( u"Sorry, the page you are looking for couldn't be found. But not to worry. You've got a few options.", Ul( Li(u"Return to the", A(u"Luminotes personal wiki notebook", href=u"/"), u"home page."), Li( A(u"Contact support", href=u"mailto:%s" % support_email), u"and report that the page you expected to find here is missing." ), ), ), class_=u"error_box", ), )
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) # Label prompting user to enter a question question_label = tk.Label(self, text="Enter your question below:") # Textbox where question can be entered self.question_textbox = tk.Text(self, height=15, width=45) # Put label and textbox onto the page question_label.grid(row=0, sticky='W') self.question_textbox.grid(row=1) # Label prompting user to enter a solution to the question answer_label = tk.Label(self, text="Enter the solution to the question:") # Textbox for the answer self.answer_textbox = tk.Text(self, height=15, width=45) # Put the answer label and textbox onto page answer_label.grid(row=3, sticky='W') self.answer_textbox.grid(row=4) # Create and add to the page a submit button to submit a question submit_question_button = tk.Button(self, text="Submit", command=self.submit_question) submit_question_button.grid(row=5)
def __init__(self, httpSession, agent, error, netconfReply, info): Page.__init__(self, httpSession, agent, error, netconfReply, info) self.addMenu(MenuAgentReachable(self.agent)) self.addContent(AgentInfo(self.agent)) if self.netconfReply != "": self.addContent(NetconfReply(self.netconfReply))
def readPage(self, page_name): if self.page_window is None: self.page_window = Page(page_name, 1) self.page_window.show() else: self.page_window.close() self.page_window = None
def __init__( self, user, first_notebook, login_url, logout_url, note_title, *nodes ): Page.__init__( self, ( note_title != "home" ) and note_title or None, # use the default title for the "home" page Link( rel = u"stylesheet", type = u"text/css", href = u"/static/css/header.css?%s" % VERSION ), Link( rel = u"stylesheet", type = u"text/css", href = u"/static/css/product.css?%s" % VERSION ), Meta( name = u"description", content = u"Luminotes is a WYSIWYG personal wiki notebook for organizing your notes and ideas." ), Meta( name = u"keywords", content = u"note taking, personal wiki, wysiwyg wiki, easy wiki, simple wiki, wiki notebook" ), Header( user, first_notebook, login_url, logout_url, note_title ), Span( *nodes ), Div( Div( Div( Div( Ul( Li( u"About", class_ = u"footer_category" ), Li( A( u"tour", href = u"/tour" ) ), Li( A( u"demo", href = u"/users/demo" ) ), Li( A( u"faq", href = u"/faq" ) ), Li( A( u"team", href = u"/meet_the_team" ) ), Li( A( u"user guide", href = u"/guide" ) ), Li( A( u"privacy", href = u"/privacy" ) ), class_ = u"footer_list", ), Ul( Li( u"Get Started", class_ = u"footer_category" ), Li( A( u"download", href = u"/download" ) ), Li( A( u"sign up", href = u"/pricing" ) ), Li( A( u"source code", href = u"/source_code" ) ), class_ = u"footer_list", ), Ul( Li( u"Community", class_ = u"footer_category" ), Li( A( u"contact support", href = u"/contact_info" ) ), Li( A( u"discussion forums", href = u"/forums/" ) ), Li( A( u"blog", href = u"/blog/" ) ), Li( A( u"Facebook group", href = u"http://www.facebook.com/pages/Luminotes-personal-wiki-notebook/17143857741" ) ), Li( A( u"Twitter stream", href = u"http://twitter.com/Luminotes" ) ), class_ = u"footer_list", ), Ul( Li( u"Copyright ©2008 Luminotes" ), class_ = u"footer_list wide_footer_list", ), Br(), class_ = u"footer_column", ), class_ = u"footer_links", ), class_ = u"wide_center_area", ), class_ = u"footer", ), )
def get_all_friends(total_page_number, original_url): all_friends = [] for page_num in range(0, total_page_number): url = original_url + '&curpage=' + str(page_num) page = Page(url) parser = PageParser(page.fetch()) all_friends.extend(parser.get_friends()) return all_friends
def view(page): """View multiple Pages.""" path = page path = str(path) print(path) x = Page(path) x.disp() input()
def __init__(self): self.Inicio = Page() self.Inicio2 = Page() self.NBinsert = NodoB() self.Enlace = Page() self.Pivote = False self.Bandera = False self.Bandera2 = False """"""
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) # Search box to type query search_box = tk.Text(self, height = 1, width = 15) # Search button to trigger search query search_button = tk.Button(self, text="Search", command = self.query_questions) # Place box and button onto the page search_box.grid(row="0", column="0") search_button.grid(row="0", column="1")
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) file = "" mesages = MailOperations("*****@*****.**", "testSMTP$$").readMail() print(mesages) label = tk.Text(self, width="80", height="35") label.insert(tk.END, mesages) label.pack(expand=True)
def getPageList(self, page) : if page.isBranchPage() == True : for pageNumber in page.readPageNumberList() : page = Page(self.path, self.pageSize, pageNumber, self.columns) self.getPageList(page) else : pageNumber = page.getPageNumber() self.normalDataPageDict[pageNumber] = page if page.getPrePageNumber() == 0 : self.firstDataPageList.append(pageNumber)
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) # ***** Need To Parse Questions In ***** having db problems ***** assignment_number_label = tk.Label(self, text="Enter Assignment Number") self.assignment_number_textbox = tk.Text(self, height=1, width=15) id = self.assignment_number_textbox.get("1.0", "end") assignments = reader.get_assign()
def __init__(self, support_email, message=None): header_image = Div( A(Img(src=u"/static/images/luminotes_title_full.png", width=u"206", height=u"69"), href=u"/", alt=u"Luminotes personal wiki notebook"), class_=u"error_header", ) if message: title = u"whoops" Page.__init__( self, title, header_image, Div( H2(title), P(message), class_=u"error_box", ), ) return title = u"uh oh" Page.__init__( self, title, header_image, Div( H2(title), Noscript( P( Strong( u""" Please enable JavaScript in your web browser. JavaScript is necessary for many Luminotes features to work properly. """, ), ), ), P( u"Something went wrong! If you care, please", A("let me know about it.", href="mailto:%s" % support_email), u"Be sure to include the following information:", ), Ul( Li(u"the series of steps you took to produce this error"), Li(u"the time of the error"), Li(u"the name of your web browser and its version"), Li(u"any other information that you think is relevant"), ), P(u"Thanks!", ), class_=u"error_box", ), )
def InsertarNodo(self, usuario, nombre, clave, root): self.Add(usuario, nombre, clave, root) if (self.getPivote() == True): self.Inicio = Page(Ramas=[None, None, None, None, None], Claves=[None, None, None, None], Cuentas=0) self.Inicio.setCuentas(1) self.Inicio.Claves[0] = self.getInsert() self.Inicio.Ramas[0] = root self.Inicio.Ramas[1] = self.getEnlace() """"""
class IndexPage(object): ''' 天秤首页 ''' def __init__(self): self.PO = Page() def Open(self, browser, url): '''打开天秤首页''' self.PO.OpenUrl(browser, url) return True def InputUser(self,user): '''输入用户名''' EleO = self.PO.FindElement("id", "username") EleO.Input(user) return True def InputPasswd(self,passwd): '''输入密码''' EleO = self.PO.FindElement("id", "password") EleO.Input(passwd) return True def CkJZWCheckBox(self): '''勾选记住我''' EleO = self.PO.FindElement("id", "rememberMe") EleO.Click() return True def CkLoginButton(self): '''点击登录按钮''' EleO = self.PO.FindElement("class", "login_btn") EleO.Click() return True def Close(self): '''关闭浏览器''' self.PO.CloseBrowser() delattr(self.PO, 'driverO') return True def Logout(self): '''登出''' self.PO.SwithToFrame() EleO = self.PO.FindElement("css", "a[onclick='logoutOrExit()']") EleO.Click() return True def LoginSucessCheck(self): '''登录成功检查点''' self.PO.SwithToFrame() EleO = self.PO.FindElement("class", 'dropdown-toggle') return EleO.GetText()
def __init__( self, support_email, message = None ): header_image = Div( A( Img( src = u"/static/images/luminotes_title_full.png", width = u"206", height = u"69" ), href = u"/", alt = u"Luminotes personal wiki notebook" ), class_ = u"error_header", ) if message: title = u"whoops" Page.__init__( self, title, header_image, Div( H2( title ), P( message ), class_ = u"error_box", ), ) return title = u"uh oh" Page.__init__( self, title, header_image, Div( H2( title ), Noscript( P( Strong( u""" Please enable JavaScript in your web browser. JavaScript is necessary for many Luminotes features to work properly. """, ), ), ), P( u"Something went wrong! If you care, please", A( "let me know about it.", href = "mailto:%s" % support_email ), u"Be sure to include the following information:", ), Ul( Li( u"the series of steps you took to produce this error" ), Li( u"the time of the error" ), Li( u"the name of your web browser and its version" ), Li( u"any other information that you think is relevant" ), ), P( u"Thanks!", ), class_ = u"error_box", ), )
def __init__(self, *, postId: str, page: Page): self.postId = postId self.page = page self.pageId = page.getPageId() self.postUrl = f"{page.getUrl()}posts/{self.postId}" self.accessToken = page.getAccessToken() with open("secrets/config.json", "r") as cfg: cfg = json.load(cfg) self.verify = cfg["verify"] self.apiversion = cfg["api_version"] self.likes = self.findLikes()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) container = Frame(self) container.pack(fill=BOTH, expand=TRUE, padx=7, pady=5) controlsFrame(container) # ----------- LEFT-SIDE POINTS OF INTEREST VIEW FRAME ----------- poiViewFrame = Frame(container, height=1, bd=2, relief=RIDGE) poiViewFrame.pack(side=LEFT, fill=Y, padx=1) projectsFrame = Frame(poiViewFrame) projectsFrame.pack(side=TOP, fill=Y) titleLabel = Label(projectsFrame, text="Point of Interest View", fg="white", bg="RoyalBlue4", font=Fonts.LARGE_FONT) titleLabel.grid(row=0, column=0, sticky=NSEW) # The following adds checkboxes for selecting points of interest poi1 = IntVar() Checkbutton(projectsFrame, text="Point of Interest A", variable=poi1).grid(row=2, column=0, sticky=NSEW) # ----------- END OF POINTS OF INTEREST VIEW FRAME ----------- # ----------- DETAILED POINTS OF INTEREST VIEW FRAME ----------- detailedPOIFrame = Frame(container, bd=2, relief=RIDGE) detailedPOIFrame.pack(fill=BOTH, expand=TRUE, padx=1) dPV_Title = Label(detailedPOIFrame, text="Detailed Points Of Interest View", fg="white", bg="RoyalBlue4", font=Fonts.LARGE_FONT) dPV_Title.pack(side=TOP, fill=X) mainFrame = Frame(detailedPOIFrame, bd=2) mainFrame.pack(fill=BOTH, expand=TRUE) # bottomFrame = Frame(detailedPOIFrame, bd=2, relief=RIDGE) # bottomFrame.pack(side=BOTTOM, fill=X) # middleFrame.grid_columnconfigure(0, weight=3) global poiText poiText = Text(mainFrame) poiText.pack(fill=BOTH, expand=TRUE) # poiText.grid(row=0) poiText.bind("<Key>", "ignore")
def pull(): url = str(input("Enter the url for the first page of the reader: ")) firstPage = Page(url) page = firstPage while page.get_next(): if page.get_next(): page = Page(page.get_next()) else: print("End of chapters") path = os.path.join(os.getcwd(), 'novels', firstPage.title, "lastRead.txt") with open(path, 'w', encoding='utf-8') as info: info.write("{}\n".format(firstPage.title)) info.write(firstPage.name) info.write(0)
class Page_Login(): def __init__(self): self.a = Page() def get_driver(self, browser='Ie'): ''' Set the browser to test ''' if browser == 'Ie': return webdriver.Ie() elif browser == 'Chrome': return webdriver.Chrome() return webdriver.Firefox() def login(self, driver, user_name, password, url="https://crossroads-test.syniverse.com"): ''' Login to the system with provided user_name and password. ''' driver.get(url) driver.maximize_window() self.a.find_element_by_id(driver, 'username').send_keys(user_name) self.a.find_element_by_id(driver, 'password').send_keys(password) self.a.find_element_by_xpath(driver, "//button[@name='Submit']").click() logger.info("==Logged into %s"%url) def navigate_to_admin_page(self, driver): ''' navigate to the admin page ''' time.sleep(10) driver.switch_to_frame("NavFrame") elem = self.a.find_element_by_id(driver, "navcenterAdmin") elem.click() driver.switch_to_window(driver.window_handles[1]) #Switch to new admin window def click_on_product(self, driver, product_name): time.sleep(6) driver.switch_to_frame("NavFrame") elem = self.a.find_element_by_link_text(driver, product_name) elem.click() driver.switch_to_window(driver.window_handles[1]) #Switch to new admin window def close_browser(self, driver, wait_time=10): self.a.close_browser(driver, int(wait_time))
def get_page(self, page_id): # try: self.cursor.execute( "SELECT title, in_page_title, summary, content FROM pages WHERE page_id = %s;", (page_id,)) title, in_page_title, summary, content = self.cursor.fetchall()[0] return Page(title, in_page_title, summary, content)
def reformBlockCanvas(self): self.canvas.resize(self.canvasWidth,self.canvasHeight); #scrollPane.revalidate(); self.repaint(); from Page import Page widthCounter = 0; for i in range(0, len(self.pages)): p = self.pages[i]; if(p.getDefaultPageColor() == None): if (i % 2 == 1): p.setPageColor(QtGui.QColor(200,200,200,150)); else: p.setPageColor(QtGui.QColor(180,180,180,150)); else: p.setPageColor(p.getDefaultPageColor()); p.repaint() widthCounter = widthCounter + p.reformBounds(widthCounter); for d in self.dividers: d.resize(5, d.getLeftPage().height()); d.move(d.getLeftPage().x()+d.getLeftPage().width()-3, 0,) self.canvas.resize(widthCounter,(Page.DEFAULT_ABSTRACT_HEIGHT*Page.getZoomLevel())); #scrollPane.revalidate(); self.repaint();
def add_page_to_memory(new_process, page_number): global global_time # Check available frames if memory_available(M) <= 0: # Swap swap(new_process, page_number) else: # Insert new_frame = -1 for index, memory in enumerate(M): if memory == [-1, -1]: M[index] = [new_process, page_number] new_frame = index break if page_number not in processes[new_process].table: # Create page object new_page_obj = Page(page_number, new_frame, 1) # Insert into process table processes[new_process].insert_page(new_page_obj) else: #Change S memory S[processes[new_process].table[page_number].frame] = [-1, -1] #Changes page characteristics in processes processes[new_process].table[page_number].frame = new_frame processes[new_process].table[page_number].bit_memory = 1 algorithm[PAGE_REPLACEMENT_ALGORITHM].insert(new_process, page_number) #adds 1 sec to global time for adding page to M global_time += 10
def scrape(site, prefix="https://en.wikipedia.org"): page = BeautifulSoup(urlopen(site.url), 'html.parser') links_to = OccurrenceList() for link in page.find_all('a'): if link.get('href'): url_link = link.get('href') if not url_link.startswith("http"): url_link = prefix + url_link links_to = links_to.union(OccurrenceList([url_link])) """ Remove script tags """ for script in page("script"): page.script.extract() """ Remove style tags """ for style in page("style"): page.style.extract() """ Remove comments """ comments = page.findAll(text=lambda text: isinstance(text, Comment)) for comment in comments: comment.extract() return Page(page.title.string, site.url, page.text, links_to)
def ouv(self, path): if path[-7:] == ".projpy": self.sommets = [] fichier = open(path, "r") i = 0 somm = {} for ligne in fichier.readlines(): ligne = ligne.replace("\n", "") if ligne == "---": i = i + 1 else: if i == 0: str = ligne.split(":") if str[1] == "U": carac = str[2].split(",") somm[str[0]] = Utilisateur(carac[0], carac[1], int(carac[2])) self.add_sommet(somm[str[0]]) if str[1] == "P": somm[str[0]] = Page(str[2]) self.add_sommet(somm[str[0]]) if i == 1: firstUtil = ligne.split(":")[0] others = ligne.split(":")[1].split(",") for followed in others: somm[firstUtil].connect(somm[followed]) if i == 2: thePage = ligne.split(":")[0] theAdmins = ligne.split(":")[1].split(",") for admin in theAdmins: somm[thePage].add_admin(somm[admin]) fichier.close() else: print("mauvais format.\nextention .projpy")
def SIMULATE(Frames, Pages, PRL, ZLO): """ PRL - Page Reference Lenght :param int Frames: :param int Pages: :param int PRL: :param boolean ZLO: :return: """ pages = [] for i in range(Pages): pages.append(Page(i)) pageReferences = [] if not ZLO: for index in range(PRL): pageReferences.append(pages[random.randint(0, len(pages) - 1)]) else: for index in range(PRL): odw = pages[index - 1].pageN - 5 + random.randint(0, 1 + 5 * 2) pageReferences.append(pages[max(0, min(Pages, odw))]) executeFIFO(Frames, pageReferences) executeLRU(Frames, pageReferences) executeALRU(Frames, pageReferences) executeOPT(Frames, pageReferences) executeRAND(Frames, pageReferences)
def crawler(self, search_type, node): while len(self.to_visit ) > 0 and not self.stop_crawl and self.count < MAX_URLS: print('crawling') # check if link has already been crawled crawled = node.url in self.visited_set if not crawled: self.graph.add_node(node, self.id) self.count += 1 self.id += 1 self.visited_set.add(node.url) if node.parents_list: # get the node's parent node source_node = node.parents_list.pop() # update the node depth node.node_depth = source_node.node_depth + 1 if node.id is not None and source_node.id is not None: # create an edge between the current node and its parent node self.graph.add_edge(source_node.id, node.id) # set node's parent node node.parent_node = source_node.id # create new Page object pg = Page(node.url) # if node limit has not been reached if node.node_depth < self.depth_limit: links = pg.get_links(node.url) links = validate_url(links, self.count, MAX_URLS) # remove any duplicate links present links = remove_duplicates(links) self.crawl_links(node, links) # check if stop keyword is found if self.keyword and pg.find_keyword(self.keyword): node.found = True self.stop_crawl = True #self.end_crawl() if self.stop_crawl: break # get next node to crawl if self.count < MAX_URLS: node = self.get_next() self.end_crawl() return self.visited_set
def __init__(self): self.max_memory = int(max_pages) self.main_memory = [] #list of Pages for i in range(self.max_memory): page = Page() self.main_memory.append(page) self.disk_memory = "vm.txt" self.command_list = command_list
def DivPage(self, clave, root, position): posi = 0 PosPiv = 0 if (position <= 2): PosPiv = 2 else: PosPiv = 3 Medio = Page(Ramas=[None, None, None, None, None], Claves=[None, None, None, None], Cuentas=0) Posi = PosPiv + 1 while (posi != 5): i = ((posi - PosPiv) - 1) j = posi - 1 Medio.Claves[i] = root.Claves[j] Medio.Ramas[posi - PosPiv] = root.Ramas[posi] posi += 1 Medio.setCuentas(4 - PosPiv) root.setCuentas(PosPiv) if (posi < 2): self.ClaveInsert(clave, root, position) else: self.ClaveInsert(clave, Medio, (position - PosPiv)) self.setNBInsert(root.Claves[root.getCuentas() - 1]) Medio.Ramas[0] = root.Ramas[root.getCuentas()] valor = root.getCuentas() - 1 root.setCuentas(valor) self.setEnlace(Medio) """"""
def __add_existing_page(self, configs=None): """ adds a page and fills with the given widgets """ page = Page(self.stack, self) if configs is not None: for config in configs: self.__add_existing_widget(page, config) self.stack.addWidget(page)
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.font10 = "-family {Times New Roman} -size 24 -weight bold " "-slant roman -underline 0 -overstrike 0" self.font11 = "-family {Times New Roman} -size 12 " "-slant roman -underline 0 -overstrike 0" self.font12 = "-family {Times New Roman} -size 12 " "-slant roman -underline 0 -overstrike 0" self.bugsTitle = tk.LabelFrame(self, text="Fixes", labelanchor="nw") self.bugsTitle.configure(font=self.font10) self.bugsTitle.grid(row=10, columnspan=50, padx=10, pady=10, ipadx=10, ipady=10) self.bugsTitle.place(relx=0.5, rely=0.25, anchor="center") self.aboutInfo = tk.Label(self.bugsTitle) self.aboutInfo.configure( text="AS MANY TICKETS AS WE WANT!\n" + "Code Cleanup\n" + "Changes towards Monthly Program", justify="left", font=self.font11, ) self.aboutInfo.grid(row=0, column=0, padx=5, pady=0)
def get(self, path): print(self) print("I happen!") p = Page.by_path(path).get() print(path) if p: self.render('Templates/Page.html', page=p, path=path) else: self.redirect('/_edit' + path)
def recursiveScrape(url, visitedLinks, domain): if url in visitedLinks : return True try: if domain not in url : return True except TypeError: return True print(url) # page object for the current page curPage = Page() # open url source = requests.get(url).text soup = BeautifulSoup(source, 'lxml') # set curPage elements try: curPage.title = soup.find('title').text except AttributeError: curPage.title = None curPage.url = url curPage.childLinks = [] hyperLinks = soup.find_all('a') hyperLinks = list(filter((None).__ne__, hyperLinks)) # get all links on a page for link in hyperLinks: # set hyperLink to href of link hyperLink = link.get('href') # remove '.' or '..' from the link if hyperLink == None: pass elif len(hyperLink) >= 2 and hyperLink[0:2] == '..': hyperLink = hyperLink.replace('..', '') elif len(hyperLink) == 1 and hyperLink[0] == '.': hyperLink = hyperLink.replace('.', '') # if not an external url add domain to hyperLink if hyperLink == None: pass elif hyperLink[0:4] != "http" and hyperLink[0] != '/': hyperLink = 'http://' + domain + '/' + hyperLink elif hyperLink[0:4] != "http": hyperLink = 'http://' + domain + hyperLink curPage.childLinks.append(hyperLink) # write curPage object to file curPage.appendToFile(domain) # add current link to visitedLinks visitedLinks.append(url) # for all child links in the page for link in curPage.childLinks: # call this function on that link recursiveScrape(link, visitedLinks, domain)
def init(): global driver, soup, page_type, page, website driver = webdriver.Chrome() soup = "" page_type = "" page = Page() page = Article() page = YoutubePage() page = YoutubeVideo() website = ""
def __init__(self, seed_url, search_type, depth_limit, keyword=None): Page.__init__(self, seed_url) self.seed_url = complete_url(seed_url) self.search_type = search_type # 'BFS' or 'DFS' if keyword is not None: # change keyword to lowercase self.keyword = str(keyword).lower() else: self.keyword = keyword self.count = 0 # track number of links crawled self.depth_limit = int(depth_limit) # max depth to crawl self.depth = 0 # current node depth self.to_visit = Page.to_visit # list of urls to crawl self.visited_set = Page.visited_set # set of urls already crawled self.graph = Graph() # page nodes graph self.id = 0 self.stop_crawl = bool() # track if stop keyword is found root_node = Page_Node(seed_url, None, 0, None, 0, False) self.start(self.search_type, root_node)
def __init__(self, name, content=""): """ """ Page.__init__(self, name, content) self.body = "" self.projectname = "" self.logo = "" self.login = False self.divlevel = [] self._inBlockType = "" self._inBlockClosingStatement = "" self._bulletslevel = 0 self._codeblockid = 0 self.hasfindmenu = False self.padding = True self.processparameters = {} self.bodyattributes = [] self.documentReadyFunctions = []
def createIndex(self,max_level): ind = '' base_page = self.pages[self.root_url] base_page.text += '{{RiferimentiEsterni \ |esercizi= \n|dispense=\n|testi=}}\n' #book export: link base_page.text+= '{{libro|Project:Libri/'+self.doc_title+\ '|'+ self.doc_title + '}}\n' #book export: setting title self.book_export_index.append('=='+ self.doc_title+'==') #creating root index base_page.text+= '\n\n==' +self.keywords['chapters']+'==\n' base_page.text+= self._createIndex(self.root_url,'',max_level) #creating book export page book_title = 'Project:Libri_'+self.doc_title book_export_page= Page(book_title,book_title, 'Project:Libri/'+self.doc_title,'root',-1,None) #inserting index text book_export_page.addText(u'\n'.join(self.book_export_index)) #the export book page is inserted in the pages dict and index self.pages['Project:Libri/'+self.doc_title] = book_export_page
def __generate_pages(self): print "Generating BroadCast Pages: Started" self.__pages = [] it = iter(self.__indexes) for i in it: jt = iter(i.get_nodes()) for j in jt: p = Page(j.get_name(), INDEX_TYPE) self.__pages.append(p) dt = iter(i.get_data_segment().get_data()) for d in dt: p = Page(d.get_name(), DATA_TYPE) p.set_data(d.get_data()) p.set_name(d.get_name()) self.__pages.append(p) for i in range(len(self.__pages)): found = False count = 0 for j in range(len(self.__pages)): if (self.__pages[i].get_type() == INDEX_TYPE) and (self.__pages[i].get_name() == self.__pages[j].get_name()): found = True count += 1 if found and (count > 1): name = self.__pages[i].get_name() count = 1 for j in range(i, len(self.__pages)): if (self.__pages[j].get_type() == INDEX_TYPE) and (name == self.__pages[j].get_name()): self.__pages[j].set_name(name + '-' + str(count)) self.__pages[j].set_type(INDEX_TYPE) count += 1 print "Generating BroadCast Pages: Finished"
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.font10 = "-family {Times New Roman} -size 24 -weight bold " \ "-slant roman -underline 0 -overstrike 0" self.font11 = "-family {Times New Roman} -size 12 " \ "-slant roman -underline 0 -overstrike 0" self.font12 = "-family {Times New Roman} -size 12 " \ "-slant roman -underline 0 -overstrike 0" self.bugsTitle = tk.LabelFrame(self, text="Bugs", labelanchor='nw') self.bugsTitle.configure(font=self.font10) self.bugsTitle.grid(row=10, columnspan=50, padx=10, pady=10, ipadx=10, ipady=10) self.bugsTitle.place(relx=0.5, rely=0.25, anchor="center") self.aboutInfo = tk.Label(self.bugsTitle) self.aboutInfo.configure(text="Adding users after rolling prevents rolling - restart the program to fix\n" + "Changing pages will keep typing in an entry box if selected\n", justify="left", font=self.font11) self.aboutInfo.grid(row=0, column=0, padx=5, pady=0) self.aboutLink = tk.Label(self.bugsTitle) self.aboutLink.configure(text="https://snoring.ninja/crewarea/lotto/bugs", font=self.font12, fg="blue", cursor="hand2") self.aboutLink.bind("<Button-1>", lambda x:self.openURL("https://snoring.ninja/crewarea/lotto/bugs")) self.aboutLink.grid(row=1, column=0, padx=5, pady=0)
def __init__( self, support_email ): title = u"404" header_image = Div( A( Img( src = u"/static/images/luminotes_title_full.png", width = u"206", height = u"69" ), href = u"/", alt = u"Luminotes personal wiki notebook" ), class_ = u"error_header", ) Page.__init__( self, title, header_image, Div( H2( title ), P( u"Sorry, the page you are looking for couldn't be found. But not to worry. You've got a few options.", Ul( Li( u"Return to the", A( u"Luminotes personal wiki notebook", href = u"/" ), u"home page." ), Li( A( u"Contact support", href = u"mailto:%s" % support_email ), u"and report that the page you expected to find here is missing." ), ), ), class_ = u"error_box", ), )
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.font10 = "-family {Times New Roman} -size 24 -weight bold " \ "-slant roman -underline 0 -overstrike 0" self.font11 = "-family {Times New Roman} -size 18 " \ "-slant roman -underline 0 -overstrike 0" self.font12 = "-family {Times New Roman} -size 18 " \ "-slant roman -underline 0 -overstrike 0" self.aboutTitle = tk.LabelFrame(self, text="About", labelanchor='nw') self.aboutTitle.configure(font=self.font10) self.aboutTitle.grid(row=10, columnspan=50, padx=10, pady=10, ipadx=10, ipady=10) self.aboutTitle.place(relx=0.5, rely=0.25, anchor="center") self.aboutInfo = tk.Label(self.aboutTitle) self.aboutInfo.configure(text="[Crew] Lotto Manager\nVersion %s\n© 2015, Eñd Game [Crew]\nManager written by Ryan 'T D' Malacina" % (Version.getVersion()), justify="left", font=self.font11) self.aboutInfo.grid(row=0, column=0, padx=5, pady=0) self.aboutLink = tk.Label(self.aboutTitle) self.aboutLink.configure(text="http://endgame.wtf/lottery", font=self.font12, fg="blue", cursor="hand2") self.aboutLink.bind("<Button-1>", lambda x:self.openURL("http://endgame.wtf/lottery")) self.aboutLink.grid(row=1, column=0, padx=5, pady=0) self.checkUpdate()
class Page_Role_Maintain(): ''' This test is used for daily testing, since I can not get the User Permission ID from DB. To keep consistant, i let company permission ID get from test case as well. ''' def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None self.ext_url = "/servlet/CompanySelect?action=modify_role&nextpage=/servlet/RoleMaintenance" self.testEnv=None def navigate_to_page_role_maintain(self, driver): full_url = self.page.get_base_url(driver) + self.ext_url if "crossroads-test" in full_url: self.testEnv = "xroad6_test" self.page.navigate_to_page(full_url) def select_company_for_role(self, driver, company_name): self.page.find_element_by_xpath("//input[name='searchStr']").send_keys(company_name) time.sleep(1) self.page.find_element_by_id("submitBtn").click() def create_role(self, driver, role_name, desc): self.page.find_element_by_link_text(driver, 'Create Role').click() time.sleep(2) driver.switch_to_window() time.sleep(1) self.page.find_element_by_name(driver, 'rolename').send_keys(role_name) self.page.find_element_by_name(driver, 'roledesc').send_keys(desc) self.page.find_element_by_name(driver, 'Button').click() driver.switch_to_window() self.page.find_element_by_name(driver, 'Button1').click() def modify_role(self, driver, role_name): self.page.find_element_by_id(driver, role_name).click() self.page.find_element_by_link_text(driver, 'Modify Roles').click() driver.switch_to_window()
def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None self.ext_url = "/servlet/CompanySelect?action=modify_role&nextpage=/servlet/RoleMaintenance" self.testEnv=None
def web_update_hpm(self, i_image, i_component=BMC_CONST.UPDATE_BMCANDPNOR): try: import argparse from selenium import webdriver from easyprocess import EasyProcess from pyvirtualdisplay import Display from FWUpdatePage import FWUpdatePage from LoginPage import LoginPage from MaintenancePage import MaintenancePage from Page import Page #Open web browser using headless selenium display = Display(visible=0, size=(1024, 768)) display.start() BMC_IP='https://'+self.ip browser = webdriver.Firefox() except: print BMC_CONST.ERROR_SELENIUM_HEADLESS raise OpTestError(BMC_CONST.ERROR_SELENIUM_HEADLESS) try: #Open BMC webpage BMC = Page(browser, BMC_IP) BMC.getPage() #Login to BMC BMCAuth = LoginPage(BMC, self.id, self.password) BMCAuth.login() #Find FW Update Option in menus BMCUpdate = FWUpdatePage(BMC) #Get Maintenance Page Maintenance = MaintenancePage(BMC) Maintenance.getMaintenancePage() Maintenance.preserveIPMI() Maintenance.preserveNetwork() Maintenance.savePage() #Configure TFTP Protocol Server and Image BMCUpdate.getProtocolConfigPage() BMCUpdate.selectProtocolType('TFTP') BMCUpdate.inputServerAddress(self.ip) BMCUpdate.inputImageName(i_image) BMCUpdate.doSave() #Traverse Back to FW Update Page BMCUpdate.getUpdateOptionsPage() BMCUpdate.selectHPM() BMCUpdate.doContinue() BMCUpdate.selectFile(i_image) BMCUpdate.doOK() if(i_component == BMC_CONST.UPDATE_BMC): BMCUpdate.selectUpdateBios() elif(i_component == BMC_CONST.UPDATE_PNOR): BMCUpdate.selectUpdateBoot_APP() else: BMCUpdate.selectUpdateAll() BMCUpdate.doProceed() BMCUpdate.WaitForFWUpdateComplete(BMC_CONST.WEB_UPDATE_DELAY) browser.quit() except: browser.close() l_msg = "hpm update using webgui failed" print l_msg raise OpTestError(l_msg) return BMC_CONST.FW_SUCCESS
#!/usr/bin/python #coding:utf8 # Created: 2013-11-11 # import sys sys.path.append('..') from Page import Page from lxml import etree page = Page() page.title = u'title' page.ns = u'0' page.id = u'10' page.text = u'text' page.redirect = u'redirect' print page.toTuple() print page.toDict() print page.toDict(noNone=True) print etree.tostring(page.toXML())
def __init__( self, user, rate_plan, notebooks, notebook, parent_id = None, login_url = None, logout_url = None, startup_notes = None, total_notes_count = None, notes = None, note_read_write = True, start = None, count = None, http_url = None, conversion = None, rename = False, deleted_id = None, invites = None, invite_id = None, after_login = None, signup_plan = None, signup_yearly = None, recent_notes = None, groups = None, ): startup_note_ids = [ startup_note.object_id for startup_note in startup_notes ] def note_controls( note, read_write ): read_write_access = ( read_write == Notebook.READ_WRITE ) or \ ( read_write == Notebook.READ_WRITE_FOR_OWN_NOTES and note.user_id == user.object_id ) return Div( read_write_access and Input( type = "button", class_ = "note_button", id = "delete_note_%s" % note.object_id, value = "delete" + ( note.deleted_from_id and " forever" or "" ), title = "delete note [ctrl-d]" ) or None, read_write_access and note.deleted_from_id and Input( type = "button", class_ = "note_button", id = "undelete_note_%s" % note.object_id, value = "undelete", title = "undelete note" ) or None, ( read_write == Notebook.READ_WRITE ) and not note.deleted_from_id and Input( type = "button", class_ = "note_button", id = "changes_note_%s" % note.object_id, value = "changes", title = "previous revisions", ) or None, ( read_write == Notebook.READ_WRITE ) and not note.deleted_from_id and Input( type = "button", class_ = "note_button", id = "tools_note_%s" % note.object_id, value = "tools", title = "note tools", ) or None, ( read_write != Notebook.READ_ONLY or not note.startup ) and not note.deleted_from_id and \ ( read_write != Notebook.READ_WRITE_FOR_OWN_NOTES ) and Input( type = "button", class_ = "note_button", id = "hide_note_%s" % note.object_id, value = "hide", title = "hide note [ctrl-h]", ) or None, id = u"note_controls_%s" % note.object_id, class_ = u"note_controls", ) def static_note_divs( notes, read_write ): return [ Table( Tr( Td( note_controls( note, read_write ), ) ), Tr( Td( Div( Span( note.contents, class_ = u"static_note_contents", separator = "", ), id = "static_note_%s" % note.object_id, class_ = u"static_note_div", ), width = "100%", ), Td( u".....", id = u"note_grabber_%s" % note.object_id, class_ = u"note_grabber" + ( read_write != Notebook.READ_WRITE and " invisible" or "" ), ), ), Tr( Td( Div( class_ = "note_shadow_corner" ), id = u"note_shadow_%s" % note.object_id, class_ = u"note_shadow undisplayed", ), ), id = u"note_holder_%s" % note.object_id, class_ = u"note_holder", ) for note in notes ] static_notes = notes and static_note_divs( notes, note_read_write and notebook.read_write or Notebook.READ_ONLY ) or \ static_note_divs( startup_notes, notebook.read_write ) # Since the contents of these notes are included in the static_notes section below, don't # include them again in the hidden fields here. Accomplish this by making custom dicts for # sending to the client. startup_note_dicts = [ { u"object_id" : startup_note.object_id, u"revision" : startup_note.revision, u"deleted_from_id" : startup_note.deleted_from_id, u"user_id": startup_note.user_id, u"username": startup_note.username, } for startup_note in startup_notes ] note_dicts = [ { u"object_id" : note.object_id, u"revision" : note.revision, u"deleted_from_id" : note.deleted_from_id, u"user_id": note.user_id, u"username": note.username, u"creation" : note.creation, } for note in notes ] root_notes = startup_notes + ( notes and [ note for note in notes if note.object_id not in startup_note_ids ] or [] ) def json( string ): return escape( unicode( Json( string ) ), quote = True ) if len( notes ) == 1: title = notes[ 0 ].title else: title = notebook.name if rate_plan.get( u"notebook_sharing" ): updates_path = u"/notebooks/updates/%s?rss&%s" % ( notebook.object_id, urlencode( [ ( u"notebook_name", notebook.name.encode( "utf8" ) ) ] ), ) else: updates_path = None forum_tags = [ tag for tag in notebook.tags if tag.name == u"forum" ] forum_tag = None if notebook.name == u"Luminotes": notebook_path = u"/" updates_path = None # no RSS feed for the main notebook elif notebook.name == u"Luminotes user guide": notebook_path = u"/guide" elif forum_tags: forum_tag = forum_tags[ 0 ] if forum_tag.value == u"blog": notebook_path = u"/blog/%s" % notebook.friendly_id else: notebook_path = u"/forums/%s/%s" % ( forum_tag.value, notebook.object_id ) else: notebook_path = u"/notebooks/%s" % notebook.object_id conversion_js = None if conversion: try: conversion_js = file( u"static/js/%s_conversion.js" % conversion ).read() except IOError: pass if notebook.read_write == Notebook.READ_WRITE: header_note_title = u"wiki" else: all_notes = startup_notes + notes header_note_title = ( notebook.name == "Luminotes" ) and all_notes and all_notes[ 0 ].title or notebook.name header_note_title = { "contact info": "contact", "meet the team": "team", "Luminotes user guide": "guide", "Luminotes privacy policy": "privacy", }.get( header_note_title, header_note_title ) own_notebooks = [ nb for nb in notebooks if nb.read_write == Notebook.READ_WRITE ] header_notebook = own_notebooks and own_notebooks[ 0 ] or notebook Page.__init__( self, title, Link( rel = u"stylesheet", type = u"text/css", href = u"/static/css/header.css?%s" % VERSION ), updates_path and \ Link( rel = u"alternate", type = u"application/rss+xml", title = notebook.name, href = updates_path ) or None, Script( type = u"text/javascript", src = u"/static/js/MochiKit.js?%s" % VERSION ) or None, Script( type = u"text/javascript", src = u"/static/js/Invoker.js?%s" % VERSION ) or None, Script( type = u"text/javascript", src = u"/static/js/Editor.js?%s" % VERSION ) or None, Script( type = u"text/javascript", src = u"/static/js/Wiki.js?%s" % VERSION ) or None, Input( type = u"hidden", name = u"user", id = u"user", value = json( user ) ), Input( type = u"hidden", name = u"rate_plan", id = u"rate_plan", value = json( rate_plan ) ), Input( type = u"hidden", name = u"yearly", id = u"yearly", value = json( signup_yearly ) ), Input( type = u"hidden", name = u"notebooks", id = u"notebooks", value = json( notebooks ) ), Input( type = u"hidden", name = u"notebook", id = u"notebook", value = json( notebook ) ), Input( type = u"hidden", name = u"parent_id", id = u"parent_id", value = parent_id or "" ), Input( type = u"hidden", name = u"startup_notes", id = u"startup_notes", value = json( startup_note_dicts ) ), Input( type = u"hidden", name = u"current_notes", id = u"current_notes", value = json( note_dicts ) ), Input( type = u"hidden", name = u"note_read_write", id = u"note_read_write", value = json( note_read_write ) ), Input( type = u"hidden", name = u"rename", id = u"rename", value = json( rename ) ), Input( type = u"hidden", name = u"deleted_id", id = u"deleted_id", value = deleted_id ), Input( type = u"hidden", name = u"invites", id = u"invites", value = json( invites ) ), Input( type = u"hidden", name = u"invite_id", id = u"invite_id", value = invite_id ), Input( type = u"hidden", name = u"after_login", id = u"after_login", value = after_login ), Input( type = u"hidden", name = u"signup_plan", id = u"signup_plan", value = signup_plan ), Input( type = u"hidden", name = u"groups", id = u"groups", value = json( groups ) ), Div( id = u"status_area", ), Header( user, header_notebook, login_url, logout_url, header_note_title, rate_plan ), Div( Div( Link_area( Toolbar( notebook, hide_toolbar = parent_id or notebook.read_write == Notebook.READ_ONLY, note_word = forum_tag and u"post" or u"note", ), notebooks, notebook, parent_id, notebook_path, updates_path, user, rate_plan, ), id = u"left_area", ), Div( ( notebook.read_write != Notebook.READ_ONLY ) and Noscript( P( Strong( u""" Luminotes requires JavaScript to be enabled in your web browser in order to edit your wiki. Please <a href="/enable_javascript">enable JavaScript</a> before continuing. """ ) ), ) or None, Rounded_div( ( notebook.name == u"trash" ) and u"trash_notebook" or u"current_notebook", parent_id and Span( A( u"empty", href = u"/notebooks/%s" % notebook.object_id, id = u"empty_trash_link" ), u" | ", A( u"go back", href = u"/notebooks/%s" % parent_id ), id = u"notebook_header_links", ) or None, ( notebook.name == u"Luminotes" and title == u"source code" ) and \ Strong( "%s %s" % ( notebook.name, VERSION ) ) or \ Span( ( notebook.name == u"trash" or notebook.read_write != Notebook.READ_WRITE ) \ and Strong( notebook.name ) \ or Span( Strong( notebook.name ), id = u"notebook_header_name", title = "Rename this notebook." ), ), id = u"notebook_header_area", corners = ( u"tl", u"tr", u"br" ), ), Div( Rounded_div( ( notebook.name == u"trash" ) and u"trash_notebook_inner" or u"current_notebook_inner", Div( id = u"deleted_notebooks", ), Page_navigation( notebook_path, len( notes ), total_notes_count, start, count, ), Div( Span( id = u"notes_top" ), static_notes, id = u"notes", ), ( notebook.read_write == Notebook.READ_WRITE ) and Div( id = u"blank_note_stub", class_ = u"blank_note_stub_hidden_border", ) or None, ( forum_tag and user.username and user.username != u"anonymous" ) and \ Span( ( forum_tag.value == "blog" ) and P( u"To write a comment, click that large \"+\" button to the left. To publish your comment, click the save button.", class_ = u"small_text" ) or P( u"To write a comment, click that large \"+\" button to the left. To publish your comment, click the save button. Or, ", A( u"start a new discussion", href = u"/forums/%s/create_thread" % forum_tag.value ), u".", separator = "", class_ = u"small_text" ), ) or None, ( forum_tag and ( not user.username or user.username == u"anonymous" ) ) and \ P( u"To write a comment, please login first. No account?", A( u"Sign up", href = u"/pricing" ), u"to get a free account.", class_ = "small_text" ) or None, Page_navigation( notebook_path, len( notes ), total_notes_count, start, count, return_text = u"return to the discussion", ), Div( id = u"iframe_area", ), id = u"notebook_background", corners = ( u"tl", ), ), id = u"notebook_border", class_ = ( notebook.name == u"trash" ) and u"trash_notebook_color" or u"current_notebook_color", ), id = u"center_content_area", ), Div( Note_tree_area( notebook, root_notes, recent_notes, total_notes_count, user, ), id = u"right_area", ), id = u"everything_area", ), Span( id = "grabber_hover_preload" ), )
def __init__(self, name, content, parent="Home"): Page.__init__(self, name, content, parent) self.toc = False
def __init__(self): self.page = Page() self.user_name = None self.user_id = None
def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None self.db_conn = Call_Oracle() self.ldap_conn = Call_LDAP()
class Page_Add_Company(): def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None def add_company(self, driver, company_name, type=None): ext_url = r"/servlet/AddNewCompanyProfile?action=add_company_profile" full_url = self.page.get_base_url(driver) + ext_url time.sleep(10) logger.info("Go directly to add company page") driver.get(full_url) self.page.find_element_by_xpath(driver, "//input[@tabindex='1']").send_keys(company_name) if type!=None: option = "//option[@value='%s']",type self.page.find_element_by_xpath(driver, option).click() self.page.find_element_by_tag_name(driver, "button").click() logger.info("Save company info") result_title = self.page.find_element_by_xpath(driver, "//strong") logger.info(result_title) #Get the carrier_id for the new company self.carrier_id = self.page.find_elements_by_xpath(driver, "//input[@name='carrieruid']").get_attribute("value") def get_new_carrier_id(self): if self.carrier_id==None: logger.warn("Sorry, you need add company to get the new carrier_id") return False else: return self.carrier_id def set_new_company_permission(self, driver, permission_group_label, permission_label, element_type='checkbo'): #click on the "Update Permission" button on the page logger.info("To update company permissions....") self.page.find_element_by_xpath("//input[@type='submit']").click() #get permission id, which will be used to find the label in permission change page db_conn = Call_Oracle() db_conn.login_to_xroad6() perm_group_id = db_conn.get_permission_id_from_label(permission_group_label, 'group', element_type) perm_id = db_conn.get_permission_id_from_label(permission_label, 'company_permission', element_type) db_conn.close_connection() perm_group_tag = perm_group_id + '_span' perm_id_tag = perm_id perm_group_xpath = "//span[@id='%s']"%perm_group_tag per_id_xpath = "//input[@id='%s']"%perm_id_tag self.page.find_element_by_xpath(driver, perm_group_xpath).click() self.page.find_elements_by_xpath(driver, per_id_xpath).click() def save_company_permission(self, driver): logger.info("To save permissions....") time.sleep(5) self.page.find_element_by_xpath(driver, "//input[@type='button']").click()
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) # label = tk.Label(self, text="Page One Test") # label.pack(side="top", fill="both", expand=True) self.font10 = "-family {Times New Roman} -size 18 -weight bold " \ "-slant roman -underline 0 -overstrike 0" self.font11 = "-family {Times New Roman} -size 12 " \ "-slant roman -underline 0 -overstrike 0" self.font12 = "-family {Times New Roman} -size 12 -weight normal " \ "-slant roman -underline 0 -overstrike 0" self.searchText = tk.StringVar() self.searchText.set('You need to enter a user!') def isFloat(string): try: float(string) return True except ValueError: return False def callback(*args): y = self.userName.get() z = self.ticketAmount.get() #z = self.list.get() #x = self.checkBox.get() #print z if y and isFloat(z): self.searchButton.config(state='active') else: self.searchButton.config(state='disabled') def goldCallback(*args): x = self.goldAmount.get() if isFloat(x): self.goldButton.config(state='active') else: self.goldButton.config(state='disabled') self.userName = tk.StringVar() self.userName.trace("w", callback) self.goldAmount = tk.StringVar() self.goldAmount.trace("w", goldCallback) self.ticketAmount = tk.StringVar() self.ticketAmount.trace("w", callback) self.potAmount = tk.StringVar() self.goldInit = MyDB().fetchresult("""SELECT `amount` FROM `gold`""", ())[0] self.potAmount.set(self.goldInit) self.origGold = self.potAmount.get() self.goldInit70 = (.7 * float(self.potAmount.get())) self.potAmount.set("70%% of %s = %s" % (self.origGold, self.goldInit70)) # self.list = tk.StringVar() # self.list.trace("w", callback) # self.choices = ('1', '2', '3', '4', '5', '6') # self.ticketsBox = tk.StringVar() # self.premium = tk.Checkbutton(self, text="Click here to allow 6 ticket entries", variable=self.checkBox).place(relx=0.215, rely=0.225) # self.checkBox.trace("w", callback) self.ticketsBox = tk.Entry(self, width=25, font=self.font11, textvariable=self.ticketAmount) self.ticketsBox.place(relx=0.22, rely=0.235, relheight=0.05, relwidth=0.30) self.ticketsBox.configure(width=25) self.ticketsBox.configure(takefocus="") self.ticketsBox.configure(cursor="ibeam") # "title bar" self.mainCredit = tk.Label(self) self.mainCredit.place(relx=0.5, rely=0.05, anchor="center") self.mainCredit.configure(disabledforeground="#a3a3a3") self.mainCredit.configure(font=self.font10) self.mainCredit.configure(foreground="#000000") self.mainCredit.configure(text='''Lotto System''') self.mainCredit.configure(width=614) # example search self.exampleSearch = tk.Label(self) self.exampleSearch.place(relx=0.5, rely=0.1, anchor="center") self.exampleSearch.configure(disabledforeground="#a3a3a3") self.exampleSearch.configure(font=self.font11) self.exampleSearch.configure(foreground="#000000") self.exampleSearch.configure(text='''Fill Out User + Tickets and Click Submit''') self.exampleSearch.configure(width=354) self.searchBox = tk.Entry(self, width=25, font=self.font11, textvariable=self.userName) self.searchBox.place(relx=0.22, rely=0.15, relheight=0.08, relwidth=0.50) self.searchBox.configure(width=25) self.searchBox.configure(takefocus="") self.searchBox.configure(cursor="ibeam") # self.options = tk.OptionMenu(self, self.list, *self.choices) # self.options.place(relx=0.720, rely=0.15, relheight=0.05, relwidth=0.1) # self.options.configure(width=25) # self.options.configure(takefocus="") self.searchButton = tk.Button(self, text="Submit", command=self.on_button, width=10, state='disabled') #self.searchButton.place(relx=0.5, rely=0.25, anchor=CENTER) self.searchButton.place(relx=0.65, rely=0.255, anchor="center") self.searchButton.configure(disabledforeground="#a3a3a3") self.searchButton.configure(foreground="#000000") self.searchButton.configure(highlightbackground="#d9d9d9") self.searchButton.configure(highlightcolor="black") self.searchButton.configure(pady="0") self.infoBoxLabel = tk.LabelFrame(self, text="Information", labelanchor='nw') self.infoBoxLabel.configure(font=self.font10) self.infoBoxLabel.grid(row=10, columnspan=50, padx=10, pady=10, ipadx=10, ipady=10) self.infoBoxLabel.place(relx=0.5, rely=0.35, anchor="center") # message box self.infoBoxArea = tk.Label(self.infoBoxLabel) self.infoBoxArea.configure(font=self.font12, textvariable=self.searchText, wraplength=500, justify="left") self.infoBoxArea.grid(row=0, column=0, padx=5, pady=0) self.wikiLink = tk.Label(self.infoBoxLabel) self.linkText = tk.StringVar() self.linkText.set('') self.goldBox = tk.Entry(self, width=25, font=self.font11, textvariable=self.goldAmount) self.goldBox.place(relx=0.22, rely=0.50, relheight=0.08, relwidth=0.50) self.goldBox.configure(width=25) self.goldBox.configure(takefocus="") self.goldBox.configure(cursor="ibeam") self.goldButton = tk.Button(self, text="Submit", command=self.gold_button, width=10, state='disabled') #self.searchButton.place(relx=0.5, rely=0.25, anchor=CENTER) self.goldButton.place(relx=0.66, rely=0.605, anchor="center") self.goldButton.configure(disabledforeground="#a3a3a3") self.goldButton.configure(foreground="#000000") self.goldButton.configure(highlightbackground="#d9d9d9") self.goldButton.configure(highlightcolor="black") self.goldButton.configure(pady="0") self.currentGoldInfo = tk.LabelFrame(self, text="Current Winner's Pot", labelanchor='nw') self.currentGoldInfo.configure(font=self.font10) self.currentGoldInfo.grid(row=10, columnspan=50, padx=10, pady=10, ipadx=10, ipady=10) self.currentGoldInfo.place(relx=0.5, rely=0.70, anchor="center") # message box self.currentGoldLabel = tk.Label(self.currentGoldInfo) self.currentGoldLabel.configure(font=self.font12, textvariable=self.potAmount, wraplength=500, justify="left") self.currentGoldLabel.grid(row=0, column=0, padx=5, pady=0) self.bind_class("Entry", "<Control-a>", self.select_all)
class Page_Add_User: def __init__(self): self.page = Page() self.user_name = None self.user_id = None def navigate_to_add_user_page(self, driver): ext_url = r"/servlet/UserSelect?action=add_user_profile" full_url = self.page.get_base_url(driver) + ext_url time.sleep(10) logger.info("Go directly to add company page") driver.get(full_url) def select_user_company(self, driver, company_name): input_box = self.page.find_element_by_xpath(driver, "//input[@name='searchStr']") input_box.send_keys(company_name) time.sleep(1) self.page.find_element_by_xpath(driver, "//input[@type='submit']").click() def select_user_type(self, driver, type): if type == "End User": self.page.find_element_by_xpath(driver, "//option[@value='0']").click() elif type == "Crossroads Administrator": self.page.find_element_by_xpath(driver, "//option[@value='20']").click() elif type == "Super Tester": self.page.find_element_by_xpath(driver, "//option[@value='77']").click() elif type == "Associate Administrator": self.page.find_element_by_xpath(driver, "//option[@value='associateadmin']").click() else: raise AssertionError("Sorry, does not support such type of user: %s" % type) def add_user( self, driver, user_type, last_name, first_name, phone="12345", email="*****@*****.**", contact_last_name="Zhang", contact_first_name="Alan", contact_phone="12345", ): self.select_user_type(driver, user_type) self.page.find_element_by_xpath(driver, "//input[@name='sn']").send_keys(last_name) self.page.find_element_by_xpath(driver, "//input[@name='givenname']").send_keys(first_name) self.page.find_element_by_xpath(driver, "//input[@name='telephonenumber']").send_keys(phone) self.page.find_element_by_xpath(driver, "//input[@name='mail']").send_keys(email) self.page.find_element_by_xpath(driver, "//input[@name='contactsn']").send_keys(contact_last_name) self.page.find_element_by_xpath(driver, "//input[@name='contactgivenname']").send_keys(contact_first_name) self.page.find_element_by_xpath(driver, "//input[@name='contacttelephonenumber']").send_keys(contact_phone) self.page.find_element_by_xpath(driver, "//input[@id='submitBtn']").click() driver.switch_to_alert_window().accept() if self.page.find_element_by_xpath(driver, "//div[id='error']"): raise AssertionError("Sorry, can not create user, saving error")
def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None
def __init__(self, *args, **kwargs): Page.__init__(self, *args, **kwargs) self.font10 = "-family {Times New Roman} -size 24 -weight bold " \ "-slant roman -underline 0 -overstrike 0" self.font11 = "-family {Times New Roman} -size 12 " \ "-slant roman -underline 0 -overstrike 0" self.font12 = "-family {Times New Roman} -size 10 " \ "-slant roman -underline 0 -overstrike 0" self.checkBox = tk.IntVar() def callbackDelete(*args): y = self.checkBox.get() x = self.deleteBox.get() if x == 'cogbeard' and y == 1: self.deleteButton.config(state='active') else: self.deleteButton.config(state='disabled') self.winnerText = tk.StringVar() self.winnerText.trace("w", callbackDelete) # "title bar" self.mainCredit = tk.Label(self) self.mainCredit.place(relx=0.5, rely=0.05, anchor="center") self.mainCredit.configure(disabledforeground="#a3a3a3") self.mainCredit.configure(font=self.font10) self.mainCredit.configure(foreground="#000000") self.mainCredit.configure(text='''Delete Page''') self.mainCredit.configure(width=614) # example search self.rollExample = tk.Label(self) self.rollExample.place(relx=0.5, rely=0.1, anchor="center") self.rollExample.configure(disabledforeground="#a3a3a3") self.rollExample.configure(font=self.font11) self.rollExample.configure(foreground="#000000") self.rollExample.configure(text='''Click the checkbox and hit delete to clear the database.''') self.rollExample.configure(width=354) # example search self.rollExample = tk.Label(self) self.rollExample.place(relx=0.5, rely=0.13, anchor="center") # self.rollExample.configure(disabledforeground="#a3a3a3") self.rollExample.configure(font=self.font12) self.rollExample.configure(foreground="red") self.rollExample.configure(text='''THIS ACTION IS IRREVERSIBLE AND FINAL UPON CLICKING DELETE; YOU HAVE BEEN WARNED.''') self.rollExample.configure(width=354) self.confirmDelete = tk.Checkbutton(self, text="Click here to confirm database clearing", variable=self.checkBox).place(relx=0.215, rely=0.225) self.checkBox.trace("w", callbackDelete) self.deleteBox = tk.Entry(self, width=25, font=self.font11, textvariable=self.winnerText, state='normal') self.deleteBox.configure(disabledbackground="#FFFFFF") self.deleteBox.place(relx=0.22, rely=0.15, relheight=0.08, relwidth=0.40) self.deleteBox.configure(width=25) self.deleteBox.configure(takefocus="") self.deleteBox.configure(cursor="ibeam") self.deleteButton = tk.Button(self, text="Clear Database", command=self.clearDatabase, width=20, state='disabled') #self.searchButton.place(relx=0.5, rely=0.25, anchor=CENTER) self.deleteButton.place(relx=0.695, rely=0.65, anchor="center") self.deleteButton.configure(disabledforeground="#a3a3a3") self.deleteButton.configure(foreground="#000000") self.deleteButton.configure(highlightbackground="#d9d9d9") self.deleteButton.configure(highlightcolor="black") self.deleteButton.configure(pady="0")
class Page_Modify_Company_Profile(): ''' This test is used for daily testing, since I can not get the User Permission ID from DB. To keep consistant, i let company permission ID get from test case as well. ''' def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None self.db_conn = Call_Oracle() self.ldap_conn = Call_LDAP() def navigate_to_page_modify_company_profile(self, driver): ''' Navigate to Company Permission Modification Page ''' ext_url = r"/servlet/CompanySelect?action=modify_company_profile" full_url = self.page.get_base_url(driver) + ext_url time.sleep(6) driver.get(full_url) logger.info("==Navigated to Company Permission Modification Page") def select_company(self, driver, company_name, carrier_id=None): ''' Use the exact full company_name to find the company, ''' self.page.find_element_by_xpath(driver, "//input[@name='searchStr']").send_keys(company_name) time.sleep(1) self.page.find_element_by_xpath(driver, "//button[@id='submitPermBtn']").click() logger.info("====Selected Company %s for permission change"%company_name) def assign_company_permission(self, driver, group_label, group_id, company_label, company_id): ''' From the Design document, you already know the group_label, group_id, company_label, company_id So, we use this parameter to select the new permission and check it. ''' group_elem_xpath = self.page.get_xpath(group_id, 'group') comp_elem_xpath = self.page.get_xpath(company_id, 'single') try: comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath) if comp_elem.get_attribute('checked') is None: time.sleep(1) comp_elem.click() time.sleep(1) logger.info("====Assigned company permission: '%s/%s'"%(group_label, company_label)) else: logger.warn("..The permission '%s' was already assigned. Continue without change"%company_label) except (NoSuchElementException, ElementNotVisibleException): group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath) group_elem.click() time.sleep(1) comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath) if comp_elem.get_attribute('checked') is None: time.sleep(1) comp_elem.click() time.sleep(1) logger.info("====Assigned company permission: '%s/%s'"%(group_label, company_label)) else: time.sleep(1) logger.warn("..The permission '%s' was already assigned. Continue without change"%company_label) def verify_permission_invisible_to_company(self, driver, group_label, group_id, company_label, company_id): group_elem_xpath = self.page.get_xpath(group_id, 'group') comp_elem_xpath = self.page.get_xpath(company_id, 'single') try: group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath) group_elem.click() # The page's find_element_by_xpath will not throw out the exception. So use the driver's method. comp_elem = driver.find_element_by_xpath(comp_elem_xpath) comp_elem.click() except NoSuchElementException, ex: logger.info("==Correct!, current company unable to find permission '%s/%s'"%(group_label,company_label)) except ElementNotVisibleException, ex: logger.info("==Correct!, current company unable to see permission '%s/%s'"%(group_label,company_label))
class Page_Modify_User_Profile(): ''' This test is used for daily testing, since I can not get the User Permission ID from DB. To keep consistant, i let company permission ID get from test case as well. ''' def __init__(self): self.page = Page() self.company_name = None self.carrier_id = None def navigate_to_page_modify_user_profile(self, driver): ''' Navigate to Modify User Profile Page ''' ext_url = r"/servlet/UserSelect?action=modify_user_profile" full_url = self.page.get_base_url(driver) + ext_url time.sleep(6) driver.get(full_url) logger.info("==Navigated to Modify User Profile Page") def select_user_from_company(self, driver, company_name, user_id, first_name=None, last_name=None, alternate_id=None): ''' This key word has not imply first_name, last_name into test now. ''' self.page.find_element_by_xpath(driver, "//input[@name='searchStr']").send_keys(company_name) self.page.find_element_by_xpath(driver, "//input[@name='dnqualifier']").send_keys(user_id) self.page.find_element_by_xpath(driver, "//input[@value='Search']").click() logger.info("==Selected User: '******' from Company: '%s'"%(user_id, company_name)) def __click_button_update_permissions(self, driver): time.sleep(2) self.page.find_element_by_id(driver, 'permButton').click() def grant_user_permission(self, driver, group_label, group_perm_id, user_label, user_perm_id): self.__click_button_update_permissions(driver) group_xpath = self.page.get_xpath(group_perm_id, 'group') user_xpath = self.page.get_xpath(user_perm_id, 'single') driver.switch_to_frame('MiddleFrame') try: comp_elem = self.page.find_element_by_xpath(driver, user_xpath) if comp_elem.get_attribute('checked') is None: time.sleep(1) comp_elem.click() logger.info("====Assigned User permission: '%s/%s'"%(group_label, user_label)) else: logger.warn("..The permission '%s' was already assigned. Continue without change"%user_label) except (NoSuchElementException, ElementNotVisibleException): group_elem = self.page.find_element_by_xpath(driver, group_xpath) logger.info("Find group label and click on %s"%group_elem) group_elem.click() comp_elem = self.page.find_element_by_xpath(driver, user_xpath) if comp_elem.get_attribute('checked') is None: time.sleep(1) comp_elem.click() logger.info("====Assigned User permission: '%s/%s'"%(group_label, user_label)) else: logger.warn("..The permission '%s' was already assigned. Continue without change"%user_label) def verify_user_has_no_such_permission_on_webpage(self, driver, group_label, group_perm_id, user_label, user_perm_id): try: self.grant_user_permission( driver, group_label, group_perm_id, user_label, user_perm_id) except (NoSuchElementException, ElementNotVisibleException): logger.info("==Correct! Current User can not find permission %s in permission Tree") return True raise AssertionError("==Incorrect! Current User should not find permission %s in permission Tree") def revoke_user_permission(self, driver, group_label, group_perm_id, user_label, user_perm_id): self.__click_button_update_permissions(driver) group_elem_xpath = self.page.get_xpath(group_perm_id, 'group') comp_elem_xpath = self.page.get_xpath(user_perm_id, 'single') driver.switch_to_frame('MiddleFrame') try: comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath) if comp_elem.get_attribute('checked') is None: logger.warn("..The permission '%s' was NOT checked before. Continue without change"%user_label) else: time.sleep(1) comp_elem.click() logger.info("====Revoked the company permission '%s/%s'"%(group_label, user_label)) except (NoSuchElementException, ElementNotVisibleException): group_elem = self.page.find_element_by_xpath(driver, group_elem_xpath) group_elem.click() comp_elem = self.page.find_element_by_xpath(driver, comp_elem_xpath) if comp_elem.get_attribute('checked') is None: logger.warn("..The permission '%s' was NOT checked before. Continue without change"%user_label) else: time.sleep(1) comp_elem.click() logger.info("====Revoked the company permission '%s/%s'"%(group_label, user_label)) def verify_user_has_permission_in_DB(self, user_id, permission_id, db_name='xroad6_test'): a = Call_Oracle() a.login_db(db_name) a.verify_user_has_permission_in_DB(user_id, permission_id) a.close_db_connection() def verify_user_has_no_such_permission_in_DB(self, user_id, permission_id, db_name='xroad6_test'): a = Call_Oracle() a.login_db(db_name) a.verify_user_has_no_such_permission_in_DB(user_id, permission_id) a.close_db_connection() def verify_user_has_permission_in_ldap(self, user_id, permission_id, ldap_name='LDAP'): a = Call_LDAP() a.login_ldap(ldap_name) a.verify_user_has_permission_in_ldap(user_id, permission_id) a.close_ldap_connection() def verify_user_has_no_such_permission_in_ldap(self, user_id, permission_id, ldap_name='LDAP'): a = Call_LDAP() a.login_ldap(ldap_name) a.verify_user_has_no_such_permission_in_ldap(user_id, permission_id) a.close_ldap_connection() def verify_user_has_product_link(self, driver, product_label): time.sleep(10) driver.switch_to_frame("NavFrame") elem = self.page.find_element_by_link_text(driver, product_label) elem.click() logger.info("==Find product %s"%product_label) driver.switch_to_window(driver.window_handles[1]) def verify_user_has_no_such_product_link(self, driver, product_label): try: self.verify_user_has_product_link(driver, product_label) except (NoSuchElementException, ElementNotVisibleException): logger.info("==Correct, user don't have product %s"%product_label) return True raise AssertionError("==Correct, user should NOT has product %s"%product_label) def verify_user_has_menu_link(self, driver, menu_link, sub_menu=''): time.sleep(10) if sub_menu=='': try: driver.switch_to.default_content driver.switch_to_frame("MenuFrame") elems = self.page.find_elements_by_xpath(driver, "//span") found_flag=0 for each in elems: if each.text == menu_link: logger.info("Found the menu link: '%s'"%menu_link) found_flag=1 return True if found_flag==0: raise AssertionError("Sorry, not abel to find the menu link '%s'"%menu_link) except NoSuchFrameException: elems = self.page.find_elements_by_xpath(driver, "//span") found_flag=0 for each in elems: if each.text == menu_link: logger.info("Found the menu link: '%s'"%menu_link) found_flag=1 return True if found_flag==0: raise AssertionError("Sorry, not abel to find the menu link '%s'"%menu_link) else: self.verify_user_has_menu_link(driver,menu_link) self.verify_user_has_menu_link(driver, sub_menu) # def verify_user_has_product_and_menu_link_on_webpage(self, driver, product_label, first_level_menu, second_level_menu=''): # time.sleep(10) # link=string.replace(product_label, ' ','') # ext_url = '/servlet/MenuTree?menuid=%s'%link # full_url = self.page.get_base_url(driver) + ext_url # driver.get(full_url) # elems = self.page.find_elements_by_xpath(driver, '//span') # for each in elems: # if each.text == first_level_menu: # logger.info("==Success, found the first level menu '%s'"%first_level_menu) # each.click() # if second_level_menu=='': # return True # else: # elems = self.page.find_elements_by_xpath(driver, '//span') # for each in elems: # if each.text == second_level_menu: # logger.info("==Success, found the first level menu '%s'"%first_level_menu) # each.click() # else: # raise NoSuchElementException("Not able to find the second level menu '%s'"%second_level_menu) # else: # raise NoSuchElementException("Not able to find the first level menu '%s'"%first_level_menu) def verify_user_has_no_product_or_menu_link_on_webpage(self, driver, product_label, first_level_menu, second_level_menu=''): try: self.verify_user_has_product_and_menu_link_on_webpage(driver, product_label, first_level_menu,second_level_menu) except NoSuchElementException: logger.info("==Correct, User is not able to see the %s and %s"%(product_label, first_level_menu)) return True raise AssertionError("==Wrong! User should not able to find product %s and menu %s"(product_label, second_level_menu)) def select_menu_on_big_frame(self, driver, menu_text): #driver.switch_to_frame("NavFrame") driver.switch_to.default_content() driver.switch_to_frame('MenuFrame') elems = self.page.find_elements_by_xpath(driver, "//span") found_flag = 0 for each in elems: if each.text == menu_text: found_flag=1 each.click() logger.info("Click on menu '%s'"%menu_text) if found_flag==0: raise AssertionError("==Not able to find the menu %s"%menu_text) def save_user_permission(self, driver): driver.switch_to.default_content() driver.switch_to_frame('BottomFrame') self.page.find_element_by_id(driver, 'continue').click()
def __init__(self): self.a = Page()
def getPageData(self,page): data = Page() for elem in page: tag = elem.tag if tag == self.tags.title: if self.select.title is None: if u'title' in self.fields: data.title = elem.text else: continue else: data.title = elem.text if not all(select(data.toTuple()) for select in self.select.title): return None if u'title' not in self.fields: data.title = None elif tag == self.tags.ns: if self.select.ns is None: if u'ns' in self.fields: data.ns = elem.text else: continue else: data.ns = elem.text if not all(select(data.toTuple()) for select in self.select.ns): return None if u'ns' not in self.fields: data.ns = None elif tag == self.tags.id: if self.select.id is None: if u'id' in self.fields: data.id = elem.text else: continue else: data.id = elem.text if not all(select(data.toTuple()) for select in self.select.id): return None if u'id' not in self.fields: data.id = None elif tag == self.tags.redirect: if self.select.redirect is None: if u'redirect' in self.fields: data.redirect = elem.get(u'title') else: continue else: data.redirect = elem.get(u'title') if not all(select(data.toTuple()) for select in self.select.redirect): return None if u'redirect' not in self.fields: data.redirect = None elif tag == self.tags.revision: if self.select.text is None: if u'text' in self.fields: text = elem.find(self.tags.text).text data.text = text if self.parse_text is None else self.parse_text(text) else: continue else: text = elem.find(self.tags.text).text data.text = text if self.parse_text is None else self.parse_text(text) if not all(select(data.toTuple()) for select in self.select.text): return None if u'text' not in self.fields: data.text = None break elif tag == self.tags.upload: break return data