mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-04 02:48:12 +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
|
||||
*.log.*
|
||||
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
||||
+2
-1
@@ -11,9 +11,10 @@ RUN pip install --no-cache-dir --upgrade pycryptodomex==3.11.0 -r requirements.t
|
||||
|
||||
COPY SunGather/ .
|
||||
|
||||
VOLUME /logs
|
||||
VOLUME /config
|
||||
COPY SunGather/config-example.yaml /config/config.yaml
|
||||
|
||||
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
|
||||
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
|
||||
<p align="right">(<a href="#top">back to top</a>)</p>
|
||||
|
||||
|
||||
+524
-99
File diff suppressed because it is too large
Load Diff
+11
-5
@@ -8,6 +8,7 @@ from datetime import datetime
|
||||
|
||||
import importlib
|
||||
import logging
|
||||
import logging.handlers
|
||||
import sys
|
||||
import getopt
|
||||
import yaml
|
||||
@@ -394,9 +395,10 @@ class SungrowInverter():
|
||||
|
||||
def main():
|
||||
configfilename = 'config.yaml'
|
||||
logfolder = ''
|
||||
|
||||
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:
|
||||
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'Options and arguments:')
|
||||
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'--runonce : Run once then exit')
|
||||
print(f'-h : print this help message and exit (also --help)')
|
||||
@@ -414,7 +417,9 @@ def main():
|
||||
print(f'python3 sungather.py -c /full/path/config.yaml\n')
|
||||
sys.exit()
|
||||
elif opt == '-c':
|
||||
configfilename = arg
|
||||
configfilename = arg
|
||||
elif opt == '-l':
|
||||
logfolder = arg
|
||||
elif opt == '-v':
|
||||
if arg.isnumeric():
|
||||
if int(arg) >= 0 and int(arg) <= 50:
|
||||
@@ -426,7 +431,7 @@ def main():
|
||||
logging.error(f"Valid verbose options: 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error")
|
||||
sys.exit(2)
|
||||
elif opt == '--runonce':
|
||||
runonce = True
|
||||
runonce = True
|
||||
|
||||
logging.info(f'Starting SunGather {__version__}')
|
||||
|
||||
@@ -443,6 +448,7 @@ def main():
|
||||
try:
|
||||
registersfile = yaml.safe_load(open('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:
|
||||
logging.error(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 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")
|
||||
fh = logging.FileHandler(logfile, mode='w', encoding='utf-8')
|
||||
logfile = logfolder + "SunGather.log"
|
||||
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.setLevel(config_inverter['log_file'])
|
||||
logger.addHandler(fh)
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = '0.3.5'
|
||||
__version__ = '0.3.6'
|
||||
Reference in New Issue
Block a user