示例#1
0
    def _initGlobalSettings(self):
        cmdLineParams = ZCommandLineParameters(sys.argv[1:])
        setCommandLineParameters(cmdLineParams)

        # Add an uncaught exception hook so that we can display a dialog if something bad happens.
        sys.excepthook = self.handleException

        # If the application is installed (not in dev-mode), redirect stderr and stdout.
        # FIXME (EPW) hook up the stderr/stdout to the logger at some point
        if getOSUtil().isInstalledAsExe():
            stdPath = getOSUtil().getApplicationDataDirectory()
            if isPortableEnabled():
                stdPath = getOSUtil().getInstallDirectory()

            stdoutFile = os.path.join(stdPath, u"stdout.txt") #$NON-NLS-1$
            stderrFile = os.path.join(stdPath, u"stderr.txt") #$NON-NLS-1$
            sys.stderr = open(stderrFile, u"w")  #$NON-NLS-1$
            sys.stdout = open(stdoutFile, u"w") #$NON-NLS-1$

        # Set up the string bundle path.
        installDir = os.path.join(getOSUtil().getInstallDirectory(), u"system/bundles") #$NON-NLS-1$
        os.environ[IZI18NConstants.BUNDLE_PATH_ENV_VAR] = installDir

        # The MakeActiveXClass wrapper must be explicitely imported or
        # else instantiating the mshtml wrapper will hard-crash :(
        # FIXME (EPW) move this into an osutil init phase - to eliminate a dependency on Win32 stuff
        from wx.lib.activexwrapper import MakeActiveXClass #@UnusedImport
示例#2
0
文件: raven.py 项目: mpm2050/Raven
    def _initGlobalSettings(self):
        cmdLineParams = ZCommandLineParameters(sys.argv[1:])
        setCommandLineParameters(cmdLineParams)

        # Add an uncaught exception hook so that we can display a dialog if something bad happens.
        sys.excepthook = self.handleException

        # If the application is installed (not in dev-mode), redirect stderr and stdout.
        # FIXME (EPW) hook up the stderr/stdout to the logger at some point
        if getOSUtil().isInstalledAsExe():
            stdPath = getOSUtil().getApplicationDataDirectory()
            if isPortableEnabled():
                stdPath = getOSUtil().getInstallDirectory()

            stdoutFile = os.path.join(stdPath, u"stdout.txt")  #$NON-NLS-1$
            stderrFile = os.path.join(stdPath, u"stderr.txt")  #$NON-NLS-1$
            sys.stderr = open(stderrFile, u"w")  #$NON-NLS-1$
            sys.stdout = open(stdoutFile, u"w")  #$NON-NLS-1$

        # Set up the string bundle path.
        installDir = os.path.join(getOSUtil().getInstallDirectory(),
                                  u"system/bundles")  #$NON-NLS-1$
        os.environ[IZI18NConstants.BUNDLE_PATH_ENV_VAR] = installDir

        # The MakeActiveXClass wrapper must be explicitely imported or
        # else instantiating the mshtml wrapper will hard-crash :(
        # FIXME (EPW) move this into an osutil init phase - to eliminate a dependency on Win32 stuff
        from wx.lib.activexwrapper import MakeActiveXClass  #@UnusedImport
