Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
source
TMTC COMMANDER CORE
Commits
4bf6c552
Commit
4bf6c552
authored
Feb 21, 2021
by
Robin Mueller
Browse files
dependency inversion continued
parent
43520385
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/hook_base.py
View file @
4bf6c552
import
argparse
from
abc
import
abstractmethod
from
typing
import
Union
,
Dict
from
typing
import
Union
,
Dict
,
Tuple
class
TmTcHookBase
:
...
...
@@ -15,6 +15,11 @@ class TmTcHookBase:
def
__init__
(
self
):
pass
@
abstractmethod
def
get_version
(
self
)
->
Tuple
[
str
,
int
,
int
]:
from
tmtc_core.core.version
import
SW_NAME
,
SW_VERSION
,
SW_SUBVERSION
return
SW_NAME
,
SW_VERSION
,
SW_SUBVERSION
@
abstractmethod
def
set_object_ids
(
self
,
object_id_dict
:
Dict
[
int
,
bytearray
]):
pass
...
...
tmtcc_runner.py
View file @
4bf6c552
...
...
@@ -8,6 +8,7 @@
@author R. Mueller
"""
import
sys
from
typing
import
Tuple
from
tmtc_core.core.hook_base
import
TmTcHookBase
from
tmtc_core.core.definitions
import
CoreGlobalIds
...
...
@@ -16,15 +17,6 @@ from tmtc_core.utility.tmtcc_logger import set_tmtc_logger, get_logger
logger
=
get_logger
()
try
:
from
config.tmtcc_version
import
SW_NAME
,
SW_VERSION
,
SW_SUBVERSION
except
ImportError
as
error
:
import
tmtc_core.core.version
as
core_version
SW_NAME
=
core_version
.
SW_NAME
SW_VERSION
=
core_version
.
SW_VERSION
SW_SUBVERSION
=
core_version
.
SW_SUBVERSION
logger
.
warning
(
"TMTC Runner: No user versioning file found!"
)
def
initialize_tmtc_commander
(
hook_object
:
TmTcHookBase
):
"""
...
...
@@ -85,8 +77,6 @@ def set_up_tmtc_commander(use_gui: bool, reduced_printout: bool):
from
tmtc_core.core.definitions
import
CoreGlobalIds
from
tmtc_core.core.hook_base
import
TmTcHookBase
from
typing
import
cast
if
not
reduced_printout
:
handle_init_printout
(
use_gui
)
set_tmtc_logger
()
# First, we check whether a hook object was passed to the TMTC commander. This hook object
...
...
@@ -97,6 +87,10 @@ def set_up_tmtc_commander(use_gui: bool, reduced_printout: bool):
logger
.
info
(
"No valid hook object found. Please make sure to implement it, instantiate it "
"and pass it via the assign_tmtc_commander_hooks function!"
)
hook_obj
=
cast
(
TmTcHookBase
,
hook_obj_raw
)
if
not
reduced_printout
:
handle_init_printout
(
use_gui
,
hook_obj
.
get_version
())
logger
.
info
(
"Starting TMTC Commander.."
)
if
use_gui
:
...
...
@@ -105,13 +99,14 @@ def set_up_tmtc_commander(use_gui: bool, reduced_printout: bool):
handle_cli_args_and_globals
()
def
handle_init_printout
(
use_gui
:
bool
):
def
handle_init_printout
(
use_gui
:
bool
,
version_tuple
:
Tuple
[
str
,
int
,
int
]
):
print
(
"-- Python TMTC Commander --"
)
if
use_gui
:
print
(
"-- GUI mode --"
)
else
:
print
(
"-- Command line mode --"
)
print
(
f
"-- Software version
{
SW_NAME
}
v
{
SW_VERSION
}
.
{
SW_SUBVERSION
}
--"
)
print
(
f
"-- Software version
{
version_tuple
[
0
]
}
v
{
version_tuple
[
1
]
}
.
{
version_tuple
[
2
]
}
--"
)
def
handle_cli_args_and_globals
():
...
...
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