Esempio n. 1
0
    def test_e_testXMLContent(self):
        # Check content of XML is as expected
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs, Job
        from Ganga.GPIDev.Base.Proxy import stripProxy

        from tempfile import NamedTemporaryFile

        j = jobs(0)
        assert path.isfile(getXMLFile(j))
        with open(getXMLFile(j)) as handler:
            tmpobj, errs = from_file(handler)

            assert hasattr(tmpobj, 'name')

            assert tmpobj.name == testStr

            ignore_subs = [
                'time', 'subjobs', 'info', 'application', 'backend', 'id'
            ]

            with NamedTemporaryFile(delete=False) as new_temp_file:
                temp_name = new_temp_file.name

                to_file(stripProxy(j), new_temp_file, ignore_subs)
                new_temp_file.flush()

            with NamedTemporaryFile(delete=False) as new_temp_file2:
                temp_name2 = new_temp_file2.name

                j2 = Job()
                j2.name = testStr
                j2.submit()
                from GangaTest.Framework.utils import sleep_until_completed
                sleep_until_completed(j2)

                to_file(stripProxy(j2), new_temp_file2, ignore_subs)
                new_temp_file2.flush()

            #import filecmp
            #assert filecmp.cmp(handler.name, new_temp_file.name)
            #assert not filecmp.cmp(new_temp_file.name, new_temp_file2.name)

            #assert open(getXMLFile(j)).read() == open(temp_name).read()
            assert open(temp_name).read() == open(temp_name2).read()

            unlink(temp_name)
            unlink(temp_name2)
Esempio n. 2
0
    def test_e_testXMLContent(self):
        # Check content of XML is as expected
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs, Job
        from Ganga.GPIDev.Base.Proxy import stripProxy

        from tempfile import NamedTemporaryFile

        j = jobs(0)
        assert path.isfile(getXMLFile(j))
        with open(getXMLFile(j)) as handler:
            tmpobj, errs = from_file(handler)

            assert hasattr(tmpobj, 'name')

            assert tmpobj.name == testStr

            ignore_subs = ['time', 'subjobs', 'info', 'application', 'backend', 'id']

            with NamedTemporaryFile(delete=False) as new_temp_file:
                temp_name = new_temp_file.name


                to_file(stripProxy(j), new_temp_file, ignore_subs)
                new_temp_file.flush()

            with NamedTemporaryFile(delete=False) as new_temp_file2:
                temp_name2 = new_temp_file2.name

                j2 = Job()
                j2.name = testStr
                j2.submit()
                from GangaTest.Framework.utils import sleep_until_completed
                sleep_until_completed(j2)

                to_file(stripProxy(j2), new_temp_file2, ignore_subs)
                new_temp_file2.flush()

            #import filecmp
            #assert filecmp.cmp(handler.name, new_temp_file.name)
            #assert not filecmp.cmp(new_temp_file.name, new_temp_file2.name)

            #assert open(getXMLFile(j)).read() == open(temp_name).read()
            assert open(temp_name).read() == open(temp_name2).read()

            unlink(temp_name)
            unlink(temp_name2)
Esempio n. 3
0
    def test_g_testSJXMLContent(self):
        # Check SJ content
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs
        from tempfile import NamedTemporaryFile
        from Ganga.GPIDev.Base.Proxy import stripProxy

        ignore_subs = [
            'subjobs', 'time', 'backend', 'id', 'splitter', 'info',
            'application', 'inputdata'
        ]

        with NamedTemporaryFile(delete=False) as new_temp_file_a:
            temp_name_a = new_temp_file_a.name

            j = jobs(0)
            to_file(stripProxy(j), new_temp_file_a, ignore_subs)
            new_temp_file_a.flush()

        counter = 0
        for sj in j.subjobs:
            XMLFileName = getSJXMLFile(sj)
            assert path.isfile(XMLFileName)

            with open(XMLFileName) as handler:
                tmpobj, errs = from_file(handler)
                assert hasattr(tmpobj, 'id')
                assert tmpobj.id == counter

                with NamedTemporaryFile(delete=False) as new_temp_file:
                    temp_name = new_temp_file.name
                    to_file(stripProxy(sj), new_temp_file, ignore_subs)
                    new_temp_file.flush()

                #import filecmp
                #assert filecmp.cmp(XMLFileName, temp_name)
                assert open(temp_name_a).read() == open(temp_name).read()
                unlink(temp_name)

            counter += 1

        assert counter == len(jobs(0).subjobs)
        unlink(temp_name_a)
Esempio n. 4
0
    def test_f_testXMLContent(self):
        # Check their content
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs, Job
        from Ganga.GPIDev.Base.Proxy import stripProxy

        from tempfile import NamedTemporaryFile

        j = jobs(0)
        XMLFileName = getXMLFile(j)
        assert path.isfile(XMLFileName)
        with open(XMLFileName) as handler:
            tmpobj, errs = from_file(handler)

            assert hasattr(tmpobj, 'name')

            assert tmpobj.name == testStr

            ignore_subs = [
                'status', 'subjobs', 'time', 'backend', 'id', 'splitter',
                'info', 'application'
            ]

            with NamedTemporaryFile(delete=False) as new_temp_file:
                temp_name = new_temp_file.name

                to_file(stripProxy(j), new_temp_file, ignore_subs)
                new_temp_file.flush()

            with NamedTemporaryFile(delete=False) as new_temp_file2:
                temp_name2 = new_temp_file2.name

                j2 = Job()
                j2.name = testStr

                to_file(stripProxy(j2), new_temp_file2, ignore_subs)
                new_temp_file2.flush()

            #assert open(XMLFileName).read() == open(temp_name).read()
            assert open(temp_name).read() == open(temp_name2).read()

            unlink(temp_name)
            unlink(temp_name2)
Esempio n. 5
0
    def write_subJobIndex(self):

        all_caches = {}
        for i in range(len(self)):
            this_cache = self._registry.getIndexCache( self.__getitem__(i) )
            all_caches[i] = this_cache
            disk_location = self.__get_dataFile(i)
            import os
            all_caches[i]['modified'] = os.stat(disk_location).st_ctime

        import os.path
        try:
            from Ganga.Core.GangaRepository.PickleStreamer import to_file
            index_file = os.path.join(self._jobDirectory, self._subjob_master_index_name )
            index_file_obj = open( index_file, "w" )
            to_file( all_caches, index_file_obj )
            index_file_obj.close()
        except Exception, err:
            logger.debug( "cache write error: %s" % str(err) )
Esempio n. 6
0
    def test_g_testSJXMLContent(self):
        # Check SJ content
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs
        from tempfile import NamedTemporaryFile
        from Ganga.GPIDev.Base.Proxy import stripProxy

        ignore_subs = ['subjobs', 'time', 'backend', 'id', 'splitter', 'info', 'application', 'inputdata']

        with NamedTemporaryFile(delete=False) as new_temp_file_a:
            temp_name_a = new_temp_file_a.name

            j=jobs(0)
            to_file(stripProxy(j), new_temp_file_a, ignore_subs)
            new_temp_file_a.flush()

        counter = 0
        for sj in j.subjobs:
            XMLFileName = getSJXMLFile(sj)
            assert path.isfile(XMLFileName)

            with open(XMLFileName) as handler:
                tmpobj, errs = from_file(handler)
                assert hasattr(tmpobj, 'id')
                assert tmpobj.id == counter

                with NamedTemporaryFile(delete=False) as new_temp_file:
                    temp_name = new_temp_file.name
                    to_file(stripProxy(sj), new_temp_file, ignore_subs)
                    new_temp_file.flush()

                #import filecmp
                #assert filecmp.cmp(XMLFileName, temp_name)
                assert open(temp_name_a).read() == open(temp_name).read()
                unlink(temp_name)

            counter+=1

        assert counter == len(jobs(0).subjobs)
        unlink(temp_name_a)
Esempio n. 7
0
    def test_f_testXMLContent(self):
        # Check their content
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs, Job
        from Ganga.GPIDev.Base.Proxy import stripProxy

        from tempfile import NamedTemporaryFile

        j=jobs(0)
        XMLFileName = getXMLFile(j)
        assert path.isfile(XMLFileName)
        with open(XMLFileName) as handler:
            tmpobj, errs = from_file(handler)

            assert hasattr(tmpobj, 'name')

            assert tmpobj.name == testStr

            ignore_subs = ['status', 'subjobs', 'time', 'backend', 'id', 'splitter', 'info', 'application']

            with NamedTemporaryFile(delete=False) as new_temp_file:
                temp_name = new_temp_file.name

                to_file(stripProxy(j), new_temp_file, ignore_subs)
                new_temp_file.flush()

            with NamedTemporaryFile(delete=False) as new_temp_file2:
                temp_name2 = new_temp_file2.name

                j2=Job()
                j2.name=testStr

                to_file(stripProxy(j2), new_temp_file2, ignore_subs)
                new_temp_file2.flush()

            #assert open(XMLFileName).read() == open(temp_name).read()
            assert open(temp_name).read() == open(temp_name2).read()

            unlink(temp_name)
            unlink(temp_name2)
Esempio n. 8
0
    def test_d_testXMLContent(self):
        # Check content of XML is as expected
        from Ganga.Core.GangaRepository.VStreamer import to_file, from_file

        from Ganga.GPI import jobs, Job, ArgSplitter
        from Ganga.GPIDev.Base.Proxy import stripProxy

        from tempfile import NamedTemporaryFile

        j = jobs(0)
        assert path.isfile(getXMLFile(j))
        with open(getXMLFile(j)) as handler:
            tmpobj, errs = from_file(handler)

            assert tmpobj.splitter
            assert tmpobj.splitter.args == getNestedList()

            ignore_subs = ''

            with NamedTemporaryFile(delete=False) as new_temp_file:

                to_file(stripProxy(j), new_temp_file, ignore_subs)
                new_temp_file.flush()

            with NamedTemporaryFile(delete=False) as new_temp_file2:
                j2 = Job()
                j2.splitter = ArgSplitter()
                j2.splitter.args = getNestedList()

                to_file(stripProxy(j2), new_temp_file2, ignore_subs)
                new_temp_file2.flush()

            assert open(handler.name).read() == open(new_temp_file.name).read()
            assert open(handler.name) != open(new_temp_file2.name).read()

            unlink(new_temp_file.name)
            unlink(new_temp_file2.name)