Beispiel #1
0
 def test_login(self):
     users = [
         ('*****@*****.**', '233330059'),
         ('*****@*****.**', '410941086'),
         ('*****@*****.**', '498934189')
     ]
     #each account login only once to avoid safety policy
     #istance user
     user, expt = users[0]
     dl = browser.browser(user)
     rid, info = dl.login()
     self.assertEquals(rid, expt)
     #explict login
     user, expt = users[1]
     dl = browser.browser(user)
     rid, info = dl.login(user)
     self.assertEquals(rid, expt)
     #explict and wrong passwd
     user, expt = users[2]
     dl = browser.browser(user)
     rid, info = dl.login(user, 'error')
     self.assertEquals(rid, None)
     #instance passwd wrong, but login explict with correct passwd
     dl = browser.browser(user, 'error')
     rid, info = dl.login(user)
     self.assertEquals(rid, expt)
Beispiel #2
0
    def __init__(self, screen, config, loop=None):
        self.screen = screen
        self.config = config
        self.loop = loop if loop != None else asyncio.get_event_loop()

        self.ui_q = janus.Queue(loop=self.loop)
        self.joycontrol_q = janus.Queue(loop=self.loop)

        self.font = pygame.freetype.SysFont(pygame.font.get_default_font(),
                                            self.config.font_size)

        bins = sorted(
            (SimpleNamespace(path=os.path.join(path, fn), name=fn)
             for path, dirs, files in os.walk(self.config.bins_root)
             for fn in files if os.path.splitext(fn)[1].lower() == ".bin"),
            key=lambda b: b.name)
        self.browser = browser(
            bins,
            self.screen,
            self.config,
            self.font,
            self.select_nfc,
            filter_item=lambda b, f: f.lower() in b.name.lower(),
            show_item=lambda b: b.name)
        self.proctrl = proctrl(self.screen, self.config, self.font,
                               self.browse_nfc, self.joycontrol_q)

        self.ctrl = self.proctrl
Beispiel #3
0
def save_picture(pictureName):
    driver = browser().resue_browser()
    file_path = os.path.join(os.path.dirname(os.path.dirname(__file__)),
                             'screenshots')  # 获取截图保存地址
    now = time.strftime('%Y_%m_%d %H_%M_%S')  # 获取当前时间
    picture = file_path + '/' + now + '_' + pictureName + '.png'  # 拼接截图保存地址
    driver.save_screenshot(picture)  # 截图
 def __init__(self):
     '''
     Initializes all the models,
     for use within.
     '''
     print 'Creating the program model'
     self.Browser = browser()
Beispiel #5
0
def run():
    print(logo)
    _config()
    _browser = browser()
    for url in link:
        _browser.start(url)
        print(url)
Beispiel #6
0
 def test_download(self):
     dl = browser.browser()
     dl.login('test', 'test')
     url_normal = "http://www.baidu.com"
     self.assertTrue(isinstance(dl._download(url_normal), str))
     url_timeout = "http://1.1.1.1"
     self.assertEquals(dl._download(url_timeout), None)
     self.assertTrue(isinstance(dl._download(url_timeout), str))
Beispiel #7
0
 def get_test_data(self, pageStyle, rid, uppage=110):
     if self.dl is None:
         self.dl = browser.browser('*****@*****.**')
         self.dl.login()
     meth = getattr(browser.browser, pageStyle)
     browser.run_level = 'debug'
     meth(self.dl, rid, uppage)
     browser.run_level = 'info'
Beispiel #8
0
 def get_test_data(self, pageStyle, rid, uppage=110):
     if self.dl is None:
         self.dl = browser.browser('*****@*****.**')
         self.dl.login()
     meth = getattr(browser.browser, pageStyle)
     browser.run_level = 'debug'
     meth(self.dl, rid, uppage)
     browser.run_level = 'info'
Beispiel #9
0
 def test_download(self):
     dl = browser.browser()
     dl.login('test', 'test')
     url_normal = "http://www.baidu.com"
     self.assertTrue(isinstance(dl._download(url_normal), str))
     url_timeout = "http://1.1.1.1"
     self.assertEquals(dl._download(url_timeout), None)
     self.assertTrue(isinstance(dl._download(url_timeout), str))
Beispiel #10
0
 def __init__(self, parent, name):
     KCModule.__init__(self, parent, name)
     KGlobal.locale().insertCatalogue(mod_app)
     KGlobal.iconLoader().addAppDir(mod_app)
     self.config = KConfig(mod_app)
     self.aboutdata = AboutData()
     widget = browser(self)
     toplayout = QVBoxLayout(self, 0, KDialog.spacingHint())
     toplayout.addWidget(widget)
 def __init__(self, parent, name):
     KCModule.__init__(self, parent, name)
     KGlobal.locale().insertCatalogue(mod_app)
     KGlobal.iconLoader().addAppDir(mod_app)
     self.config = KConfig(mod_app)
     self.aboutdata = AboutData()
     widget = browser(self)
     toplayout = QVBoxLayout(self, 0, KDialog.spacingHint())
     toplayout.addWidget(widget)
Beispiel #12
0
	def __init__(self,repo_name='test',user='******',passwd=None):
		self.dl=browser.browser(user,passwd)
		if default_storage is None:
			set_repo()
		self.repo=default_storage(repo_name)
		self.log=runlog('spider')

		self.searched=dict()
		self.searched['friendList']=self.repo.getSearched('friendList')
Beispiel #13
0
    def __init__(self,repo_name='test',user='******',passwd=None):
        self.dl=browser.browser(user,passwd)
        if default_storage is None:
            set_repo()
        self.repo=default_storage(repo_name)
        self.log=runlog('spider')

        self.searched=dict()
        self.searched['friendList']=self.repo.getSearched('friendList')
Beispiel #14
0
def execute_cmd(cmd):
    global startTime
    if cmd == 'ctime':
        now = datetime.datetime.now()
        speak("Сейчас {0}:{1}".format(str(now.hour), str(now.minute)))
    elif cmd == "findFilmInfoInCinema":
        cpm.cinemaParser(cmd)
    elif cmd == "findFilms":
        cpm.cinemaParser(cmd)
    elif cmd == 'timer':
        timer.time_r()
    elif cmd == 'shutdown':
        os.system('shutdown -s')
        speak("Выключаю...")
    elif cmd == 'calc':
        calc.calculator()
    elif cmd == 'weather':
        weather.check_weather()
    elif cmd == 'conv':
        convert.convertation()
    elif cmd == 'translator':
        translate.translate()
    elif cmd == 'stupid1':
        anekdot.fun()
    elif cmd == 'internet':
        browser.browser()
    elif cmd == 'startStopwatch':
        speak("Секундомер запущен")
        startTime = time.time()
    elif cmd == "find":
        browser_find.google_find()
    elif cmd == "stopStopwatch":
        if startTime != 0:
            Time = time.time() - startTime
            speak(
                f"Прошло {round(Time // 3600)} часов {round(Time // 60)} минут {round(Time % 60, 2)} секунд"
            )
            startTime = 0
        else:
            speak("Секундомер не включен")
    elif cmd == 'deals':
        speak("Голова пока цела. Я имею ввиду процессор.")
    else:
        print("Команда не распознана")
Beispiel #15
0
def isElementExist(locator):
    '''判断元素是否存在,存在返回True,不存在返回False'''
    flag = True
    driver = browser().resue_browser()
    try:
        WebDriverWait(driver, 10,
                      1).until(EC.presence_of_element_located(locator))
        return flag
    except:
        flag = False
        return flag
Beispiel #16
0
 def test_login(self):
     users = [('*****@*****.**', '233330059'),
              ('*****@*****.**', '410941086'),
              ('*****@*****.**', '498934189')]
     #each account login only once to avoid safety policy
     #istance user
     user, expt = users[0]
     dl = browser.browser(user)
     rid, info = dl.login()
     self.assertEquals(rid, expt)
     #explict login
     user, expt = users[1]
     dl = browser.browser(user)
     rid, info = dl.login(user)
     self.assertEquals(rid, expt)
     #explict and wrong passwd
     user, expt = users[2]
     dl = browser.browser(user)
     rid, info = dl.login(user, 'error')
     self.assertEquals(rid, None)
     #instance passwd wrong, but login explict with correct passwd
     dl = browser.browser(user, 'error')
     rid, info = dl.login(user)
     self.assertEquals(rid, expt)
Beispiel #17
0
def main():
    obj = browser()
    if (obj == False):
        sys.exit(1)
    obj.openUrl()
    obj.search()
    resultsLists = obj.getResulstList()
    if (len(resultsLists) == 0):
        print("No results")
        sys.exit(1)
    if (obj.getResultsNum() < obj.getActualResultsNum()):
        print("Expected results num %d, actual %d" %
              (obj.resultNum, obj.actualResultsNum))

    nameList = obj.getItemsWithoutRating()
    if (nameList):
        print("Items without rating: ")
        for i in range(len(nameList)):
            print("%d - %s " % (i + 1, nameList[i]))
    def ask(self, error):

        # Si l'utilisateur c'est trompé
        # != 1 ou != 2
        if (error == True):
            print(self.err['invalid_input'])

        fileortext = self.askFileOrText()

        # Ouvre le browser (tkinter)
        if (fileortext == "1"):
            file = browser(self.debug)
            return file.get()

        # Texte saisi par l'user
        if (fileortext == "2"):
            return self.askText()

        return False
Beispiel #19
0
def main():
    about_data = AboutData()
    KCmdLineArgs.init(sys.argv, about_data)
    if not KUniqueApplication.start():
        print i18n('Proxy Manager is already running!')
        return
    app = KUniqueApplication(True, True, True)

    win = QDialog()
    win.setCaption(i18n('Proxy Manager'))
    win.setIcon(loadIconSet("proxy").pixmap(QIconSet.Small, QIconSet.Normal))
    widget = browser(win)
    win.aboutus = KAboutApplication(win)
    toplayout = QVBoxLayout(win, 0, KDialog.spacingHint())
    toplayout.addWidget(widget)
    win.setMinimumSize(620, 420)
    win.resize(620, 420)

    app.setMainWidget(win)
    sys.exit(win.exec_loop())
def main():
    about_data = AboutData()
    KCmdLineArgs.init(sys.argv, about_data)
    if not KUniqueApplication.start():
        print i18n('Proxy Manager is already running!')
        return
    app = KUniqueApplication(True, True, True)

    win = QDialog()
    win.setCaption(i18n('Proxy Manager'))
    win.setIcon(loadIconSet("proxy").pixmap(QIconSet.Small, QIconSet.Normal))
    widget = browser(win)
    win.aboutus = KAboutApplication(win)
    toplayout = QVBoxLayout(win, 0, KDialog.spacingHint())
    toplayout.addWidget(widget)
    win.setMinimumSize(620, 420)
    win.resize(620, 420)

    app.setMainWidget(win)
    sys.exit(win.exec_loop())
Beispiel #21
0
def scroll_end():
    '''滚动到底部'''
    driver = browser().resue_browser()
    js = "window.scrollTo(0,document.body.scrollHeight);"
    driver.execute_script(js)
Beispiel #22
0
def scroll_top():
    '''滚到顶部'''
    driver = browser().resue_browser()
    js = "window.scrollTo(0,0);"
    driver.execute_script(js)
Beispiel #23
0
    def __init__(self):
        # initialize the window
        super().__init__()
        self.wm_title(f'BEE Manipulator v{config.version()}')
        self.geometry("600x500")
        self.lift()
        # set window icon
        self.wm_iconbitmap(default="assets/icon.ico")
        set_window_icon(self)
        # check updates
        logWindow.init(self)
        self.LOGGER = get_logger("mainLoop")
        try:
            if (config.load("logWinodowVisible")):
                logWindow.toggleVisibility()
        except:
            logWindow.toggleVisibility()
        self.LOGGER.debug(
            "starting background update check for BEE Manipulator")
        self.checkUpdates(window=False)
        r"""
            there are the functions to make the main window, every # comment indicates
            what part is build there, to make it more clear and readable
            ttb = top tool bar
            TODO: make every dropdown menu a class
        """
        # top tool bar
        self.toolBarFrame = tk.Menu(self, bg="lightgrey", fg="black")
        # file ttb menu
        self.fileMenu = tk.Menu(self.toolBarFrame,
                                tearoff=0,
                                bg="white",
                                fg="black")
        self.fileMenu.add_command(label="Open Portal 2 Directory",
                                  command=self.openp2dir)
        self.fileMenu.add_command(label="Open BEEmod Directory",
                                  command=self.openBEEdir)
        self.fileMenu.add_command(label="Sync Games", command=self.syncGames)
        self.fileMenu.add_command(label="Quit", command=self.quit)

        # options ttb menu
        self.optionMenu = tk.Menu(self.toolBarFrame,
                                  tearoff=0,
                                  bg="white",
                                  fg="black")
        self.optionMenu.add_command(label="Settings",
                                    command=self.openSettingsWindow)
        self.optionMenu.add_command(label="Toggle Log Window",
                                    command=logWindow.toggleVisibility)
        self.optionMenu.add_command(label="Reload Configs",
                                    command=self.reloadConfig)
        self.optionMenu.add_command(label="Reload Packages",
                                    command=self.reloadPackages)
        self.optionMenu.add_command(label="Manage Games",
                                    command=self.openGameManager)
        self.optionMenu.add_command(label="Manage Packages",
                                    command=self.openPackageManager)
        self.optionMenu.add_command(label="Manage Plugins",
                                    command=self.openPackageManager)

        # options ttb menu
        self.portal2 = tk.Menu(self.toolBarFrame,
                               tearoff=0,
                               bg="white",
                               fg="black")
        self.portal2.add_command(label="Verify Game Cache",
                                 command=self.verifyGameCache)
        self.portal2.add_command(label="Uninstall BEE2.4",
                                 command=self.uninstallBee)
        self.portal2.add_command(label="Install BEE2.4",
                                 command=self.installBee)

        # help ttb menu
        self.helpMenu = tk.Menu(self.toolBarFrame,
                                tearoff=0,
                                bg="white",
                                fg="black")
        self.helpMenu.add_command(label="About..",
                                  command=self.openAboutWindow)
        self.helpMenu.add_command(label="Check Updates",
                                  command=self.checkUpdates)
        self.helpMenu.add_command(label="Open Wiki", command=self.openWiki)
        self.helpMenu.add_command(label="Github", command=self.openGithub)
        self.helpMenu.add_command(label="Discord", command=self.openDiscord)

        # put all the ttb together
        self.toolBarFrame.add_cascade(label="File", menu=self.fileMenu)
        self.toolBarFrame.add_cascade(label="Options", menu=self.optionMenu)
        self.toolBarFrame.add_cascade(label="Portal 2", menu=self.portal2)
        self.toolBarFrame.add_cascade(label="Help", menu=self.helpMenu)
        self.configure(menu=self.toolBarFrame)
        # pack the browser
        self.browser = browser(self)
        self.browser.pack()

        self.bind("<Control-l>", logWindow.toggleVisibility)
Beispiel #24
0
def browser(PGL, N=0, S=0, P=0, Q=0, tN='pgl_track'):
    """Takes a PyGL object and returns a string formatted for the UCSC genome browser."""
    return _brow.browser(PGL, N, S, P, Q, tN)
Beispiel #25
0
import os
import glob
import pandas as pd
from browser import browser
from selenium.webdriver.support.ui import Select

bro = browser()  # Create Webdriver instance
bro.open(
    "https://www.ebay.com/sch/Cars-Trucks/6001/i.html?_from=R40&_nkw=&_in_kw=1&_ex_kw=&_sacat=6001&LH_Sold=1&_udlo=&_udhi=&_samilow=&_samihi=&_sadis=15&_stpos=01923&_sargn=-1%26saslc%3D1&_salic=1&_sop=12&_dmd=1&_ipg=200&LH_Complete=1"
)  # Go to Ebay page

# Don't redo acquired data
makes_done = sorted(glob.glob(".\\DataBackup\\*.csv"))
makes_dropdown = Select(
    bro.driver.find_element_by_xpath("//select[@name='Make']"))
makes = makes_dropdown.options[1:]
make_texts = [make.text for make in makes if make.text not in str(makes_done)]

for make in make_texts:
    found = bro.select_make(make)
    if found:
        # Continue where last left off if failure occured
        if os.path.isfile(".\\Data\\" + make.replace('/', '_') + ".pkl"):
            df = pd.read_pickle(".\\Data\\" + make.replace('/', '_') + ".pkl")
        else:
            df = pd.DataFrame()

        ads_info = bro.get_ads()
        count = bro.driver.find_element_by_xpath("//span[@class='rcnt']")
        if int(count.text.replace(',', '')) > 200:
            for x in range(int(count.text.replace(',', '')) / 200):
Beispiel #26
0
def scroll_length(y):
    '''向下滚动指定长度'''
    driver = browser().resue_browser()
    js = 'window.scrollTo(0,%d);' % y
    driver.execute_script(js)
Beispiel #27
0
def element(locator, timeout=5):
    '''等待元素出现并定位元素 - 单个元素,参数locator是元祖类型'''
    driver = browser().resue_browser()
    element = WebDriverWait(driver, timeout,
                            1).until(EC.presence_of_element_located(locator))
    return element
Beispiel #28
0
 def start(self):
     self.browser = browser()
     self.browser.maximize_window()
     self.browser.get(self.ibge_url)