Thanks for reporting, it's probably a bug. The guest interface is named br-guest-turris
whereas the Pakon configuration contains br-guest_turris
. We will fix it. Please try to change the name in /etc/config/pakon
for now.
I don't trust all home appliances (heat pump, thermometer, ...), so I have most of them on the wifi network for guests. Now I wanted to find out where they connect to, but Pakon doesn't monitor devices on the guest wifi network. Can this setting be changed?
please check aa77c1d5 in that regard
Filip Hron (aa77c1d5) at 24 May 10:16
fix: create directory if not exists
Filip Hron (8eddbaa1) at 24 May 08:15
Apply 2 suggestion(s) to 1 file(s)
Overall the code looks fine.
I have just few notes and suggestions.
This looks fine in general, but sadly it still interferes with other high level actions (create-databases, backup) in __main__.py
.
If there is no archive file found, then it works fine.
But in case there is no /srv/pakon
, then any maintain action fails with following traceback:
$ pakon-maintain create-databases
Traceback (most recent call last):
File "/usr/lib/python3.10/site-packages/pakon/maintain/archive.py", line 38, in <module>
con = sqlite3.connect(archive_path, isolation_level=None, timeout=30.0)
sqlite3.OperationalError: unable to open database file
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/bin/pakon-maintain", line 33, in <module>
sys.exit(load_entry_point('pakon==1.2.2', 'console_scripts', 'pakon-maintain')())
File "/usr/bin/pakon-maintain", line 25, in importlib_load_entry_point
return next(matches).load()
File "/usr/lib/python3.10/importlib/metadata/__init__.py", line 171, in load
File "/usr/lib/python3.10/importlib/__init__.py", line 126, in import_module
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "/usr/lib/python3.10/site-packages/pakon/maintain/__main__.py", line 4, in <module>
from .archive import archive
File "/usr/lib/python3.10/site-packages/pakon/maintain/archive.py", line 40, in <module>
raise NotExistsException(f"The database {archive_path} does not exist yet.") from e
pakon.maintain.archive.NotExistsException: The database /srv/pakon/pakon-archive.db does not exist yet.
I'd suggest either adding this somewhere before the try/except block
os.makedirs("/srv/pakon", exist_ok=True)
or wrap this try/except block inside function, so it does not get executed immediately just by
# some other file
from .archive import archive
This exception handling does not work quite right.
except sqlite3.OperationalError as e:
INTERVALS.get()
could return None
, thus multiplying decimal value with result of dict.get()
could fail on:
unsupported operand type(s) for *: 'int' and 'NoneType'
But I see that previous code was event more fragile, so I guess that this can be postponed to additional refactoring.
I'd suggest to fallback to some safe value, let's say 1 second.
return dec * INTERVALS.get(st.upper(), 1)
Fair point. In that case, let's postpone it to later refactoring.
I believe that creating the directory, if it doesn't exist, should be enough.
Quick test on TOS 7.0 shows that sqlite handles creating file just fine, but parent directory has to exist.
>>> import sqlite3
>>> sqlite3.connect("/tmp/foo.db")
<sqlite3.Connection object at 0x7fae82c460>
>>> sqlite3.connect("/some/nonsense/path/foo.db")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
sqlite3.OperationalError: unable to open database file
This need another ticket. Given that the refactoring of the whole package took place, I'd postpone this comment to another issue.
The thing is, that the code is not optimized in any way. We are making it to be proper package first, the rest of refactoring is postponed for another issues.
Filip Hron (7e550a00) at 17 May 09:46
fix: make directory, skip if exists
make some cli commands to better handle corner cases that might occur in app.
It means making directory should be sufficient enough? It might got out at some point, I don't really remember from the top of my head.
No problem, I understand. I have to kick it myself from this now on :)
Sorry, but I am not going to work on this anymore.