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


Python QNetworkDiskCache.setMaximumCacheSize方法代码示例

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


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

示例1: construct

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
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,代码行数:9,代码来源:cache.py

示例2: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
 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,代码行数:20,代码来源:NetworkAccessManager.py

示例3: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
 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,代码行数:20,代码来源:webkit.py

示例4: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
 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,代码行数:22,代码来源:webkit.py

示例5: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
 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,代码行数:23,代码来源:qt_framework.py

示例6: __init__

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
    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,代码行数:25,代码来源:networkaccessmanager.py

示例7: initOutputDir

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
  plugins_dir = os.path.dirname(plugin_dir)

  # python path setting
  sys.path.append(plugins_dir)

  # initialize output directory
  initOutputDir()

  plugin_name = os.path.basename(plugin_dir)
  suite = unittest.TestLoader().discover(plugin_name + ".tests")
  unittest.TextTestRunner(verbosity=2).run(suite)


if __name__ == "__main__":
  gui_mode = True
  QGISAPP = QgsApplication(sys.argv, gui_mode)
  QGISAPP.initQgis()
  print "=" * 70
  print QGISAPP.showSettings()
  print "=" * 70

  # set up network disk cache
  manager = QgsNetworkAccessManager.instance()
  cache = QNetworkDiskCache(manager)
  cache.setCacheDirectory(pluginPath(os.path.join("tests", "cache")))
  cache.setMaximumCacheSize(50 * 1024 * 1024)
  manager.setCache(cache)

  # run test!
  runTest()
开发者ID:biapar,项目名称:Qgis2threejs,代码行数:32,代码来源:run_test.py

示例8: construct

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
def construct(path=defaults.CACHE_PATH, size=defaults.CACHE_SIZE):
    cache = QNetworkDiskCache()
    cache.setCacheDirectory(path)
    cache.setMaximumCacheSize(size * 1024**2)
    return cache
开发者ID:redapple,项目名称:splash,代码行数:7,代码来源:cache.py

示例9: setCache

# 需要导入模块: from PyQt4.QtNetwork import QNetworkDiskCache [as 别名]
# 或者: from PyQt4.QtNetwork.QNetworkDiskCache import setMaximumCacheSize [as 别名]
 def setCache(self, cacheDir, cacheSize):
     cache = QNetworkDiskCache()
     cache.setCacheDirectory(cacheDir)
     cache.setMaximumCacheSize(cacheSize * 1024 * 1024)
     self.page().networkAccessManager().setCache(cache)
开发者ID:kumaran-5555,项目名称:Webscrapping,代码行数:7,代码来源:webkitBrowser.py


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