Beispiel #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
Beispiel #2
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
Beispiel #3
0
 def runAction(self, actionContext):
     blog = actionContext.getBlog()
     url = blog.getUrl()
     if not url:
         msg = _extstr(u"blogactions.CouldNotDetermineURLForBlog") % blog.getName() #$NON-NLS-1$
         title = _extstr(u"blogactions.ProblemOpeningBlogURL") #$NON-NLS-1$
         ZShowWarnMessage(actionContext.getParentWindow(), msg, title)
     else:
         getOSUtil().openUrlInBrowser(url)
Beispiel #4
0
 def runAction(self, actionContext):
     blog = actionContext.getBlog()
     url = blog.getUrl()
     if not url:
         msg = _extstr(u"blogactions.CouldNotDetermineURLForBlog"
                       ) % blog.getName()  #$NON-NLS-1$
         title = _extstr(u"blogactions.ProblemOpeningBlogURL")  #$NON-NLS-1$
         ZShowWarnMessage(actionContext.getParentWindow(), msg, title)
     else:
         getOSUtil().openUrlInBrowser(url)
Beispiel #5
0
 def onDetectImport(self):
     osutil = getOSUtil()
     if osutil.getOperatingSystemId() == u"win32": #$NON-NLS-1$
         action = ZDetectImportAction(self, self.model)
         context = ZMenuActionContext(self)
         action.runAction(context)
         pass
Beispiel #6
0
def ZHTMLViewControl(*args, **kw):
    osutil = getOSUtil()
    osId = osutil.getOperatingSystemId()
    if osId == u"win32": #$NON-NLS-1$
        return ZIExploreHTMLViewControl(*args, **kw)
    else:
        raise ZNotYetImplementedException()
# end ZHTMLViewControl
Beispiel #7
0
 def run(self):
     appModel = getApplicationModel()
     if self.isUpToDate:
         ZShowInfoMessage(appModel.getTopWindow(), self.message, self.title)
     else:
         if ZShowYesNoMessage(appModel.getTopWindow(), self.message, self.title):
             osutil = getOSUtil()
             osutil.openUrlInBrowser(u"http://www.zoundryraven.com/download.html") #$NON-NLS-1$
Beispiel #8
0
    def runAction(self, actionContext):
        selection = actionContext.getViewSelection()
        url = None
        if selection.getType() == IZViewSelectionTypes.BLOG_SELECTION:
            (accountId, blogId) = selection.getData()
            blog = getBlogFromIds(accountId, blogId)
            url = blog.getUrl()
        elif selection.getType() == IZViewSelectionTypes.DOCUMENT_SELECTION:
            (blog, document) = selection.getData()
            url = getBlogPostUrl(document, blog.getId())
        elif selection.getType() == IZViewSelectionTypes.LINK_SELECTION:
            url = selection.getData()[1].getUrl()
        elif selection.getType() == IZViewSelectionTypes.IMAGE_SELECTION:
            url = selection.getData()[1].getUrl()

        if url is not None:
            getOSUtil().openUrlInBrowser(url)
    def runAction(self, actionContext):
        selection = actionContext.getViewSelection()
        url = None
        if selection.getType() == IZViewSelectionTypes.BLOG_SELECTION:
            (accountId, blogId) = selection.getData()
            blog = getBlogFromIds(accountId, blogId)
            url = blog.getUrl()
        elif selection.getType() == IZViewSelectionTypes.DOCUMENT_SELECTION:
            (blog, document) = selection.getData()
            url = getBlogPostUrl(document, blog.getId())
        elif selection.getType() == IZViewSelectionTypes.LINK_SELECTION:
            url = selection.getData()[1].getUrl()
        elif selection.getType() == IZViewSelectionTypes.IMAGE_SELECTION:
            url = selection.getData()[1].getUrl()

        if url is not None:
            getOSUtil().openUrlInBrowser(url)
Beispiel #10
0
 def _detectZBWProfilePath(self):
     osutil = getOSUtil()
     if osutil.getOperatingSystemId() == u"win32":  #$NON-NLS-1$
         from zoundry.blogapp.profile.zbwimporter import getZBWProfilePath
         path = getZBWProfilePath()
         if path:
             return path
     return u""  #$NON-NLS-1$
Beispiel #11
0
    def _detectZBWProfilePath(self):
        osutil = getOSUtil()
        if osutil.getOperatingSystemId() == u"win32":  # $NON-NLS-1$
            from zoundry.blogapp.profile.zbwimporter import getZBWProfilePath

            path = getZBWProfilePath()
            if path:
                return path
        return u""  # $NON-NLS-1$
Beispiel #12
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()
Beispiel #13
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()
    def runAction(self, actionContext):
        blogId = self.blogId
        if blogId is None:
            blogId = self._findFirstBlogId(actionContext)
        if blogId is None:
            return

        url = None

        editor = actionContext.getEditor()
        zblogDocument = editor.getDocument()
        blogInfos = zblogDocument.getBlogInfoList()
        for blogInfo in blogInfos:
            if blogInfo.getBlogId() == blogId:
                pubInfo = blogInfo.getPublishInfo()
                url = pubInfo.getUrl()

        if url is not None:
            getOSUtil().openUrlInBrowser(url)
Beispiel #15
0
def ZHTMLViewControl(*args, **kw):
    osutil = getOSUtil()
    osId = osutil.getOperatingSystemId()
    if osId == u"win32":  #$NON-NLS-1$
        return ZIExploreHTMLViewControl(*args, **kw)
    else:
        raise ZNotYetImplementedException()


# end ZHTMLViewControl
Beispiel #16
0
    def runAction(self, actionContext):
        blogId = self.blogId
        if blogId is None:
            blogId = self._findFirstBlogId(actionContext)
        if blogId is None:
            return

        url = None

        editor = actionContext.getEditor()
        zblogDocument = editor.getDocument()
        blogInfos = zblogDocument.getBlogInfoList()
        for blogInfo in blogInfos:
            if blogInfo.getBlogId() == blogId:
                pubInfo = blogInfo.getPublishInfo()
                url = pubInfo.getUrl()

        if url is not None:
            getOSUtil().openUrlInBrowser(url)
Beispiel #17
0
 def _copyAspellDirToTemp(self, spellingDir):
     osutil = getOSUtil()
     tempDir = osutil.getSystemTempDirectory()
     if not os.path.isdir(tempDir):
         raise ZException(u"System temp directory not found.") #$NON-NLS-1$
     tempSpellingDir = os.path.join(tempDir, u"_RavenSpellcheck_tmp") #$NON-NLS-1$
     if not os.path.exists(tempSpellingDir):
         os.mkdir(tempSpellingDir)
     copyFiles(spellingDir, tempSpellingDir)
     return tempSpellingDir
Beispiel #18
0
 def _copyAspellDirToTemp(self, spellingDir):
     osutil = getOSUtil()
     tempDir = osutil.getSystemTempDirectory()
     if not os.path.isdir(tempDir):
         raise ZException(u"System temp directory not found.")  #$NON-NLS-1$
     tempSpellingDir = os.path.join(tempDir,
                                    u"_RavenSpellcheck_tmp")  #$NON-NLS-1$
     if not os.path.exists(tempSpellingDir):
         os.mkdir(tempSpellingDir)
     copyFiles(spellingDir, tempSpellingDir)
     return tempSpellingDir
Beispiel #19
0
def getZBWProfilePath():
    import _winreg
    try:
        handle = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, u"Software\\Zoundry Blog Writer") #$NON-NLS-1$
        installPath = _winreg.QueryValueEx(handle, u"Path")[0] #$NON-NLS-1$
        if not installPath:
            return None
        userName = getOSUtil().getCurrentUserName()
        path = os.path.join(installPath, u"users", userName) #$NON-NLS-1$
        _winreg.CloseKey(handle)
        return path
    except:
        return None
Beispiel #20
0
    def start(self, applicationModel): #@UnusedVariable
        self.userProfile = applicationModel.getUserProfile()
        userProps = self.userProfile.getProperties()

        loggerConfigNode = userProps.getPropertyNode(u"/user-properties/logger") #$NON-NLS-1$
        if not loggerConfigNode:
            loggerConfigNode = self._loadDefaultLoggerNode()
        isInstalled = getOSUtil().isInstalledAsExe()
        isMaster = userProps.getPropertyBool(u"/user-properties/logger/master", False) #$NON-NLS-1$
        isEclipse = userProps.getPropertyBool(u"/user-properties/logger/eclipse", not isInstalled) #$NON-NLS-1$
        isConsole = userProps.getPropertyBool(u"/user-properties/logger/console", False) #$NON-NLS-1$

        self.logger = ZLogger(loggerConfigNode, isMaster, isEclipse, isConsole, self.userProfile.getLogDirectory())
        self.logger.start()
Beispiel #21
0
def getPngFileFromClipboard(copyToResourceStore=False):
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip", u".png") #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath( os.path.join(tempDir, name) )
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
Beispiel #22
0
def getPngFileFromClipboard(copyToResourceStore=False):
    u"""Returns the (temp) file path to png file representing the clipboard bitmap or None otherwise.
    If copyToResourceStore = true, then the tmp image file is copied to the resource store.
    """ #$NON-NLS-1$
    filepath = None
    bmp = getBitmapFromClipboard()
    if bmp:
        try:
            osutil = getOSUtil()
            tempDir = osutil.getSystemTempDirectory()
            name = generateFilename(u"zrclip",
                                    u".png")  #$NON-NLS-1$ #$NON-NLS-2$
            filepath = os.path.abspath(os.path.join(tempDir, name))
            bmp.SaveFile(filepath, wx.BITMAP_TYPE_PNG)
        except Exception, e:
            filepath = None
            getLoggerService().exception(e)
Beispiel #23
0
    def OnLinkClicked(self, linkInfo):
        href = linkInfo.GetHref()
        if href.startswith(u"http"): #$NON-NLS-1$
            osutil = getOSUtil()
            osutil.openUrlInBrowser(href)
            return

        meth = None
        # Try the optional handler first
        if self.handler:
            meth = getattr(self.handler, href)
        # Next try the widget's parent
        if not meth or not callable(meth):
            meth = getattr(self.GetParent(), href)

        # If a method was found, call it, otherwise do nothing.
        if meth and callable(meth):
            meth()
Beispiel #24
0
def isPortableEnabled():
    u"""Returns true if the --portable command line option is set to enabled.""" #$NON-NLS-1$
    global PORTABLE_ENABLED
    if PORTABLE_ENABLED is None:
        PORTABLE_ENABLED = False

        # If the OS Util thinks we're installed as a portable app, then it is
        # probably true, unless overridden by the cmd line.
        osutil = getOSUtil()
        if osutil.isInstalledAsPortable():
            PORTABLE_ENABLED = True
    
        # The command line parameter can always override the value.
        cmdLineParams = getCommandLineParameters()
        if cmdLineParams is not None and u"portable" in cmdLineParams: #$NON-NLS-1$
            PORTABLE_ENABLED = cmdLineParams[u"portable"] == u"true" #$NON-NLS-1$ #$NON-NLS-2$

    return PORTABLE_ENABLED
Beispiel #25
0
def isPortableEnabled():
    u"""Returns true if the --portable command line option is set to enabled."""  #$NON-NLS-1$
    global PORTABLE_ENABLED
    if PORTABLE_ENABLED is None:
        PORTABLE_ENABLED = False

        # If the OS Util thinks we're installed as a portable app, then it is
        # probably true, unless overridden by the cmd line.
        osutil = getOSUtil()
        if osutil.isInstalledAsPortable():
            PORTABLE_ENABLED = True

        # The command line parameter can always override the value.
        cmdLineParams = getCommandLineParameters()
        if cmdLineParams is not None and u"portable" in cmdLineParams:  #$NON-NLS-1$
            PORTABLE_ENABLED = cmdLineParams[
                u"portable"] == u"true"  #$NON-NLS-1$ #$NON-NLS-2$

    return PORTABLE_ENABLED
Beispiel #26
0
    def start(self, applicationModel):  #@UnusedVariable
        self.userProfile = applicationModel.getUserProfile()
        userProps = self.userProfile.getProperties()

        loggerConfigNode = userProps.getPropertyNode(
            u"/user-properties/logger")  #$NON-NLS-1$
        if not loggerConfigNode:
            loggerConfigNode = self._loadDefaultLoggerNode()
        isInstalled = getOSUtil().isInstalledAsExe()
        isMaster = userProps.getPropertyBool(u"/user-properties/logger/master",
                                             False)  #$NON-NLS-1$
        isEclipse = userProps.getPropertyBool(
            u"/user-properties/logger/eclipse", not isInstalled)  #$NON-NLS-1$
        isConsole = userProps.getPropertyBool(
            u"/user-properties/logger/console", False)  #$NON-NLS-1$

        self.logger = ZLogger(loggerConfigNode, isMaster, isEclipse, isConsole,
                              self.userProfile.getLogDirectory())
        self.logger.start()
Beispiel #27
0
    def populateWidgets(self):
        enable = self.session.getUserPreferenceBool(IZAppUserPrefsKeys.PROXY_ENABLE, False) #$NON-NLS-1$
        self.enableCB.SetValue(enable)
        self.controlsPanel.Enable(enable)
        
        host = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_HOST, u"") #$NON-NLS-1$
        port = self.session.getUserPreferenceInt(IZAppUserPrefsKeys.PROXY_PORT, 0) #$NON-NLS-1$
        if not host:
            # get data from os registry
            proxy = getOSUtil().getProxyConfig()
            if proxy and proxy.isConfigured():
                host = proxy.getHost()            
                port = proxy.getPortInt()
        self.hostTxt.SetValue(host)        
        if port > 0:
            self.portTxt.SetValue( unicode(port) )
        username = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_USERNAME, u"") #$NON-NLS-1$
        self.usernameTxt.SetValue(username)

        cyppass = self.session.getUserPreference(IZAppUserPrefsKeys.PROXY_PASSWORD, u"") #$NON-NLS-1$
        cyppass = getNoneString(cyppass)
        if cyppass:
            password = crypt.decryptCipherText(cyppass, PASSWORD_ENCRYPTION_KEY)
            self.passwordTxt.SetValue(password)
Beispiel #28
0
 def runAction(self, actionContext):
     busyCursor = wx.BusyCursor()
     try:
         getOSUtil().openFileInDefaultEditor(self.task.getLogLocation())
     except Exception, e:
         ZShowExceptionMessage(actionContext.getParentWindow(), e)
Beispiel #29
0
 def runAction(self, actionContext):  # @UnusedVariable
     url = u"http://forums.zoundry.com/viewforum.php?f=12"  # $NON-NLS-1$
     getOSUtil().openUrlInBrowser(url)
Beispiel #30
0
 def _createSystemProfile(self):
     factory = ZSystemProfileFactory()
     path = os.path.join(getOSUtil().getInstallDirectory(), u"system") #$NON-NLS-1$
     return factory.createSystemProfile(SYSTEM_PROFILE_TYPE_FILE, path)
Beispiel #31
0
 def __init__(self):
     self.osutil = getOSUtil()
     self.profilesDom = self._loadProfilesDom()
Beispiel #32
0
 def _handleUrlAction(self, url):
     getOSUtil().openUrlInBrowser(url)
Beispiel #33
0
 def _handleUrlAction(self, url):
     getOSUtil().openUrlInBrowser(url)
Beispiel #34
0
 def _createSystemProfile(self):
     factory = ZSystemProfileFactory()
     path = os.path.join(getOSUtil().getInstallDirectory(),
                         u"system")  #$NON-NLS-1$
     return factory.createSystemProfile(SYSTEM_PROFILE_TYPE_FILE, path)
Beispiel #35
0
 def _getDefaultWLWProfilePath(self):
     osutil = getOSUtil()
     return os.path.join(osutil.getApplicationDataDirectory(), u"Windows Live Writer") #$NON-NLS-1$
Beispiel #36
0
 def onLinkClick(self, event):
     url = getSafeString( event.getHref() )
     if url.lower().startswith(u"http"): #$NON-NLS-1$
         url = unquote_plus(url)
         osutil = getOSUtil()
         osutil.openUrlInBrowser(url)
Beispiel #37
0
 def runAction(self, actionContext):
     busyCursor = wx.BusyCursor()
     try:
         getOSUtil().openFileInDefaultEditor(self.task.getLogLocation())
     except Exception, e:
         ZShowExceptionMessage(actionContext.getParentWindow(), e)
Beispiel #38
0
 def runAction(self, actionContext):
     cursor = wx.BusyCursor()
     url = actionContext.getUrl()
     getOSUtil().openUrlInBrowser(url)
     del cursor
Beispiel #39
0
 def runAction(self, actionContext): #@UnusedVariable
     url = u"http://forums.zoundry.com/viewforum.php?f=12" #$NON-NLS-1$
     getOSUtil().openUrlInBrowser(url)
Beispiel #40
0
 def runAction(self, actionContext):
     cursor = wx.BusyCursor()
     url = actionContext.getUrl()
     getOSUtil().openUrlInBrowser(url)
     del cursor
Beispiel #41
0
 def __init__(self):
     self.osutil = getOSUtil()
     self.profilesDom = self._loadProfilesDom()