当前位置: 首页>>代码示例>>Python>>正文


Python QtNetwork.QNetworkDiskCache类代码示例

本文整理汇总了Python中PyQt4.QtNetwork.QNetworkDiskCache的典型用法代码示例。如果您正苦于以下问题:Python QNetworkDiskCache类的具体用法?Python QNetworkDiskCache怎么用?Python QNetworkDiskCache使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QNetworkDiskCache类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, directory=None, maxSize=104857600, parent=None):
        QNetworkDiskCache.__init__(self, parent=parent)

        if directory is None:
            directory = str(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))

        self.setMaximumCacheSize(maxSize)
        self.setCacheDirectory(directory)
开发者ID:rugolotti,项目名称:PyTileMap,代码行数:8,代码来源:maptilesourcehttp.py

示例2: __init__

    def __init__(self, diskCacheEnabled, parent = None):
        QNetworkAccessManager.__init__(self, parent)
        self.finished.connect(self.handleFinished)

        if diskCacheEnabled == 'yes':
            m_networkDiskCache = QNetworkDiskCache()
            m_networkDiskCache.setCacheDirectory(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))
            self.setCache(m_networkDiskCache)
开发者ID:NathanHowell,项目名称:phantomjs-waf,代码行数:8,代码来源:networkaccessmanager.py

示例3: __init__

    def __init__(self, diskCacheEnabled, ignoreSslErrors, parent=None):
        QNetworkAccessManager.__init__(self, parent)
        self.m_ignoreSslErrors = ignoreSslErrors

        if parent.m_verbose:
            self.finished.connect(self.handleFinished)

        if diskCacheEnabled == 'yes':
            m_networkDiskCache = QNetworkDiskCache()
            m_networkDiskCache.setCacheDirectory(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))
            self.setCache(m_networkDiskCache)

        do_action('NetworkAccessManagerInit', Bunch(locals()))
开发者ID:10git,项目名称:TheObserver,代码行数:13,代码来源:networkaccessmanager.py

示例4: __init__

    def __init__(self, parent=None):
        QObject.__init__(self, parent=None)
        assert QThread.currentThread() is QApplication.instance().thread()

        netmanager = self._NETMANAGER_REF and self._NETMANAGER_REF()
        if netmanager is None:
            netmanager = QNetworkAccessManager()
            cache = QNetworkDiskCache()
            cache.setCacheDirectory(
                os.path.join(settings.widget_settings_dir(),
                             __name__ + ".ImageLoader.Cache")
            )
            netmanager.setCache(cache)
            ImageLoader._NETMANAGER_REF = weakref.ref(netmanager)
        self._netmanager = netmanager
开发者ID:TimothyXie,项目名称:orange3,代码行数:15,代码来源:owimageviewer.py

示例5: __init__

    def __init__(self, diskCacheEnabled, ignoreSslErrors, parent=None):
        QNetworkAccessManager.__init__(self, parent)

        self.m_ignoreSslErrors = ignoreSslErrors
        self.m_idCounter = 0
        self.m_ids = {}
        self.m_started = []

        self.finished.connect(self.handleFinished)

        if diskCacheEnabled:
            m_networkDiskCache = QNetworkDiskCache()
            m_networkDiskCache.setCacheDirectory(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))
            self.setCache(m_networkDiskCache)

        do_action('NetworkAccessManagerInit')
开发者ID:antlong,项目名称:jellypy,代码行数:16,代码来源:networkaccessmanager.py

