コード例 #1
0
ファイル: GangaUnitTest.py プロジェクト: pseyfert/ganga
def emptyRepositories():
    """
    A method which attempts to remove jobs from various repositories in a sane manner,
    This is preferred to just shutting down and runnning rm -fr ... as it catches a few errors hard to test for
    """
    from Ganga.Utility.logging import getLogger
    logger = getLogger()
    # empty repository so we start again at job 0 when we restart
    logger.info("Clearing the Job and Template repositories")

    from Ganga.GPI import jobs, templates, tasks
    for j in jobs:
        try:
            j.remove()
        except:
            pass
    for t in templates:
        try:
            t.remove()
        except:
            pass
    for t in tasks:
        try:
            t.remove(remove_jobs=True)
        except:
            pass
    if hasattr(jobs, 'clean'):
        jobs.clean(confirm=True, force=True)
    if hasattr(templates, 'clean'):
        templates.clean(confirm=True, force=True)
    if hasattr(tasks, 'clean'):
        tasks.clean(confirm=True, force=True)
コード例 #2
0
ファイル: GangaUnitTest.py プロジェクト: datty/ganga
def emptyRepositories():
    """
    A method which attempts to remove jobs from various repositories in a sane manner,
    This is preferred to just shutting down and runnning rm -fr ... as it catches a few errors hard to test for
    """
    from Ganga.Utility.logging import getLogger
    logger = getLogger()
    # empty repository so we start again at job 0 when we restart
    logger.info("Clearing the Job and Template repositories")

    from Ganga.GPI import jobs, templates, tasks
    for j in jobs:
        try:
            j.remove()
        except:
            pass
    for t in templates:
        try:
            t.remove()
        except:
            pass
    for t in tasks:
        try:
            t.remove(remove_jobs=True)
        except:
            pass
    if hasattr(jobs, 'clean'):
        jobs.clean(confirm=True, force=True)
    if hasattr(templates, 'clean'):
        templates.clean(confirm=True, force=True)
    if hasattr(tasks, 'clean'):
        tasks.clean(confirm=True, force=True)
コード例 #3
0
ファイル: GangaUnitTest.py プロジェクト: mesmith75/ganga
def emptyRepositories():
    from Ganga.Utility.logging import getLogger
    logger = getLogger()
    # empty repository so we start again at job 0 when we restart
    logger.info("Clearing the Job and Template repositories")

    from Ganga.GPI import jobs, templates, tasks
    for j in jobs:
        try:
            j.remove()
        except:
            pass
    for t in templates:
        try:
            t.remove()
        except:
            pass
    for t in tasks:
        try:
            t.remove(remove_jobs=True)
        except:
            pass
    if hasattr(jobs, 'clean'):
        jobs.clean(confirm=True, force=True)
    if hasattr(templates, 'clean'):
        templates.clean(confirm=True, force=True)
    if hasattr(tasks, 'clean'):
        tasks.clean(confirm=True, force=True)
コード例 #4
0
ファイル: GangaUnitTest.py プロジェクト: alexpearce/ganga
def stop_ganga():

    from Ganga.Utility.logging import getLogger
    logger = getLogger()

    logger.info("Deciding how to shutdown")

    # Do we want to empty the repository on shutdown?
    from Ganga.Utility.Config import getConfig
    if 'AutoCleanup' in getConfig('TestingFramework'):
        whole_cleanup = getConfig('TestingFramework')['AutoCleanup']
    else:
        whole_cleanup = True

    logger.info("AutoCleanup: %s" % whole_cleanup)

    if whole_cleanup is True:
        # empty repository so we start again at job 0 when we restart
        logger.info("Clearing the Job and Template repositories")

        from Ganga.GPI import jobs, templates
        for j in jobs:
            try:
                j.remove()
            except:
                pass
        for t in templates:
            try:
                t.remove()
            except:
                pass
        if hasattr(jobs, 'clean'):
            jobs.clean(confirm=True, force=True)
        if hasattr(templates, 'clean'):
            templates.clean(confirm=True, force=True)

    logger.info("Shutting Down Internal Services")

    # Disable internal services such as monitoring and other tasks
    #from Ganga.Core.InternalServices import Coordinator
    # if Coordinator.servicesEnabled:
    #    Coordinator.disableInternalServices()
    #    Coordinator.servicesEnabled = False

    logger.info("Mimicking ganga exit")
    from Ganga.Core.InternalServices import ShutdownManager

    import Ganga.Core
    Ganga.Core.change_atexitPolicy(interactive_session=False, new_policy='batch')
    # This should now be safe
    ShutdownManager._ganga_run_exitfuncs()

    # Undo any manual editing of the config and revert to defaults
    from Ganga.Utility.Config import allConfigs
    for package in allConfigs.values():
        package.revertToDefaultOptions()

    # Finished
    logger.info("Test Finished")
コード例 #5
0
ファイル: GangaUnitTest.py プロジェクト: slangrock/ganga
def stop_ganga():

    import Ganga.Utility.logging
    logger = Ganga.Utility.logging.getLogger()

    logger.info("Deciding how to shutdown")

    # Do we want to empty the repository on shutdown?
    from Ganga.Utility.Config import getConfig
    if 'AutoCleanup' in getConfig('TestingFramework'):
        whole_cleanup = getConfig('TestingFramework')['AutoCleanup']
    else:
        whole_cleanup = True

    if whole_cleanup:
        # empty repository so we start again at job 0 when we restart
        logger.info("Clearing the Job and Template repositories")

        from Ganga.GPI import jobs, templates
        for j in jobs:
            try:
                j.remove()
            except:
                pass
        for t in templates:
            try:
                t.remove()
            except:
                pass
        if hasattr(jobs, 'clean'):
            jobs.clean(confirm=True, force=True)
        if hasattr(templates, 'clean'):
            templates.clean(confirm=True, force=True)

    logger.info("Shutting Down Internal Services")

    # Disable internal services such as monitoring and other tasks
    #from Ganga.Core.InternalServices import Coordinator
    # if Coordinator.servicesEnabled:
    #    Coordinator.disableInternalServices()
    #    Coordinator.servicesEnabled = False

    logger.info("Mimicking ganga exit")
    from Ganga.Core.InternalServices import ShutdownManager

    import Ganga.Core
    Ganga.Core.change_atexitPolicy(interactive_session=False, new_policy='batch')
    # This should now be safe
    ShutdownManager._ganga_run_exitfuncs()

    # Finished
    logger.info("Test Finished")
コード例 #6
0
ファイル: GangaUnitTest.py プロジェクト: chrisburr/ganga
def stopGanga():

    import Ganga.Utility.logging
    logger = Ganga.Utility.logging.getLogger()

    logger.info("Deciding how to shutdown")

    # Do we want to empty the repository on shutdown?
    from Ganga.Utility.Config import getConfig
    if 'AutoCleanup' in getConfig('TestingFramework'):
        wholeCleanup = getConfig('TestingFramework')['AutoCleanup']
    else:
        wholeCleanup = True

    if wholeCleanup:
        # empty repository so we start again at job 0 when we restart
        logger.info("Clearing the Job and Template repositories")

        from Ganga.GPI import jobs, templates
        for j in jobs:
            j.remove()
        for t in templates:
            t.remove()
        if hasattr(jobs, 'clean'):
            jobs.clean(confirm=True, force=True)
        if hasattr(templates, 'clean'):
            templates.clean(confirm=True, force=True)

    logger.info("Shutting Down Internal Services")

    # Disable internal services such as monitoring and other tasks
    #from Ganga.Core.InternalServices import Coordinator
    # if Coordinator.servicesEnabled:
    #    Coordinator.disableInternalServices()
    #    Coordinator.servicesEnabled = False

    logger.info("Mimicking ganga exit")
    from Ganga.Core.InternalServices import ShutdownManager

    import Ganga.Core
    Ganga.Core.change_atexitPolicy('batch')
    # This should now be safe
    ShutdownManager._ganga_run_exitfuncs()

    # Finished
    logger.info("Test Finished")