def on_debug_ConvertExportFileEvent(self, event):

        wildcard = "%s|*.chex|%s|*.dump|%s (*.*)|*.*" %(_(u"Export files"),
                                                        _(u"Dump files"),
                                                        _(u"All files"))
        dlg = wx.FileDialog(wx.GetApp().mainFrame,
                            _(u"Convert from export file"), "", "", wildcard,
                            wx.OPEN)

        fromPath = None
        if dlg.ShowModal() == wx.ID_OK:
            fromPath = dlg.GetPath()
        dlg.Destroy()

        if fromPath:
            wildcard = "%s|*.rec|%s (*.*)|*.*" %(_(u"Record files"),
                                                 _(u"All files"))
            dlg = wx.FileDialog(wx.GetApp().mainFrame,
                                _(u"Convert to record file"), "", "",
                                wildcard, wx.SAVE|wx.OVERWRITE_PROMPT)
            toPath = None
            if dlg.ShowModal() == wx.ID_OK:
                toPath = dlg.GetPath()
            dlg.Destroy()

            if toPath:
                activity = Activity(_(u"Convert %s") %(fromPath))
                dialogs.Progress.Show(activity)
                activity.started()

                try:
                    dumpreload.convertToTextFile(fromPath, toPath,
                                                 activity=activity)
                    activity.completed()
                except Exception, e:
                    logger.exception("Failed to convert file")
                    activity.failed(exception=e)
                    raise
                self.setStatusMessage(_(u'File converted.'))
Beispiel #2
0
    def restoreCollections(self, activity=None):
        rv = self.itsView

        if not self.isSetUp():
            return

        info = self.getPublishedShares(blocking=True)
        toRestore = list()
        for name, uuid, href, tickets, subscribed in info:
            if not subscribed and uuid in self.requested:
                toRestore.append((name, uuid, href, tickets))

        for name, uuid, href, tickets in toRestore:

            try:
                msg = _("Restoring %(collection)s collection") % {
                    'collection': name
                }
                logger.info(msg)

                subActivity = Activity(msg)
                subActivity.started()

                activity.update(msg=msg, work=1)

                altView = viewpool.getView(rv.repository)
                share = Share(itsView=altView, displayName=name)
                share.mode = 'both'
                share.conduit = CosmoConduit(
                    itsParent=share,
                    shareName=uuid,
                    account=altView.findUUID(self.itsUUID),
                    translator=translator.SharingTranslator,
                    serializer=eimml.EIMMLSerializer)
                for ticket, ticketType in tickets:
                    if ticketType == 'read-only':
                        share.conduit.ticketReadOnly = ticket
                    elif ticketType == 'read-write':
                        share.conduit.ticketReadWrite = ticket

                share.conduit.filters = set()
                share.conduit.filters.add('cid:[email protected]')
                share.conduit.filters.add('cid:[email protected]')
                share.conduit.filters.add('cid:[email protected]')

                share.get(activity=subActivity)
                if uuid in self.ignored:
                    self.ignored.remove(uuid)
                self.requested.remove(uuid)
                share.sharer = schema.ns("osaf.pim",
                                         altView).currentContact.item
                schema.ns("osaf.app",
                          altView).sidebarCollection.add(share.contents)
                # Add the collection to the Dashboard (c.f. Bug 11717)
                schema.ns("osaf.pim", altView).mine.addSource(share.contents)
                altView.commit(utility.mergeFunction)
                subActivity.completed()

            except Exception, e:
                altView.cancel()
                viewpool.releaseView(altView)
                if not isinstance(e, ActivityAborted):
                    subActivity.failed(e)
                    activity.failed(e)
                    logger.exception("Restore failed")
                if uuid in self.requested:
                    self.requested.remove(uuid)
                raise
Beispiel #3
0
    def restoreCollections(self, activity=None):
        rv = self.itsView

        if not self.isSetUp():
            return

        info = self.getPublishedShares(blocking=True)
        toRestore = list()
        for name, uuid, href, tickets, subscribed in info:
            if not subscribed and uuid in self.requested:
                toRestore.append((name, uuid, href, tickets))

        for name, uuid, href, tickets in toRestore:

                try:
                    msg = _("Restoring %(collection)s collection") % {
                        'collection' : name }
                    logger.info(msg)

                    subActivity = Activity(msg)
                    subActivity.started()

                    activity.update(msg=msg, work=1)

                    altView = viewpool.getView(rv.repository)
                    share = Share(itsView=altView, displayName=name)
                    share.mode = 'both'
                    share.conduit = CosmoConduit(itsParent=share,
                        shareName=uuid, account=altView.findUUID(self.itsUUID),
                        translator=translator.SharingTranslator,
                        serializer=eimml.EIMMLSerializer)
                    for ticket, ticketType in tickets:
                        if ticketType == 'read-only':
                            share.conduit.ticketReadOnly = ticket
                        elif ticketType == 'read-write':
                            share.conduit.ticketReadWrite = ticket

                    share.conduit.filters = set()
                    share.conduit.filters.add('cid:[email protected]')
                    share.conduit.filters.add('cid:[email protected]')
                    share.conduit.filters.add('cid:[email protected]')

                    share.get(activity=subActivity)
                    if uuid in self.ignored:
                        self.ignored.remove(uuid)
                    self.requested.remove(uuid)
                    share.sharer = schema.ns("osaf.pim",
                        altView).currentContact.item
                    schema.ns("osaf.app",
                        altView).sidebarCollection.add(share.contents)
                    # Add the collection to the Dashboard (c.f. Bug 11717)
                    schema.ns("osaf.pim",
                        altView).mine.addSource(share.contents)
                    altView.commit(utility.mergeFunction)
                    subActivity.completed()

                except Exception, e:
                    altView.cancel()
                    viewpool.releaseView(altView)
                    if not isinstance(e, ActivityAborted):
                        subActivity.failed(e)
                        activity.failed(e)
                        logger.exception("Restore failed")
                    if uuid in self.requested:
                        self.requested.remove(uuid)
                    raise