backend/common/rhnCache.py | 1
backend/satellite_tools/xmlSource.py | 55 +++++++++++++++++------------------
proxy/proxy/broker/rhnBroker.py | 2 -
3 files changed, 28 insertions(+), 30 deletions(-)
New commits:
commit bebf2a2e7c133de9b1223c834d157d12c5df2767
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed Nov 4 14:50:05 2009 +0100
499020 - bump up proxy version to 5.3.1 to enable CDN
diff --git a/proxy/proxy/broker/rhnBroker.py b/proxy/proxy/broker/rhnBroker.py
index adf8f02..1c16925 100644
--- a/proxy/proxy/broker/rhnBroker.py
+++ b/proxy/proxy/broker/rhnBroker.py
@@ -37,7 +37,7 @@ import proxy.rhnProxyAuth
# the version should not be never decreased, never mind that spacewalk has different
versioning
-_PROXY_VERSION = '5.3.0' # HISTORY: '0.9.7', '3.2.0',
'3.5.0', '3.6.0', '4.1.0', '4.2.0', '5.0.0',
'5.1.0', '5.2.0', '0.1', '5.3.0'
+_PROXY_VERSION = '5.3.1' # HISTORY: '0.9.7', '3.2.0',
'3.5.0', '3.6.0', '4.1.0', '4.2.0', '5.0.0',
'5.1.0', '5.2.0', '0.1', '5.3.0' '5.3.1'
class BrokerHandler(SharedHandler):
commit b6fd6226e56cf870ebe040038f7e648bf9b0c8de
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 3 16:17:00 2009 +0100
do not vaste time checking if string is instance of UnicodeType
isinstance is too expensive function
both normal string and UnicodeType, has function encode - just run it
if the parameter is e.g. Int, let pass down the code.
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index aab4b17..8e17d8b 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -350,9 +350,8 @@ def _stringify(data):
if isinstance(data, types.StringType):
return data
if typesHasUnicode:
- if isinstance(data, types.UnicodeType):
- # Convert Unicode data to UTF8
- return data.encode('UTF8')
+ try: return data.encode('UTF8')
+ except AttributeError: pass
return str(data)
def _dict_to_utf8(d):
@@ -362,10 +361,10 @@ def _dict_to_utf8(d):
return d
ret = {}
for k, v in d.items():
- if isinstance(k, types.UnicodeType):
- k = k.encode('UTF8')
- if isinstance(v, types.UnicodeType):
- v = v.encode('UTF8')
+ try: k = k.encode('UTF8')
+ except AttributeError: pass
+ try: v = v.encode('UTF8')
+ except AttributeError: pass
ret[k] = v
return ret
commit 582e4a70a94068252e9d43e5a7409857cbb89955
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 3 15:52:53 2009 +0100
order test according to probability that the type will appear
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index 0583493..aab4b17 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -936,20 +936,20 @@ def _normalizeAttribute(objtype, attribute):
if (objtype is None) or (objtype is types.StringType):
# (Don't know how to handle it) or (Expecting a scalar)
return attribute
-
- if not isinstance(objtype, types.ListType):
- if objtype is types.IntType:
+ elif objtype is types.IntType:
if attribute == '' or attribute == 'None':
# Treat it as NULL
return None
- return int(attribute)
- if objtype is importLib.DateType:
- return _normalizeDateType(attribute)
+ else:
+ return int(attribute)
+ elif objtype is importLib.DateType:
+ return _normalizeDateType(attribute)
+ elif isinstance(objtype, types.ListType):
+ # List type - split stuff
+ return string.split(attribute)
+ else:
raise Exception("Unhandled attribute data type %s" % objtype)
- # List type - split stuff
- return string.split(attribute)
-
def _normalizeDateType(value):
try:
value = int(value)
commit 41102051a3eb314475625c7dc92f746dfd136fb6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 3 14:23:29 2009 +0100
reverting 68bed9e28e2973d3e1e30816d9090b7f5e1d4005
that commit did not do anything usefull, it just cost us 15 seconds per channel
diff --git a/backend/common/rhnCache.py b/backend/common/rhnCache.py
index f4b31f8..8c4ad37 100644
--- a/backend/common/rhnCache.py
+++ b/backend/common/rhnCache.py
@@ -234,7 +234,6 @@ class WriteLockedFile(LockedFile):
# Set the file's mtime if necessary
self.flush()
if self.modified:
- os.system("stat %s > /dev/null" % self.fname)
os.utime(self.fname, (self.modified, self.modified))
commit e52650161c9675acded79119a133f6fa0ec6aa65
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 3 13:35:46 2009 +0100
do not ask repeatedly if types has attribute UnicodeKey
once module is imported, it will not change during runtime
we will gain at least 2 second per channel
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index 251a543..0583493 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -26,6 +26,8 @@ from common import log_debug, Traceback, rhnFlags
from server.importlib import importLib, backendLib
+typesHasUnicode = hasattr(types, "UnicodeType")
+
# Terminology used throughout this file:
# Item: an atomic entity from the database's perspective.
# A channel, or a package, or an erratum is an item.
@@ -339,7 +341,7 @@ class BaseItem:
def _is_string(obj):
if isinstance(obj, types.StringType):
return 1
- if hasattr(types, "UnicodeType") and isinstance(obj, types.UnicodeType):
+ if typesHasUnicode and isinstance(obj, types.UnicodeType):
return 1
return 0
@@ -347,7 +349,7 @@ def _stringify(data):
# Accelerate the most common cases
if isinstance(data, types.StringType):
return data
- if hasattr(types, "UnicodeType"):
+ if typesHasUnicode:
if isinstance(data, types.UnicodeType):
# Convert Unicode data to UTF8
return data.encode('UTF8')
@@ -355,7 +357,7 @@ def _stringify(data):
def _dict_to_utf8(d):
# Convert the dictionary to have non-unocide key-value pairs
- if not hasattr(types, "UnicodeType"):
+ if not typesHasUnicode:
# Nothing to do
return d
ret = {}
commit 03039711351cbb1e5227349cd785f536f3f0c85c
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Tue Nov 3 13:28:26 2009 +0100
removing unnecessary condition
this will save 3 seconds per each channel on step=rpms
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index fef07e3..251a543 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -298,10 +298,11 @@ class BaseItem:
def populateFromAttributes(self, obj, sourceDict):
# Populates dict with items from sourceDict
for key, value in sourceDict.items():
- if not obj.has_key(key) and not self.tagMap.has_key(key):
- # Unsupported key
- continue
- if self.tagMap.has_key(key):
+ if not self.tagMap.has_key(key):
+ if not obj.has_key(key):
+ # Unsupported key
+ continue
+ else:
# Have to map this key
key = self.tagMap[key]
commit bd4fae24eba89a853feef59709bd09dea45c6e11
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Mon Nov 2 17:20:44 2009 +0100
optimize code
_normalizeAttribute is called too much time (1M call for virt channel) that even
such small optimalization is worth of
diff --git a/backend/satellite_tools/xmlSource.py b/backend/satellite_tools/xmlSource.py
index 0bfbda2..fef07e3 100644
--- a/backend/satellite_tools/xmlSource.py
+++ b/backend/satellite_tools/xmlSource.py
@@ -930,14 +930,11 @@ def _normalizeSubelements(objtype, subelements):
def _normalizeAttribute(objtype, attribute):
# Deal with simple cases first
- if objtype is None:
- # Don't know how to handle it
+ if (objtype is None) or (objtype is types.StringType):
+ # (Don't know how to handle it) or (Expecting a scalar)
return attribute
if not isinstance(objtype, types.ListType):
- # Expecting a scalar
- if objtype is types.StringType:
- return attribute
if objtype is types.IntType:
if attribute == '' or attribute == 'None':
# Treat it as NULL