From 8192a34aa967662cf16e36913b3c317f99b707d6 Mon Sep 17 00:00:00 2001 From: Samuel Holland Date: Thu, 10 May 2018 15:50:16 -0500 Subject: Import urllib classes in a way compatible with Python 3 Try both the old and the new locations. --- wee_slack.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/wee_slack.py b/wee_slack.py index 281eb8b..68c2c13 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -13,7 +13,6 @@ import json import sha import os import re -import urllib import sys import traceback import collections @@ -23,6 +22,11 @@ import string from websocket import create_connection, WebSocketConnectionClosedException +try: + from urllib.parse import urlencode +except ImportError: + from urllib import urlencode + # hack to make tests possible.. better way? try: import weechat @@ -1014,7 +1018,7 @@ class SlackRequest(object): post_data["token"] = token self.post_data = post_data self.params = {'useragent': 'wee_slack {}'.format(SCRIPT_VERSION)} - self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urllib.urlencode(encode_to_utf8(post_data))) + self.url = 'https://{}/api/{}?{}'.format(self.domain, request, urlencode(encode_to_utf8(post_data))) self.response_id = sha.sha("{}{}".format(self.url, self.start_time)).hexdigest() self.retries = kwargs.get('retries', 3) # def __repr__(self): -- cgit