Esempio n. 1
0
def generate_bundle(nick, new_basename):
    """Generate a new .xo bundle for the activity and copy it into the
    Journal.

    """
    new_activity_name = _customize_activity_info(nick, new_basename)

    user_activities_path = get_user_activities_path()
    if os.path.exists(os.path.join(user_activities_path, new_basename,
                                   'dist')):
        for path in glob.glob(
                os.path.join(user_activities_path, new_basename, 'dist', '*')):
            os.remove(path)

    source_dir = os.path.join(user_activities_path, new_basename)
    config = bundlebuilder.Config(source_dir=source_dir,
                                  dist_dir=os.path.join(source_dir, 'dist'),
                                  dist_name='%s-1' % (new_activity_name))
    bundlebuilder.cmd_dist_xo(config, None)

    dsobject = datastore.create()
    dsobject.metadata['title'] = '%s-1.xo' % (new_activity_name)
    dsobject.metadata['mime_type'] = 'application/vnd.olpc-sugar'
    dsobject.set_file_path(
        os.path.join(user_activities_path, new_basename, 'dist',
                     '%s-1.xo' % (new_activity_name)))
    datastore.write(dsobject)
    dsobject.destroy()
Esempio n. 2
0
def start():
    parser = argparse.ArgumentParser(prog='./setup.py')
    subparsers = parser.add_subparsers(dest="command",
                                       help="Options for %(prog)s")

    install_parser = subparsers.add_parser(
        "install", help="Install the activity in the system")
    install_parser.add_argument("--prefix",
                                dest="prefix",
                                default=sys.prefix,
                                help="Path for installing")
    install_parser.add_argument(
        "--skip-install-mime",
        dest="install_mime",
        action="store_false",
        default=True,
        help="Skip the installation of custom mime types in the system")
    install_parser.add_argument(
        "--skip-install-desktop-file",
        dest="install_desktop_file",
        action="store_false",
        default=True,
        help="Skip the installation of desktop file in the system")

    check_parser = subparsers.add_parser("check",
                                         help="Run tests for the activity")
    check_parser.add_argument("choice",
                              nargs='?',
                              choices=['unit', 'integration'],
                              help="run unit/integration test")
    check_parser.add_argument("--verbosity",
                              "-v",
                              dest="verbose",
                              type=int,
                              choices=range(0, 3),
                              default=1,
                              nargs='?',
                              help="verbosity for the unit tests")

    dist_parser = subparsers.add_parser("dist_xo",
                                        help="Create a xo bundle package")
    dist_parser.add_argument(
        "--no-fail",
        dest="no_fail",
        action="store_true",
        default=False,
        help="continue past failure when building xo file")

    subparsers.add_parser("dist_source", help="Create a tar source package")
    subparsers.add_parser("build", help="Build generated files")
    subparsers.add_parser("genpot", help="Generate the gettext pot file")
    subparsers.add_parser("dev", help="Setup for development")

    options = parser.parse_args()

    if options.command == "genpot":
        source_dir = os.path.abspath(os.path.dirname(sys.argv[0]))
        config = bundlebuilder.Config(source_dir)
        cmd_genpot(config, options)
    else:
        bundlebuilder.start()