• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python commands.show函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: main

def main():

    login, password = get_credentials()

    # log-in to Django site
    if login and password:
        tw.go(LOGIN_URL)
        tw.formvalue('1', 'username', login)
        tw.formvalue('1', 'password', password)
        tw.submit()

    if isinstance(DATA_URL, basestring):
        urls = [DATA_URL]
    else:
        urls = list(DATA_URL)

    # retrieve URIs
    for url in urls:
        try:
            tw.go(url)
            tw.code('200')
            tw.show()
        except TwillAssertionError:
            code = get_browser().get_code()           
            print (u"Unable to access %(url)s. "
                   u"Received HTTP #%(code)s."
                   % {'url': url, 'code': code})
    tw.reset_browser()
开发者ID:yeleman,项目名称:red_nut,代码行数:28,代码来源:refresh_cache.py


示例3: login

def login(username):
    """Find user for given username and make the browser logged in"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # Set a globabl Twill variable to let Twill scripts now the name
    # of the test, e.g. the directory, as well as community name.
    #global_dict['test_name'] = test_name
    #global_dict['community_name'] = test_name + "-testcase"
    global_dict['cwd'] = os.getcwd()

    hn = global_dict['localhost_url']

    # First logout
    logout()

    # Do a login
    au = global_dict['%s_user' % username]

    # Echo to screen
    dump("Logging into %s as %s" % (hn, au))

    # Continue
    ap = global_dict['%s_password' % username]
    commands.go(hn + '/login.html')
    commands.fv("formLogin", "login", au)
    commands.fv("formLogin", "password", ap)
    commands.submit()

    # Make sure the login succeeded
    commands.show()
    commands.find("My Profile")
开发者ID:Falmarri,项目名称:karl,代码行数:32,代码来源:twillcommands.py


示例4: test_simple_index_case

def test_simple_index_case(root):
    root.join("FooBar-1.0.zip").write("")
    root.join("FooBar-1.1.zip").write("")

    go("/simple/foobar")
    show()
    links = list(showlinks())
    assert len(links) == 2
开发者ID:SAEPython,项目名称:pypiserver4sae,代码行数:8,代码来源:test_app.py


示例5: test_nonroot_simple_packages

def test_nonroot_simple_packages(root):
    root.join("foobar-1.0.zip").write("123")
    for url in ["http://nonroot/priv/packages",
                "http://nonroot/priv/packages/"]:
        go(url)
        show()
        links = list(showlinks())
        assert len(links) == 1
        assert links[0].url == "/priv/packages/foobar-1.0.zip"
开发者ID:SAEPython,项目名称:pypiserver4sae,代码行数:9,代码来源:test_app.py


示例6: test_simple_index_list

def test_simple_index_list(root):
    root.join("foobar-1.0.zip").write("")
    root.join("foobar-1.1.zip").write("")
    root.join("foobarbaz-1.1.zip").write("")
    root.join("foobar.baz-1.1.zip").write("")

    go("/simple/")
    show()
    links = list(showlinks())
    assert len(links) == 3
开发者ID:SAEPython,项目名称:pypiserver4sae,代码行数:10,代码来源:test_app.py


示例7: test_root_count

def test_root_count(root):
    go("/")
    show()
    code(200)
    find("PyPI compatible package index serving 0 packages")
    showlinks()

    root.join("Twisted-11.0.0.tar.bz2").write("")
    reload()
    show()
    find("PyPI compatible package index serving 1 packages")
开发者ID:SAEPython,项目名称:pypiserver4sae,代码行数:11,代码来源:test_app.py


示例8: test_profile_record

def test_profile_record():
    """
    Test availability of user profile
    """
    go(SITE + '/accounts/login/')
    code(200)
    show()
    formvalue(1, 'username', 'root')
    formvalue(1, 'password', '1')
    submit()
    code(200)
开发者ID:fordexa,项目名称:simpletest,代码行数:11,代码来源:tests.py


示例9: test_reset_password

def test_reset_password():
    """
    Test user password reset
    """
    go(SITE + '/accounts/password/reset/')
    code(200)
    show()
    formvalue(1, 'email', '[email protected]')
    submit()
    code(200)
    find('Password reset successful')
    return
开发者ID:fordexa,项目名称:simpletest,代码行数:12,代码来源:tests.py


示例10: test_incorrect_username

def test_incorrect_username():
    """
    Test an incorrect log in to site with invalid username
    """
    go(SITE + '/accounts/login/')
    code(200)
    show()
    formvalue(1, 'username', 'testincorrect')
    formvalue(1, 'password', '1')
    submit()
    code(200)
    find('Please enter a correct username and password.')
    return
开发者ID:fordexa,项目名称:simpletest,代码行数:13,代码来源:tests.py


示例11: test_success_login

def test_success_login():
    """
    Test a success log in to site
    """
    go(SITE + '/accounts/login/')
    code(200)
    show()
    formvalue(1, 'username', 'test')
    formvalue(1, 'password', '1')
    submit()
    code(200)
    find('<h4 align="center">My profile</h4>')
    return
开发者ID:fordexa,项目名称:simpletest,代码行数:13,代码来源:tests.py


示例12: _requestLikes

	def _requestLikes (self, startingLike, startingThumb):
		url = PANDORA_LIKES_URL.substitute(webname = self.webname, likestart = startingLike, thumbstart = startingThumb)
		Browser.go(url)

		likesList = self._songHtmlToList(Browser.show())

		soup = BeautifulSoup(Browser.show())
		nextInfoElement = soup.find('div', {'class': 'show_more tracklike'})

		nextStartingLike = self._attributeNumberValueOrZero(nextInfoElement, 'data-nextlikestartindex')
		nextStartingThumb = self._attributeNumberValueOrZero(nextInfoElement, 'data-nextthumbstartindex')

		return (likesList, nextStartingLike, nextStartingThumb)
开发者ID:jfktrey,项目名称:Pandora-Unchained,代码行数:13,代码来源:PandoraUnchained.py


示例13: test_register

def test_register():
    """
    Test user registration
    """
    go(SITE + '/accounts/register/')
    code(200)
    show()
    formvalue(1, 'username', 'demouser')
    formvalue(1, 'email', '[email protected]')
    formvalue(1, 'password1', '1')
    formvalue(1, 'password2', '1')
    submit()
    code(200)
    find('Confirmation e-mail sent')
    return
开发者ID:fordexa,项目名称:simpletest,代码行数:15,代码来源:tests.py


示例14: test_image_processing_library_error

    def test_image_processing_library_error(self):
        """
        If the image processing library errors while preparing a photo, report a
        helpful message to the user and log the error. The photo is not added
        to the user's profile.
        """
        # Get a copy of the error log.
        string_log = StringIO.StringIO()
        logger = logging.getLogger()
        my_log = logging.StreamHandler(string_log)
        logger.addHandler(my_log)
        logger.setLevel(logging.ERROR)

        self.login_with_twill()
        tc.go(make_twill_url('http://openhatch.org/people/paulproteus/'))
        tc.follow('photo')
        # This is a special image from issue166 that passes Django's image
        # validation tests but causes an exception during zlib decompression.
        tc.formfile('edit_photo', 'photo', photo('static/images/corrupted.png'))
        tc.submit()
        tc.code(200)

        self.assert_("Something went wrong while preparing this" in tc.show())
        p = Person.objects.get(user__username='paulproteus')
        self.assertFalse(p.photo.name)

        # an error message was logged during photo processing.
        self.assert_("zlib.error" in string_log.getvalue())
        logger.removeHandler(my_log)
开发者ID:boblannon,项目名称:oh-mainline,代码行数:29,代码来源:tests.py


示例15: get_job_queue

def get_job_queue():
    """
    fetch list of disease model jobs waiting to run from dismod server
    given in settings.py.
    """
    dismod_server_login()
    twc.go(DISMOD_LIST_JOBS_URL)
    return json.loads(twc.show())
开发者ID:flaxter,项目名称:gbd,代码行数:8,代码来源:disease_json.py


示例16: download_with_login

def download_with_login(url, login_url, login=None,
                              password=None, ext='',
                              username_field='username',
                              password_field='password',
                              form_id=1):
    ''' Download a URI from a website using Django by loging-in first

        1. Logs in using supplied login & password (if provided)
        2. Create a temp file on disk using extension if provided
        3. Write content of URI into file '''

    # log-in to Django site
    if login and password:
        tw.go(login_url)
        tw.formvalue('%s' % form_id, username_field, login)
        tw.formvalue('%s' % form_id, password_field, password)
        tw.submit()

    # retrieve URI
    try:
        tw.go(url)
        tw.code('200')
    except TwillAssertionError:
        code = get_browser().get_code()
        # ensure we don't keep credentials
        tw.reset_browser()
        raise DownloadFailed(u"Unable to download %(url)s. "
                             u"Received HTTP #%(code)s."
                             % {'url': url, 'code': code})
    buff = StringIO.StringIO()
    twill.set_output(buff)
    try:
        tw.show()
    finally:
        twill.set_output(None)
        tw.reset_browser()

    # write file on disk
    suffix = '.%s' % ext if ext else ''
    fileh, filename = tempfile.mkstemp(suffix=suffix)
    os.write(fileh, buff.getvalue())
    os.close(fileh)
    buff.close()

    return filename
开发者ID:radproject,项目名称:formhub,代码行数:45,代码来源:i18ntool.py


示例17: get_resourses

 def get_resourses(self):
     """ Parse resourses """
     commands.go(SERVER + 'dorf1.php')
     html = commands.show()
     soup = BeautifulSoup(html)
     self.resourses['wood'] = int(soup.find('span', {'id': 'l1'}).text)
     self.resourses['clay'] = int(soup.find('span', {'id': 'l2'}).text)
     self.resourses['iron'] = int(soup.find('span', {'id': 'l3'}).text)
     self.resourses['cereal'] = int(soup.find('span', {'id': 'l4'}).text)
开发者ID:alfonsoros88,项目名称:travianbot,代码行数:9,代码来源:travian_bot.py


示例18: get_fields

 def get_fields(self):
     """ Get lvl of production fields """
     commands.go(SERVER + 'dorf1.php')
     html = commands.show()
     soup = BeautifulSoup(html)
     self.fields['wood'] = [int(f.text) for f in soup.findAll('div', {'class': re.compile('.*gid1.*')})]
     self.fields['clay'] = [int(f.text) for f in soup.findAll('div', {'class': re.compile('.*gid2.*')})]
     self.fields['iron'] = [int(f.text) for f in soup.findAll('div', {'class': re.compile('.*gid3.*')})]
     self.fields['cereal'] = [int(f.text) for f in soup.findAll('div', {'class': re.compile('.*gid4.*')})]
开发者ID:alfonsoros88,项目名称:travianbot,代码行数:9,代码来源:travian_bot.py


示例19: getNumberOfLikes

	def getNumberOfLikes (self):
		url = PANDORA_LIKES_COUNT_URL.substitute(webname = self.webname)
		Browser.go(url)

		soup = BeautifulSoup(Browser.show())
		songsDiv = soup.find('div', {'id': 'songs'})
		numberSpan = songsDiv.find('span', {'class': 'section_count'})

		return int(numberSpan.text.strip('()'))
开发者ID:jfktrey,项目名称:Pandora-Unchained,代码行数:9,代码来源:PandoraUnchained.py


示例20: getVoteCredentials

def getVoteCredentials(redditURL):
    t.go(redditURL + "/.compact")
    page = PyQuery(t.show())
    voteHash = page(".link").find(".arrow").eq(0).attr.onclick.split("'")[1]
    storyID = page(".link").attr.class_.split("-")[1]
    modHash = getModHashFromCurrentPage()
    subredditName = redditURL.split("/")[4]

    return (storyID, voteHash, modHash, subredditName)
开发者ID:tylerkahn,项目名称:libreddit,代码行数:9,代码来源:libreddit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python commands.submit函数代码示例发布时间:2022-05-27
下一篇:
Python commands.notfind函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap