Comment 5 for bug 843342

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote : Re: [Bug 843342] Re: getJobs does not return job details

On Wed, Sep 21, 2011 at 08:26:43AM -0000, Tim Waugh wrote:
> Yes, or if you need that attribute for all jobs,
> c.getJobs(requested_attributes=['job-id', 'job-media-sheets-
> completed']).
>
> You should be getting the job-uri attribute with c.getJobs() though, and
> you're not. Could you set the environment variable PYCUPS_DEBUG=1 and
> see what output you get? I get this sort of thing:
>
> -> Connection_init(host=localhost)
> begin allow threads
> httpConnectEncrypt(...)
> end allow threads
> <- Connection_init() = 0
> -> Connection_getJobs(completed,0)
> cupsDoRequest("/")
> begin allow threads
> end allow threads
> Attribute: job-uri
> Adding job-uri to job dict
> Attribute: job-id
> Adding 1 to result dict
> <- Connection_getJobs() = dict
> httpClose()

Here you go:

Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41)
[GCC 4.4.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cups
>>> c = cups.Connection()
-> Connection_init(host=localhost)
begin allow threads
httpConnectEncrypt(...)
end allow threads
<- Connection_init() = 0
>>> jobs = c.getJobs()
-> Connection_getJobs((null),0)
cupsDoRequest("/")
begin allow threads
end allow threads
Attribute: job-uri
Attribute: job-id
Adding 14 to result dict
Attribute: job-uri
Attribute: job-id
Adding 155 to result dict
Attribute: job-uri
Attribute: job-id
Adding 156 to result dict
Attribute: job-uri
Attribute: job-id
Adding 157 to result dict
<- Connection_getJobs() = dict
>>> jobs
{155: {}, 156: {}, 157: {}, 14: {}}
>>> c.getJobs(requested_attributes=['job-id', 'job-media-sheets-completed'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'requested_attributes' is an invalid keyword argument for this function
>>> c.getJobAttributes(155)['job-id']
-> Connection_getJobAttributes(155)
cupsDoRequest("/")
begin allow threads
end allow threads
<- Connection_getJobAttributes() = dict
155
>>> c.getJobAttributes(155)['job-uri']
-> Connection_getJobAttributes(155)
cupsDoRequest("/")
begin allow threads
end allow threads
<- Connection_getJobAttributes() = dict
u'ipp://localhost:631/jobs/155'
>>> c.getJobAttributes(155)['job-media-sheets-completed']
-> Connection_getJobAttributes(155)
cupsDoRequest("/")
begin allow threads
end allow threads
<- Connection_getJobAttributes() = dict
7
>>>

# lsb_release -a
LSB Version:
core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:cxx-3.0-amd64:cxx-3.0-noarch:cxx-3.1-amd64:cxx-3.1-noarch:cxx-3.2-amd64:cxx-3.2-noarch:cxx-4.0-amd64:cxx-4.0-noarch:desktop-3.1-amd64:desktop-3.1-noarch:desktop-3.2-amd64:desktop-3.2-noarch:desktop-4.0-amd64:desktop-4.0-noarch:graphics-2.0-amd64:graphics-2.0-noarch:graphics-3.0-amd64:graphics-3.0-noarch:graphics-3.1-amd64:graphics-3.1-noarch:graphics-3.2-amd64:graphics-3.2-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-3.2-amd64:printing-3.2-noarch:printing-4.0-amd64:printing-4.0-noarch:qt4-3.1-amd64:qt4-3.1-noarch
Distributor ID: Ubuntu
Description: Ubuntu 10.04.3 LTS
Release: 10.04
Codename: lucid

Running help(cups) shows that /usr/lib/pymodules/python2.6/cups.so is
being imported which is provided by the python-cups (1.9.49) package.

getJobs in this version of cupsconnection.c has

  static char *kwlist[] = { "which_jobs", "my_jobs", "limit", "first_job_id",
                            NULL };

Ryan