Exemplo n.º 1
0
    def new(self):
        if len(self.subExercisesList) == 0:
            self.currentSubExercise = SubExercise(self)
            self.subExercisesList.append(self.currentSubExercise)
            self.currentSubExerciseId = 0
            self.currentSequenceId = 0
            languageManager = LanguagesManager()
            self.language = languageManager.get_default_language()

            self.maxSequenceLength = float(
                config.get("default_exercise_max_sequence_length")) / 1000
            self.timeBetweenSequence = float(
                config.get("default_exercise_time_between_sequences")) / 1000
            self.playMarginAfter = config.get(
                "default_exercise_play_margin_before")
            self.playMarginBefore = config.get(
                "default_exercise_play_margin_after")

            self.repeatAfterCompleted = (
                config.get("default_exercise_repeat_after_completed") == 1)
            self.randomOrder = (
                config.get("default_exercise_random_order") == 1)
            self.use_dynamic_correction = (
                config.get("default_exercise_dynamic_correction") == 1)

            self.set_language_id(config.get("default_exercise_language"))

            self.repeat_count_limit_by_sequence = int(
                config.get("default_repeat_count_limit_by_sequence"))
Exemplo n.º 2
0
    def ask_new_exercise(self):
        self.newExerciseDialog = self.builder.get_object("newExerciseDialog")

        videoChooser = self.builder.get_object("filechooserbuttonVideo")
        exerciseChooser = self.builder.get_object("filechooserbuttonExercise")
        translationChooser = self.builder.get_object("filechooserbuttonTranslation")
        videoChooser.unselect_all()
        exerciseChooser.unselect_all()
        translationChooser.unselect_all()

        self.liststoreLanguage = gtk.ListStore(str, str)

        languageManager = LanguagesManager()
        languagesList = languageManager.get_languages_list()

        for language in languagesList:
            iter = self.liststoreLanguage.append([language.name, language.id])
            if language.id == config.get("default_exercise_language"):
                currentIter = iter

        comboboxLanguage = self.builder.get_object("comboboxLanguage")

        #Clear old values
        comboboxLanguage.clear()

        cell = gtk.CellRendererText()
        comboboxLanguage.set_model(self.liststoreLanguage)
        comboboxLanguage.pack_start(cell, True)
        comboboxLanguage.add_attribute(cell, 'text', 0)

        comboboxLanguage.set_active_iter(currentIter)
    def write_personal_exercise_repository_list(self, newRepositoryList):
        """The goal of this methods is to make an inteligent write of
        config file. Lines beginning with # are comment and must be keep
        in place"""

        repositoryPath = config.get("personal_repository_source_path")
        repositoryList = []

        if os.path.isfile(repositoryPath):
            f = open(repositoryPath, 'r')
            for line in f:
                line = line.rstrip()
                if line[0] == "#":
                    #Comment line, set as keep
                    repositoryList.append(line)
                elif line in newRepositoryList:
                    repositoryList.append(line)
                    newRepositoryList.remove(line)
            f.close()

        for newRepo in newRepositoryList:
            repositoryList.append(newRepo)

        f = open(repositoryPath, 'w')
        for line in repositoryList:
            self.logger.debug(line)
            f.writelines(line + '\n')

        f.close()
Exemplo n.º 4
0
    def write_personal_exercise_repository_list(self, newRepositoryList):
        """The goal of this methods is to make an inteligent write of
        config file. Lines beginning with # are comment and must be keep
        in place"""

        repositoryPath = config.get("personal_repository_source_path")
        repositoryList = []

        if os.path.isfile(repositoryPath):
            f = open(repositoryPath, 'r')
            for line in f:
                line = line.rstrip()
                if line[0] == "#":
                    #Comment line, set as keep
                    repositoryList.append(line)
                elif line in newRepositoryList:
                    repositoryList.append(line)
                    newRepositoryList.remove(line)
            f.close()

        for newRepo in newRepositoryList:
            repositoryList.append(newRepo)

        f = open(repositoryPath, 'w')
        for line in repositoryList:
            self.logger.debug(line)
            f.writelines(line + '\n')

        f.close()
Exemplo n.º 5
0
    def _get_orphan_exercise_repository_list(self, repositoryListIn):
        repoPathList = os.listdir(config.get("local_repo_root_dir"))
        repoUsedPath = []
        repositoryList = []
        for repo in repositoryListIn:
            repoUsedPath.append(repo.get_local_path())

        for repoPath in repoPathList:
            path = os.path.join(config.get("local_repo_root_dir"), repoPath)
            if path not in repoUsedPath:
                repository = ExerciseRepository()
                repository.init_from_path(path)
                repository.set_type("orphan")
                repositoryList.append(repository)

        return repositoryList
    def _get_orphan_exercise_repository_list(self, repositoryListIn):
        repoPathList = os.listdir(config.get("local_repo_root_dir"))
        repoUsedPath = []
        repositoryList = []
        for repo in repositoryListIn:
            repoUsedPath.append(repo.get_local_path())

        for repoPath in repoPathList:
            path = os.path.join(config.get("local_repo_root_dir"), repoPath)
            if path not in repoUsedPath:
                repository = ExerciseRepository()
                repository.init_from_path(path)
                repository.set_type("orphan")
                repositoryList.append(repository)

        return repositoryList
Exemplo n.º 7
0
    def __init__(self):

        self.player = gst.Pipeline()
        self.playbin = gst.element_factory_make("playbin2", "player")

        # Disable the subtitle display if there is embeded subtitles
        # (for example, in mkv files)
        #
        # Flags activates some things
        # (1 << 0) : video
        # (1 << 1) : audio
        # (1 << 4) : software volume
        #
        # The default value is 0, 1, 2, 4. (1 << 2) display the subtitles
        #
        # For more details, see the doc
        # http://www.gstreamer.net/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin2.html#GstPlayFlags
        # http://www.gstreamer.net/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin2.html#GstPlayBin2--flags
        self.playbin.set_property("flags", (1 << 0)|(1 << 1)|(1 << 4))
        self.playbin.set_property("current-audio", 0)


        self.player.add(self.playbin)
        self.logger = logging.Logger("VideoPlayer")
        self.logger.setLevel(defaultLoggingLevel)
        self.logger.addHandler(defaultLoggingHandler)
        #Audio
        audiobin = gst.Bin("audio-speed-bin")
        try:
            self.audiospeedchanger = gst.element_factory_make("pitch")
            self.canChangeSpeed = True
        except gst.ElementNotFoundError:
            self.logger.warn(_(u"You need to install the gstreamer soundtouch elements to "
                             "use slowly play feature."))
            self.canChangeSpeed = False

        #Try to use the pitch element only if it is available
        if self.canChangeSpeed and config.get("interface_use_speed_change"):
            audiobin.add(self.audiospeedchanger)

            self.audiosink = gst.element_factory_make("autoaudiosink")

            audiobin.add(self.audiosink)
            convert = gst.element_factory_make("audioconvert")
            audiobin.add(convert)
            gst.element_link_many(self.audiospeedchanger, convert, self.audiosink)
            sink_pad = gst.GhostPad("sink", self.audiospeedchanger.get_pad("sink"))
            audiobin.add_pad(sink_pad)
            self.playbin.set_property("audio-sink", audiobin)

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)

        self.time_format = gst.Format(gst.FORMAT_TIME)
        self.timeToSeek = -1
        self.speed = 1.0
        self.nextCallbackTime = -1
Exemplo n.º 8
0
    def _get_local_exercise_repository_list(self):
        """Build and return the list of local repository.

        In fact, this list
        will contain at maximum 2 repositories.
        A local personnal repository is added to the list if a directory named 'local'
        exist in the repo root directory.
        A local system repository is added to the list if a directory named 
        'system_repo' is found in the perroquet data files.

        The local system repository is special because it is composed by 2 path : a
        system path for common data and a path for personnal data as progress
        """

        repositoryList = []
        # Build potential local repository path
        localRepoPath = os.path.join(config.get("local_repo_root_dir"),
                                     "local")

        # Test local repository existance
        if os.path.isdir(localRepoPath):
            # Repository found so Initialize it from the path and set it as local
            repository = ExerciseRepository()
            repository.init_from_path(localRepoPath)
            repository.set_type("local")
            repositoryList.append(repository)

        systemRepoPath = os.path.join(config.get("system_repo_root_dir"),
                                      "system")

        print "system repo path " + systemRepoPath
        #Test systemrepository existance
        if os.path.isdir(systemRepoPath):
            print "system repo found"
            # Repository found so Initialize it from the path and set it as local
            repository = ExerciseRepository()
            repository.set_system(True)
            repository.init_from_path(systemRepoPath)
            repository.set_type("local")
            repositoryList.append(repository)

        return repositoryList
    def _get_local_exercise_repository_list(self):
        """Build and return the list of local repository.

        In fact, this list
        will contain at maximum 2 repositories.
        A local personnal repository is added to the list if a directory named 'local'
        exist in the repo root directory.
        A local system repository is added to the list if a directory named 
        'system_repo' is found in the perroquet data files.

        The local system repository is special because it is composed by 2 path : a
        system path for common data and a path for personnal data as progress
        """

        repositoryList = []
        # Build potential local repository path
        localRepoPath = os.path.join(config.get("local_repo_root_dir"), "local")

        # Test local repository existance
        if os.path.isdir(localRepoPath):
            # Repository found so Initialize it from the path and set it as local
            repository = ExerciseRepository()
            repository.init_from_path(localRepoPath)
            repository.set_type("local")
            repositoryList.append(repository)

        systemRepoPath = os.path.join(config.get("system_repo_root_dir"), "system")

        print "system repo path "+systemRepoPath
        #Test systemrepository existance
        if os.path.isdir(systemRepoPath):
            print "system repo found"
            # Repository found so Initialize it from the path and set it as local
            repository = ExerciseRepository()
            repository.set_system(True);
            repository.init_from_path(systemRepoPath)
            repository.set_type("local")
            repositoryList.append(repository)


        return repositoryList
Exemplo n.º 10
0
    def __init__(self, id, name, availableChars, helpChar="~"):
        self.id = id
        self.name = name
        self.availableChars = availableChars
        self.helpChar = helpChar
        self._aliases = []

        try:
            synonyms_list = config.get("synonyms." + self.id)
        except KeyError:
            warnings.warn("No aliases defined for language " + self.id, UserWarning)
        else:
            for synonyms in synonyms_list:
                self.add_synonyms(synonyms)
Exemplo n.º 11
0
    def __init__(self, id, name, availableChars, helpChar="~"):
        self.id = id
        self.name = name
        self.availableChars = availableChars
        self.helpChar = helpChar
        self._aliases = []

        try:
            synonyms_list = config.get("synonyms." + self.id)
        except KeyError:
            warnings.warn("No aliases defined for language " + self.id,
                          UserWarning)
        else:
            for synonyms in synonyms_list:
                self.add_synonyms(synonyms)
Exemplo n.º 12
0
    def new(self):
        if len(self.subExercisesList) == 0:
            self.currentSubExercise = SubExercise(self)
            self.subExercisesList.append(self.currentSubExercise)
            self.currentSubExerciseId = 0
            self.currentSequenceId = 0
            languageManager = LanguagesManager()
            self.language = languageManager.get_default_language()

            self.maxSequenceLength = float(config.get("default_exercise_max_sequence_length")) / 1000
            self.timeBetweenSequence = float(config.get("default_exercise_time_between_sequences")) / 1000
            self.playMarginAfter = config.get("default_exercise_play_margin_before")
            self.playMarginBefore = config.get("default_exercise_play_margin_after")

            self.repeatAfterCompleted = (config.get("default_exercise_repeat_after_completed") == 1)
            self.randomOrder = (config.get("default_exercise_random_order") == 1)
            self.use_dynamic_correction = (config.get("default_exercise_dynamic_correction") == 1)

            self.set_language_id(config.get("default_exercise_language"))

            self.repeat_count_limit_by_sequence = int(config.get("default_repeat_count_limit_by_sequence"))
Exemplo n.º 13
0
    def get_personal_exercise_repository_list(self):
        """Return the list of the url of the repository url add by the user"""
        repositoryPath = config.get("personal_repository_source_path")
        repositoryList = []

        if os.path.isfile(repositoryPath):
            f = open(repositoryPath, 'r')
            for line in f:
                line = line.rstrip()
                if line and line[0] == "#":
                    #Comment line
                    continue

                repositoryList.append(line)

        return repositoryList
Exemplo n.º 14
0
    def get_personal_exercise_repository_list(self):
        """Return the list of the url of the repository url add by the user"""
        repositoryPath = config.get("personal_repository_source_path")
        repositoryList = []

        if os.path.isfile(repositoryPath):
            f = open(repositoryPath, 'r')
            for line in f:
                line = line.rstrip()
                if line and line[0] == "#":
                    #Comment line
                    continue

                repositoryList.append(line)

        return repositoryList
Exemplo n.º 15
0
    def _update_last_open_files_tab(self):
        #TODO: move part in controller ?
        gtkTree = self.builder.get_object("lastopenfilesTreeView")

        cell = gtk.CellRendererText()

        treeViewColumn = gtk.TreeViewColumn(_("Path"))
        treeViewColumn.pack_start(cell, False)
        treeViewColumn.add_attribute(cell, 'markup', 0)
        treeViewColumn.set_expand(False)
        gtkTree.append_column(treeViewColumn)


        treeStore = gtk.TreeStore(str, str)
        for obj in config.get("lastopenfiles"):
            path = obj[0]
            name = obj[1] if len(obj) >= 2 else path
            treeStore.append(None, [name, path])

        gtkTree.set_model(treeStore)
Exemplo n.º 16
0
    def __init__(self, controller):

        locale.bindtextdomain(config.get("gettext_package"), config.get("localedir"))

        self.logger = logging.Logger("GUI")
        self.logger.setLevel(defaultLoggingLevel)
        self.logger.addHandler(defaultLoggingHandler)
        self.controller = controller

        self.builder = gtk.Builder()
        self.builder.set_translation_domain("perroquet")
        self.builder.add_from_file(config.get("ui_path"))
        self.builder.connect_signals(self)
        self.window = self.builder.get_object("MainWindow")
        self.window.set_icon_from_file(config.get("logo_path"))
        self.window.maximize()

        self.hpaned = self.builder.get_object("hpaned1")
        self.vpaned = self.builder.get_object("vpaned1")
        self.hpaned.connect("size_allocate", self.on_resize_hpaned)
        self.vpaned.connect("size_allocate", self.on_resize_vpaned)

        self.aboutDialog = self.builder.get_object("aboutdialog")
        icon = gtk.gdk.pixbuf_new_from_file(config.get("logo_path"))
        self.aboutDialog.set_logo(icon)
        self.aboutDialog.set_version(config.get("version"))

        # Sound icon
        self.builder.get_object("imageAudio").set_from_file(config.get("audio_icon"))

        self.typeLabel = self.builder.get_object("typeView")

        self.disable_changed_text_event = False
        self.setted_speed = 100
        self.setted_sequence_number = 0
        self.setted_position = 0
        self.setted_typing_area_text = ""

        self.newExerciseDialog = None
        self.liststoreLanguage = None

        self.disable_correction_event = False

        self._update_last_open_files_tab()
Exemplo n.º 17
0
    def import_package(self, import_path):

        #Verify file existence
        if not os.path.isfile(import_path):
            return _("File not found: ") + import_path + "."

        #Create temporary directory to extract the tar before install it
        tempPath = tempfile.mkdtemp("", "perroquet-");

        #Extract tar in temp directory
        tar = tarfile.open(import_path)
        tar.extractall(tempPath)
        tar.close()

        #Check package integrity
        template_path = os.path.join(tempPath, "template.perroquet")
        if not os.path.isfile(template_path):
            shutil.rmtree(tempPath)
            return _("Invalid package, missing template.perroquet.")


        #Find install path
        exercise = load_exercise(template_path)
        if exercise.get_name() != '':
            name = exercise.get_name()
        else:
            name = exercise.GetVideoPath()


        localRepoPath = os.path.join(config.get("local_repo_root_dir"), "local")
        group_path = os.path.join(localRepoPath, "Imported")
        install_path = os.path.join(group_path, name)

        #Copy files
        if not os.path.isdir(group_path):
            try:
                os.makedirs(group_path)
            except OSError, (ErrorNumber, ErrorMessage): # Python <=2.5
                if ErrorNumber == errno.EEXIST:
                    pass
                else: raise
Exemplo n.º 18
0
    def import_package(self, import_path):

        #Verify file existence
        if not os.path.isfile(import_path):
            return _("File not found: ") + import_path + "."

        #Create temporary directory to extract the tar before install it
        tempPath = tempfile.mkdtemp("", "perroquet-")

        #Extract tar in temp directory
        tar = tarfile.open(import_path)
        tar.extractall(tempPath)
        tar.close()

        #Check package integrity
        template_path = os.path.join(tempPath, "template.perroquet")
        if not os.path.isfile(template_path):
            shutil.rmtree(tempPath)
            return _("Invalid package, missing template.perroquet.")

        #Find install path
        exercise = load_exercise(template_path)
        if exercise.get_name() != '':
            name = exercise.get_name()
        else:
            name = exercise.GetVideoPath()

        localRepoPath = os.path.join(config.get("local_repo_root_dir"),
                                     "local")
        group_path = os.path.join(localRepoPath, "Imported")
        install_path = os.path.join(group_path, name)

        #Copy files
        if not os.path.isdir(group_path):
            try:
                os.makedirs(group_path)
            except OSError, (ErrorNumber, ErrorMessage):  # Python <=2.5
                if ErrorNumber == errno.EEXIST:
                    pass
                else:
                    raise
Exemplo n.º 19
0
# Copyright (C) 2009-2011 Matthieu Bizien.
#
# This file is part of Perroquet.
#
# Perroquet is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Perroquet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Perroquet.  If not, see <http://www.gnu.org/licenses/>.

import logging
import sys

from perroquetlib.config import config

# Build some logger related objects
defaultLoggingHandler = logging.StreamHandler(sys.stdout)
defaultLoggingHandler.setFormatter(
    logging.Formatter(
        "%(asctime)s.%(msecs)d-[%(name)s::%(levelname)s] %(message)s",
        "%a %H:%M:%S"))
defaultLoggingLevel = logging.DEBUG
defaultLoggingLevel = logging._levelNames[config.get("default_debug_level")]
Exemplo n.º 20
0
    def load(self):

        adjustmentTimeBetweenSequence = self.builder.get_object(
            "adjustmentTimeBetweenSequence")
        adjustmentTimeBetweenSequence.set_value(
            float(config.get("default_exercise_time_between_sequences")) /
            1000)

        adjustmentMaximumSequenceTime = self.builder.get_object(
            "adjustmentMaximumSequenceTime")
        adjustmentMaximumSequenceTime.set_value(
            float(config.get("default_exercise_max_sequence_length")) / 1000)

        adjustmentTimeBeforeSequence = self.builder.get_object(
            "adjustmentTimeBeforeSequence")
        adjustmentTimeBeforeSequence.set_value(
            float(config.get("default_exercise_play_margin_after")))

        adjustmentTimeAfterSequence = self.builder.get_object(
            "adjustmentTimeAfterSequence")
        adjustmentTimeAfterSequence.set_value(
            float(config.get("default_exercise_play_margin_before")))

        checkbuttonRepeatAfterComplete = self.builder.get_object(
            "checkbuttonRepeatAfterComplete")
        checkbuttonRepeatAfterComplete.set_active(
            config.get("default_exercise_repeat_after_completed") == 1)

        checkbuttonRandomOrder = self.builder.get_object(
            "checkbuttonRandomOrder")
        checkbuttonRandomOrder.set_active(
            config.get("default_exercise_random_order") == 1)

        #General
        checkbutton_navigation_skip_valid_sequences = self.builder.get_object(
            "checkbutton_navigation_skip_valid_sequences")
        checkbutton_navigation_skip_valid_sequences.set_active(
            config.get("navigation_skip_valid_sequences") == 1)

        checkbutton_use_speed_changer = self.builder.get_object(
            "checkbutton_use_speed_changer")
        checkbutton_use_speed_changer.set_active(
            config.get("interface_use_speed_change") == 1)

        #Interface
        checkbuttonShowPlayPauseButtons = self.builder.get_object(
            "checkbuttonShowPlayPauseButtons")
        checkbuttonShowPlayPauseButtons.set_active(
            config.get("interface_show_play_pause_buttons") == 1)

        checkbuttonShowSettings = self.builder.get_object(
            "checkbuttonShowSettings")
        checkbuttonShowSettings.set_active(
            config.get("interface_lock_settings") != 1)

        # Language
        self.liststoreLanguage = gtk.ListStore(str, str)

        languageManager = LanguagesManager()
        languagesList = languageManager.get_languages_list()

        currentLangId = config.get("default_exercise_language")

        for language in languagesList:
            iter = self.liststoreLanguage.append([language.name, language.id])
            if language.id == currentLangId:
                currentIter = iter

        comboboxLanguage = self.builder.get_object("comboboxLanguage")

        cell = gtk.CellRendererText()
        comboboxLanguage.set_model(self.liststoreLanguage)
        comboboxLanguage.pack_start(cell, True)
        comboboxLanguage.add_attribute(cell, 'text', 0)

        comboboxLanguage.set_active_iter(currentIter)
Exemplo n.º 21
0
            for mo in glob.glob(
                    os.path.join(MO_DIR, '*', 'LC_MESSAGES/perroquet.mo')):
                lang = os.path.basename(os.path.dirname(os.path.dirname(mo)))
                dest = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
                data_files.append((dest, [mo]))

        return data_files


if platform.system() == 'FreeBSD':
    man_dir = 'man'
else:
    man_dir = 'share/man'

setup(name='perroquet',
      version=config.get("version"),
      description='Perroquet, listening comprehension tutor ',
      author='Frédéric Bertolus',
      author_email='*****@*****.**',
      url='http://perroquet.niavok.com',
      license='GNU GPL v3',
      scripts=['perroquet'],
      data_files=[
          ('share/applications', ['data/perroquet.desktop']),
          ('share/mime/packages', ['data/perroquet.xml']),
          ('share/pixmaps', ['data/icons/48x48/apps/perroquet.png']),
          ('share/icons/hicolor/scalable/apps',
           glob.glob('data/icons/scalable/apps/*.svg')),
          ('share/icons/hicolor/16x16/apps',
           glob.glob('data/icons/16x16/apps/*.png')),
          ('share/icons/hicolor/22x22/apps',
Exemplo n.º 22
0
    def __init__(self):

        self.player = gst.Pipeline()
        self.playbin = gst.element_factory_make("playbin2", "player")

        # Disable the subtitle display if there is embeded subtitles
        # (for example, in mkv files)
        #
        # Flags activates some things
        # (1 << 0) : video
        # (1 << 1) : audio
        # (1 << 4) : software volume
        #
        # The default value is 0, 1, 2, 4. (1 << 2) display the subtitles
        #
        # For more details, see the doc
        # http://www.gstreamer.net/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin2.html#GstPlayFlags
        # http://www.gstreamer.net/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin2.html#GstPlayBin2--flags
        self.playbin.set_property("flags", (1 << 0) | (1 << 1) | (1 << 4))
        self.playbin.set_property("current-audio", 0)

        self.player.add(self.playbin)
        self.logger = logging.Logger("VideoPlayer")
        self.logger.setLevel(defaultLoggingLevel)
        self.logger.addHandler(defaultLoggingHandler)
        #Audio
        audiobin = gst.Bin("audio-speed-bin")
        try:
            self.audiospeedchanger = gst.element_factory_make("pitch")
            self.canChangeSpeed = True
        except gst.ElementNotFoundError:
            self.logger.warn(
                _(u"You need to install the gstreamer soundtouch elements to "
                  "use slowly play feature."))
            self.canChangeSpeed = False

        #Try to use the pitch element only if it is available
        if self.canChangeSpeed and config.get("interface_use_speed_change"):
            audiobin.add(self.audiospeedchanger)

            self.audiosink = gst.element_factory_make("autoaudiosink")

            audiobin.add(self.audiosink)
            convert = gst.element_factory_make("audioconvert")
            audiobin.add(convert)
            gst.element_link_many(self.audiospeedchanger, convert,
                                  self.audiosink)
            sink_pad = gst.GhostPad("sink",
                                    self.audiospeedchanger.get_pad("sink"))
            audiobin.add_pad(sink_pad)
            self.playbin.set_property("audio-sink", audiobin)

        bus = self.player.get_bus()
        bus.add_signal_watch()
        bus.enable_sync_message_emission()
        bus.connect("message", self.on_message)
        bus.connect("sync-message::element", self.on_sync_message)

        self.time_format = gst.Format(gst.FORMAT_TIME)
        self.timeToSeek = -1
        self.speed = 1.0
        self.nextCallbackTime = -1
Exemplo n.º 23
0
        if not self.distribution.without_gettext:
            for mo in glob.glob (os.path.join (MO_DIR, '*', 'LC_MESSAGES/perroquet.mo')):
                lang = os.path.basename(os.path.dirname(os.path.dirname(mo)))
                dest = os.path.join('share', 'locale', lang, 'LC_MESSAGES')
                data_files.append((dest, [mo]))

        return data_files


if platform.system() == 'FreeBSD':
    man_dir = 'man'
else:
    man_dir = 'share/man'

setup(name='perroquet',
      version=config.get("version"),
      description='Perroquet, listening comprehension tutor ',
      author='Frédéric Bertolus',
      author_email='*****@*****.**',
      url='http://perroquet.niavok.com',
      license='GNU GPL v3',
      scripts=['perroquet'],
      data_files=[
      ('share/applications', ['data/perroquet.desktop']),
      ('share/mime/packages', ['data/perroquet.xml']),
          
      ('share/pixmaps', ['data/icons/48x48/apps/perroquet.png']),
      ('share/icons/hicolor/scalable/apps', glob.glob('data/icons/scalable/apps/*.svg')),
      ('share/icons/hicolor/16x16/apps', glob.glob('data/icons/16x16/apps/*.png')),
      ('share/icons/hicolor/22x22/apps', glob.glob('data/icons/22x22/apps/*.png')),
      ('share/icons/hicolor/24x24/apps', glob.glob('data/icons/24x24/apps/*.png')),
Exemplo n.º 24
0
    def _get_distant_exercise_repository_list(self):
        """Build and return a list of distant and offline repositories.
        There is one repository initialized for each url found in the
        config files. If the url is reachable, a distant repository is
        initialized, else an offline repository is created.
        """
        #Get the list of files containing url list
        repositoryPathList = config.get("repository_source_list")
        repositoryList = []
        offlineRepoList = []

        #Fetch repository urls file
        for path in repositoryPathList:
            f = open(path, 'r')
            #Fetch urls of repo description
            for line in f:
                line = line.rstrip()
                if line and line[0] == "#":
                    #Comment line
                    continue
                req = urllib2.Request(line)
                try:
                    #try to download the file headers
                    handle = urllib2.urlopen(req)
                except IOError:
                    #if the download failed store the url in a list of
                    #offline urls
                    self.logger.error("Fail to connection to repository '" +
                                      line + "'")
                    offlineRepoList.append(line)
                except ValueError:
                    self.logger.exception("Unknown url type '" + line + "'")
                    offlineRepoList.append(line)
                else:
                    #if the download success, init a repository from the
                    #downloaded file and regenerate the tree
                    self.logger.debug("init distant repo")
                    repository = ExerciseRepository()
                    repository.parse_distant_repository_file(handle)
                    repository.set_url(line)
                    repositoryList.append(repository)
                    repository.generate_description()
        #if the list of url is not empty, add a list of offline repository
        if len(offlineRepoList) > 0:
            repoPathList = os.listdir(config.get("local_repo_root_dir"))
            for repoPath in repoPathList:
                #for eaach directory in the repo root path analyse the
                #description file. If the url of this repo match with one
                #of offline url, then init an offline repository from this
                #path
                repository = ExerciseRepository()
                repoDescriptionPath = os.path.join(
                    config.get("local_repo_root_dir"), repoPath,
                    "repository.xml")
                if not os.path.isfile(repoDescriptionPath):
                    continue
                f = open(repoDescriptionPath, 'r')
                dom = parse(f)
                repository.parse_description(dom)
                self.logger.debug("test offline url : " + repository.get_url())
                if repository.get_url() in offlineRepoList:
                    self.logger.info("add url : " + repository.get_url())
                    repository = ExerciseRepository()
                    repository.init_from_path(
                        os.path.join(config.get("local_repo_root_dir"),
                                     repoPath))
                    repository.set_type("offline")
                    repositoryList.append(repository)

        return repositoryList
Exemplo n.º 25
0
    def load(self):

        adjustmentTimeBetweenSequence = self.builder.get_object("adjustmentTimeBetweenSequence")
        adjustmentTimeBetweenSequence.set_value(float(config.get("default_exercise_time_between_sequences")) / 1000)

        adjustmentMaximumSequenceTime = self.builder.get_object("adjustmentMaximumSequenceTime")
        adjustmentMaximumSequenceTime.set_value(float(config.get("default_exercise_max_sequence_length")) / 1000)

        adjustmentTimeBeforeSequence = self.builder.get_object("adjustmentTimeBeforeSequence")
        adjustmentTimeBeforeSequence.set_value(float(config.get("default_exercise_play_margin_after")))

        adjustmentTimeAfterSequence = self.builder.get_object("adjustmentTimeAfterSequence")
        adjustmentTimeAfterSequence.set_value(float(config.get("default_exercise_play_margin_before")))

        checkbuttonRepeatAfterComplete = self.builder.get_object("checkbuttonRepeatAfterComplete")
        checkbuttonRepeatAfterComplete.set_active(config.get("default_exercise_repeat_after_completed") == 1)

        checkbuttonRandomOrder = self.builder.get_object("checkbuttonRandomOrder")
        checkbuttonRandomOrder.set_active(config.get("default_exercise_random_order") == 1)

        #General
        checkbutton_navigation_skip_valid_sequences = self.builder.get_object("checkbutton_navigation_skip_valid_sequences")
        checkbutton_navigation_skip_valid_sequences.set_active(config.get("navigation_skip_valid_sequences") == 1)

        checkbutton_use_speed_changer = self.builder.get_object("checkbutton_use_speed_changer")
        checkbutton_use_speed_changer.set_active(config.get("interface_use_speed_change") == 1)




        #Interface
        checkbuttonShowPlayPauseButtons = self.builder.get_object("checkbuttonShowPlayPauseButtons")
        checkbuttonShowPlayPauseButtons.set_active(config.get("interface_show_play_pause_buttons") == 1)

        checkbuttonShowSettings = self.builder.get_object("checkbuttonShowSettings")
        checkbuttonShowSettings.set_active(config.get("interface_lock_settings") != 1)


        # Language
        self.liststoreLanguage = gtk.ListStore(str, str)

        languageManager = LanguagesManager()
        languagesList = languageManager.get_languages_list()

        currentLangId = config.get("default_exercise_language")

        for language in languagesList:
            iter = self.liststoreLanguage.append([language.name, language.id])
            if language.id == currentLangId:
                currentIter = iter


        comboboxLanguage = self.builder.get_object("comboboxLanguage")

        cell = gtk.CellRendererText()
        comboboxLanguage.set_model(self.liststoreLanguage)
        comboboxLanguage.pack_start(cell, True)
        comboboxLanguage.add_attribute(cell, 'text', 0)

        comboboxLanguage.set_active_iter(currentIter)
Exemplo n.º 26
0
    def _get_distant_exercise_repository_list(self):
        """Build and return a list of distant and offline repositories.
        There is one repository initialized for each url found in the
        config files. If the url is reachable, a distant repository is
        initialized, else an offline repository is created.
        """
        #Get the list of files containing url list
        repositoryPathList = config.get("repository_source_list")
        repositoryList = []
        offlineRepoList = []

        #Fetch repository urls file
        for path in repositoryPathList:
            f = open(path, 'r')
            #Fetch urls of repo description
            for line in f:
                line = line.rstrip()
                if line and line[0] == "#":
                    #Comment line
                    continue
                req = urllib2.Request(line)
                try:
                    #try to download the file headers
                    handle = urllib2.urlopen(req)
                except IOError:
                    #if the download failed store the url in a list of
                    #offline urls
                    self.logger.error("Fail to connection to repository '" + line + "'")
                    offlineRepoList.append(line)
                except ValueError:
                    self.logger.exception("Unknown url type '" + line + "'")
                    offlineRepoList.append(line)
                else:
                    #if the download success, init a repository from the
                    #downloaded file and regenerate the tree
                    self.logger.debug("init distant repo")
                    repository = ExerciseRepository()
                    repository.parse_distant_repository_file(handle)
                    repository.set_url(line)
                    repositoryList.append(repository)
                    repository.generate_description()
        #if the list of url is not empty, add a list of offline repository
        if len(offlineRepoList) > 0:
            repoPathList = os.listdir(config.get("local_repo_root_dir"))
            for repoPath in repoPathList:
                #for eaach directory in the repo root path analyse the
                #description file. If the url of this repo match with one
                #of offline url, then init an offline repository from this
                #path
                repository = ExerciseRepository()
                repoDescriptionPath = os.path.join(config.get("local_repo_root_dir"), repoPath, "repository.xml")
                if not os.path.isfile(repoDescriptionPath):
                    continue
                f = open(repoDescriptionPath, 'r')
                dom = parse(f)
                repository.parse_description(dom)
                self.logger.debug("test offline url : " + repository.get_url())
                if repository.get_url() in offlineRepoList:
                    self.logger.info("add url : " + repository.get_url())
                    repository = ExerciseRepository()
                    repository.init_from_path(os.path.join(config.get("local_repo_root_dir"), repoPath))
                    repository.set_type("offline")
                    repositoryList.append(repository)

        return repositoryList
Exemplo n.º 27
0
# -*- coding: utf-8 -*-

# Copyright (C) 2009-2011 Frédéric Bertolus.
# Copyright (C) 2009-2011 Matthieu Bizien.
#
# This file is part of Perroquet.
#
# Perroquet is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Perroquet is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Perroquet.  If not, see <http://www.gnu.org/licenses/>.

import logging
import sys

from perroquetlib.config import config

# Build some logger related objects
defaultLoggingHandler = logging.StreamHandler(sys.stdout)
defaultLoggingHandler.setFormatter(logging.Formatter("%(asctime)s.%(msecs)d-[%(name)s::%(levelname)s] %(message)s", "%a %H:%M:%S"))
defaultLoggingLevel = logging.DEBUG
defaultLoggingLevel = logging._levelNames[config.get("default_debug_level")]