Changeset 42
- Timestamp:
- 09/13/07 00:11:24 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkipplib/trunk/pkipplib/pkipplib.py
r41 r42 642 642 """ 643 643 url = url or self.url 644 conne xion = urllib2.Request(url=url, \644 connection = urllib2.Request(url=url, \ 645 645 data=req.dump()) 646 conne xion.add_header("Content-Type", "application/ipp")646 connection.add_header("Content-Type", "application/ipp") 647 647 if self.username : 648 648 pwmanager = urllib2.HTTPPasswordMgrWithDefaultRealm() 649 649 pwmanager.add_password(None, \ 650 "%s%s" % (connexion.get_host(), connexion.get_selector()), \ 650 "%s%s" % (connection.get_host(), \ 651 connection.get_selector()), \ 651 652 self.username, \ 652 653 self.password or "") … … 668 669 s.settimeout(5.0) 669 670 sys.stderr.write("Opened [%s]\n" % req.get_selector()) 670 return s 671 #return s.makefile("r+b") 671 return s.makefile(mode="r+b") 672 672 673 673 opener = urllib2.build_opener(SocketHandler()) … … 677 677 self.lastErrorMessage = None 678 678 try : 679 response = urllib2.urlopen(conne xion)679 response = urllib2.urlopen(connection) 680 680 except (urllib2.URLError, urllib2.HTTPError, socket.error), error : 681 681 self.lastError = error … … 687 687 try : 688 688 while True : 689 byte = response.read(1) 689 try : 690 byte = response.read(1) 691 except AttributeError : 692 byte = response.recv(1) 690 693 if not byte : 691 694 break 692 695 else : 693 696 bytes.append(byte) 694 except socket.timeout : 697 except socket.error : 698 sys.stderr.write("socket error\n") 695 699 pass 696 700 finally : 697 701 datas = "".join(bytes) 698 #datas = response.read() 699 ippresponse = IPPRequest(datas) 700 ippresponse.parse() 701 return ippresponse 702 if datas : 703 ippresponse = IPPRequest(datas) 704 ippresponse.parse() 705 return ippresponse 706 else : 707 return None 702 708 703 709 def getPPD(self, queuename) :