I’ve tried to use PBS hook and psycopg2 python library to write jobs’ data and users’ data to postgres database.
The problem is when I let the event trigger be “queuejob,modifyjob,resvsub,movejob,runjob”, psycopg2 library is imported with no problem. But when I try the event trigger “execjob_begin,execjob_prologue,execjob_epilogue,execjob_preterm,execjob_end,exechost_periodic,execjob_launch,exechost_startup,execjob_attach” pbs_python can not import the library.
The code which I’ve tried:
try:
import psycopg2
except:
file.write("###########Can not import the module #################\n")
import os,sys
lib_path_python27='/usr/lib64/python2.7/site-packages'
if lib_path_python27 not in sys.path:
sys.path.append(lib_path_python27)
print sys.path
import psycopg2
dir(psycopg2)
To test this, just run the code using pbs_python abovecode.py , if this works, then
it should work in your hook as well.