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

Python namespaces.get_twill_glocals函数代码示例

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

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



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

示例1: set_random_word

def set_random_word(varname):
    """Create a random word based by adding an int to varname """

    global_dict, local_dict = namespaces.get_twill_glocals()

    randint = str(random.randint(100000, 999999))
    global_dict[varname] = varname + randint
开发者ID:Falmarri,项目名称:karl,代码行数:7,代码来源:twillcommands.py


示例2: get_args

def get_args(require=0):
    """
    >> get_args [<require>]

    Load the command line arguments after the last '--' into $arg1...$argN,
    optionally requiring at least 'require' such arguments.
    """
    from twill import commands, namespaces, shell, errors

    global_dict, local_dict = namespaces.get_twill_glocals()

    require = int(require)

    if len(shell.twillargs) < require:
        from twill.errors import TwillAssertionError
        raise TwillAssertionError("too few arguments; %d rather than %d" % \
                                    (len(shell.twillargs), require,))

    if shell.twillargs:
        for i, arg in enumerate(shell.twillargs):
            global_dict["arg%d" % (i + 1,)] = arg

        print>>commands.OUT, "get_args: loaded %d args as $arg1..$arg%d." % \
                             (i + 1, i + 1)
    else:
        print>>commands.OUT, "no arguments to parse!"
开发者ID:marcosptf,项目名称:fedora,代码行数:26,代码来源:argparse.py


示例3: catalog_find

def catalog_find(searchterm, urlfrag, notfind=False):
    """Just like Twill find, but issues a searchpage-search search"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # This will navigate us away from the place the Twill script is
    # sitting.  Thus, stash away to the current URL, then navigate
    # back to that URL after searching.
    br = get_browser()
    start_url = br.get_url()

    esc_searchterm = urllib.quote(searchterm)
    url = "/searchresults.html?body=" + esc_searchterm
    commands.go(url)

    # Now do the test.  With the fragment of the URL that was
    # provided, we can do a double-check, to make sure the
    # searchresults provide that.
    if notfind:
        commands.notfind(urlfrag)
    else:
        commands.find(urlfrag)

    # Finally, send them back to the original URL.
    commands.go(start_url)
开发者ID:Falmarri,项目名称:karl,代码行数:25,代码来源:twillcommands.py


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


示例5: make_intranets

def make_intranets(intranets_name):
    """ Make the offices root hierarchy, deleting if it exists"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    global_dict['intranets_name'] = intranets_name

    # Check to see if we have that community, if so, delete it.
    commands.go('/' + intranets_name)
    br = get_browser()
    status = br.get_code()
    if status != 404:
        # The community shouldn't exist, and so we should get 404
        # looking for it.  If no 404, then it exists and we should
        # delete it.
        url = "/%s/delete.html?confirm=1" % intranets_name
        commands.go(url)

    # Now, make the community and make sure it exists
    commands.go("/add_community.html")
    commands.fv("save", "title", intranets_name)
    desc = "Test intranets root created for Twill test case named '%s'"
    commands.fv("save", "description", desc % test_name)
    commands.submit()
    commands.find("Add Existing")
开发者ID:Falmarri,项目名称:karl,代码行数:25,代码来源:twillcommands.py


示例6: _run_xpath

def _run_xpath(xpath):
    _, twill_locals = get_twill_glocals()
    browser = get_browser()
    html = browser.get_html()
    tree = lxml.html.document_fromstring(html)

    try:
        results = tree.xpath(xpath)
    except XPathEvalError:
        err_msg = "Invalid xpath expression: '%s'" % xpath
        log_error(err_msg)
        raise TwillException(err_msg)

    # XXX we aggregate all the values together and warn when there is more than
    # one result
    if results:
        if len(results) > 1:
            log_warn("xpath '%s' found multiple results: using all of them" % xpath)
        result = "\n".join(lxml.html.tostring(r) for r in results)
    else:
        log_error("xpath '%s' found no results")
        result = ""
    # in case we want to cache it at some point
    twill_locals["__xpath_result__"] = result
    twill_locals["__xpath_expr__"] = xpath
    return result
