当前位置: 首页>>代码示例>>Python>>正文


Python Display.stop方法代码示例

本文整理汇总了Python中pyvirtualdisplay.Display.stop方法的典型用法代码示例。如果您正苦于以下问题:Python Display.stop方法的具体用法?Python Display.stop怎么用?Python Display.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyvirtualdisplay.Display的用法示例。


在下文中一共展示了Display.stop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: retrieveTTdata

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def retrieveTTdata(url):
    print "processing tenTeb ..."

    display = Display(visible=0, size=(1024, 1024))
    display.start()

    # driver = webdriver.Firefox()

    # http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium
    driver = webdriver.Chrome()
    driver.get(url)
    sleep(5)
    html = driver.page_source
    driver.quit()

    display.stop()

    parser = etree.HTMLParser()
    tree = etree.parse(StringIO(html), parser)

    for div_element in tree.getiterator("div"):
        if "class" in div_element.keys() and div_element.attrib["class"] == "types_bg":
            tree = div_element

    for div_element in tree.getiterator("div"):
        if "class" in div_element.keys() and div_element.attrib["class"] == "bets ml":
            parse_div_element(div_element)
开发者ID:mastinux,项目名称:tebRotarapmoc,代码行数:29,代码来源:views.py

示例2: getupc

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def getupc(data, sleeptime):
    display = Display(visible=0, size=(800, 600))
    display.start()
    a = webdriver.Firefox()
    a.get('https://www.google.com/ncr')
    time.sleep(sleeptime)
    search = WebDriverWait(a, 5).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='text']")))
    for i in data:
        ActionChains(a).move_to_element(search).click(search).send_keys(i['name'] + ' upc', Keys.ENTER).perform()
        time.sleep(sleeptime)
        contents = WebDriverWait(a, 5).until(EC.presence_of_all_elements_located((By.XPATH, "//div[@class='g']")))
        try:
            upc = next(
                    (re.split(r'/', href.find_element_by_tag_name('a').get_attribute('href'))[-1] for
                     href in contents if
                     href.find_element_by_tag_name('a').get_attribute('href').startswith(
                             'http://www.upcitemdb.com/upc')))
            i['upc'] = upc
        except StopIteration:
            pass

        search = WebDriverWait(a, 5).until(EC.element_to_be_clickable((By.XPATH, "//input[@type='text']")))
        search.clear()
    a.close()
    display.stop()
    return data
开发者ID:zheverson,项目名称:videoitem,代码行数:28,代码来源:scrapeinfo.py

示例3: webthumb

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def webthumb(url, filename, is_flash=False):
    script = """
        var s = document.createElement('script');
        s.src = 'http://cruels.net/sb/flashfix.js';
        document.body.appendChild(s);
    """
    print "webthumb(%s, %s)" % (url, filename)
    display = Display(visible=0, size=(1200, 900))
    display.start()
    browser = webdriver.Firefox()
    browser.get(url)
    if is_flash:
        time.sleep(1)
    else:
        browser.execute_script(script)
        time.sleep(6)
    tmpfile = "%s.tmp" % filename
    browser.get_screenshot_as_file(tmpfile)
    img = pil.open(tmpfile)
    width, height = img.size
    if is_flash:
        resized = img.resize((LIBRARYFILE_THUMB_WIDTH, LIBRARYFILE_THUMB_HEIGHT), pil.ANTIALIAS)
    else:
        ratio = float(width) / float(height)
        resized = img.resize((LIBRARYFILE_THUMB_WIDTH, int(LIBRARYFILE_THUMB_WIDTH / ratio)), pil.ANTIALIAS)
    resized.save(filename)
    os.remove(tmpfile)
    print "Saved %s." % filename
    browser.quit()
    display.stop()
    return True
开发者ID:Cruel,项目名称:Anondex,代码行数:33,代码来源:utils.py

示例4: TestContext

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
class TestContext(object):
    
    def open_browser(self):

#         if test_config.SELENIUM_USE_REMOTE:
#             dc = getattr(DesiredCapabilities, self.driver.upper())
#             dc['name'] = test_config.SELENIUM_TEST_NAME
#             cmd_exec = test_config.SELENIUM_REMOTE_CMD_EXEC
#             self.browser = webdriver.Remote(desired_capabilities=dc, command_executor=cmd_exec)

        if test_config.SELENIUM_USE_VIRTUALDISPLAY:
            self.virtualdisplay = Display(backend=test_config.SELENIUM_VIRTUALDISPLAY_BACKEND, size=(600, 800)).start()

        self.browser = webdriver.Firefox(firefox_binary=FirefoxBinary(test_config.SELENIUM_FIREFOX_PATH))
        self.browser.implicitly_wait(test_config.SELENIUM_PAGE_WAIT)
        
    def close(self):
        self.browser.quit()
        if hasattr(self, 'virtualdisplay'):
            self.virtualdisplay.stop()
            
    def get(self, url):
        self.browser.get(url)
        self.url = url
    
    def follow_link(self, link):
        link.click()
        self.url = self.browser.current_url
        
    def wait_for(self, by, thing):
        wait = WebDriverWait(self.browser, test_config.SELENIUM_PAGE_WAIT)
        wait.until(EC.presence_of_element_located((by, thing)))
开发者ID:aaccomazzi,项目名称:adsabs,代码行数:34,代码来源:utils.py

示例5: load

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
 def load(self):
     min_time = 3600 # 1 hour in seconds
     max_time = 7179 # 2 hours in seconds (less 21)
     tasktime = randint(min_time, max_time)
     threading.Timer(tasktime, self.load).start()
     tasktime_m , tasktime_s = divmod( tasktime , 60)
     tasktime_h , tasktime_m = divmod( tasktime_m , 60) 
     output_content = "Load execution - waiting %dh %02dmin %02dsec for the next time." % (tasktime_h, tasktime_m, tasktime_s)
     print "[KeepUp]" , output_content
     
     from selenium import webdriver
     from selenium.webdriver.common.by import By
     from selenium.webdriver.support.ui import WebDriverWait
     from selenium.webdriver.support import expected_conditions as ec
     from selenium.webdriver.common.keys import Keys
     from pyvirtualdisplay import Display
     
     # Initial
     display = Display(visible=0, size=(1600, 900))
     display.start()
     profile = webdriver.FirefoxProfile()
     profile.set_preference("browser.cache.disk.enable", False)
     profile.set_preference("browser.cache.memory.enable", False)
     profile.set_preference("browser.cache.offline.enable", False)
     profile.set_preference("network.http.use-cache", False)
     driver = webdriver.Firefox()
     driver.get("https://c9.io/dashboard.html")
     driver.save_screenshot(self.directory_img + 'login.png')
     
     #Username
     username = driver.find_element_by_id("id-username")
     username.click()
     username.clear()
     username.send_keys(self.user, Keys.ARROW_DOWN)
     
     #Password
     password = driver.find_element_by_id("id-password")
     password.click()
     password.clear()
     password.send_keys(self.password, Keys.ARROW_DOWN)
     
     #Submit
     submit_button = driver.find_element_by_css_selector("button[type=submit]")
     # print submit_button.text
     
     # Click submition
     submit_button.click();
     time.sleep(5)
     driver.save_screenshot(self.directory_img + 'user_profile.png')
     
     # Target dir
     driver.get(self.target_workspace)
     time.sleep(10)
     
     self.log({'log_html': driver.page_source, 'log_file': output_content}) #make log
     driver.save_screenshot(self.directory_img + 'final_workspace.png')
     
     # End
     driver.quit()
     display.stop()
开发者ID:Fal34,项目名称:PFG-NFC-Android,代码行数:62,代码来源:keepUp.py

示例6: TestCase

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
class TestCase(unittest.TestCase):
    def setUp(self):
        app.config['TESTING'] = True
        app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///:memory:'
        self.app = app.test_client()
        db.create_all()

        self.display = Display(visible=0, size=(800, 600))
        self.display.start()
        self.driver = webdriver.Firefox()

    def tearDown(self):
        db.session.remove()
        db.drop_all()

        self.driver.quit()
        self.display.stop()

    def test_extract_funds(self):
        funds = extract_funds(
            # some javascript going on that I can't figure out how to mock
            #'file:///%s/t/test_files/list_mutual_funds.html' % basedir,

            self.driver
        )

        self.assertTrue(len(funds) > 110)
开发者ID:ssloat,项目名称:vanguard,代码行数:29,代码来源:unmocked_extract_funds.py

示例7: loadSite

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def loadSite(url):
    profile = webdriver.FirefoxProfile()
    profile.set_preference("network.proxy.type", 1)
    profile.set_preference("network.proxy.http", "74.84.131.34")
    profile.set_preference("network.proxy.http_port", int('80'))
    profile.update_preferences()
    #
    display = Display(visible=0, size=(800, 600))
    display.start()
    path_to_chromedriver = '/home/alexandr/www/html/python/prs/files/geckodriver'
    browser = webdriver.Firefox(firefox_profile = profile, executable_path = path_to_chromedriver)
    #
    browser.delete_all_cookies()
    browser.get(url)
    #print(browser.page_source)
    #print(browser.page_source)
    tree = etree.HTML( browser.page_source)
    #
    browser.close()
    display.stop()
    #
    nodes = tree.xpath('//table[@class="network-info"]//tr/td')
    for node in nodes:
        print(node.text)
    return 1
