diff options
-rw-r--r-- | .gitignore | 27 | ||||
-rw-r--r-- | activity/activity.info | 2 | ||||
-rw-r--r-- | restore.py | 105 | ||||
-rwxr-xr-x | setup.py | 2 | ||||
-rw-r--r-- | zipfile26.py | 2 |
5 files changed, 69 insertions, 69 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4da7333 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +*.py[co] +*.bak +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg diff --git a/activity/activity.info b/activity/activity.info index e7a6ace..57cf54b 100644 --- a/activity/activity.info +++ b/activity/activity.info @@ -1,6 +1,6 @@ [Activity] name = Restore -activity_version = 4 +activity_version = 5 bundle_id = org.sugarlabs.Restore exec = sugar-activity restore.RestoreActivity icon = Restore_icon @@ -33,22 +33,17 @@ else: import zipfile import dbus -import gobject -import gtk +import gi +from gi.repository import GObject +from gi.repository import Gtk -try: - from sugar.activity.widgets import StopButton - from sugar.graphics.toolbarbox import ToolbarBox - pre_086_toolbars = False - -except ImportError: - from sugar.graphics.toolbox import Toolbox - pre_086_toolbars = True +from sugar3.activity.widgets import StopButton +from sugar3.graphics.toolbarbox import ToolbarBox -from sugar.activity import activity -import sugar.env -from sugar.graphics.toolbutton import ToolButton -import sugar.logger +from sugar3.activity import activity +import sugar3.env +from sugar3.graphics.toolbutton import ToolButton +import sugar3.logger try: import json @@ -101,19 +96,6 @@ class SaveFailedException(Exception): self.traceback_string = traceback_string -if pre_086_toolbars: - class StopButton(ToolButton): - - def __init__(self, activity, **kwargs): - ToolButton.__init__(self, 'activity-stop', **kwargs) - self.props.tooltip = _('Stop') - self.props.accelerator = '<Ctrl>Q' - self.connect('clicked', self.__stop_button_clicked_cb, activity) - - def __stop_button_clicked_cb(self, button, activity): - activity.close() - - class RestoreButton(ToolButton): def __init__(self, **kwargs): @@ -122,7 +104,7 @@ class RestoreButton(ToolButton): self.props.accelerator = '<Alt>r' -class AsyncRestore(gobject.GObject): +class AsyncRestore(GObject.GObject): """ Restore a backup to the Sugar data store asynchronously. """ @@ -130,14 +112,14 @@ class AsyncRestore(gobject.GObject): _METADATA_JSON_NAME = '_metadata.json' __gsignals__ = { - 'progress': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, + 'progress': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ([int, int])), - 'done': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])), - 'error': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([str])), + 'done': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ([])), + 'error': (GObject.SIGNAL_RUN_FIRST, GObject.TYPE_NONE, ([str])), } def __init__(self, bundle_path, tmp_dir): - gobject.GObject.__init__(self) + GObject.GObject.__init__(self) self._path = bundle_path self._tmp_dir = tmp_dir self._bundle = None @@ -167,9 +149,9 @@ class AsyncRestore(gobject.GObject): os.close(to_child_read_fd) self._pipe_from_child = os.fdopen(from_child_read_fd, 'r') self._pipe_to_child = os.fdopen(to_child_write_fd, 'w') - self._pipe_from_child_watch_id = gobject.io_add_watch( + self._pipe_from_child_watch_id = GObject.io_add_watch( self._pipe_from_child, - gobject.IO_IN | gobject.IO_ERR | gobject.IO_HUP, + GObject.IO_IN | GObject.IO_ERR | GObject.IO_HUP, self._child_io_cb) def abort(self): @@ -179,7 +161,7 @@ class AsyncRestore(gobject.GObject): def _child_io_cb(self, source_, condition): """Receive and handle message from child.""" - if condition in [gobject.IO_ERR, gobject.IO_HUP]: + if condition in [GObject.IO_ERR, GObject.IO_HUP]: logging.debug('error condition: %r', condition) self.emit('error', _('Lost connection to child process').encode('utf-8')) @@ -233,7 +215,7 @@ class AsyncRestore(gobject.GObject): def _parent_close(self): """Close connections to child and wait for it.""" - gobject.source_remove(self._pipe_from_child_watch_id) + GObject.source_remove(self._pipe_from_child_watch_id) self._pipe_from_child.close() self._pipe_to_child.close() pid_, status = os.waitpid(self._child_pid, 0) @@ -564,47 +546,38 @@ class RestoreActivity(activity.Activity): self._setup_main_view() def _setup_main_view(self): - vbox = gtk.VBox() + vbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) warning = _('No bundle selected. Please close this activity and' ' choose a bundle to restore from the Journal.') - self._no_bundle_warning = gtk.Label(warning.encode('utf-8')) + self._no_bundle_warning = Gtk.Label(warning.encode('utf-8')) self._no_bundle_warning.set_line_wrap(True) self._no_bundle_warning.connect('size-allocate', label_size_allocate) self._no_bundle_warning.show() - vbox.pack_start(self._no_bundle_warning, True) + vbox.pack_start(self._no_bundle_warning, True, True, 0) instruction = _('Press the button to restore entries from the' ' bundle to the Journal. Only entries in the bundle' ' that are not in the Journal or are newer than what' ' is in the Journal will be restored.') - self._instruction = gtk.Label(instruction.encode('utf-8')) + self._instruction = Gtk.Label(instruction.encode('utf-8')) self._instruction.set_line_wrap(True) self._instruction.connect('size-allocate', label_size_allocate) self._instruction.hide() - vbox.pack_start(self._instruction, True) + vbox.pack_start(self._instruction, True, True, 0) self.set_canvas(vbox) vbox.show() def _setup_toolbar(self): - if pre_086_toolbars: - self.toolbox = Toolbox() - self.set_toolbox(self.toolbox) - - toolbar = gtk.Toolbar() - self.toolbox.add_toolbar('Toolbar', toolbar) - toolbar_box = self.toolbox - - else: - toolbar_box = ToolbarBox() - toolbar = toolbar_box.toolbar - self.set_toolbar_box(toolbar_box) + toolbar_box = ToolbarBox() + toolbar = toolbar_box.toolbar + self.set_toolbar_box(toolbar_box) self._restore_button = RestoreButton() self._restore_button.connect('clicked', self._restore_cb) self._restore_button.set_sensitive(False) toolbar.insert(self._restore_button, -1) - separator = gtk.SeparatorToolItem() + separator = Gtk.SeparatorToolItem() separator.props.draw = False separator.set_expand(True) toolbar.insert(separator, -1) @@ -623,7 +596,7 @@ class RestoreActivity(activity.Activity): """Set up and start background worker process.""" base_dir = os.environ.get('SUGAR_ACTIVITY_ROOT') if not base_dir: - base_dir = sugar.env.get_profile_path(self.get_bundle_id()) + base_dir = sugar3.env.get_profile_path(self.get_bundle_id()) tmp_dir = os.path.join(base_dir, 'instance') self._restore = AsyncRestore(self._path, tmp_dir) @@ -635,28 +608,28 @@ class RestoreActivity(activity.Activity): def _setup_restore_view(self): """Set up UI for showing feedback from worker process.""" self._restore_button.set_sensitive(False) - vbox = gtk.VBox(False) + vbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) label_text = _('Restoring Journal from %s') % (self._path, ) - label = gtk.Label(label_text.encode('utf-8')) + label = Gtk.Label(label_text.encode('utf-8')) label.set_line_wrap(True) label.connect('size-allocate', label_size_allocate) label.show() - vbox.pack_start(label) + vbox.pack_start(label, False, False, 0) - alignment = gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5) + alignment = Gtk.Alignment(xalign=0.5, yalign=0.5, xscale=0.5) alignment.show() - self._progress_bar = gtk.ProgressBar() + self._progress_bar = Gtk.ProgressBar() self._progress_bar.props.text = _('Scanning bundle').encode('utf-8') self._progress_bar.show() alignment.add(self._progress_bar) vbox.add(alignment) - self._message_box = gtk.Label() + self._message_box = Gtk.Label() self._message_box.set_line_wrap(True) self._message_box.connect('size-allocate', label_size_allocate) - vbox.pack_start(self._message_box) + vbox.pack_start(self._message_box, False, False, 0) # FIXME # self._close_button = gtk.Button(_('Abort')) @@ -682,13 +655,13 @@ class RestoreActivity(activity.Activity): logging.debug('_done_cb') self._restore_button.set_sensitive(True) - vbox = gtk.VBox(False) + vbox = Gtk.Box(orientation = Gtk.Orientation.VERTICAL) label_text = _('Successfully restored %d Journal entries from %s') \ % (self._num_entries, self._path) - label = gtk.Label(label_text.encode('utf-8')) + label = Gtk.Label(label_text.encode('utf-8')) label.set_line_wrap(True) label.connect('size-allocate', label_size_allocate) - vbox.pack_start(label) + vbox.pack_start(label, False, False, 0) self.set_canvas(vbox) self.show_all() @@ -712,4 +685,4 @@ class RestoreActivity(activity.Activity): # pylint isn't smart enough for the gettext.install() magic _ = lambda msg: msg gettext.install('restore', 'po', unicode=True) -sugar.logger.start() +sugar3.logger.start() @@ -14,7 +14,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -from sugar.activity import bundlebuilder +from sugar3.activity import bundlebuilder bundlebuilder.start() diff --git a/zipfile26.py b/zipfile26.py index 34b3f1a..950a1cd 100644 --- a/zipfile26.py +++ b/zipfile26.py @@ -231,7 +231,7 @@ def _EndRecData(fpin): return -class ZipInfo (object): +class ZipInfo (): """Class with attributes describing each file in the ZIP archive.""" __slots__ = ( |