Exemple #1
0
def app_launch(fn, prefix=config.root_dir, additional_args=None):
    """
    Launch the application `fn` (with optional additional command line
    arguments), in the prefix (which defaults to the root environment).
    Returned is the process object (the one returned by subprocess.Popen),
    or None if the application `fn` is not installed in the prefix.
    """
    from conda.misc import launch

    return launch(fn, prefix, additional_args)
Exemple #2
0
def app_launch(fn, prefix=config.root_dir, additional_args=None):
    """
    Launch the application `fn` (with optional additional command line
    arguments), in the prefix (which defaults to the root environment).
    Returned is the process object (the one returned by subprocess.Popen),
    or None if the application `fn` is not installed in the prefix.
    """
    from conda.misc import launch

    return launch(fn, prefix, additional_args)
Exemple #3
0
def execute(args, parser):
    if not args.package:
        parser.print_help()
        return

    import conda.install
    import conda.resolve
    from conda.api import get_package_versions, app_is_installed
    from conda.misc import launch

    prefix = common.get_prefix(args)

    if args.quiet:
        logging.disable(logging.CRITICAL)

    if args.package.endswith('.tar.bz2'):
        if app_is_installed(args.package, prefixes=[prefix]):
            fn = args.package
        else:
            error_message = "Package {} not installed.".format(args.package)
            common.error_and_exit(error_message, json=args.json,
                                  error_type="PackageNotInstalled")
    else:
        installed = []
        for pkg in get_package_versions(args.package):
            if app_is_installed(pkg.fn, prefixes=[prefix]):
                installed.append(pkg)

        for pkg in conda.install.linked(prefix):
            name, version, build = pkg.rsplit('-', 2)
            if name == args.package:
                installed = [conda.resolve.Package(pkg + '.tar.bz2',
                                                   conda.install.is_linked(prefix, pkg))]
                break

        if installed:
            package = max(installed)
            fn = package.fn

            try:
                subprocess = launch(fn, prefix=prefix,
                                    additional_args=args.arguments,
                                    background=args.json)
                if args.json:
                    common.stdout_json(dict(fn=fn, pid=subprocess.pid))
                elif not args.quiet:
                    print("Started app. Some apps may take a while to finish loading.")
            except TypeError:
                execute_command(args.package, prefix, args.arguments, args.json)
            except Exception as e:
                common.exception_and_exit(e, json=args.json)
        else:
            # Try interpreting it as a command
            execute_command(args.package, prefix, args.arguments, args.json)
Exemple #4
0
def execute(args, parser):
    if not args.package:
        parser.print_help()
        return

    import conda.install
    import conda.resolve
    from conda.api import get_package_versions, app_is_installed
    from conda.misc import launch

    prefix = common.get_prefix(args)

    if args.quiet:
        logging.disable(logging.CRITICAL)

    if args.package.endswith('.tar.bz2'):
        if app_is_installed(args.package, prefixes=[prefix]):
            fn = args.package
        else:
            error_message = "Package {} not installed.".format(args.package)
            common.error_and_exit(error_message, json=args.json,
                                  error_type="PackageNotInstalled")
    else:
        installed = []
        for pkg in get_package_versions(args.package):
            if app_is_installed(pkg.fn, prefixes=[prefix]):
                installed.append(pkg)

        for pkg in conda.install.linked(prefix):
            name, version, build = pkg.rsplit('-', 2)
            if name == args.package:
                installed = [conda.resolve.Package(pkg + '.tar.bz2',
                                                   conda.install.is_linked(prefix, pkg))]
                break

        if installed:
            package = max(installed)
            fn = package.fn

            try:
                subprocess = launch(fn, prefix=prefix,
                                    additional_args=args.arguments,
                                    background=args.json)
                if args.json:
                    common.stdout_json(dict(fn=fn, pid=subprocess.pid))
                elif not args.quiet:
                    print("Started app. Some apps may take a while to finish loading.")
            except TypeError:
                execute_command(args.package, prefix, args.arguments, args.json)
            except Exception as e:
                common.exception_and_exit(e, json=args.json)
        else:
            # Try interpreting it as a command
            execute_command(args.package, prefix, args.arguments, args.json)