示例6: __init__

    def __init__(self, user_agent=default_user_agent, wait_timeout=8,
            wait_callback=None, log_level=logging.WARNING, display=False,
            viewport_size=(800, 600), cache_dir='/tmp/ghost.py'):
        self.http_resources = []

        self.user_agent = user_agent
        self.wait_timeout = wait_timeout
        self.wait_callback = wait_callback

        self.loaded = True

        if not sys.platform.startswith('win') and not 'DISPLAY' in os.environ\
                and not hasattr(Ghost, 'xvfb'):
            try:
                os.environ['DISPLAY'] = ':99'
                Ghost.xvfb = subprocess.Popen(['Xvfb', ':99'])
            except OSError:
                raise Exception('Xvfb is required to a ghost run oustside ' +\
                    'an X instance')

        self.display = display

        if not Ghost._app:
            Ghost._app = QApplication.instance() or QApplication(['ghost'])

        self.page = GhostWebPage(Ghost._app)
        QtWebKit.QWebSettings.setMaximumPagesInCache(0)
        QtWebKit.QWebSettings.setObjectCacheCapacities(0, 0, 0)

        self.set_viewport_size(*viewport_size)

        self.page.loadFinished.connect(self._page_loaded)
        self.page.loadStarted.connect(self._page_load_started)

        self.manager = self.page.networkAccessManager()
        self.manager.finished.connect(self._request_ended)
        # Cache
        self.cache = QNetworkDiskCache()
        self.cache.setCacheDirectory(cache_dir)
        self.manager.setCache(self.cache)
        # Cookie jar
        self.cookie_jar = QNetworkCookieJar()
        self.manager.setCookieJar(self.cookie_jar)
        # User Agent
        self.page.setUserAgent(self.user_agent)

        self.page.networkAccessManager().authenticationRequired\
            .connect(self._authenticate)
        self.page.networkAccessManager().proxyAuthenticationRequired\
            .connect(self._authenticate)

        self.main_frame = self.page.mainFrame()

        logger.setLevel(log_level)

        if self.display:
            self.webview = QtWebKit.QWebView()
            self.webview.setPage(self.page)
            self.webview.show()
开发者ID:moon2l,项目名称:Ghost.py,代码行数:59,代码来源:ghost.py

示例7: construct

def construct(path=defaults.CACHE_PATH, size=defaults.CACHE_SIZE):
    log.msg("Initializing cache on %s (maxsize: %d Mb)" % (path, size))
    cache = QNetworkDiskCache()
    cache.setCacheDirectory(path)
    cache.setMaximumCacheSize(size * 1024**2)
    cache.cacheSize()  # forces immediate initialization
    return cache
开发者ID:0xmilk,项目名称:splash,代码行数:7,代码来源:cache.py

示例8: __init__

 def __init__(self, *args, **kwargs):
     cache_dir = kwargs.pop("cache_dir", "/tmp/ghost.py")
     cache_size = kwargs.pop("cache_size", 0)
     self._prevent_download = kwargs.pop("prevent_download", [])
     
     super(NetworkAccessManager, self).__init__(*args, **kwargs)
     if cache_size > 0:
         cache = QNetworkDiskCache()
         cache.setCacheDirectory(cache_dir)
         cache.setMaximumCacheSize(cache_size * 1024 * 1024)
         self.setCache(cache)
     
     # Manages the authentication for the proxy
     self.proxyAuthenticationRequired.connect(self._authenticateProxy)
     self.authenticationRequired.connect(self._authenticate)
     
     # Handles redirects
     self.finished.connect(self._replyFinished)
开发者ID:handloomweaver,项目名称:Ghost.py,代码行数:18,代码来源:NetworkAccessManager.py

示例9: __init__

 def __init__(self, proxy, forbidden_extensions, allowed_regex, cache_size=100, cache_dir='.webkit_cache'):
     """
     See WebkitBrowser for details of arguments
 
     cache_size:
         the maximum size of the webkit cache (MB)
     """
     QNetworkAccessManager.__init__(self)
     # and proxy
     self.setProxy(proxy)
     # initialize the manager cache
     QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
     cache = QNetworkDiskCache()
     cache.setCacheDirectory(cache_dir)
     cache.setMaximumCacheSize(cache_size * 1024 * 1024) # need to convert cache value to bytes
     self.setCache(cache)
     self.allowed_regex = allowed_regex
     self.forbidden_extensions = forbidden_extensions
开发者ID:Hack42,项目名称:BusNotifier,代码行数:18,代码来源:webkit.py

示例10: __init__

 def __init__(self, proxy, allowed_media, allowed_regex, cache_size=100, cache_dir='.webkit_cache'):
     """
     See JQueryBrowser for details of arguments
     cache_size is the maximum size of the webkit cache (MB)
     """
     QNetworkAccessManager.__init__(self)
     # initialize the manager cache
     #QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
     cache = QNetworkDiskCache()
     cache.setCacheDirectory(cache_dir)
     cache.setMaximumCacheSize(cache_size * 1024 * 1024) # need to convert cache value to bytes
     self.setCache(cache)
     self.allowed_regex = allowed_regex
     # allowed content extensions
     self.banned_extensions = common.MEDIA_EXTENSIONS
     for ext in allowed_media:
         if ext in self.banned_extensions:
             self.banned_extensions.remove(ext)
     # and proxy
     self.setProxy(proxy)
开发者ID:gotomypc,项目名称:webscraping,代码行数:20,代码来源:webkit.py

