Example #1
0
def write_interop(header, filepath, backup, schema_name, cppheaderdir):
    writect = 0

    schema.load(schema_name, header)

    # validate: class role must be defined for all header classes
    for cls in header.get_classes():
        if not schema.is_handler(cls) and not schema.is_proxy(cls):
            msg = 'Class role must be defined. Class name %s.' % cls.get_name()
            sys.stdout.write('ERROR! %s\n' % msg)
            raise Exception(msg)

    # structs
    for cls in header.get_classes():
        content = make_struct_file(cls)
        writect += update_file(filepath + '/' + schema.struct_path,
                               cls.get_capi_name() + ".g.cs", content, backup)

    # libcef.g.cs
    writect += update_file(filepath + '/' + schema.libcef_path,
                           schema.libcef_filename, make_libcef_file(header),
                           backup)

    # wrapper
    for cls in header.get_classes():
        content = make_wrapper_g_file(cls)
        writect += update_file(filepath + '/' + schema.wrapper_g_path,
                               schema.cpp2csname(cls.get_name()) + ".g.cs",
                               content, backup)

    # userdata
    userdatacls = obj_class(header, 'CefUserData', '', 'CefUserData',
                            'CefBaseRefCounted', '', '', '', [])
    content = make_struct_file(userdatacls)
    writect += update_file(filepath + '/' + schema.struct_path,
                           userdatacls.get_capi_name() + ".g.cs", content,
                           backup)
    content = make_wrapper_g_file(userdatacls)
    writect += update_file(filepath + '/' + schema.wrapper_g_path,
                           schema.cpp2csname(userdatacls.get_name()) + ".g.cs",
                           content, backup)

    # impl template
    for cls in header.get_classes():
        content = make_impl_tmpl_file(cls)
        tmplpath = schema.handler_tmpl_path
        if schema.is_proxy(cls):
            tmplpath = schema.proxy_tmpl_path
        writect += update_file(
            './' + tmplpath,
            schema.cpp2csname(cls.get_name()) + ".tmpl.g.cs", content, backup)

    # process cef_version_h
    content = make_version_cs(read_file(cppheaderdir + '/' + 'cef_version.h'))
    writect += update_file(filepath + '/' + schema.libcef_path,
                           schema.libcef_version_filename, content, backup)

    return writect
def process(cfg, parms):
    """ Product processing state flow management and fulfilment

    Args:
        cfg (dict): environmental configuration
        parms (dict): processing request options

    Returns:
        dict: execution status, resources used, and metadata
    """

    # Verify work request schema
    parms = schema.load(parms)

    # Make a sub-directory
    bucket_name = get_product_bucket(parms, cfg.get('output_bucket_fmt'))

    # Initialize the processing directory.
    directories = staging.initialize_processing_directory(cfg.get('work_dir'), bucket_name)

    # Build the product name
    product_name = get_product_name(parms['input_name'],
                                    cfg.get('output_filename_fmt'))

    # Stage the required input data
    staging.stage_input_data(download_urls=parms['input_urls'],
                             staging=directories.get('stage'),
                             destination=directories.get('work'),
                             unpack=cfg.get('auto_unpack_files'),
                             remove_staged=cfg.get('keep_intermediate','').lower() != 'false')

    shell_sequence = providers.sequence(parms['products'][0], product_id=parms['input_name'])
    logging.warning(shell_sequence)

    results = list()
    for cmd in shell_sequence.split(';'):
        r = utilities.execute_cmd(cmd, directories.get('work'))
        r.update(utilities.snapshot_resources(log=False))
        results.append(r)

    # Remove science products and intermediate data not requested
    cleanup_work_dir()

    # Customize products
    customize_products()

    # Generate statistics products
    generate_statistics()

    # Reformat product
    reformat_products()

    # Package and deliver product
    destination_product, destination_cksum = distribute_product()

    # Remove the product directory
    # Free disk space to be nice to the whole system.
    remove_product_directory(directories['base'])

    return results
