예제 #1
0
 def test_get_marker_from_db(self):
     marker_dt = date_utils.get_datetime_utc_now() - datetime.timedelta(minutes=5)
     marker_db = DumperMarkerDB(marker=isotime.format(marker_dt, offset=False),
                                updated_at=date_utils.get_datetime_utc_now())
     DumperMarker.add_or_update(marker_db)
     exec_exporter = ExecutionsExporter(None, None)
     export_marker = exec_exporter._get_export_marker_from_db()
     self.assertEqual(export_marker, date_utils.add_utc_tz(marker_dt))
예제 #2
0
파일: dumper.py 프로젝트: st2sandbox/st2
    def _write_marker_to_db(self, new_marker):
        LOG.info("Updating marker in db to: %s", new_marker)
        markers = DumperMarker.get_all()

        if len(markers) > 1:
            LOG.exception(
                "More than one dumper marker found. Using first found one.")

        marker = isotime.format(new_marker, offset=False)
        updated_at = date_utils.get_datetime_utc_now()

        if markers:
            marker_id = markers[0]["id"]
        else:
            marker_id = None

        marker_db = DumperMarkerDB(id=marker_id,
                                   marker=marker,
                                   updated_at=updated_at)
        return DumperMarker.add_or_update(marker_db)
예제 #3
0
    def _write_marker_to_db(self, new_marker):
        LOG.info('Updating marker in db to: %s', new_marker)
        marker = DumperMarker.get_all()

        if len(marker) > 1:
            LOG.exception(
                'More than one dumper marker found. Using first found one.')

        marker_db = None
        if marker:
            marker = marker[0]
            marker_db = DumperMarkerDB(id=marker['id'])
        else:
            marker_db = DumperMarkerDB()

        marker_db.marker = isotime.format(new_marker, offset=False)
        marker_db.updated_at = date_utils.get_datetime_utc_now()
        return DumperMarker.add_or_update(marker_db)
예제 #4
0
 def _create_save_dumper_marker():
     created = DumperMarkerDB()
     created.marker = '2015-06-11T00:35:15.260439Z'
     created.updated_at = date_utils.get_datetime_utc_now()
     return DumperMarker.add_or_update(created)
 def _create_save_dumper_marker():
     created = DumperMarkerDB()
     created.marker = '2015-06-11T00:35:15.260439Z'
     created.updated_at = date_utils.get_datetime_utc_now()
     return DumperMarker.add_or_update(created)