Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Projects
B.I.T.S. 4.0
bits-companion
Commits
99101d26
Verified
Commit
99101d26
authored
Oct 27, 2021
by
Mroik
Browse files
Added env var checking
parent
7dc161a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
config.py
View file @
99101d26
from
os
import
environ
from
sys
import
exit
import
logging
LOGGER
=
logging
.
getLogger
(
__name__
)
SERVER
=
environ
.
get
(
"BITS_SERVER"
)
PORT
=
int
(
environ
.
get
(
"BITS_PORT"
,
default
=
1883
))
USERNAME
=
environ
.
get
(
"BITS_USER"
)
PASSWORD
=
environ
.
get
(
"BITS_PASSWORD"
,
default
=
""
)
TG_KEY
=
environ
.
get
(
"BITS_TG_KEY"
,
default
=
""
)
PASSWORD
=
environ
.
get
(
"BITS_PASSWORD"
)
TG_KEY
=
environ
.
get
(
"BITS_TG_KEY"
)
ADMIN_CHANNELS_FULL
=
[]
# Channels that are allowed to change HQ's status
ADMIN_CHANNELS_PRIV
=
[]
# Channels that are allowed to change HQ's status
DEBUG
=
environ
.
get
(
"DEBUG"
,
default
=
None
)
for
chan
in
environ
.
get
(
"BITS_TG_GROUPS_FULL"
,
default
=
""
).
split
(
":"
):
if
chan
==
""
:
continue
ADMIN_CHANNELS_FULL
.
append
(
chan
)
for
chan
in
environ
.
get
(
"BITS_TG_GROUPS_PRIV"
,
default
=
""
).
split
(
":"
):
if
chan
==
""
:
continue
ADMIN_CHANNELS_PRIV
.
append
(
chan
)
if
SERVER
is
None
:
LOGGER
.
critical
(
"An IP for the mqtt broker must be specified"
)
exit
()
if
USERNAME
is
None
or
PASSWORD
is
None
:
LOGGER
.
critical
(
"Credentials for both username and password are unspecified"
)
exit
()
if
TG_KEY
is
None
:
LOGGER
.
critical
(
"The token for the telegrambot is unspecified"
)
exit
()
if
len
(
ADMIN_CHANNELS_PRIV
)
==
0
and
len
(
ADMIN_CHANNELS_FULL
)
==
0
:
LOGGER
.
critical
(
"Atleast 1 admin channel must be given"
)
exit
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment