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

Python sh.curl函数代码示例

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

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



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

示例1: skeletonize

def skeletonize():
    '''Update Skeleton HTML5-Boilerplate.'''
    print green("Skeletonizing the project directory...")

    # Skeleton
    print blue("Installing skeleton HTML5 Boilerplate.")
    os.chdir(PROJ_DIR)
    sh.git.submodule.update(init=True)

    os.chdir(PROJ_DIR + "/skeleton")
    sh.git.pull("origin", "master")
    sh.rsync("-av", "images", "{0}/{1}/static/".format(PROJ_DIR,APP_NAME))
    sh.rsync("-av", "stylesheets",  "{0}/{1}/static/".format(PROJ_DIR,APP_NAME))
    sh.rsync("-av", "index.html",  "{0}/{1}/templates/base_t.html".format(PROJ_DIR,APP_NAME))
    os.chdir(PROJ_DIR)

    # Patch the base template with templating tags
    print blue("Patching the base template.")
    os.chdir(PROJ_DIR + "/{0}/templates/".format(APP_NAME))
    template_patch = open("base_t.patch".format(APP_NAME))
    sh.patch(strip=0, _in=template_patch)
    template_patch.close()
    os.chdir(PROJ_DIR)

    # Jquery
    print blue("Installing jquery 1.9.0.")
    os.chdir(PROJ_DIR + "/" + APP_NAME + "/static/js")
    sh.curl("http://code.jquery.com/jquery-1.9.0.min.js", O=True)
    os.chdir(PROJ_DIR)
开发者ID:springcoil,项目名称:flask-boilerplate,代码行数:29,代码来源:fabfile.py


示例2: create

def create(version_number):
    heading1("Creating new version based on Fedora " + version_number + "\n")

    # Update git and create new version.
    heading2("Updating master branch.")
    print(git.checkout("master"))
    print(git.pull())  # Bring branch current.

    heading2("Creating new branch")
    print(git.checkout("-b" + version_number))  # Create working branch.

    # Get kickstart files.
    heading2("Creating fedora-kickstarts directory\n")
    mkdir("-p", (base_dir + "/fedora-kickstarts/"))
    cd(base_dir + "/fedora-kickstarts/")

    heading2("Downloading Fedora kickstart files.")
    ks_base = "https://pagure.io/fedora-kickstarts/raw/f" \
              + version_number + "/f"

    for file in ks_files:
        file_path = ks_base + "/fedora-" + file

        print ("Downloading " + file_path)
        curl("-O", file_path)
开发者ID:RobbHendershot,项目名称:tananda-os-builder,代码行数:25,代码来源:tananda_os_builder.py


示例3: prebuild_arch

 def prebuild_arch(self, arch):
     hostpython = sh.Command(self.ctx.hostpython)
     sh.curl("-O",  "https://bootstrap.pypa.io/ez_setup.py")
     dest_dir = join(self.ctx.dist_dir, "root", "python")
     build_env = arch.get_env()
     build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages')
     # shprint(hostpython, "./ez_setup.py", "--to-dir", dest_dir)
     shprint(hostpython, "./ez_setup.py", _env=build_env)
开发者ID:byrot,项目名称:kivy-ios,代码行数:8,代码来源:__init__.py


示例4: setup_vim

def setup_vim():
    autoload = join(HOME, '.vim', 'autoload')
    mkdir_p(autoload)
    sh.curl('-fLo', join(autoload, 'plug.vim'), 'https://raw.github.com/junegunn/vim-plug/master/plug.vim')
    link_home('vimrc')

    print '  Running PlugInstall'
    sh.vim('+PlugInstall', '+qall')
开发者ID:krx,项目名称:dotfiles,代码行数:8,代码来源:install.py


示例5: test_keyword_arguments

def test_keyword_arguments():
    from sh import curl, adduser
    # resolves to "curl http://duckduckgo.com/ -o page.html --silent"
    curl('http://duckduckgo.com/', o='page.html', silent=True)

    # or if you prefer not to use keyword arguments, this does the same thing
    curl('http://duckduckgo.com/', '-o', 'page.html', '--silent')

    # resolves to "adduser amoffat --system --shell=/bin/bash --no-create-home"
    adduser('amoffat', system=True, shell='bin/bash', no_create_home=True)
开发者ID:vhnuuh,项目名称:pyutil,代码行数:10,代码来源:sample.py


示例6: add_pr_to_checkout

def add_pr_to_checkout(repo, pr_id, head_sha1, pr_branch, spec):
    sh.curl(
        '-s', '-k', '-L',
        "https://github.com/crowbar/%s/compare/%s...%s.patch" % (
            repo, pr_branch, head_sha1),
        '-o', 'prtest.patch')
    sh.sed('-i', '-e', 's,Url:.*,%define _default_patch_fuzz 2,',
           '-e', 's,%patch[0-36-9].*,,', spec)
    Command('/usr/lib/build/spec_add_patch')(spec, 'prtest.patch')
    iosc('vc', '-m', "added PR test patch from %s#%s (%s)" % (
        repo, pr_id, head_sha1))
开发者ID:hbcbh1999,项目名称:automation,代码行数:11,代码来源:crowbar-testbuild.py


示例7: swatch

def swatch():
    proj()

    print(". rocking the bootswatch plunder")
    
    themes = json.loads(str(sh.curl("http://api.bootswatch.com")))["themes"]
    for theme in themes:
        print(".. getting %s" % theme["name"])
        open(
            "lib/swatch/bootswatch.%s.min.css" % theme["name"], "w"
        ).write(
            re.sub(
                r'background.*glyphicons[^;]*;',
                "",
                str(sh.curl(theme["css-min"])))
        )
开发者ID:JiangKevin,项目名称:blockd3,代码行数:16,代码来源:fabfile.py


示例8: search_single

def search_single(term):
    UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36" 
    base = "https://www.google.com/search?q="
    query = base + term 
    res = curl(query, A=UA)
    soup = BeautifulSoup(res.stdout)
    return soup
开发者ID:ChenFengAndy,项目名称:icml2015_papers,代码行数:7,代码来源:scraper.py


示例9: fix_bootstrap_py

def fix_bootstrap_py(folder):
    """
    Update boostrap.py to make sure its the latest version.

    This fixes some buildout bootstrapping failures on old sites.
    """
    from sh import curl

    bootstrap_py = os.path.join(folder, "bootstrap.py")

    # http://stackoverflow.com/questions/14817138/zc-buildout-2-0-0-release-somehow-ends-up-breaking-plone-3-3-buildouts/14817272#14817272
    url = "http://downloads.buildout.org/1/bootstrap.py"

    print "Fixing %s to known good version" % bootstrap_py

    curl("-L", "-o", bootstrap_py, url)
开发者ID:miohtama,项目名称:senorita.plonetool,代码行数:16,代码来源:main.py


示例10: send_email

def send_email(user, event, message, **kw):
  if not user in config['email']['user_emails']:
    return

  args = {
    'f': config['email']['from_address'],
    't': config['email']['user_emails'][user],
    'u': kw['subject'] if 'subject' in kw else 'Notification',
  }

  if not 'app' in kw:
    kw['app'] = config['default_app']

  body = HTML('html')
  tr = body.table().tr()
  tr.td(valign='top').img(src=config['icons'][kw['app']], style='float:left; margin: 15px')
  try:
    if 'email_body' in kw:
      tr.td().text(kw['email_body'], escape=False)
    else:
      getattr(notifications, event + '_email')(tr.td(), message, **kw)
  except:
    with tr.td().p(style='margin-top: 15px') as p:
      p.b("Message:")
      p.br()
      p.text(message)

  ip = curl('ifconfig.me').strip()
  if ip != config['ip']:
    ybdst = ssh.bake(config['ip'])
    print "Sent %s email to %s" % (event, user)
    return ybdst.sendemail(_in=str(body), **args)
  else:
    print "Sent %s email to %s" % (event, user)
    return sendemail(_in=str(body), **args)
开发者ID:adharris,项目名称:yb-scripts,代码行数:35,代码来源:notifications.py


示例11: check_upgrade

def check_upgrade():
        server_file = curl(PIFM_HOST + '/client_agent/pifm_agent.py')
        server_sum = awk(
                        md5sum(
                            grep(server_file, '-v', '^PIFM_HOST')
                        ), '{print $1}'
        )

        local_sum = awk(
                        md5sum(
                            grep('-v', '^PIFM_HOST', OUR_SCRIPT)
                        ), '{print $1}'
        )

        if str(server_sum) != str(local_sum):
            logging.info(
                "server: {server}, local: {local}, should update.".format(
                    server=server_sum,
                    local=local_sum
                )
            )
            with open(TMP_SCRIPT, 'w') as f:
                f.write(str(server_file))
            sed('-i',
                "0,/def/ s#http://pi_director#{myhost}#".format(myhost=PIFM_HOST),
                OUR_SCRIPT
                )
            status = python('-m', 'py_compile', TMP_SCRIPT)
            if (status.exit_code == 0):
                shutil.copy(TMP_SCRIPT, OUR_SCRIPT)
                os.chmod(OUR_SCRIPT, 0755)
                sys.exit(0)
开发者ID:artschwagerb,项目名称:pi_director,代码行数:32,代码来源:pifm_agent.py


示例12: get_token

def get_token():
#    curl("-d", "'{\"auth\":{\"passwordCredentials\":{\"username\": \"%(username)s\", \"password\": \"%(password)s\"}}}' -H \"Content-type: application/json\" http://%(ip)s:35357/v2.0/tokens" % data
    result = curl("-d",
		  "'{\"auth\":{\"passwordCredentials\":{\"username\": \"gvonlasz\", \"password\": \"OTg5NmVkZTdkMzEwOThmMDMxZDJmNmY1\"}}}'",
	"-H",
	"\"Content-type: application/json\"",
	"http://149.165.146.50:35357/v2.0/tokens")
    print result
开发者ID:futuregrid,项目名称:cm,代码行数:8,代码来源:a.py


示例13: fullquery

 def fullquery(
     self,
     database,
     dataset,
     data_format="j",
     limit=None,
     rows=None,
     start_date=None,
     end_date=None,
     order="asc",
     column_index=None,
     collapse=None,
     transform=None,
     send=False,
 ):
     database = database.upper() + "/"
     dataset = dataset.upper() + typetable[data_format] + "?"
     # validate start and end date arguments and append '&'
     if validate_date(start_date):
         start_date = "start_date=" + start_date + "&"
     else:
         start_date = ""
     if validate_date(end_date):
         end_date = "end_date=" + end_date + "&"
     else:
         end_date = ""
     # hacky solution to Error('Cannot concatenate str and NoneType objects')
     # just set default args to ''
     # what was u thinkin, musta bn hi or some shit
     column_index = "column_index=" + str(column_index) + "&" if column_index else ""
     limit = "limit=" + str(limit) + "&" if limit else ""
     rows = "rows=" + str(rows) + "&" if rows else ""
     column_index = "column_index=" + str(column_index) + "&" if column_index else ""
     collapse = "collapse=" + collapse + "&" if collapse else ""
     transform = "transformation=" + transform + "&" if transform else ""
     order = "order=" + order + "&"
     api_key = "api_key=" + self.APIKEY + "&"
     qstring = (
         self.BASEURL
         + "datasets/"
         + database
         + dataset
         + api_key
         + limit
         + rows
         + start_date
         + end_date
         + order
         + column_index
         + collapse
         + transform
     )
     if send:
         return sh.curl(qstring)
     else:
         return qstring
开发者ID:Bannanna,项目名称:AVA,代码行数:56,代码来源:quandl.py


示例14: prebuild_arch

 def prebuild_arch(self, arch):
     hostpython = sh.Command(self.ctx.hostpython)
     sh.curl("-O",  "https://bootstrap.pypa.io/ez_setup.py")
     shprint(hostpython, "./ez_setup.py")
     # Extract setuptools egg and remove .pth files. Otherwise subsequent
     # python package installations using setuptools will raise exceptions.
     # Setuptools version 28.3.0
     site_packages_path = join(
         self.ctx.dist_dir, 'hostpython',
         'lib', 'python2.7', 'site-packages')
     os.chdir(site_packages_path)
     with open('setuptools.pth', 'r') as f:
         setuptools_egg_path = f.read().strip('./').strip('\n')
         unzip = sh.Command('unzip')
         shprint(unzip, setuptools_egg_path)
     os.remove(setuptools_egg_path)
     os.remove('setuptools.pth')
     os.remove('easy-install.pth')
     shutil.rmtree('EGG-INFO')
开发者ID:cbenhagen,项目名称:kivy-ios,代码行数:19,代码来源:__init__.py


示例15: send_requests

def send_requests(hostname, throughput, duration, sections_number):
    """

    :param str hostname: destination host or IP
    :param int throughput: number of requests per sec
    :param int duration: in [s]
    :param int sections_number: number of sections
    :return:
    """

    print 'Sending {0} requests per sec for {1} seconds ... '.format(throughput, duration)
    sleep_time = 1 / float(throughput)
    print 'Sleeping {0}[s] between requests.'.format(sleep_time)
    for i in range(0, duration * throughput):
        section_id = random.randint(0, sections_number-1)
        url_path = 'http://{0}/{1}/{2}'.format(hostname, section_id, 'test.html')
        curl(url_path, silent=True)
        print url_path
        time.sleep(sleep_time)
开发者ID:inthefog,项目名称:access_log_monitor,代码行数:19,代码来源:access_log_monitor_test.py


示例16: do_curl

def do_curl(_url, **kw):
  args = {}
  if 'cookie' in kw:
    cookie = kw['cookie']
    del kw['cookie']
    args['b'] = cookie
  data = urlencode(kw)
  if len(kw) > 0:
    args['d'] = data
  return curl(_url, **args)
