예제 #1
0
파일: cache.py 프로젝트: synctext/tribler
 def load(self):
     if os.path.exists(self._file_path):
         try:
             with codecs.open(self._file_path, 'rb', encoding='utf-8') as f:
                 self._cache_list = json.load(f)
         except Exception as e:
             self._logger.error(u"Failed to load cache file %s: %s", self._file_path, repr(e))
     else:
         self._cache_list = list()
     self._initial_cache_size = len(self._cache_list)
예제 #2
0
파일: cache.py 프로젝트: ankushshr1993/EDMP
 def load(self):
     if os.path.exists(self._file_path):
         try:
             with codecs.open(self._file_path, 'rb', encoding='utf-8') as f:
                 self._cache_list = json.load(f)
         except Exception as e:
             self._logger.error(u"Failed to load cache file %s: %s",
                                self._file_path, repr(e))
     else:
         self._cache_list = list()
     self._initial_cache_size = len(self._cache_list)
예제 #3
0
파일: channel.py 프로젝트: yanheven/tribler
    def initialize(self):
        # load existing rss_feeds
        if os.path.exists(self._rss_file_path):
            self._logger.debug(u"loading existing channel rss list from %s...", self._rss_file_path)

            with codecs.open(self._rss_file_path, 'rb', encoding='utf8') as f:
                rss_list = json.load(f)
                for rss_url in rss_list:
                    self._rss_feed_dict[rss_url] = None

        if self._is_created:
            # create rss-parsers
            for rss_feed_url in self._rss_feed_dict:
                rss_parser = ChannelRssParser(self._session, self._channel_community, rss_feed_url)
                rss_parser.initialize()
                self._rss_feed_dict[rss_feed_url] = rss_parser
        else:
            # subscribe to the channel creation event
            self._session.add_observer(self._on_channel_created, SIGNAL_CHANNEL, [SIGNAL_ON_CREATED])
예제 #4
0
파일: channel.py 프로젝트: synctext/tribler
    def initialize(self):
        # load existing rss_feeds
        if os.path.exists(self._rss_file_path):
            self._logger.debug(u"loading existing channel rss list from %s...", self._rss_file_path)

            with codecs.open(self._rss_file_path, 'rb', encoding='utf8') as f:
                rss_list = json.load(f)
                for rss_url in rss_list:
                    self._rss_feed_dict[rss_url] = None

        if self._is_created:
            # create rss-parsers
            for rss_feed_url in self._rss_feed_dict:
                rss_parser = ChannelRssParser(self._session, self._channel_community, rss_feed_url)
                rss_parser.initialize()
                self._rss_feed_dict[rss_feed_url] = rss_parser
        else:
            # subscribe to the channel creation event
            self._session.add_observer(self._on_channel_created, SIGNAL_CHANNEL, [SIGNAL_ON_CREATED])