Httplib problem

Hello,

I am using version 7.2.4 (b48) of Ignition Gateway. I do need httplib from Jython std library in my script. I am not able to do my work by system.net-implementations. Httplib is listed as a supported std library. I am trying out first GET - example in following example:

docs.python.org/release/2.1/lib/ ... mples.html

With following error:

AttributeError: module 'httplib' has no attribute 'HTTP'

When I try out to import httplib and print dir listing of this library, output is quite minimal when comparing regular Jython implementation:

Ignition:

import httplib
print dir(httplib)

['doc', 'file', 'name', 'socket']

Regular Jython in Debian 5.0:

Jython 2.2.1 on java1.6.0_12
Type "copyright", "credits" or "license" for more information.

import httplib
print dir(httplib)
['BadStatusLine', 'CannotSendHeader', 'CannotSendRequest', 'FakeSocket', 'HTTP', 'HTTPConnection', 'HTTPException', 'HTTPMessage', 'HTTPResponse', 'HTTPS', 'HTTPSConnection', 'HTTPS_PORT', 'HTTP_PORT', 'ImproperConnectionState', 'IncompleteRead', 'InvalidURL', 'LineAndFileWrapper', 'NotConnected', 'ResponseNotReady', 'SSLFile', 'SharedSocket', 'SharedSocketClient', 'StringIO', 'UnimplementedFileMode', 'UnknownProtocol', 'UnknownTransferEncoding', '_CS_IDLE', '_CS_REQ_SENT', '_CS_REQ_STARTED', '_UNKNOWN', 'all', 'doc', 'file', 'name', 'errno', 'error', 'mimetools', 'socket', 'test', 'urlsplit']

I tried also import HTTP from httplib,

Ignition:

from httplib import HTTP

ImportError: cannot import name HTTP

Jython in Debian 5.0:

from httplib import HTTP
print dir(HTTP)
['doc', 'init', 'module', '_connection_class', '_http_vsn', '_http_vsn_str', '_setup', 'close', 'connect', 'debuglevel', 'getfile', 'getreply', 'putheader']

What can be behind of this difference?

I checked out Java local cache in my workstation (\Application Data\Sun\Java\Deployment\cache\FPMI\script_lib). There are lot of python files, also file named httplib.py. There are implementations of full implementation of httplib, also class HTTP is implemented. This httplib.py tries to import file named mimetools.py. I noticed this mimetools.py file does not exist in this cache folder. I am not able to import mimetools also. Can it be root cause of original problem?

BR, Ossi Syri, Ouman Ltd

Yes, I think your troubleshooting is 100% right - that library is missing some dependent libraries. A quick look shows that those libraries (such as mimetools) themselvers require other ones, so it might be a bit of a mess for us to fix. I’ve made a bug ticket to look into the issue.

In the meantime take a look at the system.net.httpGet() and system.net.httpPost() functions. Do these cover what you wanted to do with the [tt]httplib[/tt] library?