Hi,

I guess, you are using other credentials in Python than in the bconsole. The bconsole has normally root access, while in Python you are typically using a named console with limited permissions (profile).

Regards,
Jörg

On 31.05.24 at 18:39 wrote Yan Silva:
Hi folks!!

I have a script in python to get a number of jobs in Warning and Error, but when i try to execute the script, for example: python testing_script.py get_error_jobs, hes show me this error:

   File "/usr/lib/python3.9/site-packages/bareos/bsock/directorconsolejson.py", line 93, in call
     raise bareos.exceptions.JsonRpcErrorReceivedException(json)
bareos.exceptions.JsonRpcErrorReceivedException: failed: .sql: is an invalid command.

The function from script is:

def get_error_jobs(args):
     console = create_console()
    error_jobs = console.call('.sql query="SELECT COUNT(Job) FROM Job where jobstatus=\'E\' AND starttime >= current_date - INTERVAL \'1 days\';"')
     try:
         print((error_jobs["query"][0]["count"]))
     except KeyError:
         print(0)

I execute directly this comand (.sql query="SELECT COUNT(Job) FROM Job where jobstatus=\'E\' AND starttime >= current_date - INTERVAL \'1 days\';) in the bconsole, and hes works fine.

Has anyone experienced this problem?

--
You received this message because you are subscribed to the Google Groups "bareos-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/bareos-users/ca42ebd4-19b8-4de3-a855-0160ad718700n%40googlegroups.com <https://groups.google.com/d/msgid/bareos-users/ca42ebd4-19b8-4de3-a855-0160ad718700n%40googlegroups.com?utm_medium=email&utm_source=footer>.

--
 Jörg Steffens                   [email protected]
 Bareos GmbH & Co. KG            Phone: +49 221 630693-91
 https://www.bareos.com

 Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646
 Komplementär: Bareos Verwaltungs-GmbH
 Geschäftsführer: Stephan Dühr, Jörg Steffens, Philipp Storz


--
You received this message because you are subscribed to the Google Groups 
"bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bareos-users/v3eu0v%24n9g%241%40ciao.gmane.io.

Reply via email to