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


Python twill.set_output函数代码示例

本文整理汇总了Python中twill.set_output函数的典型用法代码示例。如果您正苦于以下问题:Python set_output函数的具体用法?Python set_output怎么用?Python set_output使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: setAgent

    def setAgent(self, agentAcronym):
       # Decide on the agent that will be used to power the smoke test
        if agentAcronym == "g":
            self.agent = "Ghost"
            try:
                from ghost import Ghost
                self.ghost = Ghost(wait_timeout = 360)
            except ImportError:
                raise NameError("Ghost not installed")

            from using_ghost import login, visit

        else:
            self.agent = "Twill"
            try:
                from twill import get_browser
                from twill import set_output
            except ImportError:
                raise NameError("Twill not installed")

            try:
                import mechanize
            except ImportError:
                raise NameError("Mechanize not installed")

            self.b = get_browser()
            self.b_data = StringIO()
            set_output(self.b_data)

            from using_twill import login, visit

        self.visit = MethodType(visit, self)
        self.login = MethodType(login, self)
开发者ID:arnavsharma93,项目名称:eden,代码行数:33,代码来源:broken_links.py

示例2: __init__

 def __init__(self):
     Web2UnitTest.__init__(self)
     self.b = get_browser()
     self.b_data = StringIO()
     set_output(self.b_data)
     self.clearRecord()
     # This string must exist in the URL for it to be followed
     # Useful to avoid going to linked sites
     self.homeURL = self.url
     # Link used to identify a URL to a ticket
     self.url_ticket = "/admin/default/ticket/"
     # Tuple of strings that if in the URL will be ignored
     # Useful to avoid dynamic URLs that trigger the same functionality
     self.include_ignore = ("_language=",
                            "logout",
                            "appadmin",
                            "admin",
                            "delete",
                           )
     # tuple of strings that should be removed from the URL before storing
     # Typically this will be some variables passed in via the URL
     self.strip_url = ("?_next=",
                       )
     self.reportOnly = False
     self.maxDepth = 16 # sanity check
     self.setThreshold(10)
     self.setUser("[email protected]/eden")
     self.total_visited = 0
     self.broken_links_count = 0
开发者ID:AyudaEcuador,项目名称:eden,代码行数:29,代码来源:broken_links.py

示例3: _grab_remote_html

def _grab_remote_html(url):

  global base_url, data_output, screen_output

  twill.commands.clear_cookies()
  twill.commands.agent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/29.0.1547.65 Safari/537.36')
  twill.commands.go(base_url + url)

  # Ensure we get a 200 http status code back
  try:
    code_response = twill.commands.code(200)
  except:
    code_response = ""

  # Step into the html and extract the links
  if code_response is None:

    # Reset buffer
    data_output.seek(0)
    data_output.truncate(0)

    # Change sys output to capture output in a variable
    sys.stdout = data_output
    twill.set_output(data_output)

    # Grab the HTML data which will be stored in data_reponse
    twill.commands.show()

    # Change the sys output back to the screen, now we have captured the data
    sys.stdout = screen_output
    twill.set_output(screen_output)

  return data_output
开发者ID:ayupdigital,项目名称:google-cache-scraper,代码行数:33,代码来源:cache_scraper.py

示例4: __init__

    def __init__(self):
        Web2UnitTest.__init__(self)
        self.b = get_browser()
        self.b_data = StringIO()
        set_output(self.b_data)

        # list of links that return a http_code other than 200
        # with the key being the URL and the value the http code
        self.brokenLinks = dict()
        # List of links visited (key) with the depth
        self.urlList = dict()
        # List of urls for each model
        self.model_url = dict()
        # This string must exist in the URL for it to be followed
        # Useful to avoid going to linked sites
        self.homeURL = self.url
        # Tuple of strings that if in the URL will be ignored
        # Useful to avoid dynamic URLs that trigger the same functionality 
        self.include_ignore = ("_language=",
                               "/admin/default/",
                              )
        # tuple of strings that should be removed from the URL before storing
        # Typically this will be some variables passed in via the URL 
        self.strip_url = ("?_next=",
                          )
        self.maxDepth = 2 # sanity check
