quick-emulators.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:quick-emulators 作者: dvoiss 项目源码 文件源码
def create_app(name, command_to_execute, is_genymotion=False):
    app_file = "%s/Applications/Quick Emulators/%s.app" % (expanduser('~'), name)
    app_contents = "%s/Contents" % app_file
    app_resources = "%s/Resources" % app_contents
    app_mac_os = "%s/MacOS" % app_contents

    mkdir_p(app_file)
    mkdir_p(app_contents)
    mkdir_p(app_resources)
    mkdir_p(app_mac_os)

    # create the plist file with the app name
    with cd(app_contents):
        with open("Info.plist", 'w') as f:
            f.write(plist_template.format(**{"app_name": name}))

    # use the genymotion app icon if it exists
    if is_genymotion and isfile(genymotion_icon):
        copyfile(genymotion_icon, "%s/%s.icns" % (app_resources, name))

    # write the script file and set it as executable
    with cd(app_mac_os):
        write_script_file(name, command_to_execute)
        st = os.stat(name)
        chmod_flags = st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
        os.chmod(name, chmod_flags)

    # add tags to file that can be used by spotlight:
    tags = ["Android", "Emulator", ("Genymotion" if is_genymotion else "AVD")]
    write_xattrs(app_file, tags)

    # add app to spotlight index
    call(["mdimport", app_file])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号