Beispiel #1
0
 def do_ls(self, args=''):
     """List contents of a directory/file"""
     opts = self.ls_parser.parse_args(args.split())
     if opts.paths:          # w/ args
         for path in opts.paths:
             isdir = self.rdir_helper.get_dir(path)
             indent = ''
             if isdir:
                 if not isinstance(isdir, ROOT.TFile):
                     # convert to TKey when TDirectoryFile
                     dirname = isdir.GetName()
                     with savepwd():
                         isdir.cd('..')
                         # read the latest cycle
                         isdir = filter(lambda k: k.GetName() == dirname,
                                        gDirectory.GetListOfKeys())[0]
                 self.print_key(isdir, self.get_ls_fmt(opts.showtype))
                 indent = ' '
             keys = self.rdir_helper.ls(path)
             try:
                 self.ls_objs(keys, opts.showtype, indent)
             except ValueError as err:
                 print(str(err).format('ls', path))
     else:                     # no args
         if gROOT == self.pwd:
             # can't access files trivially when in root
             for f in gROOT.GetListOfFiles():
                 self.print_key(f, self.get_ls_fmt(opts.showtype))
         else:               # in a file
             try:
                 self.ls_objs(self.rdir_helper.ls(), opts.showtype)
             except ValueError as err:
                 print(str(err).format('ls', ''))
                 print('Warning: this shouldn\'t happen, something went '
                       'terribly wrong!')
Beispiel #2
0
 def test_restore_fail(self):
     self.dir1.cd()
     oldpwd = gDirectory.GetName()
     try:
         with savepwd():
             self.dir2.cd()
             raise KeyboardInterrupt('Testing')
     except KeyboardInterrupt:
         pass
     self.assertEqual(oldpwd, gDirectory.GetName())
Beispiel #3
0
 def test_restore_fail(self):
     self.dir1.cd()
     oldpwd = gDirectory.GetName()
     try:
         with savepwd():
             self.dir2.cd()
             raise KeyboardInterrupt('Testing')
     except KeyboardInterrupt:
         pass
     self.assertEqual(oldpwd, gDirectory.GetName())
Beispiel #4
0
 def do_ls(self, args=''):
     """List contents of a directory/file"""
     opts = self.ls_parser.parse_args(args.split())
     if opts.paths:  # w/ args
         for path in opts.paths:
             isdir = self.rdir_helper.get_dir(path)
             indent = ''
             if isdir:
                 if not isinstance(isdir, ROOT.TFile):
                     # convert to TKey when TDirectoryFile
                     dirname = isdir.GetName()
                     with savepwd():
                         isdir.cd('..')
                         # read the latest cycle
                         isdir = filter(lambda k: k.GetName() == dirname,
                                        gDirectory.GetListOfKeys())[0]
                 self.print_key(isdir, self.get_ls_fmt(opts.showtype))
                 indent = ' '
             keys = self.rdir_helper.ls(path)
             try:
                 self.ls_objs(keys, opts.showtype, indent)
             except ValueError as err:
                 print(str(err).format('ls', path))
     else:  # no args
         if gROOT == self.pwd:
             # can't access files trivially when in root
             for f in gROOT.GetListOfFiles():
                 self.print_key(f, self.get_ls_fmt(opts.showtype))
         else:  # in a file
             try:
                 self.ls_objs(self.rdir_helper.ls(), opts.showtype)
             except ValueError as err:
                 print(str(err).format('ls', ''))
                 print(
                     'Warning: this shouldn\'t happen, something went '
                     'terribly wrong!')
Beispiel #5
0
 def test_restore_pass(self):
     self.dir1.cd()
     oldpwd = gDirectory.GetName()
     with savepwd():
         self.dir2.cd()
     self.assertEqual(oldpwd, gDirectory.GetName())
Beispiel #6
0
 def test_restore_pass(self):
     self.dir1.cd()
     oldpwd = gDirectory.GetName()
     with savepwd():
         self.dir2.cd()
     self.assertEqual(oldpwd, gDirectory.GetName())