Example #1
0
    def test_directory(self):
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        assert(jobtree.pwd() == '/')

        jobtree.mkdir('testdir')

        # it is OK to mkdir an existing directory
        jobtree.mkdir('testdir')

        assert('testdir' in jobtree.ls()['folders'])

        jobtree.cd('testdir')
        assert(jobtree.pwd() == '/testdir')

        j = Job()
        jobtree.add(j)
        assert(str(j.id) in jobtree.ls()['jobs'])
        assert(str(j.id) in jobtree.ls('/testdir')['jobs'])

        jobtree.cd('..')
        assert(jobtree.pwd() == '/')

        assert(str(j.id) in jobtree.ls('/testdir')['jobs'])

        assert(str(j.id) not in jobtree.ls()['jobs'])

        jobtree.rm('/*')
Example #2
0
    def test_directory(self):
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        assert (jobtree.pwd() == '/')

        jobtree.mkdir('testdir')

        # it is OK to mkdir an existing directory
        jobtree.mkdir('testdir')

        assert ('testdir' in jobtree.ls()['folders'])

        jobtree.cd('testdir')
        assert (jobtree.pwd() == '/testdir')

        j = Job()
        jobtree.add(j)
        assert (str(j.id) in jobtree.ls()['jobs'])
        assert (str(j.id) in jobtree.ls('/testdir')['jobs'])

        jobtree.cd('..')
        assert (jobtree.pwd() == '/')

        assert (str(j.id) in jobtree.ls('/testdir')['jobs'])

        assert (str(j.id) not in jobtree.ls()['jobs'])

        jobtree.rm('/*')
Example #3
0
 def test_faults(self):
     from Ganga.GPI import jobtree, TreeError
     try:
         # add rubbish
         jobtree.add(1)
     except TreeError as x:
         pass
Example #4
0
 def test_faults(self):
     from Ganga.GPI import jobtree, TreeError
     try:
         # add rubbish
         jobtree.add(1)
     except TreeError as x:
         pass
Example #5
0
    def test_Savannah14799(self):
        from Ganga.GPI import Job, jobtree, jobs

        from Ganga.GPIDev.Base.Proxy import stripProxy
        j = Job()
        jobtree.add(j)
        self.assertNotEqual(
            stripProxy(j)._getRegistry(),
            stripProxy(jobtree)._getRegistry())
        self.assertTrue(str(j.id) in jobtree.listjobs())
        jt2 = jobtree.copy()
        self.assertTrue(str(j.id) in jt2.listjobs())
        jobs(j.id).remove()
        jt2.cleanlinks()

        self.assertFalse(str(j.id) in jobtree.listjobs())
        print jt2.listjobs()
        print jt2
        self.assertFalse(str(j.id) in jt2.listjobs())
        jt3 = jobtree.copy()
        l1 = jobtree.listjobs()
        l3 = jt3.listjobs()
        l1.sort()
        l3.sort()

        self.assertEqual(l1, l3)
Example #6
0
    def test_clean(self):  # asaroka
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('testdir')
        jobtree.add(Job())
        print("%s" % jobtree)
        jobtree.add(Job(), 'testdir')

        jobtree.rm('/*')
        assert (jobtree.listjobs('/') == [])
        assert (jobtree.listdirs('/') == [])
Example #7
0
    def test_clean(self):  # asaroka
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('testdir')
        jobtree.add(Job())
        print("%s" % jobtree)
        jobtree.add(Job(), 'testdir')

        jobtree.rm('/*')
        assert(jobtree.listjobs('/') == [])
        assert(jobtree.listdirs('/') == [])
Example #8
0
    def test_find_job(self):  # asaroka
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('a')
        jobtree.mkdir('b')

        j1 = Job(name='j1')
        j2 = Job(name='j2')

        jobtree.add(j1, 'a')
        jobtree.add(j2, 'a')
        jobtree.add(j2, 'b')

        # Make sure we find correct locations
        assert ('/a' in jobtree.find(j1))
        assert ('/a' in jobtree.find(j2))
        assert ('/b' in jobtree.find(j2))

        # Look for rubbish
        assert (jobtree.find(j1.application) == [])

        jobtree.rm('b')
        jobtree.rm('a')

        jobtree.rm('/*')
Example #9
0
    def test_find_job(self):  # asaroka
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('a')
        jobtree.mkdir('b')

        j1 = Job(name='j1')
        j2 = Job(name='j2')

        jobtree.add(j1, 'a')
        jobtree.add(j2, 'a')
        jobtree.add(j2, 'b')

        # Make sure we find correct locations
        assert('/a' in jobtree.find(j1))
        assert('/a' in jobtree.find(j2))
        assert('/b' in jobtree.find(j2))

        # Look for rubbish
        assert(jobtree.find(j1.application) == [])

        jobtree.rm('b')
        jobtree.rm('a')

        jobtree.rm('/*')
Example #10
0
    def test_find(self):  # uegede
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('a')
        jobtree.mkdir('b')

        j1 = Job(name='j1')
        j2 = Job(name='j2')

        jobtree.listdirs()
        jobtree.add(j1, 'a')
        jobtree.add(j2, 'a')
        jobtree.add(j2, 'b')

        # Make sure we find correct locations
        assert('/a' in jobtree.find(str(j1.id)))
        assert('/a' in jobtree.find(str(j2.id)))
        assert('/b' in jobtree.find(str(j2.id)))

        # Look for rubbish
        assert(jobtree.find(-1) == [])

        jobtree.rm('b')
        jobtree.rm('a')

        jobtree.rm('/*')
Example #11
0
    def test_find(self):  # uegede
        from Ganga.GPI import jobtree, Job
        jobtree.cd()
        jobtree.mkdir('a')
        jobtree.mkdir('b')

        j1 = Job(name='j1')
        j2 = Job(name='j2')

        jobtree.listdirs()
        jobtree.add(j1, 'a')
        jobtree.add(j2, 'a')
        jobtree.add(j2, 'b')

        # Make sure we find correct locations
        assert ('/a' in jobtree.find(str(j1.id)))
        assert ('/a' in jobtree.find(str(j2.id)))
        assert ('/b' in jobtree.find(str(j2.id)))

        # Look for rubbish
        assert (jobtree.find(-1) == [])

        jobtree.rm('b')
        jobtree.rm('a')

        jobtree.rm('/*')
Example #12
0
    def test_addremove(self):
        from Ganga.GPI import jobtree, Job
        jobtree.cd()

        # make sure the job is really added
        j = Job()
        jobtree.add(j)
        assert (str(j.id) in jobtree.ls()['jobs'])

        # make sure the addition is not automatic
        j2 = Job()
        assert (not str(j2.id) in jobtree.ls()['jobs'])

        try:
            jobtree.rm(j2.id)
        except TreeError as x:
            pass

        # make sure the job may be deleted
        jobtree.rm(j.id)

        jobtree.rm('/*')
Example #13
0
    def test_addremove(self):
        from Ganga.GPI import jobtree, Job
        jobtree.cd()

        # make sure the job is really added
        j = Job()
        jobtree.add(j)
        assert(str(j.id) in jobtree.ls()['jobs'])

        # make sure the addition is not automatic
        j2 = Job()
        assert(not str(j2.id) in jobtree.ls()['jobs'])

        try:
            jobtree.rm(j2.id)
        except TreeError as x:
            pass

        # make sure the job may be deleted
        jobtree.rm(j.id)

        jobtree.rm('/*')
Example #14
0
    def test_Savannah14799(self):
        from Ganga.GPI import Job, jobtree, jobs

        from Ganga.GPIDev.Base.Proxy import stripProxy
        j = Job()
        jobtree.add(j)
        self.assertNotEqual(stripProxy(j)._getRegistry(), stripProxy(jobtree)._getRegistry())
        self.assertTrue(str(j.id) in jobtree.listjobs())
        jt2 = jobtree.copy()
        self.assertTrue(str(j.id) in jt2.listjobs())
        jobs(j.id).remove()
        jt2.cleanlinks()

        self.assertFalse(str(j.id) in jobtree.listjobs())
        print jt2.listjobs()
        print jt2
        self.assertFalse(str(j.id) in jt2.listjobs())
        jt3 = jobtree.copy()
        l1 = jobtree.listjobs()
        l3 = jt3.listjobs()
        l1.sort()
        l3.sort()

        self.assertEqual(l1, l3)
Example #15
0
    def test_i_MiscellaneousFunctionality(self):
        from Ganga.GPI import JobTemplate, Local, Job, templates, jobtree

        # -- MISCFUNCTIONALITY TEMPLATE1 START
        j = JobTemplate()
        j.name = 'LsExeLocal'
        j.application.exe = 'ls'
        j.backend = Local()
        # -- MISCFUNCTIONALITY TEMPLATE1 STOP

        # -- MISCFUNCTIONALITY TEMPLATE2 START
        templates
        # -- MISCFUNCTIONALITY TEMPLATE2 STOP

        # -- MISCFUNCTIONALITY TEMPLATE3 START
        j = Job(templates[0], name = 'JobFromTemplate')
        j.submit()
        # -- MISCFUNCTIONALITY TEMPLATE3 STOP

        # -- MISCFUNCTIONALITY JOBTREE START
        # show the current job tree (empty to start with)
        jobtree

        # make some dirs and subdirs
        jobtree.mkdir('test_old')
        jobtree.mkdir('test')
        jobtree.mkdir('prod')
        jobtree.mkdir('/test/jan')
        jobtree.mkdir('/prod/full')

        # have a look at the tree
        jobtree.printtree()

        # remove a dir
        jobtree.rm('test_old')

        # create some jobs and add them
        jobtree.cd('/test/jan')
        jobtree.add( Job() )
        jobtree.cd('/prod/full')
        jobtree.add(Job())
        jobtree.add(Job())

        # look at the tree again
        jobtree.printtree()

        # submit the some jobs
        jobtree.getjobs().submit()
Example #16
0
    def test_i_MiscellaneousFunctionality(self):
        from Ganga.GPI import JobTemplate, Local, Job, templates, jobtree

        # -- MISCFUNCTIONALITY TEMPLATE1 START
        j = JobTemplate()
        j.name = 'LsExeLocal'
        j.application.exe = 'ls'
        j.backend = Local()
        # -- MISCFUNCTIONALITY TEMPLATE1 STOP

        # -- MISCFUNCTIONALITY TEMPLATE2 START
        templates
        # -- MISCFUNCTIONALITY TEMPLATE2 STOP

        # -- MISCFUNCTIONALITY TEMPLATE3 START
        j = Job(templates[0], name='JobFromTemplate')
        j.submit()
        # -- MISCFUNCTIONALITY TEMPLATE3 STOP

        # -- MISCFUNCTIONALITY JOBTREE START
        # show the current job tree (empty to start with)
        jobtree

        # make some dirs and subdirs
        jobtree.mkdir('test_old')
        jobtree.mkdir('test')
        jobtree.mkdir('prod')
        jobtree.mkdir('/test/jan')
        jobtree.mkdir('/prod/full')

        # have a look at the tree
        jobtree.printtree()

        # remove a dir
        jobtree.rm('test_old')

        # create some jobs and add them
        jobtree.cd('/test/jan')
        jobtree.add(Job())
        jobtree.cd('/prod/full')
        jobtree.add(Job())
        jobtree.add(Job())

        # look at the tree again
        jobtree.printtree()

        # submit the some jobs
        jobtree.getjobs().submit()
Example #17
0
    def Savannah74531(self):
        from Ganga.GPI import Job, jobs, jobtree

        index = 10
        while index > 0:
            Job()
            index -= 1

        testSlice = jobs[0:4]
        testList1 = jobs.select(4, 7)
        testList2 = [jobs[8], jobs[9]]

        jobtree.cd()
        jobtree.mkdir('testTreeOne')

        jobtree.add(testSlice, 'testTreeOne')
        jobtree.add(testList1, 'testTreeOne')
        jobtree.add(testList2, 'testTreeOne')

        jobtree.rm('testTreeOne')
Example #18
0
    def Savannah74531(self):
        from Ganga.GPI import Job, jobs, jobtree

        index = 10
        while index > 0:
           Job()
           index -= 1

        testSlice = jobs[0:4]
        testList1 = jobs.select(4, 7)
        testList2 = [jobs[8], jobs[9]]

        jobtree.cd()
        jobtree.mkdir('testTreeOne')

        jobtree.add(testSlice, 'testTreeOne')
        jobtree.add(testList1, 'testTreeOne')
        jobtree.add(testList2, 'testTreeOne')

        jobtree.rm('testTreeOne')