本文整理汇总了Python中spacewalk.common.rhnCache.set函数的典型用法代码示例。如果您正苦于以下问题:Python set函数的具体用法?Python set怎么用?Python set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_opening_raw_data_as_pickled
def test_opening_raw_data_as_pickled(self):
"Should return None, opening uncompressed data as compressed"
rhnCache.set(self.key, "12345", raw=1)
self.assertEqual(None, rhnCache.get(self.key, raw=0))
self._cleanup(self.key)
开发者ID:m47ik,项目名称:uyuni,代码行数:7,代码来源:test_rhnCache.py
示例2: _cache_channel_packages_short
def _cache_channel_packages_short(self, channel_id, key, last_modified):
""" Caches the short package entries for channel_id """
# Create a temporary file
temp_stream = tempfile.TemporaryFile()
# Always compress the result
compress_level = 5
stream = gzip.GzipFile(None, "wb", compress_level, temp_stream)
writer = xmlWriter.XMLWriter(stream=stream)
# Fetch packages
h = rhnSQL.prepare(self._query_get_channel_packages)
h.execute(channel_id=channel_id)
package_ids = h.fetchall_dict() or []
# Sort packages
package_ids.sort(lambda a, b: cmp(a['package_id'], b['package_id']))
dumper = SatelliteDumper(writer,
ShortPackagesDumper(writer, package_ids))
dumper.dump()
writer.flush()
# We're done with the stream object
stream.close()
del stream
temp_stream.seek(0, 0)
# Set the value in the cache. We don't recompress the result since
# it's already compressed
rhnCache.set(key, temp_stream.read(), modified=last_modified,
compressed=0, raw=1)
return self._normalize_compressed_stream(temp_stream)
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:29,代码来源:dumper.py
示例3: test_opening_uncompressed_data_as_compressed
def test_opening_uncompressed_data_as_compressed(self):
"Should return None, opening uncompressed data as compressed"
rhnCache.set(self.key, self.content, raw=1)
self.assertEqual(None, rhnCache.get(self.key, compressed=1, raw=1))
self._cleanup(self.key)
开发者ID:m47ik,项目名称:uyuni,代码行数:7,代码来源:test_rhnCache.py
示例4: test_cache_5
def test_cache_5(self):
content = self.content * 10
timestamp = '20041110001122'
self._cleanup(self.key)
rhnCache.set(self.key, content, modified=timestamp)
self.failUnless(rhnCache.has_key(self.key))
self.failUnless(rhnCache.has_key(self.key, modified=timestamp))
self.failIf(rhnCache.has_key(self.key, modified='20001122112233'))
self._cleanup(self.key)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:11,代码来源:test_rhnCache.py
示例5: _test
def _test(self, key, content, **modifiers):
# Blow it away
rhnCache.CACHEDIR = '/tmp/rhn'
self._cleanup(key)
rhnCache.set(key, content, **modifiers)
self.failUnless(rhnCache.has_key(key))
content2 = rhnCache.get(key, **modifiers)
self.assertEqual(content, content2)
self._cleanup(key)
self.failIf(rhnCache.has_key(key))
return (key, content)
开发者ID:m47ik,项目名称:uyuni,代码行数:12,代码来源:test_rhnCache.py
示例6: no_test_as_streams_1
def no_test_as_streams_1(self):
"Tests storing and retrieval as streams"
t = tempfile.TemporaryFile()
content = self.content * 100
t.write(content)
t.seek(0, 0)
self._cleanup(self.key)
rhnCache.set(self.key, None, raw=1, stream=t)
self.failUnless(rhnCache.has_key(self.key))
ss = rhnCache.get(self.key, as_stream=1)
self.failUnless(hasattr(ss, "read"))
content2 = ss.read()
self.assertEquals(content, content2)
self._cleanup(self.key)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:17,代码来源:test_rhnCache.py
示例7: cache_set
def cache_set(self, params, value):
log_debug(4, params)
last_modified = self._get_last_modified(params)
key = self._get_key(params)
if not self.use_database_cache:
set_cache = rhnCache.set(key, value, modified=last_modified, \
raw=1, user='apache', group='apache', mode=0755)
return set_cache
return rhnDatabaseCache.set(key, value, modified=last_modified, raw=1,
compressed=1)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:10,代码来源:dumper.py
示例8: cache_set
def cache_set(self, params, value):
log_debug(4, params)
last_modified = self._get_last_modified(params)
key = self._get_key(params)
user = 'apache'
group = 'apache'
if rhnLib.isSUSE():
user = 'wwwrun'
group = 'www'
return rhnCache.set(key, value, modified=last_modified,
raw=1, user=user, group=group, mode=int('0755', 8))
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:11,代码来源:dumper.py
示例9: _getHeaderFromFile
def _getHeaderFromFile(self, filePath, stat_info=None):
""" Wraps around common.rhnRepository's method, adding a caching layer
If stat_info was already passed, don't re-stat the file
"""
log_debug(3, filePath)
if not CFG.CACHE_PACKAGE_HEADERS:
return rhnRepository.Repository._getHeaderFromFile(self, filePath,
stat_info=stat_info)
# Ignore stat_info for now - nobody sets it anyway
stat_info = None
try:
stat_info = os.stat(filePath)
except:
raise rhnFault(17, "Unable to read package %s"
% os.path.basename(filePath)), None, sys.exc_info()[2]
lastModified = stat_info[stat.ST_MTIME]
# OK, file exists, check the cache
cache_key = os.path.normpath("headers/" + filePath)
header = rhnCache.get(cache_key, modified=lastModified, raw=1,
compressed=1)
if header:
# We're good to go
log_debug(2, "Header cache HIT for %s" % filePath)
extra_headers = {
'X-RHN-Package-Header': os.path.basename(filePath),
}
self._set_last_modified(lastModified, extra_headers=extra_headers)
return header
log_debug(3, "Header cache MISS for %s" % filePath)
header = rhnRepository.Repository._getHeaderFromFile(self, filePath,
stat_info=stat_info)
if header:
rhnCache.set(cache_key, header, modified=lastModified, raw=1,
compressed=1)
return header
开发者ID:TJM,项目名称:spacewalk,代码行数:36,代码来源:rhnRepository.py
示例10: except
# XXX For about 40M of compressed data sometimes we get:
# zlib.error: Error -3 while decompressing: incomplete dynamic bit lengths tree
v = gzip.GzipFile(None, "r", 0, io)
try:
data = v.read()
except (ValueError, IOError, gzip.zlib.error), e:
# XXX poking at gzip.zlib may not be that well-advised
log_error("rhnDatabaseCache: gzip error for key %s: %s" % (
name, e))
# Ignore this entry in the database cache, it has invalid data
return None
# We store the data in the database cache, in raw format
rhnCache.set(name, data, modified=modified, raw=1)
# Unpickle the data, unless raw access was requested
if not raw:
return cPickle.loads(data)
return data
def delete(name):
# Uses the stored procedure. Quite simple
rhnSQL.Procedure("rhn_cache_delete")(name)
# Delete it from the disk cache too, just in case
rhnCache.delete(name)
# We only set the database cache value
开发者ID:m47ik,项目名称:uyuni,代码行数:30,代码来源:rhnDatabaseCache.py
示例11: poll_packages
def poll_packages(self, release, server_arch, timestamp = 0, uuid = None):
log_debug(1, release, server_arch, timestamp, uuid)
# make sure we're dealing with strings here
release = str(release)
server_arch = rhnLib.normalize_server_arch(server_arch)
timestamp = str(timestamp)
uuid = str(uuid)
# get a list of acceptable channels
channel_list = []
channel_list = rhnChannel.applet_channels_for_uuid(uuid)
# it's possible the tie between uuid and rhnServer.id wasn't yet
# made, default to normal behavior
if not channel_list:
channel_list = rhnChannel.get_channel_for_release_arch(release,
server_arch)
channel_list = [channel_list]
# bork if no channels returned
if not channel_list:
log_debug(8, "No channels for release = '%s', arch = '%s', uuid = '%s'" % (
release, server_arch, uuid))
return { 'last_modified' : 0, 'contents' : [] }
last_channel_changed_ts = max(map(lambda a: a["last_modified"], channel_list))
# make satellite content override a cache caused by hosted
last_channel_changed_ts = str(long(last_channel_changed_ts) + 1)
# gotta be careful about channel unsubscriptions...
client_cache_invalidated = None
# we return rhnServer.channels_changed for each row
# in the satellite case, pluck it off the first...
if channel_list[0].has_key("server_channels_changed"):
sc_ts = channel_list[0]["server_channels_changed"]
if sc_ts and (sc_ts >= last_channel_changed_ts):
client_cache_invalidated = 1
if (last_channel_changed_ts <= timestamp) and (not client_cache_invalidated):
# XXX: I hate these freaking return codes that return
# different members in the dictinary depending on what
# sort of data you get
log_debug(3, "Client has current data")
return { 'use_cached_copy' : 1 }
# we'll have to return something big - compress
rhnFlags.set("compress_response", 1)
# Mark the response as being already XMLRPC-encoded
rhnFlags.set("XMLRPC-Encoded-Response", 1)
# next, check the cache if we have something with this timestamp
label_list = map(lambda a: str(a["id"]), channel_list)
label_list.sort()
log_debug(4, "label_list", label_list)
cache_key = "applet-poll-%s" % string.join(label_list, "-")
ret = rhnCache.get(cache_key, last_channel_changed_ts)
if ret: # we have a good entry with matching timestamp
log_debug(3, "Cache HIT for", cache_key)
return ret
# damn, need to do some real work from chip's requirements:
# The package list should be an array of hashes with the keys
# nvre, name, version, release, epoch, errata_advisory,
# errata_id, with the errata fields being empty strings if the
# package isn't from an errata.
ret = { 'last_modified' : last_channel_changed_ts, 'contents' : [] }
# we search for packages only in the allowed channels - build
# the SQL helper string and dictionary to make the foo IN (
# list ) constructs use bind variables
qlist = []
qdict = {}
for c in channel_list:
v = c["id"]
k = "channel_%s" % v
qlist.append(":%s" % k)
qdict[k] = v
qlist = string.join(qlist, ", ")
# This query is kind of big. One of these days I'm gonna start
# pulling them out and transforming them into views. We can
# also simulate this using several functions exposed out of
# rhnChannel, but there is no difference in speed because we
# need to do more than one query; besides, we cache the hell
# out of it
h = rhnSQL.prepare("""
select distinct
pn.name,
pe.version,
pe.release,
pe.epoch,
e_sq.errata_advisory,
e_sq.errata_synopsis,
#.........这里部分代码省略.........
开发者ID:cliffy94,项目名称:spacewalk,代码行数:101,代码来源:applet.py
示例12: cache_set
def cache_set(self, object_id, value, timestamp=None):
# Get the key
key = self._get_key(object_id)
return rhnCache.set(key, value, modified=timestamp, raw=0,
compressed=self._compressed)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:5,代码来源:syncCache.py
示例13: __setitem__
def __setitem__(self, key, val):
rkey = self._compute_key(key)
return rhnCache.set(rkey, val)
开发者ID:phurrelmann,项目名称:spacewalk,代码行数:3,代码来源:rhnProxyAuth.py
示例14: Copyright
#
# Copyright (c) 2008--2010 Red Hat, Inc.
#
# This software is licensed to you under the GNU General Public License,
# version 2 (GPLv2). There is NO WARRANTY for this software, express or
# implied, including the implied warranties of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
# along with this software; if not, see
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
#
# Red Hat trademarks are not licensed under GPLv2. No permission is
# granted to use or replicate Red Hat trademarks that are incorporated
# in this software or its documentation.
#
from spacewalk.common import rhnCache
key = "/var/goo/goo"
data = "0123456789" * 1024 * 1024
rhnCache.set(key, data, compressed=1, raw=1)
assert data == rhnCache.get(key, compressed=1, raw=1)
rhnCache.set(key, "12345", raw=1)
# Should return None, opening uncompressed data as compressed
assert None == rhnCache.get(key, compressed=1, raw=1)
# Should return None, opening raw data as pickled
assert None == rhnCache.get(key, raw=0)
开发者ID:bjmingyang,项目名称:spacewalk,代码行数:29,代码来源:test_cache.py
示例15: cache_set
def cache_set(self, params, value):
log_debug(4, params)
last_modified = self._get_last_modified(params)
key = self._get_key(params)
return rhnCache.set(key, value, modified=last_modified, raw=1, user="apache", group="apache", mode=0755)
开发者ID:kidaa30,项目名称:spacewalk,代码行数:5,代码来源:dumper.py
注:本文中的spacewalk.common.rhnCache.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论