getJobs does not return job details

Bug #843342 reported by Ryan Lovett
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-cups (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

On hardy, running:

import cups
c = cups.Connection()
c.getJobs('completed')

which return a dictionary of completed jobs where the values are dictionaries with useful information, e.g.

{'job-name': u'lab1.pdf', 'job-printer-uri': u'ipp://server:631/printers/lj', 'time-at-completed': 1315344646, 'job-priority': 50, 'time-at-processing': 1315344638, 'job-state': 9, 'job-preserved': False, 'job-k-octets': 231, 'job-media-sheets-completed': 0, 'time-at-creation': 1315344638, 'job-originating-user-name': u'user1'}

On lucid, the method returns a dictionary with empty values. /var/spool/cups does contain files with job information. Permissions on /var/spool/cups and its contents are the same between hardy and lucid.

# directory
drwx--x--- 3 root lp 4096 2011-09-06 15:05 /var/spool/cups
# spool file
-rw------- 1 root lp 10159 2011-09-06 14:35 c00128

The process table shows cupsd running as root.

Revision history for this message
Tim Waugh (twaugh) wrote :

How do you mean "empty values"? You should get a dict of job_id: {'job_uri': str}, as by default the only attributes returned now are job_id and job_uri.

To specify other attributes, use the request_attributes parameter (make sure to include 'job_id', of course).

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

On Tue, Sep 20, 2011 at 12:33:42PM -0000, Tim Waugh wrote:
> How do you mean "empty values"? You should get a dict of job_id:
> {'job_uri': str}, as by default the only attributes returned now are
> job_id and job_uri.
>
> To specify other attributes, use the request_attributes parameter (make
> sure to include 'job_id', of course).

Sorry for not including an example. Here's what we see:

>>> c.getJobs('completed')
{1: {}, 2: {}, 3: {}, 4: {}, 5: {}, 6: {}, 7: {}, 8: {}, 9: {}, 10: {},
11: {}, 12: {}, 13: {}, 15: {}, 16: {}, 17: {}, 18: {}, 19: {}, 20: {},
21: {}, 22: {}, 23: {}, 24: {}, 25: {}, 26: {}, 27: {}, 28: {}, 29: {},
30: {}, 31: {}, 32: {}, 33: {}, 34: {}, 35: {}, 36: {}, 37: {}, 38: {},
39: {}, 40: {}, 41: {}, 42: {}, 43: {}, 44: {}, 45: {}, 46: {}, 47: {},
48: {}, 49: {}, 50: {}, 51: {}, 52: {}, 53: {}, 54: {}, 55: {}, 60: {},
61: {}, 62: {}, 63: {}, 64: {}, 65: {}, 66: {}, 67: {}, 68: {}, 69: {},
70: {}, 71: {}, 72: {}, 74: {}, 77: {}, 78: {}, 83: {}, 84: {}, 85: {},
86: {}, 87: {}, 88: {}, 89: {}, 90: {}, 91: {}, 92: {}, 93: {}, 94: {},
95: {}, 96: {}, 97: {}, 98: {}, 99: {}, 100: {}, 101: {}, 102: {}, 103:
{}, 104: {}, 105: {}, 106: {}, 107: {}, 108: {}, 109: {}, 110: {}, 111:
{}, 112: {}, 113: {}, 114: {}, 115: {}, 116: {}, 117: {}, 118: {}, 119:
{}, 120: {}, 121: {}, 122: {}, 123: {}, 124: {}, 125: {}, 126: {}, 127:
{}, 128: {}, 129: {}, 130: {}, 131: {}, 132: {}, 133: {}, 134: {}, 135:
{}, 136: {}, 137: {}, 138: {}, 139: {}, 140: {}, 141: {}, 142: {}, 143:
{}, 144: {}, 145: {}, 146: {}, 147: {}, 148: {}, 149: {}, 150: {}, 151:
{}, 152: {}, 153: {}, 154: {}, 158: {}, 159: {}, 160: {}, 161: {}, 162:
{}, 163: {}, 164: {}, 165: {}, 166: {}, 167: {}, 168: {}, 169: {}, 170:
{}, 171: {}, 172: {}, 173: {}, 174: {}, 175: {}, 176: {}, 177: {}, 178:
{}, 179: {}, 180: {}, 181: {}, 182: {}, 183: {}, 184: {}, 185: {}, 186:
{}, 187: {}, 188: {}, 189: {}, 190: {}, 191: {}, 192: {}, 193: {}, 194:
{}, 195: {}, 196: {}, 197: {}, 198: {}, 199: {}, 200: {}, 201: {}, 202:
{}, 203: {}, 204: {}}

Ryan

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :

Documented in https://bugzilla.redhat.com/show_bug.cgi?id=584806 apparently. So it looks like I need to do something like:

c.getJobAttributes(202)['job-media-sheets-completed']

instead. Thanks for the pointer.

Changed in python-cups (Ubuntu):
status: New → Invalid
Revision history for this message
Tim Waugh (twaugh) 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()

Revision history for this message
Ryan Lovett (ryan-spacecoaster) wrote :
Download full text (3.4 KiB)

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/pyth...

Read more...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.