示例#3
0
    def _createSplashPanel(self, parent):
        ver = version.ZVersion()
        verDate = ZSchemaDateTime(ver.getBuildDate())

        panel = wx.Panel(parent, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)
        splashFilename = u"splash.png" #$NON-NLS-1$
        if isPortableEnabled():
            splashFilename = u"splash_portable.png" #$NON-NLS-1$
        bitmap = getResourceRegistry().getBitmap(u"images/splash/%s" % splashFilename) #$NON-NLS-1$
        splashImage = ZStaticBitmap(panel, bitmap)
        
        versionLabelLabel = wx.StaticText(panel, wx.ID_ANY, u"%s: " % _extstr(u"splash.Version")) #$NON-NLS-1$ #$NON-NLS-2$
        versionLabelLabel.SetFont(getDefaultFontBold())
        versionLabel = wx.StaticText(panel, wx.ID_ANY, ver.getFullVersionString())
        dateLabelLabel = wx.StaticText(panel, wx.ID_ANY, u"%s: " % _extstr(u"splash.BuiltOn")) #$NON-NLS-1$ #$NON-NLS-2$
        dateLabelLabel.SetFont(getDefaultFontBold())
        dateLabel = wx.StaticText(panel, wx.ID_ANY, verDate.toString(localTime = True))
        
        verAndDateSizer = wx.BoxSizer(wx.HORIZONTAL)
        verAndDateSizer.Add(versionLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(versionLabel, 0, wx.EXPAND | wx.RIGHT, 10)
        verAndDateSizer.Add(dateLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(dateLabel, 0, wx.EXPAND)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splashImage, 0, wx.EXPAND)
        sizer.AddSizer(verAndDateSizer, 0, wx.EXPAND | wx.ALL, 5)
        
        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)
        
        return panel
示例#4
0
文件: manager.py 项目: mpm2050/Raven
    def __init__(self, rvalMap, model, systemProfile):
        self.rvalMap = rvalMap
        self.model = model
        self.systemProfile = systemProfile
        self.selectedIndex = -1
        self.importMenuModel = self._createImportMenuModel()
        title = _extstr(u"manager.WindowTitle") #$NON-NLS-1$
        portable = _extstr(u"manager.Portable") #$NON-NLS-1$
        if isPortableEnabled():
            title = u"%s (%s)" % (title, portable) #$NON-NLS-1$

        wx.Frame.__init__(self, None, wx.ID_ANY, title, size=wx.Size(400, 325),
                          style = wx.DEFAULT_FRAME_STYLE)
        self._createWidgets()
        self._populateWidgets()
        self._layoutWidgets()
        self._bindWidgetEvents()
        self.CentreOnScreen()
        self.SetIcons(getResourceRegistry().getIconBundle(ICON_IMAGES))
        self.Show(True)

        # Auto-select the 'default' profile.
        defaultName = self.model.getDefaultProfileName()
        if defaultName:
            self.profilesListView.Select(self._getProfileIndex(defaultName), True)

        # Now set focus on the profileListView
        self.profilesListView.SetFocus()

        # Fire a UI exec event - detect ZBW or WLW on startup
        fireUIExecEvent(ZMethodRunnable(self.onDetectImport), self)
示例#5
0
    def _saveProfilesDom(self):
        if isPortableEnabled():
            profilesDirPath = self.getDefaultProfilesDirectory()
            if not os.path.exists(profilesDirPath):
                os.makedirs(profilesDirPath)

        domPath = self._getProfilesXmlPath()
        self.profilesDom.save(domPath)
示例#6
0
文件: manager.py 项目: mpm2050/Raven
    def _saveProfilesDom(self):
        if isPortableEnabled():
            profilesDirPath = self.getDefaultProfilesDirectory()
            if not os.path.exists(profilesDirPath):
                os.makedirs(profilesDirPath)

        domPath = self._getProfilesXmlPath()
        self.profilesDom.save(domPath)
示例#7
0
 def getDefaultProfilesDirectory(self):
     if isPortableEnabled():
         osutil = getOSUtil()
         installDir = osutil.getInstallDirectory()
         profilesDir = os.path.join(installDir, u"profiles") #$NON-NLS-1$
         profilesDir = os.path.abspath(profilesDir)
         return profilesDir
     else:
         return self.osutil.getApplicationDataDirectory()
示例#8
0
文件: manager.py 项目: mpm2050/Raven
 def getDefaultProfilesDirectory(self):
     if isPortableEnabled():
         osutil = getOSUtil()
         installDir = osutil.getInstallDirectory()
         profilesDir = os.path.join(installDir, u"profiles")  #$NON-NLS-1$
         profilesDir = os.path.abspath(profilesDir)
         return profilesDir
     else:
         return self.osutil.getApplicationDataDirectory()
示例#9
0
    def _save(self):
        if not self.registryFile:
            return

        mediaStorageDir = os.path.basename(self.registryFile)

        dom = ZDom()
        dom.loadXML(u"<registry/>")  #$NON-NLS-1$
        registryElem = dom.documentElement
        for fileName in self.fileMap:
            (size, timestamp, uploadResponse) = self.fileMap[fileName]
            relativeFileName = makeRelativePath(mediaStorageDir, fileName)
            url = uploadResponse.getUrl()
            embedFragment = uploadResponse.getEmbedFragment()
            metaData = uploadResponse.getMetaData()

            entryElem = dom.createElement(u"entry")  #$NON-NLS-1$
            entryElem.setAttribute(u"size", unicode(size))  #$NON-NLS-1$
            entryElem.setAttribute(u"timestamp",
                                   unicode(timestamp))  #$NON-NLS-1$

            fileElem = dom.createElement(u"file")  #$NON-NLS-1$
            urlElem = dom.createElement(u"url")  #$NON-NLS-1$
            embedElem = dom.createElement(u"embed")  #$NON-NLS-1$
            metaDataElem = dom.createElement(u"metaData")  #$NON-NLS-1$

            # When in portable mode, save the file paths as relative (which will
            # only happen when the image is on the same drive as the app).
            if isPortableEnabled():
                fileElem.setText(relativeFileName)
            else:
                fileElem.setText(fileName)

            entryElem.appendChild(fileElem)
            if url:
                urlElem.setText(unicode(url))
            entryElem.appendChild(urlElem)
            if embedFragment is not None:
                embedElem.appendChild(dom.importNode(embedFragment, True))
            entryElem.appendChild(embedElem)
            if metaData is not None:
                metaDataElem.appendChild(dom.importNode(metaData, True))
            entryElem.appendChild(metaDataElem)

            registryElem.appendChild(entryElem)

        dom.save(self.registryFile, True)
示例#10
0
    def _save(self):
        if not self.registryFile:
            return

        mediaStorageDir = os.path.basename(self.registryFile)

        dom = ZDom()
        dom.loadXML(u"<registry/>") #$NON-NLS-1$
        registryElem = dom.documentElement
        for fileName in self.fileMap:
            (size, timestamp, uploadResponse) = self.fileMap[fileName]
            relativeFileName = makeRelativePath(mediaStorageDir, fileName)
            url = uploadResponse.getUrl()
            embedFragment = uploadResponse.getEmbedFragment()
            metaData = uploadResponse.getMetaData()

            entryElem = dom.createElement(u"entry") #$NON-NLS-1$
            entryElem.setAttribute(u"size", unicode(size)) #$NON-NLS-1$
            entryElem.setAttribute(u"timestamp", unicode(timestamp)) #$NON-NLS-1$

            fileElem = dom.createElement(u"file") #$NON-NLS-1$
            urlElem = dom.createElement(u"url") #$NON-NLS-1$
            embedElem = dom.createElement(u"embed") #$NON-NLS-1$
            metaDataElem = dom.createElement(u"metaData") #$NON-NLS-1$

            # When in portable mode, save the file paths as relative (which will
            # only happen when the image is on the same drive as the app).
            if isPortableEnabled():
                fileElem.setText(relativeFileName)
            else:
                fileElem.setText(fileName)

            entryElem.appendChild(fileElem)
            if url:
                urlElem.setText(unicode(url))
            entryElem.appendChild(urlElem)
            if embedFragment is not None:
                embedElem.appendChild(dom.importNode(embedFragment, True))
            entryElem.appendChild(embedElem)
            if metaData is not None:
                metaDataElem.appendChild(dom.importNode(metaData, True))
            entryElem.appendChild(metaDataElem)

            registryElem.appendChild(entryElem)

        dom.save(self.registryFile, True)
示例#11
0
文件: splash.py 项目: mpm2050/Raven
    def _createSplashPanel(self, parent):
        ver = version.ZVersion()
        verDate = ZSchemaDateTime(ver.getBuildDate())

        panel = wx.Panel(parent, wx.ID_ANY)
        panel.SetBackgroundColour(wx.WHITE)
        splashFilename = u"splash.png"  #$NON-NLS-1$
        if isPortableEnabled():
            splashFilename = u"splash_portable.png"  #$NON-NLS-1$
        bitmap = getResourceRegistry().getBitmap(u"images/splash/%s" %
                                                 splashFilename)  #$NON-NLS-1$
        splashImage = ZStaticBitmap(panel, bitmap)

        versionLabelLabel = wx.StaticText(
            panel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.Version"))  #$NON-NLS-1$ #$NON-NLS-2$
        versionLabelLabel.SetFont(getDefaultFontBold())
        versionLabel = wx.StaticText(panel, wx.ID_ANY,
                                     ver.getFullVersionString())
        dateLabelLabel = wx.StaticText(
            panel, wx.ID_ANY,
            u"%s: " % _extstr(u"splash.BuiltOn"))  #$NON-NLS-1$ #$NON-NLS-2$
        dateLabelLabel.SetFont(getDefaultFontBold())
        dateLabel = wx.StaticText(panel, wx.ID_ANY,
                                  verDate.toString(localTime=True))

        verAndDateSizer = wx.BoxSizer(wx.HORIZONTAL)
        verAndDateSizer.Add(versionLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(versionLabel, 0, wx.EXPAND | wx.RIGHT, 10)
        verAndDateSizer.Add(dateLabelLabel, 0, wx.EXPAND | wx.RIGHT, 2)
        verAndDateSizer.Add(dateLabel, 0, wx.EXPAND)

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splashImage, 0, wx.EXPAND)
        sizer.AddSizer(verAndDateSizer, 0, wx.EXPAND | wx.ALL, 5)

        panel.SetSizer(sizer)
        panel.SetAutoLayout(True)

        return panel
示例#12
0
    def createProfile(self, profileInfo):
        (name, path) = profileInfo
        fullPath = path

        # if running in portable mode, the path needs to be stored
        # relative to the profiles.xml file.
        if isPortableEnabled():
            profileDirPath = self.getDefaultProfilesDirectory()
            path = makeRelativePath(profileDirPath, fullPath)

        # Check if we have one with the same name already.
        if self.getProfile(name) is not None:
            raise ZBlogAppException(_extstr(u"manager.ProfileAlreadyExists") % name) #$NON-NLS-1$

        profileElem = self.profilesDom.createElement(u"profile") #$NON-NLS-1$
        profileElem.setAttribute(u"name", name) #$NON-NLS-1$
        profileElem.setText(path)
        self.profilesDom.documentElement.appendChild(profileElem)
        self._saveProfilesDom()

        if not os.path.exists(fullPath):
            os.makedirs(fullPath)
示例#13
0
文件: manager.py 项目: mpm2050/Raven
    def createProfile(self, profileInfo):
        (name, path) = profileInfo
        fullPath = path

        # if running in portable mode, the path needs to be stored
        # relative to the profiles.xml file.
        if isPortableEnabled():
            profileDirPath = self.getDefaultProfilesDirectory()
            path = makeRelativePath(profileDirPath, fullPath)

        # Check if we have one with the same name already.
        if self.getProfile(name) is not None:
            raise ZBlogAppException(
                _extstr(u"manager.ProfileAlreadyExists") % name)  #$NON-NLS-1$

        profileElem = self.profilesDom.createElement(u"profile")  #$NON-NLS-1$
        profileElem.setAttribute(u"name", name)  #$NON-NLS-1$
        profileElem.setText(path)
        self.profilesDom.documentElement.appendChild(profileElem)
        self._saveProfilesDom()

        if not os.path.exists(fullPath):
            os.makedirs(fullPath)
示例#14
0
 def _processContent(self, element, serializationContext):
     if isPortableEnabled():
         visitor = ZMakeRelativeFilePathVisitor(serializationContext.getDataDir())
         visitor.visit(element)
示例#15
0
 def _processContent(self, element, serializationContext):
     if isPortableEnabled():
         visitor = ZMakeRelativeFilePathVisitor(
             serializationContext.getDataDir())
         visitor.visit(element)