From 8e4bffe68a8a3579a65b8e21f162d7e6c69131e2 Mon Sep 17 00:00:00 2001 From: Marcos Duarte Date: Thu, 30 Jan 2014 20:36:16 -0200 Subject: [PATCH] Make updates.py compatible with Python 3 --- updates.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/updates.py b/updates.py index e447ab5..e0b1ed5 100755 --- a/updates.py +++ b/updates.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python # -*- coding: utf-8 -*- __author__ = "Mikhail Fedosov (tbs.micle@gmail.com)" __version__ = "0.1.4" @@ -9,12 +9,20 @@ import pip import sys import socket -import xmlrpclib from multiprocessing import Pool - -reload(sys) -sys.setdefaultencoding("utf-8") - +if sys.version < '3': + from xmlrpclib import ServerProxy +else: + from xmlrpc.client import ServerProxy + +if sys.version < '3': + reload(sys) + sys.setdefaultencoding("utf-8") +else: + # http://stackoverflow.com/questions/3828723/why-we-need-sys-setdefaultencodingutf-8-in-a-py-script + pass + + class colors: """ Colored terminal text """ @@ -58,7 +66,6 @@ def simplify(cls): def check_package(dist): pypi = xmlrpclib.ServerProxy("http://pypi.python.org/pypi") - try: available = pypi.package_releases(dist.project_name) if not available: