Skip to content

Commit

Permalink
Merge branch 'master' into PR-cleanup-remove-computer
Browse files Browse the repository at this point in the history
  • Loading branch information
xresende committed Feb 10, 2020
2 parents b60fcd8 + 75dfa2d commit edb3c37
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 148 deletions.
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/clientarch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .client import ClientArchiver


SERVER_URL = _envars.server_url_archiver
SERVER_URL = _envars.SRVURL_ARCHIVER
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/clientarch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AuthenticationError(Exception):
class ClientArchiver:
"""Archiver Data Fetcher class."""

SERVER_URL = _envars.server_url_archiver
SERVER_URL = _envars.SRVURL_ARCHIVER
ENDPOINT = '/mgmt/bpl'

def __init__(self, server_url=None):
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/clientconfigdb/configdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, url=None, config_type=None):
the URL defined in siripy.envars is used.
"""
self._url = url or _envars.server_url_configdb
self._url = url or _envars.SRVURL_CONFIGDB
self._config_type = config_type

@property
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/clientweb/implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
def read_url(url, timeout=_TIMEOUT):
"""Read URL from server."""
try:
url = _envars.server_url_consts + url
url = _envars.SRVURL_CSCONSTS + url
response = _urllib_request.urlopen(url, timeout=timeout)
data = response.read()
text = data.decode('utf-8')
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/cycle/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from siriuspy.namesys import SiriusPVName as _PVName, \
get_pair_sprb as _get_pair_sprb
from siriuspy.envars import vaca_prefix as VACA_PREFIX
from siriuspy.envars import VACA_PREFIX as VACA_PREFIX
from siriuspy.search import PSSearch as _PSSearch, \
LLTimeSearch as _LLTimeSearch
from siriuspy.csdevice.pwrsupply import Const as _PSConst, ETypes as _PSet
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/diagnostics/bpms/ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import pcaspy as _pcaspy
import pcaspy.tools as _pcaspy_tools
from siriuspy.util import get_last_commit_hash as _get_version
from siriuspy.envars import vaca_prefix as PREFIX
from siriuspy.envars import VACA_PREFIX as PREFIX
from siriuspy.csdevice.bpms import get_bpm_database as _get_bpm_db
from siriuspy.csdevice.bpms import FFTWritableProps as fft_wr
from siriuspy.diagnostics.bpms.bpm_plugins import BPMFake as BPM
Expand Down
121 changes: 34 additions & 87 deletions siriuspy/siriuspy/envars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,110 +2,57 @@
import os as _os


# --- folders ---
# --- directories ---

folder_root = _os.environ.get(
'ROOT_GROUP', default='/home/fac_files')
folder_epics_base = _os.environ.get(
'EPICS_BASE', default='/opt/epics/base')
folder_lnls_sirius = _os.environ.get(
'LNLS_SIRIUS', default=_os.path.join(folder_root, 'lnls-sirius'))
folder_lnls_fac = _os.environ.get(
'LNLS_FAC', default=_os.path.join(folder_root, 'lnls-facs'))
folder_lnls_ima = _os.environ.get(
'LNLS_IMA', default=_os.path.join(folder_root, 'lnls-imas'))
folder_fac_code = _os.path.join(
folder_root, 'lnls-facs')
folder_fac_data = _os.path.join(
folder_root, 'data')
folder_lnls_sirius_csslnls = _os.path.join(
folder_lnls_sirius, 'org.csstudio.product')
folder_lnls_sirius_discs = _os.path.join(
folder_lnls_sirius, 'discs-management')
folder_lnls_sirius_csconstants = _os.path.join(
folder_lnls_sirius, 'control-system-constants')
folder_lnls_sirius_dev_packages = _os.path.join(
folder_lnls_sirius, 'dev-packages')
folder_lnls_sirius_hla = _os.path.join(
folder_lnls_sirius, 'hla')
DIR_ROOT = _os.environ.get(
'ROOT_GROUP', default='/home')
DIR_EPICS_BASE = _os.environ.get(
'EPICS_BASE', default='/usr/lib/epics')

DIR_SIRIUS = _os.environ.get(
'LNLS_SIRIUS', default=_os.path.join(DIR_ROOT, 'sirius'))
DIR_FACS = _os.environ.get(
'LNLS_FAC', default=_os.path.join(DIR_ROOT, 'facs'))
DIR_IMAS = _os.environ.get(
'LNLS_IMA', default=_os.path.join(DIR_ROOT, 'imas'))

DIR_SIRIUS_CODE = _os.environ.get(
'LNLS_SIRIUS', default=_os.path.join(DIR_ROOT, DIR_SIRIUS, 'repos'))
DIR_FACS_CODE = _os.path.join(
DIR_ROOT, DIR_FACS, 'repos')

DIR_SIRIUS_CODE_CSCNSTS = _os.path.join(
DIR_SIRIUS_CODE, 'control-system-constants')
DIR_SIRIUS_CODE_SIRIUSPY = _os.path.join(
DIR_SIRIUS_CODE, 'dev-packages')
DIR_SIRIUS_CODE_HLA = _os.path.join(
DIR_SIRIUS, 'hla')


# --- support applications IPs/URLs ---

server_url_rbac_auth = _os.environ.get(
SRVURL_RBACAUTH = _os.environ.get(
'SIRIUS_URL_RBAC_AUTH', default='https://sirius-rbac-auth.lnls.br')
server_url_rbac = _os.environ.get(
SRVURL_RBAC = _os.environ.get(
'SIRIUS_URL_RBAC', default='https://rbac:8445')
server_url_ns = _os.environ.get(
SRVURL_NS = _os.environ.get(
'SIRIUS_URL_NS', default='http://naming-service-wildfly:8089/names')
server_url_ccdb = _os.environ.get(
SRVURL_CCDB = _os.environ.get(
'SIRIUS_URL_CCDB', default='http://ccdb:8083')
server_url_cables = _os.environ.get(
SRVURL_CABLES = _os.environ.get(
'SIRIUS_URL_CABLES', default='http://cables:8086')
server_url_consts = _os.environ.get(
SRVURL_CSCONSTS = _os.environ.get(
'SIRIUS_URL_CONSTS',
default='http://sirius-consts.lnls.br/control-system-constants')
server_url_logbook = _os.environ.get(
SRVURL_LOGBOOK = _os.environ.get(
'SIRIUS_URL_LOGBOOK',
default='http://sirius-logbook.lnls.br/Olog')
server_url_configdb = _os.environ.get(
SRVURL_CONFIGDB = _os.environ.get(
'SIRIUS_URL_CONFIGDB',
default='http://sirius-configdb.lnls.br/config-db')
server_url_archiver = _os.environ.get(
SRVURL_ARCHIVER = _os.environ.get(
'SIRIUS_URL_ARCHIVER',
default='https://sirius-archiver.lnls.br')


vaca_prefix = _os.environ.get('VACA_PREFIX', default='')


# --- repositories ---

org_folders = {
'lnls-fac': folder_lnls_fac,
'lnls-ima': folder_lnls_ima,
'lnls-sirius': folder_lnls_sirius,
}

repo_names = {

'lnls-fac': ['apsuite',
'tools',
'collective_effects',
'job_manager',
'pyaccel',
'trackcpp',
'fieldmaptrack',
'lnls',
# 'sands-adaptation',
'tracy_sirius',
'mathphys',
'scripts',
'va',
'MatlabMiddleLayer',
'pymodels'],

'lnls-ima': ['bo-correctors',
'bo-sextupoles',
'tb-dipoles',
'bo-dipoles',
'si-dipoles-b1',
'si-quadrupoles-q14',
'bo-quadrupoles-qd',
'si-dipoles-b2',
'si-quadrupoles-q20',
'bo-quadrupoles-qf',
'si-fast-correctors',
'si-sextupoles-s15'],

'lnls-sirius': ['control-system-constants',
'discs-management',
'epics-dev',
'org.csstudio.product',
'dev-packages',
'machine-applications',
'hla',
'pydm',
'scripts'],

}
VACA_PREFIX = _os.environ.get('VACA_PREFIX', default='')
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/epics/properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


import numpy as _np
from siriuspy.envars import vaca_prefix as _prefix
from siriuspy.envars import VACA_PREFIX as _prefix
from siriuspy.namesys.implementation import \
SiriusPVName as _SiriusPVName, \
get_pair_sprb as _get_pair_sprb
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/pwrsupply/psconv.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from epics import PV as _PV

from siriuspy.envars import vaca_prefix as _VACA_PREFIX
from siriuspy.envars import VACA_PREFIX as _VACA_PREFIX
from siriuspy.factory import NormalizerFactory as _NormalizerFactory
from siriuspy.namesys import SiriusPVName as _SiriusPVName
from siriuspy.magnet import util as _mutil
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/ramp/conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from siriuspy.ramp import util as _rutil


_prefix = _envars.vaca_prefix
_prefix = _envars.VACA_PREFIX
_TIMEOUT_DFLT = 8
_TIMEOUT_PWRSTATE_ON = 2
_TIMEOUT_PWRSTATE_OFF = 1
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/timesys/ll_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from epics.ca import CASeverityException as _CASeverityException
from siriuspy.util import update_bit as _update_bit, get_bit as _get_bit
from siriuspy.epics import connection_timeout as _conn_timeout, PV as _PV
from siriuspy.envars import vaca_prefix as LL_PREFIX
from siriuspy.envars import VACA_PREFIX as LL_PREFIX
from siriuspy.namesys import SiriusPVName as _PVName
from siriuspy.csdevice import timesys as _cstime
from siriuspy.search import LLTimeSearch as _LLTimeSearch
Expand Down
2 changes: 1 addition & 1 deletion siriuspy/siriuspy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def beam_rigidity(energy):
def check_pv_online(pvname, timeout=1.0, use_prefix=True):
"""Return whether a PV is online."""
if use_prefix:
pvname = _envars.vaca_prefix + pvname
pvname = _envars.VACA_PREFIX + pvname
pv = _epics.PV(pvname=pvname, connection_timeout=timeout)
status = pv.wait_for_connection(timeout=timeout)
return status
Expand Down
4 changes: 2 additions & 2 deletions siriuspy/tests/clientweb/test_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import siriuspy.util as util

# Dependencies
# _envars.server_url_consts
# _envars.SRVURL_CSCONSTS
# _urllib_request.urlopen
# _urllib_request.urlopen.read

Expand All @@ -31,7 +31,7 @@ def setUp(self):
# Mocked methods
self.url_mock.urlopen.return_value.read.return_value = b'FakeResponse'
# Mock a property from envars
type(self.env_mock).server_url_consts = \
type(self.env_mock).SRVURL_CSCONSTS = \
mock.PropertyMock(return_value=self.fake_url)

def test_read_url_request(self):
Expand Down
78 changes: 30 additions & 48 deletions siriuspy/tests/test_envars.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,73 +6,55 @@
import siriuspy.envars as envars
import siriuspy.util as util

folders = (
'folder_root',
'folder_epics_base',
'folder_lnls_sirius',
'folder_lnls_fac',
'folder_lnls_ima',
'folder_fac_code',
'folder_fac_data',
'folder_lnls_sirius_csslnls',
'folder_lnls_sirius_discs',
'folder_lnls_sirius_csconstants',
'folder_lnls_sirius_dev_packages',
'folder_lnls_sirius_hla',
)
servers = (
'server_url_rbac_auth',
'server_url_rbac',
'server_url_ns',
'server_url_ccdb',
'server_url_cables',
'server_url_consts',
'server_url_logbook',
'server_url_configdb',
'server_url_archiver',
)
misc = (
'org_folders',
'repo_names',
'__loader__',
'_os',
'__doc__',
'__cached__',
'__name__',
'__spec__',
'__package__',
'__builtins__',
'__file__',
)

public_interface = folders + servers + \
('vaca_prefix', 'org_folders', 'repo_names')
DIRS = (
'DIR_ROOT',
'DIR_EPICS_BASE',
'DIR_SIRIUS',
'DIR_FACS',
'DIR_IMAS',
'DIR_SIRIUS_CODE',
'DIR_FACS_CODE',
'DIR_SIRIUS_CODE_CSCNSTS',
'DIR_SIRIUS_CODE_SIRIUSPY',
'DIR_SIRIUS_CODE_HLA')
SRVURLS = (
'SRVURL_RBACAUTH',
'SRVURL_RBAC',
'SRVURL_NS',
'SRVURL_CCDB',
'SRVURL_CABLES',
'SRVURL_CSCONSTS',
'SRVURL_LOGBOOK',
'SRVURL_CONFIGDB',
'SRVURL_ARCHIVER')
PUBLIC_INTERFACE = DIRS + SRVURLS + \
('VACA_PREFIX', )


class TestEnvars(TestCase):
"""Test envars."""

def test_public_interface(self):
"""Test module's public interface."""
valid = util.check_public_interface_namespace(envars, public_interface)
valid = util.check_public_interface_namespace(envars, PUBLIC_INTERFACE)
self.assertTrue(valid)

def test_folders(self):
def test_dirs(self):
"""Test folder names."""
for folder in folders:
for folder in DIRS:
self.assertIn(folder, envars.__dict__)
value = getattr(envars, folder)
self.assertIsInstance(value, str)

def test_servers(self):
def test_srvurls(self):
"""Test server names."""
for server in servers:
for server in SRVURLS:
self.assertIn(server, envars.__dict__)
value = getattr(envars, server)
self.assertIsInstance(value, str)

def test_vaca(self):
"""VACA prefix string."""
self.assertIn('vaca_prefix', envars.__dict__)
value = getattr(envars, 'vaca_prefix')
self.assertIn('VACA_PREFIX', envars.__dict__)
value = getattr(envars, 'VACA_PREFIX')
self.assertIsInstance(value, str)

0 comments on commit edb3c37

Please sign in to comment.