Пример #1
0
def main(log_level, pdb=False):
    """A client to support interactions with DANDI archive (http://dandiarchive.org).

    To see help for a specific command, run

        dandi COMMAND --help

    e.g. dandi upload --help
    """
    set_logger_level(get_logger(), log_level)
    if pdb:
        map_to_click_exceptions._do_map = False
        from ..utils import setup_exceptionhook

        setup_exceptionhook()
    try:
        import etelemetry

        etelemetry.check_available_version("dandi/dandi-cli",
                                           __version__,
                                           lgr=lgr)
    except Exception as exc:
        lgr.warning(
            "Failed to check for a more recent version available with etelemetry: %s",
            exc,
        )
Пример #2
0
def check_dandi_version() -> None:
    if os.environ.get("DANDI_NO_ET"):
        return
    try:
        import etelemetry

        try:
            etelemetry.check_available_version("dandi/dandi-cli",
                                               __version__,
                                               lgr=lgr,
                                               raise_exception=True)
        except etelemetry.client.BadVersionError:
            # note: SystemExit is based of BaseException, so is not Exception
            raise SystemExit(
                "DANDI CLI has detected that you are using a version that is known to "
                "contain bugs, is incompatible with our current data archive, or has "
                "other significant performance limitations. "
                "To continue using DANDI CLI, please upgrade your dandi client to a newer "
                "version (e.g., using pip install --upgrade dandi if you installed using pip). "
                "If you have any issues, please contact the DANDI "
                "helpdesk at https://github.com/dandi/helpdesk/issues/new/choose ."
            )
    except Exception as exc:
        lgr.warning(
            "Failed to check for a more recent version available with etelemetry: %s",
            exc,
        )
    os.environ["DANDI_NO_ET"] = "1"
Пример #3
0
def main(ctx, log_level, pdb=False):
    """A client to support interactions with DANDI archive (http://dandiarchive.org).

    To see help for a specific command, run

        dandi COMMAND --help

    e.g. dandi upload --help
    """
    set_logger_level(get_logger(), log_level)

    # Ensure that certain log messages are only sent to the log file, not the
    # console:
    root = logging.getLogger()
    for h in root.handlers:
        h.addFilter(lambda r: not r.msg.startswith("[META]"))

    logdir = appdirs.user_log_dir("dandi-cli", "dandi")
    logfile = os.path.join(
        logdir, "{:%Y%m%d%H%M%SZ}-{}.log".format(datetime.utcnow(),
                                                 os.getpid()))
    os.makedirs(logdir, exist_ok=True)
    handler = logging.FileHandler(logfile, encoding="utf-8")
    fmter = logging.Formatter(
        fmt="%(asctime)s [%(levelname)-8s] %(name)s %(message)s",
        datefmt="%Y-%m-%dT%H:%M:%S%z",
    )
    handler.setFormatter(fmter)
    root.addHandler(handler)

    lgr.info("[META] sys.argv = %r", sys.argv)
    lgr.info("[META] os.getcwd() = %s", os.getcwd())

    ctx.obj = SimpleNamespace(logfile=logfile)

    if pdb:
        map_to_click_exceptions._do_map = False
        from ..utils import setup_exceptionhook

        setup_exceptionhook()
    try:
        import etelemetry

        etelemetry.check_available_version("dandi/dandi-cli",
                                           __version__,
                                           lgr=lgr)
    except Exception as exc:
        lgr.warning(
            "Failed to check for a more recent version available with etelemetry: %s",
            exc,
        )
Пример #4
0
def main(args=None):
    """Main program function."""
    if args is None:
        namespace = parse_args(sys.argv[1:])
    else:
        namespace = parse_args(args)

    if namespace.verbosity is not None:
        utils.set_log_level(namespace.verbosity)

    logger.debug(vars(namespace))

    etelemetry_version = etelemetry.check_available_version(
        "ReproNim/neurodocker", __version__, lgr=logger)

    print("# Generated by: Neurodocker version {}".format(__version__))
    if etelemetry_version and 'version' in etelemetry_version:
        print("# Latest release: Neurodocker version {}".format(
            etelemetry_version["version"]))

    subparser_functions = {
        'docker': generate,
        'singularity': generate,
        'trace': reprozip_trace,
        'merge': reprozip_merge,
    }

    subparser_functions[namespace.subsubparser_name](namespace)
Пример #5
0
def check_latest_version():

    import etelemetry

    return etelemetry.check_available_version("nipype/pydra",
                                              __version__,
                                              lgr=logger)
def check_latest_version(raise_exception=False):
    """
    Check for the latest version of the library.

    Parameters
    ----------
    raise_exception: bool
        Raise a RuntimeError if a bad version is being used
    """
    import etelemetry

    logger = logging.getLogger("nipype.utils")
    return etelemetry.check_available_version("nipy/nipype", __version__,
                                              logger, raise_exception)
Пример #7
0
    def commented_header(self):

        etelemetry_version = etelemetry.check_available_version(
            "ReproNim/neurodocker", __version__)

        if etelemetry_version and "version" in etelemetry_version:
            latest = etelemetry_version["version"]
        else:
            latest = "unknown"

        t = datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S")
        header = f"""\
Generated by: Neurodocker version {__version__}
Latest release: Neurodocker version {latest}

Thank you for using Neurodocker. If you discover any issues
or ways to improve this software, please submit an issue or
pull request on our GitHub repository:

    https://github.com/ReproNim/neurodocker

Timestamp: {t} UTC"""
        return "# " + header.replace("\n", "\n# ") + "\n\n"
Пример #8
0
from __future__ import absolute_import, division, print_function
from .version import __version__
import __main__

if not hasattr(__main__, "__file__"):
    import etelemetry
    etelemetry.check_available_version("incf-nidash/pynidm", __version__)
Пример #9
0
# from .support.sshconnector import SSHManager
# ssh_manager = SSHManager()
#
import atexit
import reproman
import os
# atexit.register(ssh_manager.close, allow_fail=False)
atexit.register(lgr.log, 5, "Exiting")

from .version import __version__

try:
    import etelemetry

    etelemetry.check_available_version("repronim/reproman",
                                       __version__,
                                       lgr=lgr)
except Exception as exc:
    lgr.debug(
        "Failed to check for a more recent version available with etelemetry: %s",
        exc,
    )


def test(package='reproman', **kwargs):
    """A helper to run reproman's tests.  Requires numpy and pytest

    See numpy.testing.Tester -- **kwargs are passed into the
    Tester().test call
    """
    import pytest