mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-24 03:12:33 +10:00
v0.3.6: Registers version, logging option, hybrid registers
This commit is contained in:
+117
@@ -0,0 +1,117 @@
|
|||||||
|
config.yaml
|
||||||
|
*.log.*
|
||||||
|
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# celery beat schedule file
|
||||||
|
celerybeat-schedule
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
config.yaml
|
config.yaml
|
||||||
|
*.log.*
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|||||||
+2
-1
@@ -11,9 +11,10 @@ RUN pip install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.t
|
|||||||
|
|
||||||
COPY SunGather/ .
|
COPY SunGather/ .
|
||||||
|
|
||||||
|
VOLUME /logs
|
||||||
VOLUME /config
|
VOLUME /config
|
||||||
COPY SunGather/config-example.yaml /config/config.yaml
|
COPY SunGather/config-example.yaml /config/config.yaml
|
||||||
|
|
||||||
USER sungather
|
USER sungather
|
||||||
|
|
||||||
CMD [ "python", "sungather.py", "-c", "/config/config.yaml" ]
|
CMD [ "python", "sungather.py", "-c", "/config/config.yaml", "-l", "/logs/" ]
|
||||||
@@ -138,6 +138,10 @@ or if using the webserver export
|
|||||||
```sh
|
```sh
|
||||||
docker run -v {path to}/config.yaml:/config/config.yaml -e TZ=Australia/Sydney -p 8080:8080 --name sungather bohdans/sungather
|
docker run -v {path to}/config.yaml:/config/config.yaml -e TZ=Australia/Sydney -p 8080:8080 --name sungather bohdans/sungather
|
||||||
```
|
```
|
||||||
|
with webserever export and logging
|
||||||
|
```sh
|
||||||
|
docker run -v {path to}/config.yaml:/config/config.yaml -v{logpath}:/logs -e TZ=Australia/Sydney -p 8080:8080 --name sungather bohdans/sungather
|
||||||
|
```
|
||||||
Note: replace Australia/Sydney with relevant timezone
|
Note: replace Australia/Sydney with relevant timezone
|
||||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||||
|
|
||||||
|
|||||||
+524
-99
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ from datetime import datetime
|
|||||||
|
|
||||||
import importlib
|
import importlib
|
||||||
import logging
|
import logging
|
||||||
|
import logging.handlers
|
||||||
import sys
|
import sys
|
||||||
import getopt
|
import getopt
|
||||||
import yaml
|
import yaml
|
||||||
@@ -394,9 +395,10 @@ class SungrowInverter():
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
configfilename = 'config.yaml'
|
configfilename = 'config.yaml'
|
||||||
|
logfolder = ''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(sys.argv[1:],"hc:v:", "runonce")
|
opts, args = getopt.getopt(sys.argv[1:],"hc:l:v:", "runonce")
|
||||||
except getopt.GetoptError:
|
except getopt.GetoptError:
|
||||||
logging.debug(f'No options passed via command line')
|
logging.debug(f'No options passed via command line')
|
||||||
|
|
||||||
@@ -407,6 +409,7 @@ def main():
|
|||||||
print(f'\nCommandling arguments override any config file settings')
|
print(f'\nCommandling arguments override any config file settings')
|
||||||
print(f'Options and arguments:')
|
print(f'Options and arguments:')
|
||||||
print(f'-c config.yaml : Specify config file.')
|
print(f'-c config.yaml : Specify config file.')
|
||||||
|
print(f'-l /logs/ : Specify folder to store logs.')
|
||||||
print(f'-v 30 : Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error')
|
print(f'-v 30 : Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error')
|
||||||
print(f'--runonce : Run once then exit')
|
print(f'--runonce : Run once then exit')
|
||||||
print(f'-h : print this help message and exit (also --help)')
|
print(f'-h : print this help message and exit (also --help)')
|
||||||
@@ -415,6 +418,8 @@ def main():
|
|||||||
sys.exit()
|
sys.exit()
|
||||||
elif opt == '-c':
|
elif opt == '-c':
|
||||||
configfilename = arg
|
configfilename = arg
|
||||||
|
elif opt == '-l':
|
||||||
|
logfolder = arg
|
||||||
elif opt == '-v':
|
elif opt == '-v':
|
||||||
if arg.isnumeric():
|
if arg.isnumeric():
|
||||||
if int(arg) >= 0 and int(arg) <= 50:
|
if int(arg) >= 0 and int(arg) <= 50:
|
||||||
@@ -443,6 +448,7 @@ def main():
|
|||||||
try:
|
try:
|
||||||
registersfile = yaml.safe_load(open('registers.yaml'))
|
registersfile = yaml.safe_load(open('registers.yaml'))
|
||||||
logging.info(f"Loaded registers: {os.getcwd()}/registers.yaml")
|
logging.info(f"Loaded registers: {os.getcwd()}/registers.yaml")
|
||||||
|
logging.info(f"Registers file version: {registersfile.get('version','UNKNOWN')}")
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logging.error(f"Failed: Loading registers: {os.getcwd()}/registers.yaml {err}")
|
logging.error(f"Failed: Loading registers: {os.getcwd()}/registers.yaml {err}")
|
||||||
sys.exit(f"Failed: Loading registers: {os.getcwd()}/registers.yaml {err}")
|
sys.exit(f"Failed: Loading registers: {os.getcwd()}/registers.yaml {err}")
|
||||||
@@ -470,8 +476,8 @@ def main():
|
|||||||
|
|
||||||
if not config_inverter['log_file'] == "OFF":
|
if not config_inverter['log_file'] == "OFF":
|
||||||
if config_inverter['log_file'] == "DEBUG" or config_inverter['log_file'] == "INFO" or config_inverter['log_file'] == "WARNING" or config_inverter['log_file'] == "ERROR":
|
if config_inverter['log_file'] == "DEBUG" or config_inverter['log_file'] == "INFO" or config_inverter['log_file'] == "WARNING" or config_inverter['log_file'] == "ERROR":
|
||||||
logfile = datetime.now().strftime("%Y%m%d_%H%M%S_SunGather.log")
|
logfile = logfolder + "SunGather.log"
|
||||||
fh = logging.FileHandler(logfile, mode='w', encoding='utf-8')
|
fh = logging.handlers.RotatingFileHandler(logfile, mode='w', encoding='utf-8', maxBytes=10485760, backupCount=10) # Log 10mb files, 10 x files = 100mb
|
||||||
fh.formatter = logger.handlers[0].formatter
|
fh.formatter = logger.handlers[0].formatter
|
||||||
fh.setLevel(config_inverter['log_file'])
|
fh.setLevel(config_inverter['log_file'])
|
||||||
logger.addHandler(fh)
|
logger.addHandler(fh)
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
__version__ = '0.3.5'
|
__version__ = '0.3.6'
|
||||||
Reference in New Issue
Block a user