开发者ID:adharris,项目名称:yb-scripts,代码行数:10,代码来源:helpers.py


示例17: add_reverbrain_repos

def add_reverbrain_repos():
    # there is no docker plugin package in trusty repos, hmm...
    # ok, let's try trusty. hope that docker plugin is integrated into libcocaine-core2
    repos = """\
    deb http://repo.reverbrain.com/trusty/ current/amd64/
    deb http://repo.reverbrain.com/trusty/ current/all/
    """
    with open("/etc/apt/sources.list.d/reverbrain.list", "a") as f:
        f.write(repos)
    sh.apt_key(sh.curl("http://repo.reverbrain.com/REVERBRAIN.GPG"), "add", "-")
    sh.apt_get("-y", "update")
开发者ID:arssher,项目名称:cocaine-docker,代码行数:11,代码来源:install_cocaine.py


示例18: do_review

def do_review(data):
    pr = get_pullreq(data['pull_request']['base']['repo']['name'], data['pull_request']['number'])
    logger_handler.setFormatter(logging.Formatter("%%(asctime)s %s PR#%s %%(message)s" % (pr.base.repo.name, pr.number)))
    name = gerrit_name_for(pr.base.repo.name)
    ensure_repo(name)
    gh_name = pr.base.repo.name
    path = path_for_name(name)
    sh.cd(path)
    sh.git.reset('--hard')
    sh.git.checkout('master')
    if 'tmp' in sh.git.branch():
        sh.git.branch('-D', 'tmp')
    sh.git.checkout(pr.base.sha, '-b', 'tmp')
    logger.info('Attempting to download & apply patch on top of SHA %s' % pr.base.sha)
    sh.git.am(sh.curl(pr.patch_url))
    logger.info('Patch applied successfully')

    # Author of last patch is going to be the author of the commit on Gerrit. Hmpf
    author = sh.git('--no-pager', 'log', '--no-color', '-n', '1', '--format="%an <%ae>"')

    sh.git.checkout('master')

    branch_name = 'github/pr/%s' % pr.number

    is_new = True
    change_id = None

    if branch_name in sh.git.branch():
        is_new = False
        sh.git.checkout(branch_name)
        change_id = get_last_change_id()
        sh.git.checkout("master")
        sh.git.branch('-D', branch_name)
        logger.info('Patchset with Id %s already exists', change_id)
    else:
        is_new = True
        logger.info('Patchset not found, creating new')

    logger.info('Attempting to Squash Changes on top of %s in %s', pr.base.sha, branch_name)
    sh.git.checkout(pr.base.sha, '-b', branch_name)
    sh.git.merge('--squash', 'tmp')
    sh.git.commit('--author', author, '-m', format_commit_msg(pr, change_id=change_id))
    logger.info('Changes squashed successfully')
    if is_new:
        change_id = get_last_change_id()
        logger.info('New Change-Id is %s', change_id)
    logger.info('Attempting to push refs for review')
    sh.git.push('gerrit', 'HEAD:refs/for/master') # FIXME: Push for non master too!
    logger.info('Pushed refs for review')
    sh.git.checkout('master') # Set branch back to master when we're done
    if is_new:
        gh.repos(OWNER, gh_name).issues(pr.number).comments.post(body='Submitted to Gerrit: %s' % gerrit_url_for(change_id))
        logger.info('Left comment on Pull Request')
开发者ID:wikimedia,项目名称:labs-tools-SuchABot,代码行数:53,代码来源:github-to-gerrit.py


示例19: curl

def curl(src, dest):
    """ Installs `src` to path `dest` """
    spinner = Halo(
        text="curl {}".format(dest),
        spinner="dots",
        placement="right"
    )
    spinner.start()
    if os.path.exists(dest):
        spinner.info("{} already exists".format(dest))
        return

    try:
        sh.curl("-fLo", dest, src)
        spinner.succeed()
    except sh.ErrorReturnCode as err:
        err_message = "\n\t" + err.stderr.replace("\n", "\n\t")
        logging.error(
            "Error downloading file `%s`: %s", src, err_message
        )
        spinner.fail()
开发者ID:lemonade512,项目名称:DotFiles,代码行数:21,代码来源:install.py


示例20: send

def send(host, room_id, token, message, message_format, trigger_status,
         trigger_severity, notify=True):

    print(curl(
        URL.format(host=host, room_id=room_id, token=token),
        d=json.dumps({
            'message': message,
            'message_format': message_format,
            'notify': notify,
            'color': color(trigger_status, trigger_severity)
        }),
        H='Content-type: application/json'
    ))
开发者ID:dsociative,项目名称:zabbix_hipchat,代码行数:13,代码来源:notify.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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