From 56dd25667d1739a51a3946de060dd44e2994c39b Mon Sep 17 00:00:00 2001 From: Anders Bergh Date: Wed, 12 Dec 2012 12:51:55 +0100 Subject: [PATCH] Make fish_config compatible with Python 2.5 Try to import parse_qs from the cgi module, and simplejson instead of json. Use old string formatting. str.format() was backported from Python 3 to 2.6 and isn't available in 2.5. --- share/tools/web_config/webconfig.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/share/tools/web_config/webconfig.py b/share/tools/web_config/webconfig.py index 965832ce0..6a514256d 100755 --- a/share/tools/web_config/webconfig.py +++ b/share/tools/web_config/webconfig.py @@ -7,14 +7,21 @@ IS_PY2 = sys.version_info[0] == 2 if IS_PY2: import SimpleHTTPServer import SocketServer - from urlparse import parse_qs + try: + from urllib.parse import parse_qs + except ImportError: + from cgi import parse_qs else: import http.server as SimpleHTTPServer import socketserver as SocketServer from urllib.parse import parse_qs import webbrowser import subprocess -import re, json, socket, os, sys, cgi, select, time, glob +import re, socket, os, sys, cgi, select, time, glob +try: + import json +except ImportError: + import simplejson as json def run_fish_cmd(text): from subprocess import PIPE @@ -605,8 +612,8 @@ if len(sys.argv) > 1: initial_tab = '#' + tab break -url = 'http://localhost:{0}/{1}'.format(PORT, initial_tab) -print("Web config started at '{0}'. Hit enter to stop.".format(url)) +url = 'http://localhost:%d/%s' % (PORT, initial_tab) +print("Web config started at '%s'. Hit enter to stop." % url) webbrowser.open(url) # Select on stdin and httpd