Skip to content
Snippets Groups Projects
Commit ff88f407 authored by Jan David Mol's avatar Jan David Mol
Browse files

L2SS-1633: Sync IERS tables through minio.

parent 8668e88b
Branches
Tags
1 merge request!785L2SS-1633: Sync IERS tables through minio.
......@@ -28,6 +28,7 @@ from tango.server import attribute, command, Device, device_property
# Additional import
from tangostationcontrol import __version__ as version
from tangostationcontrol.common.device_decorators import only_in_states, fault_on_error
from tangostationcontrol.common.entrypoint import restart_python
from tangostationcontrol.common.lofar_logging import log_exceptions
from tangostationcontrol.common.proxy import create_device_proxy
from tangostationcontrol.common.states import (
......@@ -583,6 +584,16 @@ class LOFARDevice(Device):
self.set_state(DevState.DISABLE)
self.set_status("Device is in the DISABLE state.")
@command()
@DebugIt()
@log_exceptions()
def restart_device_server(self):
"""Restart the device server. Needed to reload casacore, and maybe for nasty bugs."""
logger.warning("Restarting Device Server")
restart_python()
logger.error("Failed to restart Device Server")
@only_in_states(DEFAULT_COMMAND_STATES)
@fault_on_error()
@command()
......
# Copyright (C) 2022 ASTRON (Netherlands Institute for Radio Astronomy)
# SPDX-License-Identifier: Apache-2.0
import os.path
import shutil
import tempfile
import urllib.request
from unittest import mock
from tangostationcontrol.common import measures
from test import base
# where our WSRT_Measures.ztar surrogate is located
# two versions with different timestamps are provided
FAKE_MEASURES = os.path.dirname(__file__) + "/fake_measures.ztar"
FAKE_MEASURES_NEWER = os.path.dirname(__file__) + "/fake_measures_newer.ztar"
class TestMeasures(base.TestCase):
@mock.patch.object(urllib.request, "urlretrieve")
def test_download_and_use(self, m_urlretrieve):
"""Test downloading and using new measures tables."""
with tempfile.TemporaryDirectory() as tmpdirname, mock.patch(
"tangostationcontrol.common.measures.IERS_ROOTDIR", tmpdirname
) as rootdir, mock.patch(
"tangostationcontrol.common.measures.DOWNLOAD_DIR", tmpdirname
) as downloaddir:
# emulate the download
m_urlretrieve.side_effect = lambda *args, **kw: shutil.copyfile(
FAKE_MEASURES, tmpdirname + "/WSRT_Measures.ztar"
)
# 'download' and process our fake measures
newdir = measures.download_measures()
# active them
measures.use_measures_directory(newdir)
# check if they're activated
self.assertIn(newdir, measures.get_available_measures_directories())
self.assertEqual(newdir, measures.get_measures_directory())
@mock.patch.object(urllib.request, "urlretrieve")
def test_switch_tables(self, m_urlretrieve):
"""Test switching between available sets of measures tables."""
with tempfile.TemporaryDirectory() as tmpdirname, mock.patch(
"tangostationcontrol.common.measures.IERS_ROOTDIR", tmpdirname
) as rootdir, mock.patch(
"tangostationcontrol.common.measures.DOWNLOAD_DIR", tmpdirname
) as downloaddir:
# 'download' two measures with different timestamps
m_urlretrieve.side_effect = lambda *args, **kw: shutil.copyfile(
FAKE_MEASURES, tmpdirname + "/WSRT_Measures.ztar"
)
newdir1 = measures.download_measures()
m_urlretrieve.side_effect = lambda *args, **kw: shutil.copyfile(
FAKE_MEASURES_NEWER, tmpdirname + "/WSRT_Measures.ztar"
)
newdir2 = measures.download_measures()
# check if both are available
self.assertIn(newdir1, measures.get_available_measures_directories())
self.assertIn(newdir2, measures.get_available_measures_directories())
# switch between the two
measures.use_measures_directory(newdir1)
self.assertEqual(newdir1, measures.get_measures_directory())
measures.use_measures_directory(newdir2)
self.assertEqual(newdir2, measures.get_measures_directory())
measures.use_measures_directory(newdir1)
self.assertEqual(newdir1, measures.get_measures_directory())
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment