1

I am using python to determine the status of an upstart job on Ubuntu.

I've recently changed the upstart job so that it has an Instance stanza as such: instance $some_var. As expected, my code no longer works.

If I try:

path = upstart.GetJobByName("test", dbus_interface="com.ubuntu.Upstart0_6")                                         
job = bus.get_object("com.ubuntu.Upstart", path)                           
path = job.GetInstance([], dbus_interface="com.ubuntu.Upstart0_6.Job")

It fails telling me dbus.exceptions.DBusException: org.freedesktop.DBus.Error.InvalidArgs: Unknown parameter: some_var

I need to pass the some_var environment variable to the dbus interface. How might I do that? Setting it in os.environ doesn't appear to do the trick.

rod
  • 3,403
  • 4
  • 19
  • 25

1 Answers1

0

I think job.GetInstance(["some_var=some_value"]) should work. At least this works fine for me:

dbus-send --print-reply --system /com/ubuntu/Upstart/jobs/tty \
          --dest=com.ubuntu.Upstart \
          com.ubuntu.Upstart0_6.Job.GetInstance array:string:"TTY=/dev/tty2"

(tty service was defined with instance $TTY)

Also check the description of env argument for com.ubuntu.Upstart0_6.Job.Start.

abbot
  • 27,408
  • 6
  • 54
  • 57