Ejemplo n.º 1
0
def build_ons_data(root_dir, out_dir):
    build_ons_script(root_dir, out_dir)
    se_dir = os.path.join(root_dir, 'download', 'sound')
    print("复制bgm中...")
    copyfiles(se_dir, os.path.join(out_dir, "bgm"), lambda n: n.startswith('bgm'))
    print("复制音效中...")
    copyfiles(se_dir, os.path.join(out_dir, "se"), lambda n: n.startswith('se'))
    adv_dir = os.path.join(root_dir, 'download', 'image', 'adv')
    print("解密背景图片中...")
    copyfiles(adv_dir, os.path.join(out_dir, 'bgimage'),
            lambda n: n.startswith('adv_bg'),
            decrypt=decrypt, tranformer=lambda n: n+'.png')
    copyfiles(os.path.join(root_dir, 'download', 'rest'),
            os.path.join(out_dir, 'bgimage'),
            lambda n: n == 'exp_map_bg',
            decrypt=decrypt, tranformer=lambda n: 'map.png')
    print("解密角色图片中...")
    copyfiles(adv_dir, os.path.join(out_dir, 'chara'),
            lambda n: n.startswith('adv_chara'),
            decrypt=decrypt, tranformer=lambda n: n+'.png')
    print("生成对话框中...")
    image_dir = os.path.join(out_dir, 'image')
    os.makedirs(image_dir, exist_ok=True)
    with open(os.path.join(root_dir, 'download', 'rest', 'que_adv'), 'rb') as f:
        img = decrypt(f.read())
        build_que_adv(img, os.path.join(image_dir, 'que_adv.png'))
    voice_dir = os.path.join(root_dir, 'download', 'voice')
    if os.path.isdir(voice_dir):
        print("复制语音目录中...")
        copytree(voice_dir, os.path.join(out_dir, 'voice'))
    else:
        print("语音目录不存在,已忽略")
Ejemplo n.º 2
0
Archivo: add.py Proyecto: chshouyu/ursa
def getPkgOpen(subpkgs):
    """获取open 模块
    模块地址 http://ufo.sogou-inc.com/git/open.git
    """
    targetfolder = os.path.join( conf.getConfig()['path'] ,  'static'  , 'js' )
    utils.createfolder(TEMP_FOLDER)
    
    if not os.path.exists( targetfolder ):
        utils.createfolder(targetfolder)

    subpkgs = subpkgs or conf.getConfig()['PKG_OPEN']
    
    subpkgs.insert(0 , 'common')
    
    os.system('git clone http://ufo.sogou-inc.com/git/open.git ' + os.path.join(TEMP_FOLDER , 'open'))
    successpkg = []
    for pkg in subpkgs:
        source = os.path.join( TEMP_FOLDER , 'open' , pkg )
        if not os.path.exists(source):
            log.warn('Sub package ' + pkg + ' not exist in Open.')
            continue
        utils.copyfiles( source , os.path.join( targetfolder , 'open' , pkg ) )
        successpkg.append( pkg )
    

    utils.removefolder(TEMP_FOLDER)
    log.success( 'Adding Open package include ' + ','.join(successpkg) + ' success!' )
Ejemplo n.º 3
0
def copyfiles(ptype):
    """拷贝库文件到目标文件
    """
    pfolder = 'project' if ptype == 'pc' else 'mproject'

    base = os.path.join(conf.getConfig()['base'], 'assets', pfolder)

    utils.copyfiles(base, conf.getConfig()['path'])
Ejemplo n.º 4
0
def copyfiles(ptype):
    """拷贝库文件到目标文件
    """
    pfolder = 'project' if ptype == 'pc' else 'mproject'

    base  = os.path.join(conf.getConfig()['base'] , 'assets' , pfolder  )

    utils.copyfiles(base , conf.getConfig()['path'])
Ejemplo n.º 5
0
def build_viewer_card(root_dir, out_dir):
    copyfiles(os.path.join(root_dir, 'download', 'image', 'card'), out_dir,
            decrypt=decrypt, tranformer=lambda n: n+'.png')
Ejemplo n.º 6
0
def run(params , options):
    """
    """
    tmbegin = time.time()

    buildtype = None
    if params and len(params):
        if conf.getConfig().get(params[0]):
            buildtype = params[0]
        else:
            log.error('No such build type:' + params[0])
            sys.exit(1)

    utils.removefolder(BUILD_DIR);
    utils.createfolder(BUILD_DIR);
    #直接在build目录操作哦
    utils.copyfiles( 'template' , os.path.join(BUILD_DIR , 'template') )
    utils.copyfiles( 'static' , os.path.join(BUILD_DIR , 'static') )
    
    if COMPILE_FOLDER:
        utils.copyfiles( COMPILE_FOLDER , os.path.join(BUILD_DIR , COMPILE_FOLDER) )
        
    #模块分为CSS和js,之前使用require_modules代表js,建议现在使用require_js_modules;
    #而require_css_modules代表css。
    if conf.getConfig().get('require_modules'):
        log.warn("'require_modules' is deprecated,you should use 'require_js_modules' instead!")

    require_modules = conf.getConfig().get('require_js_modules') or conf.getConfig().get('require_modules') or ['main']
    require_js_modules=require_modules#[email protected]:历史遗留
    require_css_modules = conf.getConfig().get('require_css_modules') or ['main']
    
    #@deprecated
    #maincss  = os.path.join( PATH , BUILD_DIR , 'static' , 'css' , conf.getConfig().get('css_folder') or '' , 'main.css' )

    try:
        log.log( 'Combine css&js with r.js' )
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR , 'static' , 'js' , conf.getConfig().get('js_folder') or '' , module + '.js' )
            subprocess.call( 'node ' + RJSPATH +' -o name=' + module + ' out='+ js + ' optimize=none baseUrl=' + os.path.join(PATH , BUILD_DIR , 'static' , 'js' , conf.getConfig().get('js_folder') or '')  , shell=True)#使用YUICompressor压缩,这里仅合并
        
        #[email protected]:合并css集合
        for module in require_css_modules:
            css=os.path.join( PATH , BUILD_DIR , 'static' , 'css' , conf.getConfig().get('css_folder') or '' , module + '.css' )
            subprocess.call( 'node ' + RJSPATH + ' -o cssIn=' + css + ' out=' + css  , shell=True)#cssIn参数带.css后缀
        log.success( 'Combine css&js with r.js success.' )
    except:
        log.error('Please insure you have installed r.js on your computer')
        raise
    
    log.log('Begin to add Timestamps...' , True)
    #@todo:HTML内部的css或许也需要时间戳
    compileCss();
    log.success('Success!')


    if options.get('html'):
        utils.createfolder( os.path.join( BUILD_DIR ,  'html'))

    log.log('Begin to compile tpls...' )
    compileHTML(options.get('compress') , options.get('html'))
    log.success('Success!')
    

    log.log('Begin to replace all token...', True)

    compileCommon(buildtype)
    log.success('Success!')

    if options.get('compress'):
        log.log('Begin to compile Js...' , True)
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR , 'static' , 'js', conf.getConfig().get('js_folder') or ''  , module + '.js' )
            subprocess.call( 'java -jar ' + YCPATH + ' --type js --charset ' + conf.getConfig()['encoding'] + ' ' + js + ' -o ' + js , shell=True );
        log.success('Success!')

        log.log('Begin to compile Css...' , True)
        for module in require_css_modules:#[email protected]:编辑CSS集合
            css = os.path.join(PATH, BUILD_DIR , 'static' , 'css', conf.getConfig().get('css_folder') or ''  , module + '.css' )
            subprocess.call( 'java -jar ' + YCPATH + ' --type css --charset ' + conf.getConfig()['encoding'] + ' ' + css + ' -o ' + css , shell=True );
       # subprocess.call( 'java -jar ' + YCPATH + ' --type css --charset ' + conf.getConfig()['encoding'] + ' ' + maincss + ' -o ' + maincss , shell=True);
        log.success('Success!')


    log.success('Compiled successfully.')
    log.success('Time cost %s s.' % (time.time()-tmbegin) )
Ejemplo n.º 7
0
def run(params, options):
    """
    """
    tmbegin = time.time()

    buildtype = None
    if params and len(params):
        if conf.getConfig().get(params[0]):
            buildtype = params[0]
        else:
            log.error("No such build type:" + params[0])
            sys.exit(1)

    utils.removefolder(BUILD_DIR)
    utils.createfolder(BUILD_DIR)
    # 直接在build目录操作哦
    utils.copyfiles("template", os.path.join(BUILD_DIR, "template"))
    utils.copyfiles("static", os.path.join(BUILD_DIR, "static"))

    if COMPILE_FOLDER:
        utils.copyfiles(COMPILE_FOLDER, os.path.join(BUILD_DIR, COMPILE_FOLDER))

    # 模块分为CSS和js,之前使用require_modules代表js,建议现在使用require_js_modules;
    # 而require_css_modules代表css。
    if conf.getConfig().get("require_modules"):
        log.warn("'require_modules' is deprecated,you should use 'require_js_modules' instead!")

    require_modules = conf.getConfig().get("require_js_modules") or conf.getConfig().get("require_modules") or ["main"]
    require_js_modules = require_modules  # [email protected]:历史遗留
    require_css_modules = conf.getConfig().get("require_css_modules") or ["main"]

    # @deprecated
    # maincss  = os.path.join( PATH , BUILD_DIR , 'static' , 'css' , conf.getConfig().get('css_folder') or '' , 'main.css' )

    try:
        log.log("Combine css&js with r.js")
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR, "static", "js", conf.getConfig().get("js_folder") or "", module + ".js")
            p = subprocess.Popen(
                "r.js -o name="
                + module
                + " out="
                + js
                + " optimize=none baseUrl="
                + os.path.join(PATH, BUILD_DIR, "static", "js", conf.getConfig().get("js_folder") or ""),
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                shell=True,
            )  # 使用YUICompressor压缩,这里仅合并
            (o, e) = p.communicate()
            print o
            print e
            if not p.returncode == 0:
                raise IOError("Combine js failed")

        # [email protected]:合并css集合
        for module in require_css_modules:
            css = os.path.join(
                PATH, BUILD_DIR, "static", "css", conf.getConfig().get("css_folder") or "", module + ".css"
            )
            p = subprocess.Popen(
                "r.js -o cssIn=" + css + " out=" + css, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True
            )  # cssIn参数带.css后缀
            (o, e) = p.communicate()
            print o
            print e
            if not p.returncode == 0:
                raise IOError("Combine css failed")
        log.success("Combine css&js with r.js success.")
    except:
        log.error("Please insure you have installed r.js on your computer")
        raise

    log.log("Begin to add Timestamps...", True)
    # @todo:HTML内部的css或许也需要时间戳
    compileCss()
    log.success("Success!")

    if options.get("html"):
        utils.createfolder(os.path.join(BUILD_DIR, "html"))

    log.log("Begin to compile tpls...")
    compileHTML(options.get("compress"), options.get("html"))
    log.success("Success!")

    log.log("Begin to replace all token...", True)

    compileCommon(buildtype)
    log.success("Success!")

    if options.get("compress"):
        log.log("Begin to compile Js...", True)
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR, "static", "js", conf.getConfig().get("js_folder") or "", module + ".js")
            subprocess.call(
                "java -jar " + YCPATH + " --type js --charset " + conf.getConfig()["encoding"] + " " + js + " -o " + js,
                shell=True,
            )
        log.success("Success!")

        log.log("Begin to compile Css...", True)
        for module in require_css_modules:  # [email protected]:编辑CSS集合
            css = os.path.join(
                PATH, BUILD_DIR, "static", "css", conf.getConfig().get("css_folder") or "", module + ".css"
            )
            subprocess.call(
                "java -jar "
                + YCPATH
                + " --type css --charset "
                + conf.getConfig()["encoding"]
                + " "
                + css
                + " -o "
                + css,
                shell=True,
            )
        # subprocess.call( 'java -jar ' + YCPATH + ' --type css --charset ' + conf.getConfig()['encoding'] + ' ' + maincss + ' -o ' + maincss , shell=True);
        log.success("Success!")

    log.success("Compiled successfully.")
    log.success("Time cost %s s." % (time.time() - tmbegin))
Ejemplo n.º 8
0
def leak_distinct():
    filenamepathmap = utils.visitdir(utils.LEAKCANARY_LOG_PATH)
    filenamecontentmap = utils.getfilecontentmap(filenamepathmap, utils.LEAKPATTERN)
    filenamecontentmap_noduplicate = utils.tuple_r_dict(utils.tuple_r_dict(filenamecontentmap))
    utils.copyfiles(filenamepathmap, filenamecontentmap_noduplicate, utils.LEAKCANARY_LOG_PATH)
    print("leakCanary去重成功")
Ejemplo n.º 9
0
def block_distinct():
    filenamepathmap = utils.visitdir(utils.BLOCKCANARY_LOG_PATH)
    filenamecontentmap = utils.getfilecontentmapex(filenamepathmap)
    filenamecontentmap_noduplicate = utils.tuple_r_dict(utils.tuple_r_dict(filenamecontentmap))
    utils.copyfiles(filenamepathmap, filenamecontentmap_noduplicate, utils.BLOCKCANARY_LOG_PATH)
    print("blockCanary去重成功")
