Beispiel #1
0
    def checkFile_root(self, f, tname):
        tf = None
        try:
            tf = r.TFile.Open(f)
        except IOError as e:
            print "I/O error({0}): {1}".format(e.errno, e.strerror)
        except ValueError:
            print "Could read the file"
        except:
            print "Unexpected error:", sys.exc_info()[0]
            print 'file ===%s=== must be deleted' % f
            #os.system('rm %s'%f)
            return -1, False

        tf = r.TFile.Open(f)
        tt = None
        try:
            tt = tf.Get(tname)
            if tt == None:
                print 'file ===%s=== must be deleted' % f
                #os.system('rm %s'%f)
                return -1, False

        except IOError as e:
            print "I/O error({0}): {1}".format(e.errno, e.strerror)
        except ValueError:
            print "Could read the file"
        except:
            print "Unexpected error:", sys.exc_info()[0]
            print 'file ===%s=== must be deleted' % f
            #os.system('rm %s'%f)
            return -1, False

        if not ut.isValidROOTfile(f):
            return -1, False

        f = r.TFile.Open(f)
        tt = tf.Get(tname)
        nentries = tt.GetEntries()
        if nentries == 0:
            print 'file has 0 entries ===%s=== must be deleted' % f
            return 0, False

        print '%i events in the file, job is good' % nentries
        return int(nentries), True
Beispiel #2
0
                            'out']
                        size = os.path.getsize(j['out'])
                        print 'file size  :  ', size, '  ', type(size)
                        if size == 0:
                            print 'bad job'
                            j['status'] = 'failed'
                            os.system('rm %s' % (j['out']))
                        else:
                            print "size ok %s please check" % j['out']

##########################################################
#For ROOT files
##########################################################

                if '.root' in j['out']:
                    if not ut.isValidROOTfile(j['out']):
                        print 'corrupt file'
                        j['status'] = 'failed'
                        continue

                    f = r.TFile.Open(j['out'])
                    if f:
                        size = os.path.getsize(j['out'])
                        print '--------------------   ', size
                        if size == 0:
                            print 'bad job'
                            j['status'] = 'failed'

                        else:
                            lok = [
                                key.GetName()