Exemple #1
0
def update(conf, args):
    app = App.AppPod(conf)
    installed = app.get_current_context()
    if not installed:
        return False, 'not found "%s": no marun installed status.' % Consts.APP_STATUS_FILE
    if install_to_pod(conf, app, installed.get_installs(), args.keepold):
        return True, None
    return False, None
Exemple #2
0
def install(conf, args):
    app = App.AppPod(conf)
    current = app.get_current_context()
    if not args.add and current:
        return False, 'already installed directory. Use "-a" for add jar file if you want.'
    installed = current and current.get_installs() or set()
    artifacts = installed | set(args.artifacts)
    # TODO: parse version string
    # TODO check conflict
    if artifacts <= installed:
        return True
    if install_to_pod(conf, app, artifacts):
        return True, None
    return False, None
Exemple #3
0
def run(conf, args):
    fs = [x.strip() for x in conf.flavors.split(',')]
    if args.flavors:
        if args.flavors.startswith('@'):
            fs = [x.lstrip(' @+').strip() for x in args.flavors[1:].split(',')]
        else:
            fs.extend(
                [x.lstrip(' @+').strip() for x in args.flavors.split(',')])
    jvmflags = []
    for f in fs:
        if f:
            jvmflags.extend(_apply_flavor(f, conf, jvmflags))
    java = Java.Java(conf)
    app = App.AppPod(conf)
    context = app.get_current_context()
    main = _find_main_class(args.mainclass, context.get_mains())
    classpaths = [context.get_jardir() + '/*', context.get_resourcedir()]
    java.run_class(classpaths, jvmflags, args.jvmargs, main, args.classargs)
    return (True, None)
Exemple #4
0
def init(conf, force=False):
    javas = util.find_javas()
    if len(javas) == 0:
        return False, "Command \"java\" is not found. Set JAVA_HOME/PATH/MARUN_JAVA or config file."
    rootdir = conf.workdir
    if force:
        shutil.rmtree(rootdir, True)
    util.mkdirs(rootdir)
    syspod = App.AppPod(conf, rootdir)
    sysctx = syspod.get_current_context()
    if not sysctx:
        sysctx = _init_sys(conf, syspod)
    if [x for x in conf.repository_list if x.baseurl and x.baseurl.startswith('s3:')]:
        artifacts = sysctx.get_installs()
        if not Consts.S3_ADDONS <= artifacts:
            artifacts = artifacts | Consts.S3_ADDONS
            backup = conf.repository_list
            conf.repository_list = map(Conf.StaticRepository, Consts.INIT_REPOSITORY_URLS)
            sub_install.install_to_pod(conf, syspod, artifacts)
            conf.repository_list = backup
    return True, None