Ejemplo n.º 1
0
def _store_dirac_environment():
    from GangaDirac.Lib.Utilities.DiracUtilities import write_env_cache
    platform = os.environ['CMTOPT']
    diracversion = Ganga.Utility.Config.getConfig('LHCb')['LHCbDiracVersion']
    fdir = os.path.join(os.path.expanduser("~/.cache/Ganga/GangaLHCb"), platform)
    fname = os.path.join(fdir, diracversion)
    if not os.path.exists(fname) or not os.path.getsize(fname):
        cmd =  'lb-run LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(version=diracversion)
        env = execute(cmd)
        if isinstance(env, str):
            try:
               env_temp = eval(env)
               env = env_temp

            except SyntaxError:
                logger.error("LHCbDirac version {version} does not exist".format(version=diracversion))
                raise OptionValueError("LHCbDirac version {version} does not exist".format(version=diracversion))
        try:
            write_env_cache(env, fname)
            logger.info("Storing new LHCbDirac environment (%s:%s)" % (str(diracversion), str(platform)))
        except (OSError, IOError, TypeError):
            logger.error("Unable to store LHCbDirac environment")
            raise
    logger.info("Using LHCbDirac version %s", diracversion)
    os.environ['GANGADIRACENVIRONMENT'] = fname
Ejemplo n.º 2
0
def store_dirac_environment():
    """Store the LHCbDIRAC environment in a cache file."""

#    platform_env_var = 'CMTCONFIG'
#    try:
#        platform = os.environ[platform_env_var]
#    except KeyError:
#        logger.error("Environment variable %s is missing. Can't cache LHCbDIRAC environment.", platform_env_var)
#        raise PluginError
    #While LHCbDirac is only available for gcc49 we shall unfortunately hard-code the platform.
    platform = 'x86_64-slc6-gcc49-opt'

    wildcard = Ganga.Utility.Config.getConfig('LHCb')['LHCbDiracVersion']
    diracversion = select_dirac_version(wildcard)
    fdir = join(expanduser("~/.cache/Ganga/GangaLHCb"), platform)
    fname = join(fdir, diracversion)
    if not exists(fname) or not getsize(fname):
        cmd = 'lb-run -c x86_64-slc6-gcc49-opt LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(version=diracversion)
        env = execute(cmd)
        if isinstance(env, str):
            try:
                env_temp = eval(env)
                env = env_temp

            except SyntaxError:
                logger.error("LHCbDirac version %s does not exist", diracversion)
                raise OptionValueError("LHCbDirac version {version} does not exist".format(version=diracversion))
        try:
            write_env_cache(env, fname)
            logger.info("Storing new LHCbDirac environment (%s:%s)",  str(diracversion), str(platform))
        except (OSError, IOError, TypeError):
            logger.error("Unable to store LHCbDirac environment")
            raise PluginError
    logger.info("Using LHCbDirac version %s", diracversion)
    os.environ['GANGADIRACENVIRONMENT'] = fname
Ejemplo n.º 3
0
def _store_dirac_environment():
    from GangaDirac.Lib.Utilities.DiracUtilities import write_env_cache
    platform = os.environ['CMTOPT']
    diracversion = Ganga.Utility.Config.getConfig('LHCb')['LHCbDiracVersion']
    fdir = os.path.join(os.path.expanduser("~/.cache/Ganga/GangaLHCb"),
                        platform)
    fname = os.path.join(fdir, diracversion)
    if not os.path.exists(fname) or not os.path.getsize(fname):
        cmd = 'lb-run LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(
            version=diracversion)
        env = execute(cmd)
        if isinstance(env, str):
            try:
                env_temp = eval(env)
                env = env_temp

            except SyntaxError:
                logger.error(
                    "LHCbDirac version {version} does not exist".format(
                        version=diracversion))
                raise OptionValueError(
                    "LHCbDirac version {version} does not exist".format(
                        version=diracversion))
        try:
            write_env_cache(env, fname)
            logger.info("Storing new LHCbDirac environment (%s:%s)" %
                        (str(diracversion), str(platform)))
        except (OSError, IOError, TypeError):
            logger.error("Unable to store LHCbDirac environment")
            raise
    logger.info("Using LHCbDirac version %s", diracversion)
    os.environ['GANGADIRACENVIRONMENT'] = fname
Ejemplo n.º 4
0
def _store_dirac_environment():
    from GangaDirac.Lib.Utilities.DiracUtilities import write_env_cache, get_env
    diracversion = _guess_version('LHCBDIRAC')
    platform = os.environ['CMTOPT']
    fdir = os.path.join(os.path.expanduser("~/.cache/Ganga/GangaLHCb"), platform)
    fname = os.path.join(fdir, diracversion)
    if not os.path.exists(fname) or not os.path.getsize(fname):
        logger.info("Storing new LHCbDirac environment (%s:%s)" % (str(diracversion), str(platform)))
        cmd = 'lb-run LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(version=diracversion)
        env = execute(cmd)  # grab the stdout text
        env = eval(env)  # env is a string so convert it to a dict
        write_env_cache(env, fname)
    os.environ['GANGADIRACENVIRONMENT'] = fname
Ejemplo n.º 5
0
def store_dirac_environment():
    """Store the LHCbDIRAC environment in a cache file."""

    #    platform_env_var = 'CMTCONFIG'
    #    try:
    #        platform = os.environ[platform_env_var]
    #    except KeyError:
    #        logger.error("Environment variable %s is missing. Can't cache LHCbDIRAC environment.", platform_env_var)
    #        raise PluginError
    #While LHCbDirac is only available for gcc49 we shall unfortunately hard-code the platform.
    platform = 'x86_64-slc6-gcc49-opt'

    wildcard = Ganga.Utility.Config.getConfig('LHCb')['LHCbDiracVersion']
    diracversion = select_dirac_version(wildcard)
    fdir = join(expanduser("~/.cache/Ganga/GangaLHCb"), platform)
    fname = join(fdir, diracversion)
    if not exists(fname) or not getsize(fname):
        cmd = 'lb-run -c x86_64-slc6-gcc49-opt LHCBDIRAC {version} python -c "import os; print(dict(os.environ))"'.format(
            version=diracversion)
        env = execute(cmd)
        if isinstance(env, str):
            try:
                env_temp = eval(env)
                env = env_temp

            except SyntaxError:
                logger.error("LHCbDirac version %s does not exist",
                             diracversion)
                raise OptionValueError(
                    "LHCbDirac version {version} does not exist".format(
                        version=diracversion))
        try:
            write_env_cache(env, fname)
            logger.info("Storing new LHCbDirac environment (%s:%s)",
                        str(diracversion), str(platform))
        except (OSError, IOError, TypeError):
            logger.error("Unable to store LHCbDirac environment")
            raise PluginError
    logger.info("Using LHCbDirac version %s", diracversion)
    os.environ['GANGADIRACENVIRONMENT'] = fname