This commit is contained in:
		
							
								
								
									
										38
									
								
								.drone.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								.drone.yml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
				
			|||||||
 | 
					kind: pipeline
 | 
				
			||||||
 | 
					type: docker
 | 
				
			||||||
 | 
					name: default
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					steps:
 | 
				
			||||||
 | 
					  - name: static_analysis
 | 
				
			||||||
 | 
					    image: "python:3.8"
 | 
				
			||||||
 | 
					    commands:
 | 
				
			||||||
 | 
					      - pip3 install --cache-dir='./.pipcache' pylint bandit mccabe
 | 
				
			||||||
 | 
					      - pip3 install --cache-dir='./.pipcache' -r requirements.txt
 | 
				
			||||||
 | 
					      - find . -name "*.py" -exec python3 -m py_compile '{}' \;
 | 
				
			||||||
 | 
					      - find . -name "*.py" -exec pylint '{}' + || if [ $? -eq 1 ]; then echo "you fail"; fi
 | 
				
			||||||
 | 
					      - find . -name "*.py" -exec python3 -m mccabe --min 3 '{}' + || if [ $? -eq 1 ]; then echo "you fail"; fi
 | 
				
			||||||
 | 
					      - bandit -r . + || if [ $? -eq 1 ]; then echo "you fail"; fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: code-analysis
 | 
				
			||||||
 | 
					    image: aosapps/drone-sonar-plugin
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      sonar_host:
 | 
				
			||||||
 | 
					        from_secret: SONAR_HOST
 | 
				
			||||||
 | 
					      sonar_token:
 | 
				
			||||||
 | 
					        from_secret: SONAR_CODE
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: sentry
 | 
				
			||||||
 | 
					    image: tormachris/drone-sentry
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      sentry_project: ${DRONE_REPO_NAME}
 | 
				
			||||||
 | 
					      sentry_domain: sentry.kmlabz.com
 | 
				
			||||||
 | 
					      sentry_token:
 | 
				
			||||||
 | 
					        from_secret: SENTRY_TOKEN
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  - name: ms-teams
 | 
				
			||||||
 | 
					    image: kuperiu/drone-teams
 | 
				
			||||||
 | 
					    settings:
 | 
				
			||||||
 | 
					      webhook:
 | 
				
			||||||
 | 
					        from_secret: TEAMS_WEBHOOK
 | 
				
			||||||
 | 
					    when:
 | 
				
			||||||
 | 
					      status: [ failure ]
 | 
				
			||||||
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -129,3 +129,4 @@ dmypy.json
 | 
				
			|||||||
# Pyre type checker
 | 
					# Pyre type checker
 | 
				
			||||||
.pyre/
 | 
					.pyre/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.idea/
 | 
				
			||||||
							
								
								
									
										1
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					sentry_sdk
 | 
				
			||||||
							
								
								
									
										31
									
								
								src/app.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								src/app.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,31 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					import logging
 | 
				
			||||||
 | 
					import sentry_sdk
 | 
				
			||||||
 | 
					from sentry_sdk.integrations.logging import LoggingIntegration
 | 
				
			||||||
 | 
					import config
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Main Entrypoint
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "app"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					sentry_logging = LoggingIntegration(
 | 
				
			||||||
 | 
					    level=logging.INFO,
 | 
				
			||||||
 | 
					    event_level=logging.ERROR
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if config.SENTRY_DSN:
 | 
				
			||||||
 | 
					    sentry_sdk.init(
 | 
				
			||||||
 | 
					        dsn=config.SENTRY_DSN,
 | 
				
			||||||
 | 
					        integrations=[sentry_logging],
 | 
				
			||||||
 | 
					        traces_sample_rate=1.0,
 | 
				
			||||||
 | 
					        send_default_pii=True,
 | 
				
			||||||
 | 
					        release=config.RELEASE_ID,
 | 
				
			||||||
 | 
					        environment=config.RELEASEMODE,
 | 
				
			||||||
 | 
					        _experiments={"auto_enabling_integrations": True}
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
							
								
								
									
										15
									
								
								src/config.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								src/config.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,15 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					import os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Main Flask RESTful API
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "app"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					SENTRY_DSN = os.environ.get("SENTRY_DSN")
 | 
				
			||||||
 | 
					RELEASE_ID = os.environ.get("RELEASE_ID", "test")
 | 
				
			||||||
 | 
					RELEASEMODE = os.environ.get("INPUT_SERVICE_RELEASEMODE", "dev")
 | 
				
			||||||
							
								
								
									
										0
									
								
								src/preprocessor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/preprocessor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										24
									
								
								src/preprocessor/abcpreprocessor.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/preprocessor/abcpreprocessor.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					from abc import ABC, abstractmethod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Abstract base class for Sender
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "abcpreprocessor"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AbcPreProcessor(ABC):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Abstract base class PreProcessor. Responsible for manipulating input data from a sensor.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    @abstractmethod
 | 
				
			||||||
 | 
					    def preprocesssignal(self, signal):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Preprocess a signal.
 | 
				
			||||||
 | 
					        :return:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
							
								
								
									
										0
									
								
								src/sender/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/sender/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										24
									
								
								src/sender/abcsender.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/sender/abcsender.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					from abc import ABC, abstractmethod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Abstract base class for Sender
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "abcsender"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AbcSender(ABC):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Abstract base class Sender. Responsible for sending results to the cloud.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    @abstractmethod
 | 
				
			||||||
 | 
					    def sendvalue(self, value, decision):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Send a value to the cloud.
 | 
				
			||||||
 | 
					        :return:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
							
								
								
									
										0
									
								
								src/sensor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/sensor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										24
									
								
								src/sensor/abcsensor.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/sensor/abcsensor.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					from abc import ABC, abstractmethod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Abstract base class for Sensor
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "abcsensor"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AbcSensor(ABC):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Abstract base class Sensor. Responsible for value retrieval from hardware sensors.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    @abstractmethod
 | 
				
			||||||
 | 
					    def getvalue(self):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Retrieve a value from a sensor.
 | 
				
			||||||
 | 
					        :return:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
							
								
								
									
										0
									
								
								src/signal_processor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								src/signal_processor/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										24
									
								
								src/signal_processor/abcsignalprocessor.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								src/signal_processor/abcsignalprocessor.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,24 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env python3
 | 
				
			||||||
 | 
					from abc import ABC, abstractmethod
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					Abstract base class for signalprocessor
 | 
				
			||||||
 | 
					"""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					__author__ = "@tormakris"
 | 
				
			||||||
 | 
					__copyright__ = "Copyright 2020, Birbnetes Team"
 | 
				
			||||||
 | 
					__module_name__ = "abcsignalprocessor"
 | 
				
			||||||
 | 
					__version__text__ = "1"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AbcSignalProcessor(ABC):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    Abstract base class Signal Processor. Responsible for handling a signal processor pipeline.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    @abstractmethod
 | 
				
			||||||
 | 
					    def processcurrentsignal(self):
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        Process a signal.
 | 
				
			||||||
 | 
					        :return:
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        pass
 | 
				
			||||||
		Reference in New Issue
	
	Block a user