Skip to content

Commit

Permalink
Added [cse.console].confirmQuit configuration option. It is switched…
Browse files Browse the repository at this point in the history
… off by default.
  • Loading branch information
ankraft committed Aug 5, 2021
1 parent 429dfde commit 6f3faee
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.8.1] - 2021-08-05

### Added
- [CONSOLE] Added [cse.console].confirmQuit configuration option. It is switched off by default.


## [0.8.0] - 2021-07-27

### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# ACME oneM2M CSE
An open source CSE Middleware for Education.

Version 0.8.0
Version 0.8.1

[![oneM2M](https://img.shields.io/badge/oneM2M-f00)](https://www.onem2m.org) [![Python](https://img.shields.io/badge/Python-3.8-blue)](https://www.python.org) [![Maintenance](https://img.shields.io/badge/Maintained-Yes-green.svg)](https://github.com/ankraft/ACME-oneM2M-CSE/graphs/commit-activity) [![License](https://img.shields.io/badge/License-BSD%203--Clause-green)](LICENSE) [![MyPy](https://img.shields.io/badge/MyPy-covered-green)](LICENSE)
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/acmeCSE.svg?style=social&label=%40acmeCSE)](https://twitter.com/acmeCSE)
Expand Down
5 changes: 5 additions & 0 deletions acme.ini.default
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ hideResources=
# Allowed values: normal, compact, content, contentOnly
# Default: normal
treeMode=normal
# Quitting the console needs to be confirmed.
# This may not work under Windows, so it should be switched off.
# Default: False
confirmQuit=False


#
# ID Mappings
Expand Down
2 changes: 2 additions & 0 deletions acme/Configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ def _print(out:str) -> None:
'cse.console.refreshInterval' : config.getfloat('cse.console', 'refreshInterval', fallback=2.0),
'cse.console.hideResources' : config.getlist('cse.console', 'hideResources', fallback=[]), # type: ignore[attr-defined]
'cse.console.treeMode' : config.get('cse.console', 'treeMode', fallback='normal'),
'cse.console.confirmQuit' : config.getboolean('cse.console', 'confirmQuit', fallback=False),


#
# App: Statistics AE
Expand Down
20 changes: 12 additions & 8 deletions acme/Console.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self) -> None:
self.refreshInterval = Configuration.get('cse.console.refreshInterval')
self.hideResources = Configuration.get('cse.console.hideResources')
self.treeMode = Configuration.get('cse.console.treeMode')
self.confirmQuit = Configuration.get('cse.console.confirmQuit')
if L.isInfo: L.log('Console initialized')


Expand Down Expand Up @@ -114,15 +115,18 @@ def shutdownCSE(self, key:str) -> None:
""" Shutdown the CSE. Confirm shutdown before actually doing that.
"""
if not CSE.isHeadless:
L.off()
L.console('Press quit-key again to confirm -> ', plain=True, end='')
if waitForKeypress(5) not in ['Q', '\x03']:
L.console('canceled')
if self.confirmQuit:
L.off()
L.console('Press quit-key again to confirm -> ', plain=True, end='')
if waitForKeypress(5) not in ['Q', '\x03']:
L.console('canceled')
L.on()
return
L.console('confirmed')
L.console('Shutdown CSE')
L.on()
return
L.console('confirmed')
L.console('Shutdown CSE')
L.on()
else:
L.console('Shutdown CSE')
sys.exit()


Expand Down
2 changes: 1 addition & 1 deletion acme/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
class Constants(object):

# ACME Version
version = '0.8.0'
version = '0.8.1'

# Supported release vesions
supportedReleaseVersions = ['2a', '3', '4']
Expand Down
1 change: 1 addition & 0 deletions docs/Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ The following macros are supported in addition to those defined in the sections
| refreshInterval | Interval for continuously refreshing information displays. Must be > 0.0<br/>Default: 2.0 seconds. | cse.console.refreshInterval |
| hideResources | Hide certain resources from display in the console. This is a list of resource identifiers. Wildcards are allowed.<br/>Default: Empty list. | cse.console.hideResources |
| treeMode | Set the mode how resources and their content are presented in the console's tree view.<br/>Allowed values: normal, compact, content, contentOnly<br/>Default: normal | cse.console.treeMode |
| confirmQuit | Quitting the console needs to be confirmed.<br />This may not work under Windows, so it should be switched off.<br />Default: False | cse.console.confirmQuit |


<a name="webui"></a>
Expand Down

0 comments on commit 6f3faee

Please sign in to comment.