Plotting histograms for several folders with a PyROOT loop

84 Views Asked by At

I would like to ask how to solve this error in my pyROOT code on lxplus (ssh server): This is two code sections:

def mkdir_p(path):
    #print "Making dir: ", path
    try:
        os.makedirs(path)
    except OSError as exc:  
        #print("OS error: {0}".format(exc))
        if exc.errno != errno.EEXIST:
          raise
        pass   
        if exc.errno == errno.EEXIST and os.path.isdir(path):
            pass
        #possibly handle other errno cases here, otherwise finally:
        else:
            raise Exception('Unknown exception')

def loop2Dir(hist1,hist2,spec1,spec2,n,opath=""):
    if hist1.IsA().InheritsFrom("TDirectoryFile") == True:
        opath = opath +"/"+hist2.GetName()
        mkdir_p(opath)
        a=0
        dic={}
        for key in hist2.GetListOfKeys():
            dic[key.GetName()]=key

And this is the output error on lxplus (ssh server):

Traceback (most recent call last):
  File "code_name.py", line 309, in <module>
    loop2Dir(obj1,obj2,specific,specific2,n,output_path_op)
  File "code_name.py", line 178, in loop2Dir
    loop2Dir(obj1,obj2,spec1,spec2,opath)
  File "code_name.py", line 178, in loop2Dir
    loop2Dir(obj1,obj2,spec1,spec2,opath)
  File "code_name.py", line 164, in loop2Dir
    mkdir_p(opath)
  File "code_name.py", line 9, in mkdir_p
    os.makedirs(path)
  File "/usr/lib64/python3.6/os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/DiTauHLT_Efficiency'

Any feedback is useful, thanks in advance.

To date my code can make only 1 directory and then the error appears in the output. I'm trying to make my code analyze 211 folders in a source path for plotting histograms from several .root files

1

There are 1 best solutions below

0
On

the problem seems to be in the directory creation permissions. Try to check that you have the necessary permissions