[prev in list] [next in list] [prev in thread] [next in thread] 

List:       debian-user
Subject:    tea4cups: AttributeError: \'HTTPResponse\' object has no attribute \'content\'
From:       Rainer Dorsch <ml () bokomoko ! de>
Date:       2022-02-21 16:27:03
Message-ID: 11024343.3KtiyMlAqA () h370
[Download RAW message or body]

Hi,

I receive this entry in the cups error_log:

D [21/Feb/2022:16:56:55 +0100] [Job 894] [TEA4CUPS]_DEBUG: Tea4CUPS 
v3.15alpha_unofficial (PID 29291) : Tea4CUPS (PID 29291) : ERROR: Tea4CUPS 
v3.15alpha_unofficial 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) : Traceback 
(most recent call last): 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 1177, in initBackend 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     answer = 
cupsserver.getJobAttributes(self.JobId) 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 784, in getJobAttributes 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     return 
self.doRequest(req) 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 762, in doRequest 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     
wrapper.logDebug(\"request content: %s\"%str(r.raw.content)) 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) : 
AttributeError: \'HTTPResponse\' object has no attribute \'content\' 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) : During 
handling of the above exception, another exception occurred: 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) : Traceback 
(most recent call last): 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 1547, in <module> 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     
wrapper.initBackend() 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 1183, in initBackend 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     
(ippfilename, answer) = self.parseIPPRequestFile() 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/cups/backend/tea4cups\", line 1233, in parseIPPRequestFile 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     ippmessage 
= IPPRequest(ippdatafile.read()) 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :   File \"/usr/
lib/python3.9/codecs.py\", line 322, in decode 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) :     (result, 
consumed) = self._buffer_decode(data, self.errors, final) 
E [21/Feb/2022:16:56:55 +0100] [Job 894] Tea4CUPS (PID 29291) : 
UnicodeDecodeError: \'utf-8\' codec can\'t decode byte 0xe6 in position 411: 
invalid continuation byte 
D [21/Feb/2022:16:56:55 +0100] [Job 894] root:Cleaning up...

Relevant code from tea4cups is here:

    def doRequest(self, req, url=None) :
        """Sends a request to the CUPS server.                                        \
  returns a new IPPRequest object, containing the parsed answer.                      \
  """
        data = req.dump()
        headers = {'Connection':'close','Content-Type': 'application/
ipp','Accept-Encoding':'identity'}
        auth=None
        if self.username :
            auth=(self.username, self.password or "")

        # TODO proper error handling                                                  \
  #self.lastError = None                                                              \
  #self.lastErrorMessage = None                                                       \


        r = requests.post(url=url or self.url, auth=auth, data=data, 
headers=headers, stream=True)
        r.raw.decode_content=True

        datas = r.raw

        wrapper.logDebug("data to parse: %s" % str(datas))
        wrapper.logDebug("request content: %s"%str(r.raw.content))
        ippresponse = IPPRequest(datas)

        ippresponse.parse()
        return ippresponse

I looks somewhat like something is doing wrong in the debug output which stops 
the print job. Is that correct?

Without tea4cups, everything prints correctly.

In /etc/cups/tea4cups.conf I added two scripts to power on the printer, wait 
until it responds on port 80 on the network and to power it off again:

# poweron printer when a printjob is running, count jobs, and power off printer 
again
prehook_sispmctl : /usr/local/bin/printeron.sh
posthook_sispmctl : /usr/local/bin/printerdone.sh


root@home:/etc/cups# cat /usr/local/bin/printeron.sh 
#!/bin/sh

. /var/smarthome/files/list.sh
# Check timeout
. /var/smarthome/support/time.sh


flock -x $LASTPRINTFILE /usr/local/bin/printjob_add.sh $LASTPRINTFILE 1

THRESHOLD=$(date -d "now +2 minute" --rfc-3339=ns)


# Wait until printer is active
while ! nc -vzw 1 hpljwlan 80 2> /dev/null; do
    sleep 5
    NOW=$(date --rfc-3339=ns)
    if [ "${THRESHOLD}" '<' "${NOW}" ]; then
        /usr/local/bin/knx_printer.sh off
        sleep 1
        /usr/local/bin/knx_printer.sh on
        THRESHOLD=$(date -d "now +2 minute" --rfc-3339=ns)
    fi

done

date --rfc-3339=ns > /tmp/printeron.complete
root@home:/etc/cups# cat /usr/local/bin/printerdone.sh 
#!/bin/bash

# decrement printer count in 10 minutes and power printer off if counter 
becomes zero

. /var/smarthome/files/list.sh

echo flock -x $LASTPRINTFILE /usr/local/bin/printjob_add.sh $LASTPRINTFILE -1 | 
at now + 10 minutes

root@home:/etc/cups# 

Any hint or idea how to debug this issue is welcome.


Thanks
Rainer


-- 
Rainer Dorsch
http://bokomoko.de/


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic