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


Python util.load_config函数代码示例

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


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

示例1: main

def main():
    if len(sys.argv) < 2:
        usage_and_exit()
    #print("top_dir: '%s'" % get_top_dir())
    ensure_7z_exists()
    conf = util.load_config()
    cert_pwd = conf.GetCertPwdMustExist()
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")

    ver = sys.argv[1]
    #print("ver: '%s'" % ver)
    svn_url = "https://sumatrapdf.googlecode.com/svn/tags/%srel" % ver
    src_dir_name = "SumatraPDF-%s-src" % ver
    archive_name = src_dir_name + ".7z"
    s3_path = "sumatrapdf/rel/" + archive_name
    print("svn_url: '%s'\ndir_name: '%s'\narchive_name: %s\ns3_path: %s" % (svn_url, src_dir_name, archive_name, s3_path))
    s3.verify_doesnt_exist(s3_path)

    os.chdir(get_top_dir())
    util.run_cmd_throw("svn", "export", svn_url, src_dir_name)
    util.run_cmd_throw("7z", "a", "-r", archive_name, src_dir_name)
    s3.upload_file_public(archive_name, s3_path)
    shutil.rmtree(src_dir_name)
    os.remove(archive_name)
开发者ID:tin-pot,项目名称:sumatrapdf,代码行数:25,代码来源:upload_sources.py

示例2: main

def main():
    url_update = "http://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-update.txt"
    url_latest = "http://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-latest.txt"

    conf = load_config()
    assert conf.aws_access != "" and conf.aws_secret != ""
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")

    v1 = get_latest_version(url_latest)
    (v2, ver) = get_update_versions(url_update)
    validate_ver(ver)
    assert not v2 or v1 == v2, "sumpdf-update.txt and sumpdf-latest.txt don't agree on Stable version, run build.py -release first"
    verify_version_not_lower(ver, v1, v2)
    sys.stdout.write("Going to update auto-update version to %s. Are you sure? [y/N] " % ver)
    sys.stdout.flush()
    ch = getch()
    print()
    if ch not in ['y', 'Y']:
        print("Didn't update because you didn't press 'y'")
        sys.exit(1)

    # remove the Stable version from sumpdf-update.txt
    s = "[SumatraPDF]\nLatest %s\n" % ver
    s3.upload_data_public(s, "sumatrapdf/sumpdf-update.txt")
    # keep updating the legacy file for now
    s = "%s\n" % ver
    s3.upload_data_public(s, "sumatrapdf/sumpdf-latest.txt")
    v1 = get_latest_version(url_latest)
    (v2, v3) = get_update_versions(url_update)
    if v1 != ver or v2 != None or v3 != ver:
        print("Upload failed because v1 or v3 != ver ('%s' or '%s' != '%s'" % (v1, v3, ver))
        sys.exit(1)
    print("Successfully update auto-update version to '%s'" % ver)
开发者ID:AnthonyLu-Ista,项目名称:sumatrapdf,代码行数:34,代码来源:update_auto_update_ver.py

示例3: fix

def fix():
	verify_started_in_right_directory()
	conf = load_config()
	s3.set_secrets(conf.aws_access, conf.aws_secret)
	s3.set_bucket("kjkpub")

	d = get_stats_cache_dir()
	files = os.listdir(d)
	all_vers = [stats_txt_name_to_svn_no(f) for f in files]
	all_vers_s3 = get_s3_vers()

	get_s3_files()
	for ver in all_vers_s3:
		if not valid_s3_ver(ver):
			fix_from_ver(ver, all_vers, all_vers_s3)

	prev_ver = all_vers[0]
	to_check = all_vers[1:-1]
	for ver in to_check:
		if ver != prev_ver + 1:
			missing_ver = prev_ver + 1
			print("missing ver %d" % missing_ver)
			fix_from_ver(missing_ver, all_vers, all_vers_s3)
			return
		prev_ver = ver
	print("All are ok!")
开发者ID:sparkhom,项目名称:sumatrapdf,代码行数:26,代码来源:buildbot-fix.py

示例4: _init_user_db

 def _init_user_db(self, filename=USER_DB_FILE):
     raw_user_list = load_config(filename)['users']
     for raw_user in raw_user_list:
         username, password, credit = raw_user
         self._add_user(
             dict(username=username,
                 password=password),
             credit)
开发者ID:abesto,项目名称:practical-microservices,代码行数:8,代码来源:userstore.py

示例5: email_msg

def email_msg(msg):
    c = load_config()
    if not c.HasNotifierEmail():
        print("email_build_failed() not ran because not c.HasNotifierEmail()")
        return
    sender, senderpwd = c.GetNotifierEmailAndPwdMustExist()
    subject = "SumatraPDF buildbot failed"
    util.sendmail(sender, senderpwd, ["[email protected]"], subject, msg)
开发者ID:BanalityOfSeeking,项目名称:sumatrapdf,代码行数:8,代码来源:buildbot.py

示例6: main

def main(models, source_file, nbest_file, saveto, b=80,
         normalize=False, verbose=False, alignweights=False):

    # load model model_options
    options = []
    for model in models:
        options.append(load_config(model))

        fill_options(options[-1])

    rescore_model(source_file, nbest_file, saveto, models, options, b, normalize, verbose, alignweights)
开发者ID:andre-martins,项目名称:nematus,代码行数:11,代码来源:rescore.py

示例7: main

def main():
    if len(sys.argv) < 2:
        usage_and_exit()
    #print("top_dir: '%s'" % get_top_dir())
    ensure_7z_exists()
    conf = util.load_config()
    assert conf.aws_access is not None, "conf.py is missing"
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")

    ver = sys.argv[1]
    #print("ver: '%s'" % ver)
    upload(ver)
开发者ID:kepazon,项目名称:my_sumatrapdf,代码行数:13,代码来源:upload_sources.py

示例8: email_build_failed

def email_build_failed(ver):
	s3_url_start = "http://kjkpub.s3.amazonaws.com/sumatrapdf/buildbot/"
	c = load_config()
	if not c.HasNotifierEmail():
		return
	sender, senderpwd = c.GetNotifierEmailAndPwdMustExist()
	subject = "SumatraPDF build %s failed" % str(ver)
	checkin_url = "https://code.google.com/p/sumatrapdf/source/detail?r=%s" + str(ver)
	body = "Checkin: %s\n\n" % checkin_url
	build_log_url = s3_url_start + str(ver) + "/rel_build_log.txt"
	body += "Build log: %s\n\n" % build_log_url
	buildbot_index_url = s3_url_start + "index.html"
	body += "Buildbot: %s\n\n" % buildbot_index_url
	util.sendmail(sender, senderpwd, g_email_to, subject, body)
开发者ID:Jshauk,项目名称:sumatrapdf,代码行数:14,代码来源:buildbot.py

示例9: main

def main():
	verify_started_in_right_directory()
	# to avoid problems, we build a separate source tree, just for the buildbot
	src_path = os.path.join("..", "sumatrapdf_buildbot")
	verify_path_exists(src_path)
	conf = load_config()
	s3.set_secrets(conf.aws_access, conf.aws_secret)
	s3.set_bucket("kjkpub")
	os.chdir(src_path)

	#build_version("6698", skip_release=True)
	#build_index_html()
	#build_sizes_json()
	#build_curr(force=True)
	buildbot_loop()
开发者ID:aarjones55,项目名称:sumatrapdf,代码行数:15,代码来源:buildbot.py

示例10: email_tests_failed

def email_tests_failed(ver, err):
    s3_url_start = "http://kjkpub.s3.amazonaws.com/sumatrapdf/buildbot/"
    c = load_config()
    if not c.HasNotifierEmail():
        print("email_tests_failed() not ran because not c.HasNotifierEmail()")
        return
    sender, senderpwd = c.GetNotifierEmailAndPwdMustExist()
    subject = "SumatraPDF tests failed for build %s" % str(ver)
    checkin_url = "https://code.google.com/p/sumatrapdf/source/detail?r=%s" % str(ver)
    body = "Checkin: %s\n\n" % checkin_url
    log_url = s3_url_start + str(ver) + "/tests_error.txt"
    body += "Build log: %s\n\n" % log_url
    buildbot_index_url = s3_url_start + "index.html"
    body += "Buildbot: %s\n\n" % buildbot_index_url
    body += "Error: %s\n\n" % err
    util.sendmail(sender, senderpwd, g_email_to, subject, body)
开发者ID:professosaurus,项目名称:sumatrapdf,代码行数:16,代码来源:buildbot.py

示例11: _load

    def _load(self):
        if not self.check_sanity():
            return

        if(not os.path.exists(AUTH_DIR)): os.mkdir(AUTH_DIR)

        # load config
        self.config    = util.load_config(self.path_conf)
        self.namespace = self.config.get("core", "namespace")
        self.clientid  = self.config.get("core", "clientid")

        # load services from config
        self.srvmap = {}
        for tok in self.config.get("backend", "services").split(","):
            srv = services.factory(tok)
            self.srvmap[srv.sid()] = srv

        self.nreplicas = int(self.config.get("backend", "nreplicas"))
            
        nthreads = self.options.nthreads if self.options is not None else 2
        self.scheduler = Scheduler(self.services, (nthreads+1)*len(self.srvmap))

        # load translator pipe
        if self.is_encypted():
            self.translators.append(translators.TrEncrypt(self))

        # TODO. for integrity option
        # if self.is_signed():
        #     self.translators.append(TrSigned(self))

        beg = time.time()
        if(os.path.exists(self.get_path("mapping.pcl"))):
            with open(self.get_path("mapping.pcl")) as f:
                self.mapping = pickle.load(f)
        else:
            mapconfig = []
            for srv in self.services:
                mapconfig.append((srv.sid(), srv.info_storage()/GB))
            hspacesum = sum(map(lambda x:x[1], mapconfig))
            hspace = max(hspacesum+1, 1024)
            self.mapping = DetMap2(mapconfig, hspace=hspace, replica=self.nreplicas)
            self.mapping.pack()
            with open(self.get_path("mapping.pcl"), "w") as f:
                pickle.dump(self.mapping, f)
        end = time.time()
        dbg.time("mapping init %s" % (end-beg))
        dbg.dbg("head: %s", self.get_head_name())
开发者ID:UWNetworksLab,项目名称:metasync,代码行数:47,代码来源:metasyncAPI.py

示例12: main

def main():
    cert_path()  # early check and ensures value is memoized
    verify_efi_present()
    verify_started_in_right_directory()
    # to avoid problems, we build a separate source tree, just for the buildbot
    src_path = os.path.join("..", "sumatrapdf_buildbot")
    verify_path_exists(src_path)
    conf = load_config()
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")
    os.chdir(src_path)

    # test_email_tests_failed()
    #build_version("8190", skip_release=True)
    # test_build_html_index()
    # build_sizes_json()
    # build_curr(force=True)
    buildbot_loop()
开发者ID:professosaurus,项目名称:sumatrapdf,代码行数:18,代码来源:buildbot.py

示例13: uploadStringsIfChanged

def uploadStringsIfChanged(skip_svn_check=False):
    # needs to have upload secret to protect apptranslator.org server from
    # abuse
    config = util.load_config()
    uploadsecret = config.trans_ul_secret
    if None is uploadsecret:
        print("Skipping string upload because don't have upload secret")
        return

    if not skip_svn_check:
        # Note: this check might be confusing due to how svn work
        # Unforunately, if you have local latest revision 5 and do a checkin to create
        # revision 6, svn info says that locally you're still on revision 5, even though
        # the code is actually as revision 6.
        # You need to do "svn update" to update local version number
        # Unfortunately I can't do it automatically here since it would be dangerous
        # (i.e. it would update code locally).
        # svn update is called in build.py, so it's not a problem if it's run
        # from  ./scripts/build-release.bat or ./scripts/build-pre-release.bat
        try:
            (local_ver, latest_ver) = util.get_svn_versions()
        except:
            print(
                "Skipping string upload because SVN isn't available to check for up-to-date-ness")
            return
        if int(latest_ver) > int(local_ver):
            print(
                "Skipping string upload because your local version (%s) is older than latest in svn (%s)" %
                (local_ver, latest_ver))
            return

    strings = extract_strings_from_c_files()
    strings.sort()
    s = "AppTranslator strings\n" + string.join(strings, "\n")
    s = s.encode("utf8")

    if lastUploaded() == s:
        print(
            "Skipping upload because strings haven't changed since last upload")
    else:
        uploadStringsToServer(s, uploadsecret)
        saveLastUploaded(s)
        print("Don't forget to checkin strings/last_uploaded.txt")
开发者ID:BianChengNan,项目名称:sumatrapdf,代码行数:43,代码来源:trans_upload.py

示例14: main

def main(new_ver):
    url_update = "https://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-update.txt"
    url_latest = "https://kjkpub.s3.amazonaws.com/sumatrapdf/sumpdf-latest.txt"

    conf = load_config()
    aws_access, aws_secret = conf.GetAwsCredsMustExist()
    s3.set_secrets(aws_access, aws_secret)
    s3.set_bucket("kjkpub")

    v1 = get_latest_version(url_latest)
    (v2, ver_4) = get_update_versions(url_update)
    validate_ver(ver_4)
    assert not v2 or v1 == v2, "sumpdf-update.txt and sumpdf-latest.txt don't agree on Stable version, run build.py -release first"

    if not new_ver:
        print("Current version: %s. To update run:\npython scripts\update_auto_update_ver.py <new_version>" % v1)
        return

    verify_version_not_lower(new_ver, v1, v2)
    sys.stdout.write("Current version: %s\nGoing to update auto-update version to %s. Are you sure? [y/N] " % (v1, new_ver))
    sys.stdout.flush()
    ch = getch()
    print()
    if ch not in ['y', 'Y']:
        print("Didn't update because you didn't press 'y'")
        sys.exit(1)

    # remove the Stable version from sumpdf-update.txt
    s = "[SumatraPDF]\nLatest %s\n" % new_ver
    s3.upload_data_public(s, "sumatrapdf/sumpdf-update.txt")
    # keep updating the legacy file for now
    s = "%s\n" % new_ver
    s3.upload_data_public(s, "sumatrapdf/sumpdf-latest.txt")
    v1 = get_latest_version(url_latest)
    (v2, v3) = get_update_versions(url_update)
    if v1 != new_ver or v2 != None or v3 != new_ver:
        print("Upload failed because v1 or v3 != ver ('%s' or '%s' != '%s'" % (v1, v3, new_ver))
        sys.exit(1)
    print("Successfully update auto-update version to '%s'" % new_ver)
开发者ID:BanalityOfSeeking,项目名称:sumatrapdf,代码行数:39,代码来源:update_auto_update_ver.py

示例15: uploadStringsIfChanged

def uploadStringsIfChanged():
    # needs to have upload secret to protect apptranslator.org server from abuse
    config = util.load_config()
    uploadsecret = config.trans_ul_secret
    if None is uploadsecret:
        print("Skipping string upload because don't have upload secret")
        return

    # TODO: we used to have a check if svn is up-to-date
    # should we restore it for git?

    strings = extract_strings_from_c_files()
    strings.sort()
    s = "AppTranslator strings\n" + string.join(strings, "\n")
    s = s.encode("utf8")

    if lastUploaded() == s:
        print(
            "Skipping upload because strings haven't changed since last upload")
    else:
        uploadStringsToServer(s, uploadsecret)
        saveLastUploaded(s)
        print("Don't forget to checkin strings/last_uploaded.txt")
开发者ID:Andy-Amoy,项目名称:sumatrapdf,代码行数:23,代码来源:trans_upload.py


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