开发者ID:alexandrtkachuk,项目名称:python,代码行数:27,代码来源:get_ip2.py

示例8: __init__

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
class BrowserManager:
	def __init__(self):
		self._lock = False
	def bootup(self):
		self._display = Display(visible=0, size=(1024, 768))
		self._display.start()
		profile = {}
		if 'HTTP_PROXY' in os.environ:
			proxy_url = os.environ['HTTP_PROXY']
			proxy_server = proxy_url.split(':')[1][2:]
			proxy_port = proxy_url.split(':')[-1]
			profile['network.proxy.type'] = 1
			profile['network.proxy.http'] = proxy_server
			profile['network.proxy.http_port'] = proxy_port
			profile['network.proxy.https'] = proxy_server
			profile['network.proxy.https_port'] = proxy_port
		self.browser = Browser(profile_preferences=profile)
	def obtain(self,background):
		while self._lock:
			background.wait('Browser lock', 15)
		self._lock = True
		return self.browser
	def release(self,background):
		self._lock = False
	def shutdown(self):
		self.browser.quit()
		self._display.stop()
开发者ID:adrian-r,项目名称:solar_radiation_model,代码行数:29,代码来源:worker_manager.py

示例9: SeleniumRunner

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
class SeleniumRunner(object):
    def __call__(self, f):
        @functools.wraps(f)
        def decorated(_self, *args, **kwargs):
            with self as driver:
                return f(_self, driver, *args, **kwargs)
        return decorated

    def __enter__(self):
        self.display = Display(visible=0, size=(800, 600))
        self.display.start()
        self.driver = webdriver.Chrome()
        return self.driver

    def __exit__(self, *args, **kwargs):
        try:
            self.driver.quit()
        except (AttributeError,) as e:
            # Someone has messed with our browser
            pass
        try:
            self.display.stop()
        except (AttributeError,) as e:
            # Someone has messed with our display
            pass
开发者ID:benvand,项目名称:profiler,代码行数:27,代码来源:runner.py

示例10: main

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def main():
    if (len(sys.argv) < 2):
        print "./fb_auto_commenter.py Brazil/English/French"
        return

    fb_auto_mail.write_file("---------------------------" + sys.argv[1] + "\n")

    try:
        display = Display(visible=0, size=(800,600))
        display.start()
        #打开区域权限
        logging.info(">>>>>>>open limit")
        open_limit()
        #读取googledocs 群组信息
        logging.info(">>>>>>>read from google docs")
        global french_groups_id
        french_groups_id = read_from_googledocs()
        #french_groups_id = ['309490585766406', '745769152175443', '1393190844256106', '1384933575085078', '1458512047714028', '1581747275377893', '778025652245798', '252563551503667', '1468450793419237']
        logging.info(french_groups_id)

        #打开任务进程
        logging.info(">>>>>>>start post task")
        start_task_process()

        #关闭权限
        logging.info(">>>>>>>close limit")
        close_limit()

        logging.info(">>>>>>>send result mail")
        fb_auto_mail.send_mail()
    except Exception as e:
        logging.error(e)
    finally:
        logging.info("end")
        display.stop()
开发者ID:maomaotp,项目名称:fb_post,代码行数:37,代码来源:fb_auto_commenter.py

示例11: authorizeToken

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def authorizeToken(requestTokenResponse):
  """
  Given a dict requestTokenResponse with the temporary oauth_token and oauth_token_secret,
  we generate a login link that a user should interact with to obtain an authCode <str>
  This process is automated with Splinter and pyvirtualdisplay
  """

  resource_owner_key = requestTokenResponse['oauth_token']
  resource_owner_secret = requestTokenResponse['oauth_token_secret']
  redirect_response = 'https://us.etrade.com/e/t/etws/authorize?key={}&token={}'.format(client_Consumer_Key,resource_owner_key)
  

  # print 'go to this link for authorization:', redirect_response

  # cannot parse redirect_response without a browser because the response is not pure json
  # oauth_response = oauth.parse_authorization_response(redirect_response)

  # Open URL in a new tab, if a browser window is already open.
  # webbrowser.open_new_tab(redirect_response)

  # Display allows the script to run in a linux cloud without a screen
  display = Display(visible=0, size=(1024, 768))
  display.start()


  # create a browser using Splinter library and simulate the workflow of a user logging in
  # various time.sleep(n) is inserted here to make sure login is successful even on slower connections
  with Browser() as browser:
    # Visit URL
    url = redirect_response
    browser.visit(url)
    
    if browser.is_element_present_by_name('txtPassword', wait_time=0):
      
      browser.fill('USER', etrade_settings.username)
      time.sleep(3)


      browser.find_by_name('txtPassword').click()
      
      time.sleep(3)
      # pprint(browser.html)

      browser.fill('PASSWORD', etrade_settings.userpass)
      # Find and click the 'logon' button
      browser.find_by_name('Logon').click()
      time.sleep(3)
      if browser.is_element_present_by_name('continueButton', wait_time=2):
        browser.find_by_name('continueButton').click()

      browser.find_by_value('Accept').click()
      time.sleep(3)
      # authCode = browser.find_by_xpath("//@type='text'").first.value
      authCode = browser.find_by_tag("input").first.value
      time.sleep(3)


  display.stop()
  
  return authCode
开发者ID:Anhmike,项目名称:etradePythonAPI,代码行数:62,代码来源:etradepy.py

示例12: retrieveYRdata

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def retrieveYRdata(url):
    print "processing yddapRewop ..."

    display = Display(visible=0, size=(1024, 1024))
    display.start()

    # driver = webdriver.Firefox()

    # http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium
    driver = webdriver.Chrome()
    driver.get(url)
    html = driver.page_source
    driver.quit()

    display.stop()

    parser = etree.HTMLParser()
    tree = etree.parse(StringIO(html), parser)

    first = 1

    table_list = list()

    for table_element in tree.getiterator("table"):
        if "id" in table_element.keys() and "class" in table_element.keys() and "style" in table_element.keys():
            if not first:
                table_list.append(table_element)
            first = 0

    for table_element in table_list:
        parse_table_element(table_element)
开发者ID:mastinux,项目名称:tebRotarapmoc,代码行数:33,代码来源:views.py

示例13: main

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def main() :
	display = Display(visible=0, size=(800, 600))
	display.start()
	authurl = "https://firewall.amritanet.edu:8443/auth1.html"
	delay = 3
	print "\n\n[*]  Opening a New Session.."
	driver = webdriver.Firefox()
	driver.get(authurl)

	assert "Sonic" in driver.title

	print "\n\n[*] Enumerating Login Page.."
	user = driver.find_element_by_name("userName")
	passwd = driver.find_element_by_name("pwd")

	print "\n\n[*] Sending Credentials .. "
	user.send_keys("<user_name_here>")
	passwd.send_keys("<password_here>")
	passwd.send_keys(Keys.RETURN)

	driver.get("http://www.msftncsi.com/ncsi.txt")

	print "\n\n[*] Login Done!"
	driver.quit()
	display.stop()
开发者ID:XChikuX,项目名称:hacker-scripts,代码行数:27,代码来源:soniclogin.py

示例14: Collab

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
class Collab(threading.Thread):
    """docstring forCollab"""
    def __init__(self, selector):
        threading.Thread.__init__(self)
        self.__display = Display(visible=0, size=(800, 600))
        self.__display.start()
        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument("--no-sandbox")
        chrome_options.binary_location = CHROME_LOCATION
        self.__driver = webdriver.Chrome("/opt/selenium/chromedriver",
                                         chrome_options=chrome_options,
                                         service_args=["--verbose",
                                                       "--log-path=/home/log"])
        self.__driver.get(URL + DOCID)
        self.content_editor = ""
        self.alive = False
        self.select = None
        while self.select is None:
            self.__driver.implicitly_wait(20)
            self.select = self.__driver.find_element_by_class_name(
                selector)

    def stop(self):
        self.alive = False
        self.__driver.close()
        self.__display.stop()
开发者ID:quentinl-c,项目名称:network_testing-client,代码行数:28,代码来源:webrtc.py

示例15: get_news

# 需要导入模块: from pyvirtualdisplay import Display [as 别名]
# 或者: from pyvirtualdisplay.Display import stop [as 别名]
def get_news():
    if check_wlan():
        from pyvirtualdisplay import Display
        import re

        display = Display(visible=0, size=(800, 600))
        display.start()

        driver = webdriver.Firefox()
        url = "http://www.deutschlandfunk.de/"
        driver.get(url)
        source = driver.find_element_by_xpath('//*[@id="wrapper"]/div/section[2]/div[1]').get_attribute('innerHTML')

        n_articles = source.count('<article')
        print(str(n_articles) + " articles found.")

        lst = re.findall('<h3>(.+)</h3>', source)
        result = lst

        driver.close()

        display.stop()
        return result
    else:
        print("Error: Not connected to the internet")
开发者ID:kamekame,项目名称:alpha,代码行数:27,代码来源:f.py


注:本文中的pyvirtualdisplay.Display.stop方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。