Ejemplo n.º 10
0
def run(params, options):
    """
    """
    tmbegin = time.time()

    buildtype = None
    if params and len(params):
        if conf.getConfig().get(params[0]):
            buildtype = params[0]
        else:
            log.error('No such build type:' + params[0])
            sys.exit(1)

    utils.removefolder(BUILD_DIR)
    utils.createfolder(BUILD_DIR)
    #直接在build目录操作哦
    utils.copyfiles('template', os.path.join(BUILD_DIR, 'template'))
    utils.copyfiles('static', os.path.join(BUILD_DIR, 'static'))

    if COMPILE_FOLDER:
        utils.copyfiles(COMPILE_FOLDER, os.path.join(BUILD_DIR,
                                                     COMPILE_FOLDER))

    #模块分为CSS和js,之前使用require_modules代表js,建议现在使用require_js_modules;
    #而require_css_modules代表css。
    if conf.getConfig().get('require_modules'):
        log.warn(
            "'require_modules' is deprecated,you should use 'require_js_modules' instead!"
        )

    require_modules = conf.getConfig().get(
        'require_js_modules') or conf.getConfig().get('require_modules') or [
            'main'
        ]
    require_js_modules = require_modules  #[email protected]:历史遗留
    require_css_modules = conf.getConfig().get('require_css_modules') or [
        'main'
    ]

    #@deprecated
    #maincss  = os.path.join( PATH , BUILD_DIR , 'static' , 'css' , conf.getConfig().get('css_folder') or '' , 'main.css' )

    try:
        log.log('Combine css&js with r.js')
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR, 'static', 'js',
                              conf.getConfig().get('js_folder') or '',
                              module + '.js')
            p = subprocess.Popen(
                'r.js -o name=' + module + ' out=' + js +
                ' optimize=none baseUrl=' +
                os.path.join(PATH, BUILD_DIR, 'static', 'js',
                             conf.getConfig().get('js_folder') or ''),
                stdout=subprocess.PIPE,
                stderr=subprocess.PIPE,
                shell=True)  #使用YUICompressor压缩,这里仅合并
            (o, e) = p.communicate()
            print o
            print e
            if not p.returncode == 0:
                raise IOError('Combine js failed')

        #[email protected]:合并css集合
        for module in require_css_modules:
            css = os.path.join(PATH, BUILD_DIR, 'static', 'css',
                               conf.getConfig().get('css_folder') or '',
                               module + '.css')
            p = subprocess.Popen('r.js -o cssIn=' + css + ' out=' + css,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE,
                                 shell=True)  #cssIn参数带.css后缀
            (o, e) = p.communicate()
            print o
            print e
            if not p.returncode == 0:
                raise IOError('Combine css failed')
        log.success('Combine css&js with r.js success.')
    except:
        log.error('Please insure you have installed r.js on your computer')
        raise

    log.log('Begin to add Timestamps...', True)
    #@todo:HTML内部的css或许也需要时间戳
    compileCss()
    log.success('Success!')

    if options.get('html'):
        utils.createfolder(os.path.join(BUILD_DIR, 'html'))

    log.log('Begin to compile tpls...')
    compileHTML(options.get('compress'), options.get('html'))
    log.success('Success!')

    log.log('Begin to replace all token...', True)

    compileCommon(buildtype)
    log.success('Success!')

    if options.get('compress'):
        log.log('Begin to compile Js...', True)
        for module in require_js_modules:
            js = os.path.join(PATH, BUILD_DIR, 'static', 'js',
                              conf.getConfig().get('js_folder') or '',
                              module + '.js')
            subprocess.call('java -jar ' + YCPATH + ' --type js --charset ' +
                            conf.getConfig()['encoding'] + ' ' + js + ' -o ' +
                            js,
                            shell=True)
        log.success('Success!')

        log.log('Begin to compile Css...', True)
        for module in require_css_modules:  #[email protected]:编辑CSS集合
            css = os.path.join(PATH, BUILD_DIR, 'static', 'css',
                               conf.getConfig().get('css_folder') or '',
                               module + '.css')
            subprocess.call('java -jar ' + YCPATH + ' --type css --charset ' +
                            conf.getConfig()['encoding'] + ' ' + css + ' -o ' +
                            css,
                            shell=True)
    # subprocess.call( 'java -jar ' + YCPATH + ' --type css --charset ' + conf.getConfig()['encoding'] + ' ' + maincss + ' -o ' + maincss , shell=True);
        log.success('Success!')

    log.success('Compiled successfully.')
    log.success('Time cost %s s.' % (time.time() - tmbegin))