

def store_file(self, file_content, file_info):
    import weblab.data.experiments as Experiments
    should_i_store = self._cfg_manager.get_doc_value(configuration_doc.CORE_STORE_STUDENTS_PROGRAMS)
    timestamp_before = self._utc_timestamp()
    if should_i_store:
        if isinstance(file_content, unicode):
            file_content_encoded = file_content.encode('utf8')
        else:
            file_content_encoded = file_content
        deserialized_file_content = ExperimentUtil.deserialize(file_content_encoded)
        storage_path = self._cfg_manager.get_doc_value(configuration_doc.CORE_STORE_STUDENTS_PROGRAMS_PATH)
        relative_file_path = ((_get_time_in_str() + '_') + self._reservation_id)
        sha_obj = hashlib.new('sha')
        sha_obj.update(deserialized_file_content)
        file_hash = sha_obj.hexdigest()
        where = ((storage_path + '/') + relative_file_path)
        f = open(where, 'w')
        f.write(deserialized_file_content)
        f.close()
        return Experiments.FileSent(relative_file_path, ('{sha}%s' % file_hash), timestamp_before, file_info=file_info)
    else:
        return Experiments.FileSent('<file not stored>', '<file not stored>', timestamp_before, file_info=file_info)

dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/core/file_storer.py FileStorer.store_file/original