コード例 #1
0
ファイル: experiments.py プロジェクト: lawsofthought/quezon
    def __init__(self, configuration_file):

        self.configuration_file = configuration_file

        configfile = stimuluspath(self.configuration_file)
        sys.assert_file_exists(configfile)
        self.config = configobj.ConfigObj(configfile)

        self.parameters = self.config['parameters'].dict()

        self.start_msg = self.config['start_msg'].dict()

        self.recognition_test_parameters = self.parameters['recognition']

        self.wordlist_recognition_test_times = dict(
            isi=float(self.recognition_test_parameters['isi']),
            fadeInDuration=float(self.recognition_test_parameters['fadeInDuration']),
            fadeOutDuration=float(self.recognition_test_parameters['fadeOutDuration']),
            timeOutDuration=float(self.recognition_test_parameters['timeOutDuration'])
            )

        self.word_recall_parameters = self.parameters['recall']

        self.wordlist_parameters = self.parameters['wordlist']

        self.wordlist_display_times = dict(
            isi=float(self.wordlist_parameters['isi']),
            fadeInDuration=float(self.wordlist_parameters['fadeInDuration']),
            fadeOutDuration=float(self.wordlist_parameters['fadeOutDuration']),
            stimulusDuration=float(self.wordlist_parameters['StimulusDuration'])
            )


        self.game_parameters = dict(
            game_duration = int(self.parameters['tetris']['game_duration']),
            game_speed = int(self.parameters['tetris']['game_speed'])
        )

        _slide_types\
            = ['WordlistRecallMemoryTest',
               'WordlistRecognitionMemoryTest']

        _make_slide_functions\
            = [self._make_wordlist_recall_memory_test,
               self._make_wordlist_recognition_memory_test]

        self.max_number_of_parts\
            = int(self.parameters['maximum_number_of_parts'])

        self._make_slide_function_map\
            = dict(zip(_slide_types, _make_slide_functions))

        self.instructions\
            = [ins.strip() for ins in
               self.config['wordlist-memory-instructions'].values()]

        self.wordlists = self.config['wordlists']

        self.get_slides()
        self.parse_instructions()
コード例 #2
0
ファイル: utils.py プロジェクト: lawsofthought/wilhelmproject
    def _extracted_archive_check(self):
        ''' Does extraction_dir contain the extracted contents of the archive
        tarball?  '''

        with tarfile.open(self.tarball_path, self.tarfile_method) as tarball:
            checksum_string\
                    = tarball.extractfile(conf.tarball_checksum).read().strip()

        for line in checksum_string.split('\n'):
            relative_filepath, hashsum = line.split()
            fullpath = os.path.join(self.extraction_dir, relative_filepath)
            sys.assert_file_exists(fullpath)
            assert sys.checksum(fullpath) == hashsum

        return True # If we get this far.
コード例 #3
0
ファイル: experiments.py プロジェクト: lawsofthought/brismo
    def __init__(self, configuration_file):

        self.configuration_file = configuration_file

        configfile = stimuluspath(self.configuration_file)
        sys.assert_file_exists(configfile)
        self.config = configobj.ConfigObj(configfile)

        self.parameters = self.config['parameters'].dict()
        self.text_memoranda = self.config['text_memoranda']
        self.wordlist_memoranda = self.config['wordlist_memoranda']
        self.start_msg = self.config['start_msg'].dict()

        self.recognition_test_parameters = self.parameters['recognition']

        self.wordlist_recognition_test_times = dict(
            isi=float(self.recognition_test_parameters['isi']),
            fadeInDuration=float(self.recognition_test_parameters['fadeInDuration']),
            fadeOutDuration=float(self.recognition_test_parameters['fadeOutDuration']),
            timeOutDuration=float(self.recognition_test_parameters['timeOutDuration'])
            )

        self.word_recall_parameters = self.parameters['recall']

        self.game_parameters = dict(
            game_duration = int(self.parameters['tetris']['game_duration']),
            game_speed = int(self.parameters['tetris']['game_speed'])
        )

        _slide_types\
            = ['TextRecallMemoryTest',
               'TextRecognitionMemoryTest',
               'WordlistRecallMemoryTest',
               'WordlistRecognitionMemoryTest']

        _make_slide_functions\
            = [self._make_text_recall_memory_test,
               self._make_text_recognition_memory_test,
               self._make_wordlist_recall_memory_test,
               self._make_wordlist_recognition_memory_test]

        self.max_number_of_parts\
            = int(self.parameters['maximum_number_of_parts'])

        self._make_slide_function_map\
            = dict(zip(_slide_types, _make_slide_functions))
コード例 #4
0
ファイル: utils.py プロジェクト: lawsofthought/wilhelmproject
    def __init__(self, tarball_path):


        compression_method = conf.tarball_compression_method
        self.tarfile_method = 'r:' + compression_method

        ###############
        # Some checks #
        ###############

        compression_method_info\
        = {'bz2': ('bzip2', '.bz2'), 'gz': ('gzip', '.gz')}

        # Are we dealing with a compressed tar file?
        sys.assert_file_exists(tarball_path)
        assert tarfile.is_tarfile(tarball_path),\
                '%s is not a tarball.' % tarball_path

        compression_type, compression_ext\
                = compression_method_info[compression_method]

        assert compression_type in sh.file(tarball_path),\
                '%s is not %s?' % (tarball_path, compression_method)

        root, ext = os.path.splitext(tarball_path)
        assert ext == compression_ext,\
                '%s is not %s?' % (tarball_path, compression_method)

        #################
        # Checks passed #
        #################

        self.tarball_path = tarball_path

        # Get the name of the directory where we will extract the tarball, and
        # then zap any file or dir by that name and create an empty directory.
        root, ext = os.path.splitext(self.tarball_path) # knock of the .bz2
        root, ext = os.path.splitext(root) # knock of the .tar
        self.extraction_dir = os.path.basename(root)