import pexpect
import random
import re
-import util
+import sys
+
+if sys.version_info >= (3, 0):
+ import urllib.request
+else:
+ import urllib2
admins = []
admin_role = 'Cat'
{ 'channel': 227710451226509312, 'url': 'https://miggy.org/games/elite-dangerous/devtracker/ed-dev-posts.rss', 'summary': True }
]
+def open_url(url):
+ if sys.version_info >= (3, 0):
+ # Specify our own user agent as Cloudflare doesn't seem to like the urllib one
+ request = urllib.request.Request(url, headers={'User-Agent': USER_AGENT})
+ try:
+ return urllib.request.urlopen(request)
+ except urllib.error.HTTPError as err:
+ log.error("Error {0} opening {1}: {2}".format(err.code, url, err.reason))
+ return None
+ else:
+ sslctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
+ # If we're on OSX with OpenSSL 0.9.x, manually specify preferred ciphers so CloudFlare can negotiate successfully
+ if platform.system() == 'Darwin' and ssl.OPENSSL_VERSION_INFO[0] < 1:
+ sslctx.set_ciphers("ECCdraft:HIGH:!aNULL")
+ # Specify our own user agent as Cloudflare doesn't seem to like the urllib one
+ request = urllib2.Request(url, headers={'User-Agent': USER_AGENT})
+ try:
+ return urllib2.urlopen(request, context=sslctx)
+ except urllib2.HTTPError as err:
+ log.error("Error {0} opening {1}: {2}".format(err.code, url, err.reason))
+ return None
+
def wait_for_prompt(p):
p.expect('EDI> ')