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

Python util.load_config函数代码示例

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

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



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


示例16: verify_can_send_email

def verify_can_send_email():
    c = load_config()
    if not c.HasNotifierEmail():
        print("can't run. scripts/config.py missing notifier_email and/or notifier_email_pwd")
        sys.exit(1)
开发者ID:BanalityOfSeeking,项目名称:sumatrapdf,代码行数:5,代码来源:buildbot.py


示例17: closing

	try:
		ssh_client.connect( hostip, username=userid, password=passwd)
		with closing( scpclient.Write( ssh_client.get_transport(), '.')) as scp:
			scp.send_file( 'update_cdp.py', True)
		retval = True
	except Exception:
		print 'failed to scp update_cdp.py'
	return retval


def update_cdp(hostip, userid, passwd):
	retval = True
	target_cmd = "python bootflash:update_cdp.py"
	target_cmd = util.remove_last_semicolon(target_cmd)
	resp = requests.post( util.get_nxapi_endpoint( hostip), data=json.dumps( util.get_conf_payload( target_cmd)), headers=util.myheaders,auth=(userid,passwd)).json()
	outputs = resp['ins_api']['outputs']['output']
	#print outputs
	if not 'Success' in outputs['msg']:
		retval = False
	print 'update_cdp on %s is %s' %(hostip, retval)
	return retval


if __name__ == '__main__':
	roles  = util.load_config( sys.argv[1]) #hosts.yaml
	for role in roles.keys():
		for host in roles[role]:
			scp_update_cdp_code( host, os.environ['NEXUS_USER'], os.environ['NEXUS_PASSWD'])
			update_cdp( host, os.environ['NEXUS_USER'], os.environ['NEXUS_PASSWD'])

开发者ID:javaos74,项目名称:remote_cdp,代码行数:29,代码来源:nxapi_update_cdp.py


示例18: main

def main():
  global upload
  if len(args) != 0:
    usage()
  verify_started_in_right_directory()

  if build_prerelease:
    if svn_revision is None:
      run_cmd_throw("svn", "update")
      (out, err) = run_cmd_throw("svn", "info")
      ver = str(parse_svninfo_out(out))
    else:
      # allow to pass in an SVN revision, in case SVN itself isn't available
      ver = svn_revision
  else:
    ver = extract_sumatra_version(os.path.join("src", "Version.h"))
  log("Version: '%s'" % ver)

  # don't update translations for release versions to prevent Trunk changes
  # from messing up the compilation of a point release on a branch
  if g_new_translation_system and build_prerelease and not skip_transl_update:
    trans_upload.uploadStringsIfChanged()
    changed = trans_download.downloadAndUpdateTranslationsIfChanged()
    # Note: this is not a perfect check since re-running the script will
    # proceed
    if changed:
      print("\nNew translations have been downloaded from apptranslator.og")
      print("Please verify and checkin src/Translations_txt.cpp and strings/translations.txt")
      sys.exit(1)

  filename_base = "SumatraPDF-%s" % ver
  if build_prerelease:
    filename_base = "SumatraPDF-prerelease-%s" % ver

  s3_dir = "sumatrapdf/rel"
  if build_prerelease:
    s3_dir = "sumatrapdf/prerel"
  if upload_tmp:
    upload = True
    s3_dir += "tmp"

  if upload:
    log("Will upload to s3 at %s" % s3_dir)
    conf = load_config()
    s3.set_secrets(conf.aws_access, conf.aws_secret)
    s3.set_bucket("kjkpub")

  s3_prefix = "%s/%s" % (s3_dir, filename_base)
  s3_exe           = s3_prefix + ".exe"
  s3_installer     = s3_prefix + "-install.exe"
  s3_pdb_zip       = s3_prefix + ".pdb.zip"
  s3_exe_zip       = s3_prefix + ".zip"

  s3_files = [s3_exe, s3_installer, s3_pdb_zip]
  if not build_prerelease:
    s3_files.append(s3_exe_zip)

  cert_pwd = None
  cert_path = os.path.join("scripts", "cert.pfx")
  if upload:
    map(s3.verify_doesnt_exist, s3_files)
    verify_path_exists(cert_path)
    conf = load_config()
    cert_pwd = conf.GetCertPwdMustExist()

  obj_dir = "obj-rel"
  if target_platform == "X64":
    obj_dir += "64"

  if not testing and not build_test_installer and not build_rel_installer:
    shutil.rmtree(obj_dir, ignore_errors=True)
    shutil.rmtree(os.path.join("mupdf", "generated"), ignore_errors=True)

  config = "CFG=rel"
  if build_test_installer and not build_prerelease:
    obj_dir = "obj-dbg"
    config = "CFG=dbg"
  extcflags = ""
  if build_prerelease:
    extcflags = "EXTCFLAGS=-DSVN_PRE_RELEASE_VER=%s" % ver
  platform = "PLATFORM=%s" % (target_platform or "X86")

  run_cmd_throw("nmake", "-f", "makefile.msvc", config, extcflags, platform, "all_sumatrapdf")
  exe = os.path.join(obj_dir, "SumatraPDF.exe")
  if upload:
    sign(exe, cert_pwd)
    sign(os.path.join(obj_dir, "uninstall.exe"), cert_pwd)

  build_installer_data(obj_dir)
  run_cmd_throw("nmake", "-f", "makefile.msvc", "Installer", config, platform, extcflags)

  if build_test_installer or build_rel_installer:
    sys.exit(0)

  installer = os.path.join(obj_dir, "Installer.exe")
  if upload:
    sign(installer, cert_pwd)

  pdb_zip = os.path.join(obj_dir, "%s.pdb.zip" % filename_base)

