Accesing EEnvLevel for TEnv in pyROOT

Hi ROOT users,

I was wondering if anyone has worked with a TEnv in pyROOT. My problem involves accessing EEnvLevel. My impression is that it should be import with TEnv, but I am unsure how to access kEnvUser, kEnvAll, etc. In fact, solving this would also assist me in accessing other enumerations within ROOT, such as with TColor default colors all beginning with k. Below is the test code I am using before performing an extended implementation in some analysis.

#!/usr/bin/env python

from os import environ
from sys import path

path.append(environ["ROOTSYS"] + "/lib")

from ROOT import TEnv


env = TEnv('MyTestTEnv')
env.SetValue('Test',1)
env.SaveLevel(kEnvUser)
env.WriteFile('MyTestTEnv.config')

env1 = TEnv('MyTestTEnv_Read')
env1.ReadFile('MyTestTEnv.config',kEnvUser)
env1.PrintEnv()

The above code fails at the second to last line in attempting to read the file. Python is not recognizing the kEnvUser and needs this to read in the file. I would also like to save the file with kEnvUser, but I can do that once I have access to the variables.

Any help to access to these enumerated variables in pyROOT would be great.

Cheers,

Sebastian

My ROOT version, platform, and compiler are below:


ROOT Version (6.08/06):
Platform, compiler (CentOS 7.2.1511, gcc4.8.5):


Hi @sebbyx3,

You need to import kEnvUser as well:

from ROOT import TEnv, kEnvUser

Cheers,

Enric

Thanks Enric. That worked immediately. I had tried TEnv.kEnvUser, but it must be that kEnvUser is not a instance of TEnv.

Cheers,

Sebastian

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.