Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
uppaal2jetracer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
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
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
Felix Dold
uppaal2jetracer
Commits
149b4d0a
Commit
149b4d0a
authored
1 month ago
by
Moritz Maas
Browse files
Options
Downloads
Patches
Plain Diff
fix: test version responses before continuing
parent
aa720929
Branches
dev-moritz
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
uppaal2jetracer/command_system.py
+31
-14
31 additions, 14 deletions
uppaal2jetracer/command_system.py
with
31 additions
and
14 deletions
uppaal2jetracer/command_system.py
+
31
−
14
View file @
149b4d0a
...
...
@@ -260,10 +260,10 @@ class Command(ABC):
_LINE_SEPARATOR
=
"
\n
"
_ERROR_ARG_COUNT
=
"
Invalid number of arguments provided.
"
_ERROR_EXECUTION_FAIL
=
"
Execution of
'
{}
'
failed.
"
_ERROR_FILE_NOT_FOUND
=
"'
{}
'
is not a valid file.
"
_ERROR_HARDWARE_FAIL
=
"
Execution of hardware command failed.
"
_ERROR_INVALID_ARG
=
"'
{}
'
is not a valid argument.
"
_ERROR_EXECUTION_FAIL
=
"
Execution of
'
{}
'
failed.
"
_SUCCESS_TERMINATED
=
"
Successfully terminated execution of
'
{}
'
.
"
_SUCCESS_RUN
=
"
Successfully ran
'
{}
'
.
"
...
...
@@ -343,8 +343,7 @@ Options: -d, --debug Log debug messages.
system
=
SystemParser
.
parse
(
BeautifulSoup
(
file
,
self
.
_BS_BUILDER
))
except
(
XMLParseError
,
ExecutionError
)
as
e
:
message
:
str
=
self
.
_ERROR_UPPAAL_XML
.
format
(
args
[
0
])
if
hasattr
(
e
,
"
message
"
):
message
+=
e
.
message
message
+=
"
"
+
e
.
args
[
0
]
return
CommandResult
(
message
,
CommandResultType
.
FAILURE
)
pkl_file
=
args
[
0
].
replace
(
self
.
_XML_FILE_KEY
,
self
.
_PKL_FILE_KEY
)
with
open
(
pkl_file
,
"
wb
"
)
as
file
:
...
...
@@ -585,11 +584,15 @@ Options: -d, --debug Log debug messages.
Executor
.
stop
()
return
CommandResult
(
self
.
_SUCCESS_TERMINATED
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
except
(
HardwareCallError
,
ExecutionError
)
as
e
:
except
HardwareCallError
as
e
:
message
:
str
=
self
.
_ERROR_HARDWARE_FAIL
.
format
(
args
[
0
])
if
hasattr
(
e
,
"
message
"
):
message
=
e
.
message
return
CommandResult
(
message
,
CommandResultType
.
FAILURE
)
except
ExecutionError
as
e
:
message
:
str
=
self
.
_ERROR_EXECUTION_FAIL
.
format
(
args
[
0
])
message
+=
"
"
+
e
.
args
[
0
]
return
CommandResult
(
message
,
CommandResultType
.
FAILURE
)
return
CommandResult
(
self
.
_SUCCESS_RUN
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
...
...
@@ -600,7 +603,7 @@ class VersionCommand(Command):
__slots__
=
(
"
_version_manager
"
,
"
_command_handler
"
,
"
_controller
"
)
_HELP_MESSAGE
=
"""
Usage: (version | v) (list | run <id> | fav <id> | del
ete
<id>)
_HELP_MESSAGE
=
"""
Usage: (version | v) (list | run <id> | fav <id> | del <id>
[-s | --skip]
)
[-d | --debug] [-h | --help]
The version command manages parsed versions of UPPAAL systems.
...
...
@@ -608,13 +611,17 @@ The version command manages parsed versions of UPPAAL systems.
Commands: list List all versions in current project.
run Run an existing version.
fav Prevent existing version from being automatically deleted.
del
ete
Delete existing version.
del
Delete existing version.
Options: -d, --debug Log debug messages.
Options: -s, --skip Skip the deletion confirmation dialogue for favorite versions.
-d, --debug Log debug messages.
-h, --help Show this message.
"""
_LOGGERS
=
[
"
version_control
"
,
"
controller
"
,
"
uppaal_model
"
,
"
jetracer
"
]
_SKIP_FLAG
=
"
-s
"
_SKIP_FLAG_ALT
=
"
--skip
"
_SUCCESS_FAVORITE
=
"
Version {} is now a favorite.
"
_SUCCESS_DEFAVORITE
=
"
Version {} is now no longer a favorite.
"
_SUCCESS_DELETE
=
"
Deleted version {} from project.
"
...
...
@@ -644,7 +651,7 @@ Options: -d, --debug Log debug messages.
"
list
"
:
self
.
_execute_list
,
"
run
"
:
self
.
_execute_run
,
"
fav
"
:
self
.
_execute_fav
,
"
del
ete
"
:
self
.
_execute_delete
,
"
del
"
:
self
.
_execute_delete
,
"
stop
"
:
self
.
_execute_stop
}
...
...
@@ -680,11 +687,17 @@ Options: -d, --debug Log debug messages.
Executor
.
stop
()
return
CommandResult
(
self
.
_SUCCESS_TERMINATED
.
format
(
args
[
0
]),
CommandResultType
.
SUCCESS
)
except
(
HardwareCallError
,
ExecutionError
)
as
e
:
message
:
str
=
self
.
_ERROR_HARDWARE_FAIL
.
format
(
args
[
0
])
except
HardwareCallError
as
e
:
message
:
str
=
self
.
_ERROR_HARDWARE_FAIL
if
hasattr
(
e
,
"
message
"
):
message
=
e
.
message
return
CommandResult
(
message
,
CommandResultType
.
FAILURE
)
except
ExecutionError
as
e
:
message
:
str
=
self
.
_ERROR_EXECUTION_FAIL
.
format
(
response
.
payload
.
name
)
message
+=
"
"
+
e
.
args
[
0
]
return
CommandResult
(
message
,
CommandResultType
.
FAILURE
)
return
CommandResult
(
self
.
_SUCCESS_RUN
.
format
(
response
.
payload
.
name
),
CommandResultType
.
SUCCESS
)
def
_execute_stop
(
self
,
args
:
List
[
str
])
->
CommandResult
:
if
not
len
(
args
)
==
0
:
...
...
@@ -713,12 +726,16 @@ Options: -d, --debug Log debug messages.
[
response
])
def
_execute_delete
(
self
,
args
:
List
[
str
])
->
CommandResult
:
if
not
0
<
len
(
args
)
<
3
:
if
not
1
<
=
len
(
args
)
<
=
2
:
return
CommandResult
(
self
.
_ERROR_ARG_COUNT
,
CommandResultType
.
FAILURE
)
try
:
if
(((
len
(
args
)
==
1
or
args
[
1
]
!=
"
-skip
"
)
and
self
.
_version_manager
.
get_version
(
int
(
args
[
0
])).
payload
.
favorite
)
and
not
self
.
_command_handler
.
get_confirmation
(
response
:
VersionResponse
=
self
.
_version_manager
.
get_version
(
int
(
args
[
0
]))
if
response
.
type
==
ResponseType
.
ERROR
:
return
CommandResult
(
response
.
message
,
CommandResultType
.
FAILURE
,
[
response
])
if
(
self
.
_SKIP_FLAG
not
in
args
and
self
.
_SKIP_FLAG_ALT
not
in
args
and
self
.
_version_manager
.
get_version
(
int
(
args
[
0
])).
payload
.
favorite
and
not
self
.
_command_handler
.
get_confirmation
(
self
.
_DELETE_CONFIRMATION_REQUEST
)):
return
CommandResult
(
self
.
_ABORT_DELETE
,
CommandResultType
.
SUCCESS
,
None
)
response
:
VersionResponse
=
self
.
_version_manager
.
delete_version
(
int
(
args
[
0
]))
...
...
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