开发者ID:msbongabong,项目名称:eden,代码行数:26,代码来源:broken_links.py

示例5: ssid_test

def ssid_test(ssid, session_mode):

    # Silence output from Twill commands
    f = open(os.devnull,"w")
    twill.set_output(f)

    # Generate File names for diff
    file_name = ssid + '.html'
    generated_html_path = 'output/ssid/' + file_name 
    expected_html_path = 'expected/ssidForm/' + file_name

    # Start with a fresh page every time
    go(url)

    print '\n**Testing SSID of ' + ssid + '**'

    code(200)
    # Fill the HTML forms with test values and submit
    fv("1","ssid",ssid)
    fv("1","session_mode",session_mode)

    submit('0')
    save_html(generated_html_path)

    # Diff with HTML page we know should 'come back'
    command = 'diff {0} {1}'.format(generated_html_path, expected_html_path)
    result = subprocess.call(command.split(), shell=False)

    if result is not 0:
        print 'Test failed'
    else:
        print 'Test Passed'
开发者ID:qwifi,项目名称:qwifi-ui,代码行数:32,代码来源:accesspointtest.py

示例6: timeout_test

def timeout_test(timeout, time_unit):

    # Silence output from Twill commands
    f = open(os.devnull,"w")
    twill.set_output(f)

    # Generate File names for diff
    # e.x. output/10seconds.html, expected/sessionsForm/10seconds.html
    file_name = `timeout` + time_unit + '.html'
    generated_html_path = 'output/timeout/' + file_name 
    expected_html_path = 'expected/sessionsForm/' + file_name

    # Start with a fresh page every time
    go(url)

    print '\n**Testing timeout of ' + `timeout` + ' ' + time_unit + '**'

    code(200)
    # Fill the HTML forms with test values and submit
    fv("1","timeout",`timeout`)
    fv("1","timeUnit",time_unit)
    submit('0')
    save_html(generated_html_path)

    # Diff with HTML page we know should 'come back'
    command = 'diff {0} {1}'.format(generated_html_path, expected_html_path)
    result = subprocess.call(command.split(), shell=False)

    if result is not 0:
        print 'Test failed'
    else:
        print 'Test Passed'
开发者ID:qwifi,项目名称:qwifi-ui,代码行数:32,代码来源:timeouttest.py

示例7: tearDown

 def tearDown(self):
     import twill
     import twill.commands
     twill.commands.reset_browser()
     twill.remove_wsgi_intercept('localhost', 6543)
     twill.set_output(None)
     testing.tearDown()
开发者ID:markramm,项目名称:pyramid,代码行数:7,代码来源:test_integration.py

示例8: setUp

    def setUp(self):
        '''Create the app'''
        test_path =  os.path.abspath(os.path.dirname(__file__))
        testpath_command = "setglobal test_path " + test_path
        twill.execute_string(testpath_command)

        fixtures = os.path.join(test_path, 'fixtures')
        for to_delete in [fname for fname in os.listdir(fixtures)
                          if fname.startswith('Data.fs') or fname in ['blobs']]:
            _rm(os.path.join(fixtures, to_delete))
        os.mkdir(os.path.join(fixtures, 'blobs'))
        wsgi_app = get_app(os.path.join(test_path, 'fixtures', 'karl.ini'),
                           'main')

        def build_app():
            return wsgi_app

        twill.add_wsgi_intercept('localhost', 6543, build_app)
        # XXX How do we suppress the annoying "AT LINE: " output?
        twill.set_output(open('/dev/null', 'wb'))
        twill.execute_string("extend_with karl.twillcommands")

        # mostly the same as karl3.conf without extending with flunc
        # and few other adjustments.

        twill.execute_string("runfile '" +
                             os.path.abspath(os.path.dirname(__file__)) +
                             "/test_twill_wsgi_karl3.conf'")
开发者ID:Falmarri,项目名称:karl,代码行数:28,代码来源:test_twill_wsgi.py

示例9: add_class

 def add_class(self, unique_number):
     class_url = self.url + '/' + unique_number
     tc.go(class_url)
     html = StringIO.StringIO()
     twill.set_output(html)
     tc.show()
     soup = BeautifulSoup(html.getvalue())
     table = soup.find('table')
     for row in table.findAll('tr')[1:]:
         columns = row.findAll('td')
         unique = columns[0].string
         days = [d.text for d in columns[1].findAll('span')]
         hour = [d.text for d in columns[2].findAll('span')]
         room = [d.text for d in columns[3].findAll('span')]
         instructor = columns[4].span.text
         new_course = Course(unique, days, hour, room, instructor)
         if self._check_planner_to_add(new_course):
             self.course_set.add(new_course)
             days_to_add = new_course.parse_days()
             hours_to_add = new_course.parse_hours()
             for d in range(len(days_to_add)):
                 for h in range(hours_to_add[d][0], hours_to_add[d][1]):
                     for day in days_to_add[d]:
                         self.grid[h][day] = new_course
             print("Course successfully added.")
开发者ID:jmpo1618,项目名称:UTSchedulePlanner,代码行数:25,代码来源:Planner.py

示例10: __init__

    def __init__(self):
        self.twill_browser = twill.get_browser()

        if not settings.get('verbose', True):
            twill.set_output(open(os.devnull, 'w'))
            #twill.browser.OUT = open(os.devnull, 'w')

        # Handle HTTP authentication
        if settings.get('http_auth_username', None) and settings.get('http_auth_password', None):
            base64string = base64.encodestring('%s:%s' % (settings['http_auth_username'], settings['http_auth_password'])).replace('\n', '')
            twill.commands.add_auth("wiki", settings['mediawiki_url'], settings['http_auth_username'], settings['http_auth_password'])
            #self.twill_browser._session.headers.update([("Authorization", "Basic %s" % base64string)])
            twill.commands.add_extra_header("Authorization", "Basic %s" % base64string)

        # Handle Mediawiki authentication
        if settings.get('mediawiki_username', None) and settings.get('mediawiki_password', None):
            login_url = urlparse.urljoin(settings['mediawiki_url'], '/index.php?title=Special:UserLogin')
            self.openurl(login_url)

            self._set_form_value('userlogin', 'wpName', settings.get('mediawiki_username'))
            self._set_form_value('userlogin', 'wpPassword', settings.get('mediawiki_password'))

            self.twill_browser.submit()

        self.openurl(settings['mediawiki_url'])
开发者ID:sniku,项目名称:mediawiki_client,代码行数:25,代码来源:wiki_client.py

示例11: reset_output

def reset_output():
    """
    >> reset_output

    Reset twill output to go to the screen.
    """
    import twill
    twill.set_output(None)
开发者ID:alexandre,项目名称:twill,代码行数:8,代码来源:commands.py

示例12: __enter__

 def __enter__(self):
     twill.set_output(StringIO.StringIO())
     twill.commands.clear_cookies()
     twill.add_wsgi_intercept(self.host, 
                              self.port, 
                              lambda: self.app)
 
     return self
开发者ID:gperetin,项目名称:flask-testing,代码行数:8,代码来源:testing.py

示例13: redirect_output

def redirect_output(filename):
    """
    >> redirect_output <filename>

    Append all twill output to the given file.
    """
    import twill
    fp = open(filename, 'a')
    twill.set_output(fp)
开发者ID:alexandre,项目名称:twill,代码行数:9,代码来源:commands.py

示例14: _pre_setup

 def _pre_setup(self):
     super(TwillTestCase, self)._pre_setup()
     twill.set_output(StringIO.StringIO())
     twill.commands.clear_cookies()
     twill.add_wsgi_intercept(self.twill_host, 
                              self.twill_port, 
                              lambda: self.app)
 
     self.browser = twill.get_browser()
开发者ID:gperetin,项目名称:flask-testing,代码行数:9,代码来源:testing.py

示例15: __init__

    def __init__(self):
        self.username = USERNAME
        self.password = PASSWORD
        self.resourses = defaultdict(int)
        self.fields = defaultdict(list)
        self.farms = []

        # suppress twill output
        f = open(os.devnull, "w")
        set_output(f)
开发者ID:alfonsoros88,项目名称:travianbot,代码行数:10,代码来源:travian_bot.py


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