Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
7885ad10
Commit
7885ad10
authored
4 years ago
by
Thomas Juerges
Browse files
Options
Downloads
Patches
Plain Diff
Add files for default log config starting up a device
parent
21439104
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/lofar2_config.py
+13
-0
13 additions, 0 deletions
lib/lofar2_config.py
lib/startup.py
+37
-0
37 additions, 0 deletions
lib/startup.py
with
50 additions
and
0 deletions
lib/lofar2_config.py
0 → 100755
+
13
−
0
View file @
7885ad10
#! /usr/bin/env python3
import
logging
def
configure_logging
():
# Always also log the hostname because it makes the origin of the log clear.
import
socket
hostname
=
socket
.
gethostname
()
# Set up logging in a way that it can be understood by a human reader, be
# easily grep'ed, be parsed with a couple of shell commands and
# easily fed into an Kibana/Elastic search system.
logging
.
basicConfig
(
format
=
'
%(asctime)s.%(msecs)d %(levelname)s - HOST=
"
{}
"
PID=
"
%(process)d
"
TNAME=
"
%(threadName)s
"
TID=
"
%(thread)d
"
FILE=
"
%(pathname)s
"
LINE=
"
%(lineno)d
"
FUNC=
"
%(funcName)s
"
MSG=
"
%(message)s
"'
.
format
(
hostname
),
datefmt
=
'
%Y-%m-%dT%H:%M:%S
'
,
level
=
logging
.
INFO
,
Force
=
True
)
This diff is collapsed.
Click to expand it.
lib/startup.py
0 → 100755
+
37
−
0
View file @
7885ad10
#! /usr/bin/env python3
def
startup
(
device
:
str
,
force_restart
:
bool
):
'''
Start a LOFAR Tango device:
pcc = startup(device =
'
LTS/PCC/1
'
, force_restart = False)
'''
import
tango
proxy
=
tango
.
DeviceProxy
(
device
)
state
=
proxy
.
state
()
if
force_restart
is
True
:
print
(
"
Forcing device {} restart.
"
.
format
(
device
))
proxy
.
off
()
state
=
proxy
.
state
()
if
state
is
not
tango
.
_tango
.
DevState
.
OFF
:
print
(
"
Device {} cannot perform off although restart has been enforced, state = {}. Please investigate.
"
.
format
(
device
,
state
))
return
proxy
if
state
is
not
tango
.
_tango
.
DevState
.
OFF
:
print
(
"
Device {} is not in OFF state, cannot start it. state = {}
"
.
format
(
device
,
state
))
return
proxy
print
(
"
Device {} is in OFF, performing initialisation.
"
.
format
(
device
))
proxy
.
initialise
()
state
=
proxy
.
state
()
if
state
is
not
tango
.
_tango
.
DevState
.
STANDBY
:
print
(
"
Device {} cannot perform initialise, state = {}. Please investigate.
"
.
format
(
device
,
state
))
return
proxy
print
(
"
Device {} is in STANDBY, performing on.
"
.
format
(
device
))
proxy
.
on
()
state
=
proxy
.
state
()
if
state
is
not
tango
.
_tango
.
DevState
.
ON
:
print
(
"
Device {} cannot perform on, state = {}. Please investigate.
"
.
format
(
device
,
state
))
else
:
print
(
"
Device {} has successfully reached ON state.
"
.
format
(
device
))
return
proxy
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment