Пример #1
0
    def _do_process_on_modified_event(self, event):
        do_process_on_modified_event = False

        if os.path.normpath(event.src_path) == os.path.normpath(
                self._file_path):
            if not self._last_file_version_md5_checksum:
                do_process_on_modified_event = True

                self._last_file_version_md5_checksum = hashlib.md5(
                    Utility.read_file(self._file_path,
                                      in_binary=True)).hexdigest()
            else:
                configuration_md5_checksum = hashlib.md5(
                    Utility.read_file(self._file_path,
                                      in_binary=True)).hexdigest()
                if configuration_md5_checksum != self._last_file_version_md5_checksum:
                    do_process_on_modified_event = True

                    self._last_file_version_md5_checksum = configuration_md5_checksum

        return do_process_on_modified_event
Пример #2
0
    def on_created(self, event):
        with self._lock:
            if os.path.normpath(event.src_path) == os.path.normpath(
                    self._file_path):
                self._last_file_version_md5_checksum = hashlib.md5(
                    Utility.read_file(self._file_path,
                                      in_binary=True)).hexdigest()

                logger.debug(
                    'Detected creation of logging configuration file\n'
                    'Logging configuration file path => {0}'.format(
                        self._file_path))

                Logging.set_logging_configuration()
Пример #3
0
    def load_ts_file(cls, path, recording_id):
        db_session = Database.create_session()

        try:
            segment_name = re.sub(r'/vod/(.*)\?.*', r'\1', path)

            segment_row = DatabaseAccess.query_segment_directory_path(
                db_session, segment_name, recording_id)

            if segment_row is not None:
                return Utility.read_file(os.path.join(
                    segment_row.directory_path, segment_name),
                                         in_binary=True)
            else:
                raise SegmentNotFoundError
        finally:
            db_session.close()
Пример #4
0
    def read_optional_settings_file(cls):
        with cls._lock.writer_lock:
            cls._backup_optional_settings()

            try:
                optional_settings_file_content = Utility.read_file(
                    cls._optional_settings_file_path)
                cls._set_optional_settings(
                    json.loads(optional_settings_file_content,
                               object_pairs_hook=OrderedDict))
            except OSError:
                logger.error('Failed to read optional settings file\n'
                             'Optional settings file path => {0}'.format(
                                 cls._optional_settings_file_path))
            except JSONDecodeError:
                logger.error('Invalid optional settings file syntax\n'
                             'Optional settings file path => {0}'.format(
                                 cls._optional_settings_file_path))