Пример #1
0
    def Import(self, view, filename):

        path = os.path.join(os.getenv('CHANDLERHOME') or '.',
                            'parcels', 'osaf', 'sharing', 'tests')

        sandbox = self.repo.findPath("//sandbox")

        conduit = Sharing.FileSystemConduit(parent=sandbox, sharePath=path,
                                            shareName=filename, view=view)
        format = ICalendar.ICalendarFormat(parent=sandbox)
        self.share = Sharing.Share(parent=sandbox, conduit=conduit,
                                   format=format)
        self.share.get()
        return format
Пример #2
0
    def testImport(self):
        if os.environ.get('CHANDLER_PERFORMANCE_TEST'):
            self.loadParcel("parcel:osaf.pim.calendar")
            path = os.path.join(os.getenv('CHANDLERHOME') or '.',
                                'parcels', 'osaf', 'sharing', 'tests')

            conduit = Sharing.FileSystemConduit(name="conduit",
                                                sharePath=path,
                                                shareName="3kevents.ics",
                                                view=self.rep.view)
            format = ICalendar.ICalendarFormat(name="format", view=self.rep.view)
            share = Sharing.Share(name="share", conduit=conduit, format=format,
                                  view=self.rep.view)
            share.get()
Пример #3
0
    def writeICalendarUnicodeBug3338(self):
        event = Calendar.CalendarEvent(view = self.repo.view)
        event.displayName = u"unicode \u0633\u0644\u0627\u0645"
        event.startTime = datetime.datetime(2010, 1, 1, 10)
        event.endTime = datetime.datetime(2010, 1, 1, 11)

        coll = ItemCollection(name="testcollection", 
                                             parent=self.sandbox)
        coll.add(event)
        filename = "unicode_export.ics"

        conduit = Sharing.FileSystemConduit(name="conduit", sharePath=".",
                            shareName=filename, view=self.repo.view)
        format = ICalendar.ICalendarFormat(name="format", view=self.repo.view)
        self.share = Sharing.Share(name="share",contents=coll, conduit=conduit,
                                    format=format, view=self.repo.view)
        if self.share.exists():
            self.share.destroy()
        self.share.create()
        self.share.put()
        cal=vobject.readComponents(file(filename, 'rb')).next()
        self.assertEqual(cal.vevent[0].summary[0].value, event.displayName)
        self.share.destroy()
Пример #4
0
    def OnOk(self, evt):
        title = self.textTitle.GetValue()
        shareName = self.textShareName.GetValue()

        accountIndex = self.choiceAccount.GetSelection() - 1
        account = self.accounts[accountIndex]

        if not self.join:
            collIndex = self.choiceColl.GetSelection() - 1
            collection = self.collections[collIndex]

        if self.share is None:
            conduit = Sharing.WebDAVConduit(account=account,
                                            shareName=shareName,
                                            view=self.view)
            if shareName.endswith('.ics'):
                format = ICalendar.ICalendarFormat(view=self.view)
            else:
                format = Sharing.CloudXMLFormat(view=self.view)
            if self.join:
                self.share = Sharing.Share(conduit=conduit,
                                           format=format,
                                           view=self.view)
            else:
                self.share = Sharing.Share(contents=collection,
                                           conduit=conduit,
                                           format=format,
                                           view=self.view)
            self.share.displayName = title
        else:
            self.share.displayName = title
            self.share.conduit.account = account
            self.share.conduit.shareName = shareName
            self.share.contents = collection

        self.EndModal(True)
Пример #5
0
    def OnPublish(self, evt):
        # Publish the collection


        # Update the UI by disabling/hiding various panels, and swapping in a
        # new set of buttons
        self.mainPanel.Enable(False)
        self.buttonPanel.Hide()
        self.mySizer.Detach(self.buttonPanel)
        self.buttonPanel = self.resources.LoadPanel(self,
                                                    "PublishingButtonsPanel")
        self.mySizer.Add(self.buttonPanel, 0, wx.GROW|wx.ALL, 5)
        publishingButton = wx.xrc.XRCCTRL(self, "BUTTON_PUBLISHING")
        publishingButton.Enable(False)
        self.Bind(wx.EVT_BUTTON, self.OnPublishDone, id=wx.ID_CANCEL)

        self._clearStatus()
        self._resize()
        wx.Yield()

        try:

            # Populate the list of existing shares on the selected webdav server
            self.existing = self._getExistingFiles()
            suggestedName = self._suggestName()
            shareName = suggestedName
            shareNameSafe = urllib.quote_plus(shareName.encode('utf-8'))
            accountIndex = self.accountsControl.GetSelection()
            account = self.accountsControl.GetClientData(accountIndex)

            # Create the main share object
            shareXML = Sharing.newOutboundShare(self.view,
                                                self.collection,
                                                kinds=self.filterKinds,
                                                shareName=shareNameSafe,
                                                account=account)
            self.shareXML = shareXML
            shareXML.displayName = shareName
            self._saveAttributeFilterState(shareXML)

            # Create the secondary (.ics) share object
            iCalName = "%s.ics" % shareNameSafe
            shareICal = Sharing.newOutboundShare(self.view,
                                                 self.collection,
                                                 kinds=self.filterKinds,
                                                 shareName=iCalName,
                                                 account=account)
            self.shareICal = shareICal
            shareICal.displayName = "%s.ics" % shareName
            self._saveAttributeFilterState(shareICal)

            # For the .ics share, use ICalendarFormat instead
            format = ICalendar.ICalendarFormat(view=self.view)
            shareICal.mode = "put"
            shareICal.format = format
            shareICal.hidden = True

            self._showStatus("Wait for Sharing URLs...\n")
            if shareXML.exists():
                raise Sharing.SharingError("Share already exists")
            else:
                self._showStatus("Creating collection on server...")
                shareXML.create()
                self._showStatus(" done.\n")

            self._showStatus("Publishing collection to server...")
            shareXML.put()
            self._showStatus(" done.\n")

            self._showStatus("Publishing calendar file to server...")
            shareICal.put()
            self._showStatus(" done.\n")

        except (Sharing.SharingError, zanshin.error.Error), e:

            # Display the error
            # self._clearStatus()
            self._showStatus("\nSharing error:\n%s\n" % e.message)
            logger.exception("Failed to publish collection")
            # self._showStatus("Exception:\n%s" % traceback.format_exc(10))

            # Clean up all share objects we created
            try:
                shareXML.delete(True)
                shareICal.delete(True)
            except:
                pass

            # Re-enable the main panel and switch back to the "Share" button
            self.mainPanel.Enable(True)
            self.buttonPanel.Hide()
            self.mySizer.Detach(self.buttonPanel)
            self.buttonPanel = self.resources.LoadPanel(self,
                                                        "PublishButtonsPanel")
            self.mySizer.Add(self.buttonPanel, 0, wx.GROW|wx.ALL, 5)
            self.Bind(wx.EVT_BUTTON, self.OnPublish, id=wx.ID_OK)
            self.Bind(wx.EVT_BUTTON, self.OnCancel, id=wx.ID_CANCEL)
            self._resize()

            return