#.........这里部分代码省略.........
开发者ID:aarjones55,项目名称:sumatrapdf,代码行数:101,代码来源:build-release.py


示例19: main

def main(models, source_file, saveto, save_alignment=None, k=5,
         normalize=False, n_process=5, chr_level=False, verbose=False, nbest=False, suppress_unk=False, a_json=False, print_word_probabilities=False, return_hyp_graph=False):
    # load model model_options
    options = []
    for model in models:
        options.append(load_config(model))

        fill_options(options[-1])

    dictionaries = options[0]['dictionaries']

    dictionaries_source = dictionaries[:-1]
    dictionary_target = dictionaries[-1]

    # load source dictionary and invert
    word_dicts = []
    word_idicts = []
    for dictionary in dictionaries_source:
        word_dict = load_dict(dictionary)
        if options[0]['n_words_src']:
            for key, idx in word_dict.items():
                if idx >= options[0]['n_words_src']:
                    del word_dict[key]
        word_idict = dict()
        for kk, vv in word_dict.iteritems():
            word_idict[vv] = kk
        word_idict[0] = '<eos>'
        word_idict[1] = 'UNK'
        word_dicts.append(word_dict)
        word_idicts.append(word_idict)

    # load target dictionary and invert
    word_dict_trg = load_dict(dictionary_target)
    word_idict_trg = dict()
    for kk, vv in word_dict_trg.iteritems():
        word_idict_trg[vv] = kk
    word_idict_trg[0] = '<eos>'
    word_idict_trg[1] = 'UNK'

    # create input and output queues for processes
    queue = Queue()
    rqueue = Queue()
    processes = [None] * n_process
    for midx in xrange(n_process):
        processes[midx] = Process(
            target=translate_model,
            args=(queue, rqueue, midx, models, options, k, normalize, verbose, nbest, save_alignment is not None, suppress_unk, return_hyp_graph))
        processes[midx].start()

    # utility function
    def _seqs2words(cc):
        ww = []
        for w in cc:
            if w == 0:
                break
            ww.append(word_idict_trg[w])
        return ' '.join(ww)

    def _send_jobs(f):
        source_sentences = []
        for idx, line in enumerate(f):
            if chr_level:
                words = list(line.decode('utf-8').strip())
            else:
                words = line.strip().split()

            x = []
            for w in words:
                w = [word_dicts[i][f] if f in word_dicts[i] else 1 for (i,f) in enumerate(w.split('|'))]
                if len(w) != options[0]['factors']:
                    sys.stderr.write('Error: expected {0} factors, but input word has {1}\n'.format(options[0]['factors'], len(w)))
                    for midx in xrange(n_process):
                        processes[midx].terminate()
                    sys.exit(1)
                x.append(w)

            x += [[0]*options[0]['factors']]
            queue.put((idx, x))
            source_sentences.append(words)
        return idx+1, source_sentences

    def _finish_processes():
        for midx in xrange(n_process):
            queue.put(None)

    def _retrieve_jobs(n_samples):
        trans = [None] * n_samples
        out_idx = 0
        for idx in xrange(n_samples):
            resp = rqueue.get()
            trans[resp[0]] = resp[1]
            if verbose and numpy.mod(idx, 10) == 0:
                sys.stderr.write('Sample {0} / {1} Done\n'.format((idx+1), n_samples))
            while out_idx < n_samples and trans[out_idx] != None:
                yield trans[out_idx]
                out_idx += 1

    sys.stderr.write('Translating {0} ...\n'.format(source_file.name))
    n_samples, source_sentences = _send_jobs(source_file)
    _finish_processes()
#.........这里部分代码省略.........
开发者ID:andre-martins,项目名称:nematus,代码行数:101,代码来源:translate.py


示例20: main

def main():
    global SCREEN_FULLSCREEN
    pygame.init()

    util.load_config()

    if len(sys.argv) > 1:
        for arg in sys.argv:
            if arg == "-np":
                Variables.particles = False
            elif arg == "-na":
                Variables.alpha = False
            elif arg == "-nm":
                Variables.music = False
            elif arg == "-ns":
                Variables.sound = False
            elif arg == "-f":
                SCREEN_FULLSCREEN = True

    scr_options = 0
    if SCREEN_FULLSCREEN: scr_options += FULLSCREEN
    screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT),scr_options ,32)

    pygame.display.set_icon(util.load_image("kuvake"))
    pygame.display.set_caption("Trip on the Funny Boat")

    init()

    joy = None
    if pygame.joystick.get_count() > 0:
        joy = pygame.joystick.Joystick(0)
        joy.init()

    try:
        util.load_music("JDruid-Trip_on_the_Funny_Boat")
        if Variables.music:
            pygame.mixer.music.play(-1)
    except:
        # It's not a critical problem if there's no music
        pass

    pygame.time.set_timer(NEXTFRAME, 1000 / FPS) # 30 fps

    Water.global_water = Water()

    main_selection = 0

    while True:
        main_selection = Menu(screen, ("New Game", "High Scores", "Options", "Quit"), main_selection).run()
        if main_selection == 0:
            # New Game
            selection = Menu(screen, ("Story Mode", "Endless Mode")).run()
            if selection == 0:
                # Story
                score = Game(screen).run()
                Highscores(screen, score).run()
            elif selection == 1:
                # Endless
                score = Game(screen, True).run()
                Highscores(screen, score, True).run()
        elif main_selection == 1:
            # High Scores
            selection = 0
            while True:
                selection = Menu(screen, ("Story Mode", "Endless Mode", "Endless Online"), selection).run()
                if selection == 0:
                    # Story
                    Highscores(screen).run()
                elif selection == 1:
                    # Endless
                    Highscores(screen, endless = True).run()
                elif selection == 2:
                    # Online
                    Highscores(screen, endless = True, online = True).run()
                else:
                    break
        elif main_selection == 2:
            # Options
            selection = Options(screen).run()
        else: #if main_selection == 3:
            # Quit
            return
开发者ID:italomaia,项目名称:turtle-linux,代码行数:82,代码来源:run_game.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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