Created
August 16, 2017 11:25
-
-
Save jharms/219660807fc1b103c4235d1565c3e768 to your computer and use it in GitHub Desktop.
Working Jython and Python Slack Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /opt/jython/Lib/_socket.py | |
SOCK_DGRAM = 1 | |
SOCK_STREAM = 2 | |
SOCK_RAW = 3 # not supported | |
SOCK_RDM = 4 # not supported | |
SOCK_SEQPACKET = 5 # not supported | |
SOL_SOCKET = 0xFFFF | |
IPPROTO_AH = 51 # not supported | |
IPPROTO_DSTOPTS = 60 # not supported | |
IPPROTO_ESP = 50 # not supported | |
IPPROTO_FRAGMENT = 44 # not supported | |
IPPROTO_GGP = 3 # not supported | |
IPPROTO_HOPOPTS = 0 # not supported | |
IPPROTO_ICMP = 1 # not supported | |
IPPROTO_ICMPV6 = 58 # not supported | |
IPPROTO_IDP = 22 # not supported | |
IPPROTO_IGMP = 2 # not supported | |
IPPROTO_IP = 0 | |
IPPROTO_IPV4 = 4 # not supported | |
IPPROTO_IPV6 = 41 # not supported | |
IPPROTO_MAX = 256 # not supported | |
IPPROTO_ND = 77 # not supported | |
IPPROTO_NONE = 59 # not supported | |
IPPROTO_PUP = 12 # not supported | |
IPPROTO_RAW = 255 # not supported | |
IPPROTO_ROUTING = 43 # not supported | |
IPPROTO_TCP = 6 | |
IPPROTO_UDP = 17 | |
SOL_TCP = 6 # Jonathan Harms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SlackRequest(object): | |
def __init__(self, proxies=None): | |
# __name__ returns 'slackclient.slackrequest', we only want 'slackclient' | |
client_name = __name__.split('.')[0] | |
client_version = __version__ # Version is returned from version.py | |
# Construct the user-agent header with the package info, Python version and OS version. | |
self.default_user_agent = { | |
"client": "{0}/{1}".format(client_name, client_version), | |
"python": "Jython/Jonathan Harms", | |
"system": "{0}/{1}".format(platform.system(), platform.release()) | |
} | |
self.custom_user_agent = None | |
self.proxies = proxies |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /opt/jython/Lib/socket.py | |
from _socket import ( | |
socket, error, herror, gaierror, timeout, has_ipv6, | |
create_connection, | |
getdefaulttimeout, | |
setdefaulttimeout, | |
getfqdn, | |
gethostbyaddr, | |
gethostbyname, | |
gethostbyname_ex, | |
gethostname, | |
getprotobyname, | |
getservbyname, | |
getservbyport, | |
AF_UNSPEC, | |
AF_INET, | |
AF_INET6, | |
AI_PASSIVE, | |
AI_CANONNAME, | |
AI_NUMERICHOST, | |
AI_V4MAPPED, | |
AI_ALL, | |
AI_ADDRCONFIG, | |
AI_NUMERICSERV, | |
EAI_NONAME, | |
EAI_SERVICE, | |
EAI_ADDRFAMILY, | |
NI_NUMERICHOST, | |
NI_NUMERICSERV, | |
NI_NOFQDN, | |
NI_NAMEREQD, | |
NI_DGRAM, | |
NI_MAXSERV, | |
NI_IDN, | |
NI_IDN_ALLOW_UNASSIGNED, | |
NI_IDN_USE_STD3_ASCII_RULES, | |
NI_MAXHOST, | |
SHUT_RD, | |
SHUT_WR, | |
SHUT_RDWR, | |
SOCK_DGRAM, | |
SOCK_STREAM, | |
SOCK_RAW, | |
SOCK_RDM, | |
SOCK_SEQPACKET, | |
SOCK_RDM, | |
SOCK_SEQPACKET, | |
SOL_SOCKET, | |
# not supported, but here for apparent completeness | |
IPPROTO_AH, | |
IPPROTO_DSTOPTS, | |
IPPROTO_ESP, | |
IPPROTO_FRAGMENT, | |
IPPROTO_GGP, | |
IPPROTO_HOPOPTS, | |
IPPROTO_ICMP, | |
IPPROTO_ICMPV6, | |
IPPROTO_IDP, | |
IPPROTO_IGMP, | |
IPPROTO_IP, # supported | |
# not supported | |
IPPROTO_IPV4, | |
IPPROTO_IPV6, | |
IPPROTO_MAX, | |
IPPROTO_ND, | |
IPPROTO_NONE, | |
IPPROTO_PUP, | |
IPPROTO_RAW, | |
IPPROTO_ROUTING, | |
IPPROTO_TCP, # supported | |
IPPROTO_UDP, # supported | |
SOL_TCP, # Jonathan Harms | |
# supported | |
SO_BROADCAST, | |
SO_KEEPALIVE, | |
SO_LINGER, | |
SO_RCVBUF, | |
SO_REUSEADDR, | |
SO_SNDBUF, | |
SO_TIMEOUT, | |
TCP_NODELAY, | |
# pseudo options |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To get Slack working under Jython 2.7.0 you need to fix 3 things: