Skip to content

Commit 1eedcb4

Browse files
committed
Convert osg-system-profiler-viewer to Python 3
(that is, run 2to3 on it)
1 parent 783f371 commit 1eedcb4

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

osg-system-profiler-viewer

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
#!/usr/bin/python2
1+
#!/usr/bin/python3
22
"""View the output from osg-system-profiler in a structured way"""
33

4-
from Tkinter import *
5-
import ScrolledText
4+
from tkinter import *
5+
import tkinter.scrolledtext
66
import os
77
import re
88
import subprocess
99
import sys
10-
import urllib2
11-
import tkFont
10+
import urllib.request, urllib.error, urllib.parse
11+
import tkinter.font
1212

1313

1414

@@ -70,20 +70,20 @@ def load_pdata_from_file(filename):
7070
return load_pdata_from_handle(fh)
7171
finally:
7272
fh.close()
73-
except IOError, e:
74-
print >> sys.stderr, "Error reading file %s: %s" % (filename, e.strerror)
73+
except IOError as e:
74+
print("Error reading file %s: %s" % (filename, e.strerror), file=sys.stderr)
7575
sys.exit(1)
7676

7777

7878
def load_pdata_from_url(url):
7979
try:
80-
urlhandle = urllib2.urlopen(url)
80+
urlhandle = urllib.request.urlopen(url)
8181
try:
8282
return load_pdata_from_handle(urlhandle)
8383
finally:
8484
urlhandle.close()
85-
except urllib2.URLError, e:
86-
print >> sys.stderr, "Error reading URL %s: %s" % (url, e.strerror)
85+
except urllib.error.URLError as e:
86+
print("Error reading URL %s: %s" % (url, e.strerror), file=sys.stderr)
8787
sys.exit(1)
8888

8989

@@ -99,7 +99,7 @@ def get_installed_versions(profile, script=None):
9999
try:
100100
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, env=env)
101101
output = proc.communicate()[0]
102-
except OSError, err:
102+
except OSError as err:
103103
return Section('Error getting installed versions', str(err))
104104
if output:
105105
return Section('Installed versions', output)
@@ -115,8 +115,8 @@ class Application(Frame):
115115
Frame.__init__(self, master)
116116
self.pack(fill=BOTH, expand=True)
117117

118-
self.font = tkFont.Font(family='Sans', size=12)
119-
self.textfont = tkFont.Font(family='Monospace', size=12)
118+
self.font = tkinter.font.Font(family='Sans', size=12)
119+
self.textfont = tkinter.font.Font(family='Monospace', size=12)
120120

121121
self.top = Frame(self)
122122
self.top.pack(side=TOP, fill=X)
@@ -137,7 +137,7 @@ class Application(Frame):
137137
self.label = Label(self.top, text="", font=self.font)
138138
self.label.pack(side=LEFT, fill=X)
139139

140-
self.text = ScrolledText.ScrolledText(self.bot, font=self.textfont)
140+
self.text = tkinter.scrolledtext.ScrolledText(self.bot, font=self.textfont)
141141
self.text.pack(side=RIGHT, fill=BOTH, expand=True)
142142

143143
self.pdata = pdata
@@ -177,8 +177,8 @@ class Application(Frame):
177177

178178
def main():
179179
if len(sys.argv) < 2:
180-
print "Usage: %s <FILENAME OR URL>" % sys.argv[0]
181-
print "View the output of osg-system-profiler"
180+
print("Usage: %s <FILENAME OR URL>" % sys.argv[0])
181+
print("View the output of osg-system-profiler")
182182
sys.exit(2)
183183
profile = sys.argv[1]
184184
if '://' not in profile:

0 commit comments

Comments
 (0)