示例11: __init__

 def __init__(self, proxy, allowed_extensions, cache_size=100, cache_dir='.webkit_cache'):
     """
     proxy is a QNetworkProxy
     allowed_extensions is a list of extensions to allow
     cache_size is the maximum size of the cache (MB)
     """
     QNetworkAccessManager.__init__(self)
     # initialize the manager cache
     cache = QNetworkDiskCache()
     #QDesktopServices.storageLocation(QDesktopServices.CacheLocation)
     cache.setCacheDirectory(cache_dir)
     cache.setMaximumCacheSize(cache_size * 1024 * 1024) # need to convert cache value to bytes
     self.setCache(cache)
     # allowed content extensions
     self.banned_extensions = common.MEDIA_EXTENSIONS
     for ext in allowed_extensions:
         if ext in self.banned_extensions:
             self.banned_extensions.remove(ext)
     # and proxy
     if proxy:
         self.setProxy(proxy)
开发者ID:gerrich,项目名称:qtbot,代码行数:21,代码来源:qt_framework.py

示例12: prepare

 def prepare(self, metaData):
     """
     Public method to prepare the disk cache file.
     
     @param metaData meta data for a URL (QNetworkCacheMetaData)
     @return reference to the IO device (QIODevice)
     """
     if QWebSettings.globalSettings().testAttribute(
             QWebSettings.PrivateBrowsingEnabled):
         return None
     
     return QNetworkDiskCache.prepare(self, metaData)
开发者ID:usc-bbdl,项目名称:R01_HSC_cadaver_system,代码行数:12,代码来源:NetworkDiskCache.py

示例13: _fetch_inventory

    def _fetch_inventory(self, url):
        cache_dir = config.cache_dir()
        cache_dir = os.path.join(cache_dir, "help", type(self).__qualname__)

        try:
            os.makedirs(cache_dir)
        except OSError:
            pass

        url = QUrl(self.inventory)
        if not url.isLocalFile():
            # fetch and cache the inventory file.
            manager = QNetworkAccessManager(self)
            cache = QNetworkDiskCache()
            cache.setCacheDirectory(cache_dir)
            manager.setCache(cache)
            req = QNetworkRequest(url)

            self._reply = manager.get(req)
            manager.finished.connect(self._on_finished)
        else:
            self._load_inventory(open(str(url.toLocalFile()), "rb"))
开发者ID:Coding4Sec,项目名称:orange3,代码行数:22,代码来源:provider.py

示例14: _fetch_inventory

    def _fetch_inventory(self):
        cache_dir = config.cache_dir()
        cache_dir = os.path.join(cache_dir, "help", "intersphinx")

        try:
            os.makedirs(cache_dir)
        except OSError:
            pass

        url = QUrl(self.inventory)

        if not self.islocal:
            # fetch and cache the inventory file
            manager = QNetworkAccessManager(self)
            cache = QNetworkDiskCache()
            cache.setCacheDirectory(cache_dir)
            manager.setCache(cache)
            req = QNetworkRequest(url)

            self._reply = manager.get(req)
            manager.finished.connect(self._on_finished)
        else:
            self._load_inventory(open(unicode(url.toLocalFile()), "rb"))
开发者ID:pauloortins,项目名称:Computer-Vision-Classes---UFBA,代码行数:23,代码来源:provider.py

示例15: __init__

    def __init__(self, parent, args):
        super(NetworkAccessManager, self).__init__(parent)

        self.m_userName = self.m_password = ''
        self.m_ignoreSslErrors = args.ignore_ssl_errors
        self.m_idCounter = 0
        self.m_ids = {}
        self.m_started = []

        if args.cookies_file:
            self.setCookieJar(CookieJar(self, args.cookies_file))

        if args.disk_cache:
            m_networkDiskCache = QNetworkDiskCache()
            m_networkDiskCache.setCacheDirectory(QDesktopServices.storageLocation(QDesktopServices.CacheLocation))
            if args.max_disk_cache_size > 0:
                m_networkDiskCache.setMaximumCacheSize(args.max_disk_cache_size * 1024)
            self.setCache(m_networkDiskCache)

        self.authenticationRequired.connect(self.provideAuthentication)
        self.finished.connect(self.handleFinished)

        do_action('NetworkAccessManagerInit')
开发者ID:Wolfcrush,项目名称:ios-uiautomation,代码行数:23,代码来源:networkaccessmanager.py


注:本文中的PyQt4.QtNetwork.QNetworkDiskCache类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。