Using xmlrpclib to schedule a remote command
Has anyone experienced issues using this Python library? I have to use it with Satellite's API and it constantly gives me problems. For example, when trying to schedule a script remotely I use:
import xmlrpclib
earliest_occurrence = xmlrpclib.DateTime()
client.system.scheduleScriptRun(key, id, "root", "root", 600, script, earliest_occurrence)
Sometimes it works but most of the time I get this error in response:
Responses
Hello,
In the example you mentioned above I assume that you missed to type the content of the script but in your actual code you already have it defined as a string which contains the actual script.
I tried to execute this couple of times on my test satellite (v5.4.1) and it worked fine.
..snip..
id=<systemID>
earliest_occurrence = xmlrpclib.DateTime()
script="echo test"
result=sc.system.scheduleScriptRun(sk, id, "root", "root", 600, script, earliest_occurrence)
..snip..
Are you facing this error on the same script or there are other scripts using this API call and failing randomly? When it keeps failing have you tried to execute the same remote command through web-interface of the system ?
Paresh
Hello Chris,
Yes you are right. It would check the immediate directory first and then move on to other directories as defined/exported (as per sys.path). To check the list you could execute:
import sys
print sys.path
Checking python docs for sys.path "the first item of this list, path[0], is the directory containing the script that was used to invoke the Python interpreter. If the script directory is not available (e.g. if the interpreter is invoked interactively or if the script is read from standard input), path[0] is the empty string, which directs Python to search modules in the current directory first. Notice that the script directory is inserted before the entries inserted as a result of PYTHONPATH."
So yes likely the libs in your current directory might be leading to the error. Without looking into the actual content of the directory it would be hard to confirm.
Paresh