Skip to content

Commit

Permalink
more python3 compat
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@619 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 26, 2012
1 parent 2d98dfe commit bdd1818
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
14 changes: 10 additions & 4 deletions src/parti/parti_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import sys
import gtk

import wimpiggy.lowlevel
Expand All @@ -12,13 +13,18 @@
from wimpiggy.util import gtk_main_quit_really

from parti.world_organizer import WorldOrganizer

from parti.tray import TraySet

from parti.addons.ipython_embed import spawn_repl_window

from parti.bus import PartiDBusService

if sys.version < '3':
import codecs
def u(x):
return codecs.unicode_escape_decode(x)[0]
else:
def u(x):
return x

class Parti(object):
def __init__(self, options):
self._wm = Wm("Parti", options.replace)
Expand All @@ -38,7 +44,7 @@ def __init__(self, options):
# thus (using these two functions) the module path must be specified twice
dynmodule = getattr(getattr(__import__('parti.trays.' + ltray), 'trays'), ltray)
dynclass = getattr(dynmodule, options.tray + "Tray")
self._trays.new(u"default", dynclass)
self._trays.new(u("default"), dynclass)

self._root_hotkeys = HotkeyManager(gtk.gdk.get_default_root_window())
self._root_hotkeys.add_hotkeys({"<shift><alt>r": "repl"})
Expand Down
6 changes: 3 additions & 3 deletions src/parti/scripts/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def main(cmdline):

try:
proxy = parti.bus.get_parti_proxy()
print "Using D-Bus to request running Parti spawn a REPL window"
print("Using D-Bus to request running Parti spawn a REPL window")
proxy.SpawnReplWindow()
print "Done"
print("Done")
except:
if "_PARTI_PDB" in os.environ:
import sys, pdb
pdb.post_mortem(sys.exc_traceback)
pdb.post_mortem(sys.exc_info()[2])
raise
8 changes: 4 additions & 4 deletions src/parti/test_bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,23 @@ class MockWm(object):
def __init__(self):
self.called = False
def spawn_repl_window(self):
print "spawn_repl_window called on server"
print("spawn_repl_window called on server")
self.called = True
wm = MockWm()
service = parti.bus.PartiDBusService(wm)
proxy = parti.bus.get_parti_proxy()
self.error = False
def replied():
print "got reply"
print("got reply")
gtk.main_quit()
def errored():
print "got error"
print("got error")
self.error = True
gtk.main_quit()
proxy.SpawnReplWindow(reply_handler=replied,
error_handler=errored)
assert not wm.called
gtk.main()
print "mainloop exited"
print("mainloop exited")
assert not self.error
assert wm.called
2 changes: 1 addition & 1 deletion src/parti/tray.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def has_tag(self, tag):
def __getitem__(self, tag):
tray = self.get(tag)
if tray is None:
raise KeyError, tag
raise KeyError(tag)
return tag

def get(self, tag):
Expand Down
11 changes: 10 additions & 1 deletion src/parti/trays/compositetest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,19 @@
# Parti is released under the terms of the GNU GPL v2, or, at your option, any
# later version. See the file COPYING for details.

import sys
import gtk
import parti.tray
from wimpiggy.window import WindowView

if sys.version < '3':
import codecs
def u(x):
return codecs.unicode_escape_decode(x)[0]
else:
def u(x):
return x

class CompositeTestTray(parti.tray.Tray, gtk.HPaned):
def __init__(self, trayset, tag):
super(CompositeTestTray, self).__init__(trayset, tag)
Expand Down Expand Up @@ -48,4 +57,4 @@ def _handle_title_change(self, window, *args):
for view in self.image_notebook.get_children():
if view.model is window:
self.image_notebook.set_tab_label_text(view,
u"CLONE: " + title)
u("CLONE: ") + title)
2 changes: 1 addition & 1 deletion src/parti/trays/simpletab.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def _handle_title_change(self, window, *args):
elif window in right_children:
notebook = self.right_notebook
else:
print "Mrr?"
print("Mrr?")
return
notebook.set_tab_label_text(window,
window.get_property("title"))
Expand Down

0 comments on commit bdd1818

Please sign in to comment.