Example #1
0
    def extract(download):
        """
        Extract either a .zip or a .tar.gz file into the user's home folder,
        backs up the current program directory on Windows that contains the latest Whyteboard
        source code and resources
        """
        extracted_location = os.path.join(get_home_dir(), "whyteboard-" + download.version)
        backup_direcctory = os.path.join(get_home_dir(), "backup", meta.version)
        program_directory = get_path()
        archive = download.filesystem_path()
        logger.debug("Extracting archive file")

        logger.debug("Backing up current program [%s] to [%s]", program_directory, backup_direcctory)
        distutils.dir_util.copy_tree(program_directory, backup_direcctory)
        
        if is_exe():
            os.rename(sys.argv[0], "whyteboard-tmp.exe")
            _file = zipfile.ZipFile(archive)
        else:
            _file = tarfile.open(archive)
        _file.extractall(get_home_dir())
        _file.close()

        logger.debug("Moving extracted file directory [%s] into running program directory [%s]", extracted_location, program_directory)
        distutils.dir_util.copy_tree(extracted_location, program_directory)

        logger.debug("Cleaning up.")
        distutils.dir_util.remove_tree(extracted_location)
        os.remove(archive)
Example #2
0
    def set_language(self, option_lang=None):
        """
        Sets the user's language.
        """
        set_lang = False
        lang_name = Config().get('language')
        logger.debug("Found language [%s] in config", lang_name)

        if option_lang:
            logger.debug("Attempting to set language from command line: [%s]", option_lang)
            country = wx.Locale.FindLanguageInfo(option_lang)
            if country:
                set_lang = True
                lang_name = country.Description
                self.locale = wx.Locale(country.Language)
                logger.debug("Using command-line set language [%s]", lang_name)
            else:
                logger.warning("Could not parse command-line argument [%s] into a known locale/language", option_lang)

        if not set_lang:
            for x in meta.languages:
                if lang_name.capitalize() == 'Welsh':
                    self.locale = wx.Locale()
                    self.locale.Init(u"Cymraeg", u"cy", u"cy_GB.utf8")
                    break
                elif lang_name == x[0]:
                    logger.debug("Attempting to set language to [%s] from config", lang_name)
                    nolog = wx.LogNull()
                    self.locale = wx.Locale(x[2])

        if not hasattr(self, "locale"):
            logger.debug("No locale set, reverting to system language")
            self.locale = wx.Locale(wx.LANGUAGE_DEFAULT)
            Config().language(wx.Locale.GetLanguageName(wx.LANGUAGE_DEFAULT))
            Config().write()

        if not wx.Locale.IsOk(self.locale):
            logger.warning("Could not set language to [%s]", lang_name)
            wx.MessageBox(u"Error setting language to %s - reverting to English"
                          % lang_name, u"Whyteboard")
            if not set_lang:
                Config().language('English')
                Config().write()
            self.locale = wx.Locale(wx.LANGUAGE_ENGLISH)

        logger.info("Whyteboard is running in [%s]", wx.Locale.GetLanguageName(self.locale.GetLanguage()))
        langdir = os.path.join(get_path(), u'locale')
        logger.debug("Adding locale catalogue [%s]", langdir)
        self.locale.AddCatalogLookupPathPrefix(langdir)
        self.locale.AddCatalog(u"whyteboard")
        self.locale.AddCatalog(u'wxstd')

        # nasty fix for some translated strings not being applied
        meta.languages = meta.define_languages()
        meta.types, meta.dialog_wildcard = meta.define_filetypes()
Example #3
0
    def on_about(self, event=None):
        inf = wx.AboutDialogInfo()
        inf.Name = u"Whyteboard"
        inf.Version = meta.version
        inf.Copyright = u"© 2009-2011 Steven Sproat"
        inf.Description = _("A simple whiteboard and PDF annotator")
        inf.Developers = [u"Steven Sproat <*****@*****.**>"]
        inf.Translators = meta.translators
        inf.WebSite = (u"http://www.whyteboard.org", u"http://www.whyteboard.org")
        inf.Licence = u"GPL 3"
        license = os.path.join(get_path(), u"LICENSE.txt")
        if os.path.exists(license):
            with open(license) as f:
                inf.Licence = f.read()

        if os.name == "nt":
            AboutDialog(self, inf)
        else:
            wx.AboutBox(inf)
Example #4
0
 def delete_temp_update_files(self):
     tmp_file = os.path.join(get_path(), u"whyteboard-tmp.exe")
     if is_exe() and os.path.exists(tmp_file):
         logger.info("Removing backup EXE [%s] after performing an update", tmp_file)
         os.remove(tmp_file)