本文整理汇总了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
示例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)
示例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
示例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)
示例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)
示例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')
示例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()
示例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
示例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)