예제 #1
0
 def test_full(self):
     xfile = GSMBBSFileSource('test', 0, 'tests/data/full_file.dat')
     self.assertTrue(xfile.read_and_store_data(self.conn))
     g_major =self.conn.exec_return('select g_major ' \
                                      'from detections where lra < 123.0;')
     self.assertEqual(g_major, 0.0)
     g_major =self.conn.exec_return('select g_major ' \
                                      'from detections where lra > 125.6;')
     self.assertEqual(g_major, 0.101701)
예제 #2
0
    def process(self, conn):
        """
        Read data from all sources-lists and store it into the database.
        """
        sources = self.data.get('source_lists')
        loaded_sources = 0
        if not sources:
            raise ParsetContentError('Source list (source_lists) missing')
        elif isinstance(sources, str):
            sources = sources.strip(' []').replace(' ', '').split(',')
        elif isinstance(sources, list):
            sources = ','.join(sources).strip(' []').replace(' ',
                                                             '').split(',')
        if not self.parset_id:
            raise ParsetContentError('"image_id" missing')
        conn.start()
        conn.execute(sql_insert_run())
        self.run_id = conn.exec_return("""
                select max(runid) from runs where status=0;""",
                                       single_column=True)
        for source in sources:
            if self.data.get('bbs_format'):
                if self.data.get('bbs_format') == 'PySE':
                    bbsfile = PySEFileSource(self.parset_id, self.run_id,
                                             "%s/%s" % (self.path, source),
                                             self.data.get('bbs_format'))
                else:
                    bbsfile = GSMBBSFileSource(self.parset_id, self.run_id,
                                               "%s/%s" % (self.path, source),
                                               self.data.get('bbs_format'))
            else:
                bbsfile = GSMBBSFileSource(self.parset_id, self.run_id,
                                           "%s/%s" % (self.path, source))
            bbsfile.read_and_store_data(conn)
            loaded_sources = loaded_sources + bbsfile.sources
        self.image_id = self.save_image_info(conn)
        conn.commit()
        self.log.info('%s sources loaded from parset %s' %
                      (loaded_sources, self.filename))

        self.source_count = loaded_sources
        return loaded_sources
예제 #3
0
 def test_wrong_test(self):
     xfile = GSMBBSFileSource('test', 0, 'tests/data/bbs_field.dat', 'test')
     self.assertRaises(SourceException, xfile.read_and_store_data, self.conn)
예제 #4
0
 def test_full2(self):
     xfile = GSMBBSFileSource('test', 0, 'tests/data_extended/field_ext.dat')
     self.assertTrue(xfile.read_and_store_data(self.conn))
예제 #5
0
 def test_first_file(self):
     xfile = GSMBBSFileSource('test', 0, 'tests/data/new_field.dat', 'test')
     self.assertTrue(xfile.read_and_store_data(self.conn))