LibreQoS icon indicating copy to clipboard operation
LibreQoS copied to clipboard

Running LibreQoS.py from other place like it's dir gives an error - small improvment needed

Open interduo opened this issue 2 years ago • 20 comments

python3 /root/LibreQoS/v1.1/LibreQoS.py 
Traceback (most recent call last):
  File "/root/LibreQoS/v1.1/LibreQoS.py", line 243, in <module>
    refreshShapers()
  File "/root/LibreQoS/v1.1/LibreQoS.py", line 45, in refreshShapers
    with open('Shaper.csv') as csv_file:
FileNotFoundError: [Errno 2] No such file or directory: 'Shaper.csv'

root@rty-libreqos:~# ls -la /root/LibreQoS/v1.1/Shaper.csv -rw-r--r-- 1 root root 564 Aug 31 12:07 /root/LibreQoS/v1.1/Shaper.csv

Script should:

  • use config file declared in parameter --configShaper=Shaper.csv --configNetwork=network.json,
  • if not is avaiable in parameter then use file from directory of the script,
  • if no is avaiable print an error,

This would be small improvement because if we would like to run it's from crontab we have to use bash wrapper script.

interduo avatar Aug 31 '22 15:08 interduo

a short term fix by using crontab, "cd therightdir; LibreQos whatever".

Certainly having more options that make sense would be good.

dtaht avatar Sep 03 '22 00:09 dtaht

The same fix should be done for lqTools.py.

interduo avatar Sep 21 '22 08:09 interduo

done?

also lqos is shorter... - symlink?

dtaht avatar Nov 13 '22 17:11 dtaht

This is still a thing.

interduo avatar Nov 14 '22 07:11 interduo

lq.sh ?

interduo avatar Nov 14 '22 07:11 interduo

Someday it wont be a shell script. lq has a high probability of colliding with something...

dtaht avatar Nov 14 '22 08:11 dtaht

Sorry I mean lq.py so You need always to write extension

interduo avatar Nov 14 '22 08:11 interduo

I think we have settled for lqos as the script name. AS for the locking issue?

dtaht avatar Nov 28 '22 18:11 dtaht

lqos.py is a good name.

interduo avatar Nov 28 '22 21:11 interduo

Fixed with https://github.com/LibreQoE/LibreQoS/commit/9ad1de6ef5afb7a06e059ab0025e367dbeafa7cd

rchac avatar Feb 05 '23 02:02 rchac

@rchac You closed different issue than mentioned in commit. I reopened it - my tests

ssh sshuser@libreqos -c '/opt/libreqos/src/LibreQoS.py --updateonly'

lqosd is running
refreshShapers starting at 07/02/2023 15:20:13
Rust validated ShapedDevices.csv
Traceback (most recent call last):
  File "/opt/libreqos/src/LibreQoS.py", line 1331, in <module>
    refreshShapersUpdateOnly()
  File "/opt/libreqos/src/LibreQoS.py", line 928, in refreshShapersUpdateOnly
    if (validateNetworkAndDevices() == True):
  File "/opt/libreqos/src/LibreQoS.py", line 139, in validateNetworkAndDevices
    with open('network.json') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'network.json'

interduo avatar Feb 07 '23 14:02 interduo

Just to better understand, you're wanting this ability so that you can run from crontab instead of systemd?

rchac avatar Feb 07 '23 15:02 rchac

I would like to have reloading done immediately after uploading file - so I run this magic command through SSH.

Doing it is good like that because I get back errors to my CRM when occurs.

image

@rchac how can I run --updateonly with systemd?

In other scenario/method: I can wait less than minute. (and not run a trigger command with --updateonly) - but what about errors (in this scenario i would not see them)?

interduo avatar Feb 07 '23 15:02 interduo

Is it possible to just SCP the ShapedDevices.csv file to /opt/libreqos then run --updateonly? Both the python and rust side look for a bunch of files to be available to them in the /opt/libreqos/src folder.

rchac avatar Mar 20 '23 15:03 rchac

@rchac I get few hours and do an update to current master branch state

# git status
HEAD detached from 6e92a07
nothing to commit, working tree clean

running command: root@libreqos:~# /opt/libreqos/src/LibreQoS.py --updateonly

generates an error:

Running Python Version 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0]
lqosd is running
lqosd is running
refreshShapers starting at 21/03/2023 16:24:47
Rust validated ShapedDevices.csv
Traceback (most recent call last):
  File "/opt/libreqos/src/LibreQoS.py", line 1369, in <module>
    refreshShapersUpdateOnly()
  File "/opt/libreqos/src/LibreQoS.py", line 952, in refreshShapersUpdateOnly
    if (validateNetworkAndDevices() == True):
  File "/opt/libreqos/src/LibreQoS.py", line 140, in validateNetworkAndDevices
    with open('network.json') as file:
FileNotFoundError: [Errno 2] No such file or directory: 'network.json'

interduo avatar Mar 21 '23 15:03 interduo

@interduo Your network.json file seems to be missing

rchac avatar Mar 21 '23 15:03 rchac

@rchac

root@libreqos:~# ls -la /opt/libreqos/src/network.json 
-rw-r--r-- 1 root root 3 Jan 20 14:20 /opt/libreqos/src/network.json

interduo avatar Mar 21 '23 15:03 interduo

This looks complete?

dtaht avatar Apr 05 '23 17:04 dtaht

No it isn't or what commit fixed that?

interduo avatar Apr 05 '23 17:04 interduo