Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	README.md
#	acme/etc/Constants.py
#	setup.py
  • Loading branch information
ankraft committed Oct 22, 2023
2 parents d7b9f9f + aec94ac commit 5fa29a6
Show file tree
Hide file tree
Showing 135 changed files with 13,313 additions and 3,715 deletions.
155 changes: 128 additions & 27 deletions acme.ini.default
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ size=200
[http]
; Port to listen to. Default: 8080
port=${basic.config:httpPort}
; Interface to listen to. Use 0.0.0.0 for "all" interfaces. Default:127.0.0.1
; Interface to listen to. Use 0.0.0.0 for "all" interfaces.
; Default:0.0.0.0
listenIF=${basic.config:networkInterface}
; Own address. Should be a local/public reachable address.
; Default: http://127.0.0.1:8080
Expand Down Expand Up @@ -182,6 +183,22 @@ verifyCertificate=false
caCertificateFile=${basic.config:dataDirectory}/certs/acme_cert.pem
; Path and filename of the private key file. Default: None
caPrivateKeyFile=${basic.config:dataDirectory}/certs/acme_key.pem
; Enable basic authentication for the HTTP binding.
; Default: false
enableBasicAuth=false
; Enable token authentication for the HTTP binding.
; Default: false
enableTokenAuth=false
; Path and filename of the http basic authentication file.
; The file must contain lines with the format "username:password".
; Comments are lines starting with a #.
; Default: certs/http_basic_auth.txt
basicAuthFile=${basic.config:dataDirectory}/certs/http_basic_auth.txt
; Path and filename of the http bearer token authentication file.
; The file must contain lines with the format "token".
; Comments are lines starting with a #.
; Default: certs/http_token_auth.txt
tokenAuthFile=${basic.config:dataDirectory}/certs/http_token_auth.txt


[http.cors]
Expand All @@ -193,6 +210,20 @@ enable=false
resources=/*


[http.wsgi]
; Enable WSGI support for the HTTP binding.
; Default: false
enable=false
; The number of threads used to process requests.
; This number should be of similar size as the "connectionLimit" setting.
; Default: 100
threadPoolSize=100
; The number of possible parallel connections that can be accepted by the WSGI server.
; One connection uses one system file descriptor.
; Default: 100
connectionLimit=100


;
; MQTT client settings
;
Expand All @@ -211,7 +242,7 @@ port=1883
; Default: 60 seconds
keepalive=60
; Interface to listen to. Use 0.0.0.0 for "all" interfaces.
; Default: 127.0.0.1
; Default: 0.0.0.0
listenIF=${basic.config:networkInterface}
; Optional prefix for topics.
; Default: empty string
Expand Down Expand Up @@ -248,6 +279,41 @@ caCertificateFile=${basic.config:dataDirectory}/certs/m2mqtt_ca.crt
allowedCredentialIDs=


;
; CoAP client settings
;

[coap]
; Enable the CoAP binding.
; Default: false
enable=false
serverPort=5683
; Interface to listen to. Use 0.0.0.0 for "all" interfaces.
; Default:
listenIF=${basic.config:networkInterface}


;
; CoAP security settings
;

[coap.security]
; Enable DTLS for communications with the CoAP server.
; Default: False
useDTLS=false
; TLS version to be used in connections.
; Allowed versions: TLS1.1, TLS1.2, auto . Use "auto" to allow client-server certificate
; version negotiation.
; Default: auto
dtlsVersion=auto
; Verify certificates in requests. Set to False when using self-signed certificates.
; Default: False
verifyCertificate=False
; Path and filename of the certificate file. Default: ${basic.config:dataDirectory}/certs/coap_cert.pem
certificateFile=${basic.config:dataDirectory}/certs/coap_cert.pem
; Path and filename of the private key file. Default: None
privateKeyFile=${basic.config:dataDirectory}/certs/coap_key.pem

;
; Database settings
;
Expand Down Expand Up @@ -314,19 +380,30 @@ excludeCSRAttributes=
;

[logging]
; Enable logging to file. Default: False
; Enable logging to file.
; Default: False
enableFileLogging=False
; Enable logging to the screen. Default: True
; Enable logging to the screen.
; Default: True
enableScreenLogging=true
; Path to the log files. Default: ./logs
; Path to the log files.
; Default: ./logs
path=${basic.config:dataDirectory}/logs
; Loglevel. Allowed values: debug, info, warning, error, off. Default: debug
; Loglevel. Allowed values: debug, info, warning, error, off.
; Default: debug
level=${basic.config:logLevel}
; Number of files for log rotation. Default: 10
; Number of files for log rotation.
; Default: 10
count=10
; Size per log file. Default: 100.000 bytes
; Size per log file.
; Default: 100.000 bytes
size=100000
; Print a stack trace when logging an 'error' level message. Default: True
; Maximum length of a log message. Longer messages will be truncated.
; A value of 0 means no truncation.
; Default: 1000 characters
maxLogMessageLength=1000
; Print a stack trace when logging an 'error' level message.
; Default: True
stackTraceOnError=False
; Enable logging of low-level HTTP & MQTT client events.
; Default: False
Expand All @@ -339,6 +416,7 @@ queueSize=5000
filter=werkzeug,markdown_it,asyncio



;
; Settings for resource announcements
;
Expand Down Expand Up @@ -405,6 +483,43 @@ mni=10
mbs=10000


[resource.grp]
; Set the time for aggregating the results of a group request before interrupting.
; The format is the time in ms. A value of 0 ms means no timeout.
; Default: 0 ms
resultExpirationTime=0

;
; Resource defaults: LocationPolicy
;

[resource.lcp]
; Default for maxNrOfInstances for the LocationPolicy's container.
; Default: 10
mni=10
; Default for maxByteSize for the LocationPolicy's container.
; Default: 10.000 bytes
mbs=10000


;
; Resource defaults: Request
;

[resource.req]
; A <request> resource's expiration time in seconds. Must be >0. Default: 60
expirationTime=60


;
; Resource defaults: Subscription
;

[resource.sub]
; Default for batchNotify/duration in seconds. Must be >0. Default: 60
batchNotifyDuration=60


;
; Resource defaults: TimeSeries
;
Expand Down Expand Up @@ -435,24 +550,6 @@ bcni=PT1H
bcnt=10.0


;
; Resource defaults: Request
;

[resource.req]
; A <request> resource's expiration time in seconds. Must be >0. Default: 60
expirationTime=60


;
; Resource defaults: Subscription
;

[resource.sub]
; Default for batchNotify/duration in seconds. Must be >0. Default: 60
batchNotifyDuration=60


;
; Web UI settings
;
Expand Down Expand Up @@ -521,5 +618,9 @@ verbose=False
; 0 means disable monitoring.
; Default: 2.0 seconds
fileMonitoringInterval=2.0
; Set the timeout for script execution in seconds.
; 0.0 means no timeout.
; Default: 60.0 seconds
maxRuntime=60.0


4 changes: 4 additions & 0 deletions acme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
""" This module contains the ACME CSE implementation. It is the main module of the ACME CSE.
It contains the main() function that is called when the CSE is started.
It also contains the CSE class that implements the CSE.
"""
46 changes: 36 additions & 10 deletions acme/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Starter for the ACME CSE
#

""" This module contains the ACME CSE implementation. It is the main module of the ACME CSE.
"""

import os, re, sys
if sys.version_info < (3, 8):
print('Python version >= 3.8 is required')
Expand All @@ -24,30 +27,51 @@
if 'ACME_DEBUG' in os.environ:
raise e

# Give hint to run ACME as a module
if 'attempted relative import' in e.msg:
print(f'\nPlease run acme as a package:\n\n\t{sys.executable} -m {sys.argv[0]} [arguments]\n')
match e.msg:
# Give hint to run ACME as a module
case x if 'attempted relative import' in x:
print(f'\nPlease run acme as a package:\n\n\t{sys.executable} -m {sys.argv[0]} [arguments]\n')

# Give hint how to do the installation
elif 'No module named' in e.msg:
m = re.search("'(.+?)'", e.msg)
package = f' ({m.group(1)}) ' if m else ' '
print(f'\nOne or more required packages or modules{package}could not be found.\nPlease install the missing packages, e.g. by running the following command:\n\n\t{sys.executable} -m pip install -r requirements.txt\n')
else:
print(f'\nError during import: {e.msg}\n')
# Give hint how to do the installation
case x if 'No module named' in x:
m = re.search("'(.+?)'", e.msg)
package = f' ({m.group(1)}) ' if m else ' '
print(f'\nOne or more required packages or modules{package}could not be found.\nPlease install the missing packages, e.g. by running the following command:\n\n\t{sys.executable} -m pip install -r requirements.txt\n')

# Ask if the user wants to install the missing packages
try:
if input('\nDo you want to install the missing packages now? [y/N] ') in ['y', 'Y']:
import os
os.system(f'{sys.executable} -m pip install -r requirements.txt')

# Ask if the user wants to start ACME
if input('\nDo you want to start ACME now? [Y/n] ') in ['y', 'Y', '']:
os.system(f'{sys.executable} -m acme {" ".join(sys.argv[1:])}')

except Exception as e2:
print(f'\nError during installation: {e2}\n')

case _:
print(f'\nError during import: {e.msg}\n')

quit(1)


# Handle command line arguments
def parseArgs() -> argparse.Namespace:
""" Parse the command line arguments.
Returns:
The parsed arguments.
"""
parser = argparse.ArgumentParser(prog='acme')
parser.add_argument('--config', action='store', dest='configfile', default=C.defaultUserConfigFile, metavar='<filename>', help='specify the configuration file')

# two mutual exlcusive arguments
groupEnableHttp = parser.add_mutually_exclusive_group()
groupEnableHttp.add_argument('--http', action='store_false', dest='http', default=None, help='run CSE with http server')
groupEnableHttp.add_argument('--https', action='store_true', dest='https', default=None, help='run CSE with https server')
groupEnableHttp.add_argument('--http-wsgi', action='store_true', dest='httpWsgi', default=None, help='run CSE with http WSGI support')

groupEnableMqtt = parser.add_mutually_exclusive_group()
groupEnableMqtt.add_argument('--mqtt', action='store_true', dest='mqttenabled', default=None, help='enable mqtt binding')
Expand Down Expand Up @@ -76,6 +100,8 @@ def parseArgs() -> argparse.Namespace:


def main() -> None:
""" Main function of the ACME CSE.
"""
# Start the CSE with command line arguments.
# In case the CSE should be started without command line parsing, the values
# can be passed instead. Unknown arguments are ignored.
Expand Down
9 changes: 8 additions & 1 deletion acme/etc/Constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ class Constants(object):
attrRiTyMapping = '__riTyMapping__'
""" Constant: Name of the 'Resource internal *__riTyMapping__* attribute. This attribute holds the mapping of resourceID's to resource types. """

attrLocCoordinage = '__locCoordinate__'
""" Constant: Name of the 'Resource internal *__locCoordinate__* attribute. This attribute holds the location coordinate of a resource. """


#
# Supported URL schemes
Expand All @@ -134,4 +137,8 @@ class Constants(object):
""" Maximum length of identifiers generated by the CSE """



#
# Network Coordination supported
#
networkCoordinationSupported = False
""" Network coordination supported by the CSE """
Loading

0 comments on commit 5fa29a6

Please sign in to comment.