开发者ID:socialplanning,项目名称:flunc,代码行数:26,代码来源:xpath.py


示例7: do_cleanup_for

def do_cleanup_for(name):
    if has_cleanup_handler(name) and not options.no_cleanup_mode: 
        log_info("running cleanup handler for %s" % name)
        try:
            suite_data = file(current_namespace[-1].cleanup[name]).read()
            calls = parse_suite(suite_data)
            for script,args,line in calls:
                try:
                    if current_namespace[-1].suites.get(script):
                        log_warn("Cannot call sub-suite %s during cleanup at %s(%d)" % (script,name,line))
                    else:
                        log_info("running cleanup: %s" % name)
                        script_data = read_test(script)
                        try:
                            parameters = make_dict_from_call(args,get_twill_glocals()[0])
                        except (ValueError, TypeError, SyntaxError), e:
                            e.args = ("\"%s%s\": Only positional argument passing is supported in suites." % \
                                          (name, args), ) + e.args[1:]
                            raise e
                        script_data = make_twill_local_defs(parameters) + script_data 
                        twill.execute_string(script_data, no_reset=1)
                except Exception, e:
                    maybe_print_stack() 
                    log_warn("Cleanup call to %s failed at %s(%d)" 
                         % (script + args, name + CLEANUP, line))
        except IOError,e:
            maybe_print_stack()
            log_warn("Unable to read cleanup handler for %s" % name)
        except Exception,e:
            maybe_print_stack()
            log_warn("Exception during cleanup handler for %s" % name)
开发者ID:SMFOSS,项目名称:flunc,代码行数:31,代码来源:flunc.py


示例8: getmatch

def getmatch(where, what):
     """
     >> getmatch into_var expression

     Evaluates an expression against __match__ and puts it into 'into_var'.
     """
     global_dict, local_dict = get_twill_glocals()
     match = local_dict['__match__']
     local_dict[where] = _do_eval(match, what)
开发者ID:marcosptf,项目名称:fedora,代码行数:9,代码来源:__init__.py


示例9: post_file

def post_file(form, field, file):
    globals, locals = get_twill_glocals()

    test_path = globals.get("test_path")
    file = os.path.join(test_path, file)
    file = open(file)
    body = file.read()
    file.close()
    fv(form, field, body)
开发者ID:socialplanning,项目名称:flunc,代码行数:9,代码来源:zope_run_cat_queue.py


示例10: export_file_contains

def export_file_contains(filename, content):
    globals, locals = get_twill_glocals()
    z, zipname = globals["__project_export__"]
    if filename not in z.namelist():
        raise TwillAssertionError("file %s not found in project export zipfile" % filename)
    log_warn("inspecting contents of file '%s' in project export zipfile '%s' " % (filename, zipname))
    body = z.read(filename)
    if content not in body:
        raise TwillAssertionError("text '%s' not found in contents of file '%s': %s" % (content, filename, body))
开发者ID:socialplanning,项目名称:flunc,代码行数:9,代码来源:zope_run_cat_queue.py


示例11: download_project_export

def download_project_export():
    url = get_browser().get_url()
    assert url.endswith(".zip")
    zipcontents = get_browser().get_html()
    output = StringIO()
    output.write(zipcontents)
    z = zipfile.ZipFile(output, "r")
    name = url.split("/")[-1]
    globals, locals = get_twill_glocals()
    globals["__project_export__"] = (z, name)
开发者ID:socialplanning,项目名称:flunc,代码行数:10,代码来源:zope_run_cat_queue.py


示例12: inspect

def inspect(filename):
    globals, locals = get_twill_glocals()
    z, zipname = globals["__project_export__"]
    if filename not in z.namelist():
        raise TwillAssertionError("file %s not found in project export zipfile" % filename)
    log_warn("inspecting contents of file '%s' in project export zipfile '%s' " % (filename, zipname))
    body = z.read(filename)
    import pdb

    pdb.set_trace()
开发者ID:socialplanning,项目名称:flunc,代码行数:10,代码来源:zope_run_cat_queue.py


示例13: host_alias

def host_alias(old_host, new_host):

    old_host = strip_scheme(old_host)
    new_host = strip_scheme(new_host)
    
    twill_globals, _locals = get_twill_glocals()
    old_host_subst = _substitute_vars(old_host, twill_globals)
    new_host_subst = _substitute_vars(new_host, twill_globals)

    hostname_redirect_mapping[old_host_subst] = new_host_subst
开发者ID:SMFOSS,项目名称:flunc,代码行数:10,代码来源:redirect_host.py


示例14: popmatch

def popmatch(which):
     """
     >> popmatch index

     Pops __matchlist__[i] into __match__.
     """
     global_dict, local_dict = get_twill_glocals()
     
     matchlist = local_dict['__matchlist__']
     match = matchlist.pop(int(which))
     local_dict['__match__'] = match
开发者ID:marcosptf,项目名称:fedora,代码行数:11,代码来源:__init__.py


示例15: logout

def logout():
    """Visit the logout screen"""

    global_dict, local_dict = namespaces.get_twill_glocals()

    # Visit the logout URL
    hn = global_dict['localhost_url']
    commands.go(hn + '/logout')

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


示例16: login

def login(username):
   "login to a plone site"
   global parser
   go("/login_form")
   global_dict, local_dict = get_twill_glocals()
   domain = urlparse(local_dict['__url__']).netloc
   global_dict["domain"] = domain
   global_dict["root"] = parser.get(domain, "zoperoot")
   formvalue(2,"__ac_name", username)
   formvalue(2,"__ac_password", parser.get(domain, username))
   submit()
开发者ID:petri,项目名称:pill,代码行数:11,代码来源:pill.py


示例17: split

def split(what):
     """
     >> split <regexp>

     Sets __matchlist__ to re.split(regexp, page).
     """
     page = browser.get_html()

     m = re.split(what, page)

     global_dict, local_dict = get_twill_glocals()
     local_dict['__matchlist__'] = m
开发者ID:marcosptf,项目名称:fedora,代码行数:12,代码来源:__init__.py


示例18: showvar

def showvar(which):
     """
     >> showvar var

     Shows the value of the variable 'var'.
     """
     global_dict, local_dict = get_twill_glocals()
     
     d = global_dict.copy()
     d.update(local_dict)
     
     print d.get(str(which))
开发者ID:marcosptf,项目名称:fedora,代码行数:12,代码来源:__init__.py


示例19: send_mail_string

def send_mail_string(mailStr, base_url=None):
    if base_url is None:
        tglobals, tlocals = get_twill_glocals()
        base_url = tglobals['base_url']

    receiverURL = "%s/send_listen_mail" % base_url.rstrip("/")

    tglobals, tlocals = get_twill_glocals()
    ctx = tglobals.copy()
    ctx.update(tlocals)
    mailStr = substitute_vars(mailStr, ctx)

    mail = email.message_from_string(mailStr)
    body = mail.get_payload()
    sender = mail['From']
    recipient = mail['To']
    subject = mail['Subject']
    log_warn("sending email: Subject: '%s'; From: '%s'; To: '%s'" % (
            subject, sender, recipient))

    send(receiverURL, mailStr)
开发者ID:socialplanning,项目名称:flunc,代码行数:21,代码来源:mail.py


示例20: send_mail

def send_mail(dir, file, base_url):
    if not os.path.isabs(dir):
        tglobals, tlocals = get_twill_glocals()
        test_path = tglobals['test_path']
        dir = os.path.join(test_path, dir)

    file = os.path.join(dir, file)
    fp = open(file)
    mailStr = fp.read()
    fp.close()

    send_mail_string(mailStr, base_url)
开发者ID:socialplanning,项目名称:flunc,代码行数:12,代码来源:mail.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python twindb_backup.LOG类代码示例发布时间:2022-05-27
下一篇:
Python commands.submit函数代码示例发布时间: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