Example #3
0
def write_interop(header, filepath, backup, schema_name, cppheaderdir):
    writect = 0

    schema.load(schema_name, header)

    # validate: class role must be defined for all header classes
    for cls in header.get_classes():
        if not schema.is_handler(cls) and not schema.is_proxy(cls):
            msg = 'Class role must be defined. Class name %s.' % cls.get_name()
            sys.stdout.write('ERROR! %s\n' % msg)
            raise Exception(msg)

    # structs
    for cls in header.get_classes():
        content = make_struct_file(cls)
        writect += update_file(filepath + '/' + schema.struct_path, cls.get_capi_name() + ".g.cs", content, backup)

    # libcef.g.cs
    writect += update_file(filepath + '/' + schema.libcef_path, schema.libcef_filename, make_libcef_file(header), backup)
    
    # wrapper
    for cls in header.get_classes():
        content = make_wrapper_g_file(cls)
        writect += update_file(filepath + '/' + schema.wrapper_g_path, schema.cpp2csname(cls.get_name()) + ".g.cs", content, backup)

    # userdata    
    userdatacls = obj_class(header, 'CefUserData', '', 'CefUserData', '', '', '')
    content = make_struct_file(userdatacls)
    writect += update_file(filepath + '/' + schema.struct_path, userdatacls.get_capi_name() + ".g.cs", content, backup)
    content = make_wrapper_g_file(userdatacls)
    writect += update_file(filepath + '/' + schema.wrapper_g_path, schema.cpp2csname(userdatacls.get_name()) + ".g.cs", content, backup)
    
    # impl template
    for cls in header.get_classes():
        content = make_impl_tmpl_file(cls)
        tmplpath = schema.handler_tmpl_path
        if schema.is_proxy(cls):
            tmplpath = schema.proxy_tmpl_path
        writect += update_file('./' + tmplpath, schema.cpp2csname(cls.get_name()) + ".tmpl.g.cs", content, backup)

    # process cef_version_h
    content = make_version_cs(read_file(cppheaderdir + '/' + 'cef_version.h'))
    writect += update_file(filepath + '/' + schema.libcef_path, schema.libcef_version_filename, content, backup)

    return writect
Example #4
0
def export():
	opts, args = getopt.getopt(sys.argv[1:], '-h-u:', ['help', 
		'server_path=', 
		'client_lua_path=', 'client_cs_path=', 'client_cpp_path=', 'client_js_path=', 'client_python_path=', 
		'user='******'-h', '--help'):
			print('''
--server_path 表示服务器项目路径(内含Defines、Entities、Configs、CustomConfigs等文件夹)
--client_lua_path 表示客户端Lua导出路径(内含Proxy、ProxyDefine文件夹,此路径将放置导出的lua客户端脚本)
--client_cs_path 表示客户端C#导出路径(内含Proxy、ProxyDefine文件夹,此路径将放置导出的C#客户端脚本)
--client_cpp_path 表示客户端C++导出路径(内含Proxy、ProxyDefine文件夹,此路径将放置导出的C++客户端脚本)
--client_js_path 表示客户端js导出路径(内含Proxy、ProxyDefine文件夹,此路径将放置导出的js客户端脚本)
--client_python_path 表示客户端js导出路径(内含Proxy、ProxyDefine文件夹,此路径将放置导出的python客户端脚本)
--user(-u) 表示服务器用户环境(不指定用户将无法导出服务器相关配置)
--help(-h) 显示帮助信息''')
			exit()
		if tag in ('-u','--user'):
			user = value
		if tag == '--server_path':
			exportServer = value
		if tag in CLIENT_TYPE:
			exportClient[CLIENT_TYPE[tag]] = value		

	if not exportServer:
		print("Error in Exporter : no server_path -> ")
		return
	elif not os.path.exists(exportServer):
		print("Error in Exporter : invalid server_path -> ", exportServer)
		return

	if not user:
		print("== Please set your user name in preference.bat ==")
		print("== set USER=mario ==")
		print("The user name settings exists at Server/Project/CustomConfigs")
		return
	else:
		cfgPath = exportServer + "/CustomConfigs/" + user
		if not os.path.exists(cfgPath):
			print("Error in Exporter : invalid user -> ", user)
			return

	for ctype, cpath in exportClient.items():
		if not os.path.exists(cpath):
			print("Error in Exporter : invalid client_path -> ", ctype, cpath)

	define_path = exportServer + "/Defines"
	schemaCfg = schema.load(define_path)

	cfgPath = exportServer + "/CustomConfigs/" + user
	serverCfg = server.load(cfgPath)

	exportCfgPath = exportServer + "/Configs"
	exportSchemaPath = exportCfgPath + "/Schema"
	exportServerPath = exportCfgPath + "/Server"
	exportOrmPath = exportCfgPath + "/Orm"

	schema.write(schemaCfg, exportSchemaPath)
	server.write(serverCfg, exportServerPath)
	orm.write(schemaCfg, exportOrmPath)

	exportServerScriptPath = exportServer + "/Entities"
	ss = __import__('server_js', globals(), locals(), [], 0)
	ss.write(schemaCfg, exportServerScriptPath)
	for ctype, cpath in exportClient.items():
		sc = None
		try:
			sc = __import__('client_' + ctype, globals(), locals(), [], 0)			
		except Exception as e:
			print("Exporter don't support the client script now. -> ", ctype)
		if sc:
			sc.writeCfg(schemaCfg, cpath + "/ProxyDefine")
			sc.writeScript(schemaCfg, cpath + "/Proxy")