client/tools/rhnpush/connection.py | 15 ++++++++-------
client/tools/rhnpush/rhnpush.py | 25 +++++++++++++------------
client/tools/rhnpush/uploadLib.py | 9 +++++----
3 files changed, 26 insertions(+), 23 deletions(-)
New commits:
commit b4800a7674651192fcc841f4d8c587c08d053f20
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Jan 7 16:19:53 2010 +0100
fixed typo
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 1e854ed..a9c1f4c 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -392,7 +392,7 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory
available" % pkg)
continue
- checksum = getFileChecksum(checksum_type, file=payload_stream))
+ checksum = getFileChecksum(checksum_type, file=payload_stream)
f.close()
for t in range(0, tries):
commit c6ddffca512a38ad0fd7c6bc06b842c02038d967
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Jan 7 16:17:53 2010 +0100
updated copyrights
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index d1c689b..939dce1 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008 Red Hat, Inc.
+# 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
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 29c357a..1e854ed 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008 Red Hat, Inc.
+# 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
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index fe0e5ed..a82a5d2 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2008 Red Hat, Inc.
+# 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
commit 58695ee76fe14914139ed5a7d6fb092b73bfe6d2
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Thu Jan 7 16:08:44 2010 +0100
unified checksum meaning in rhnpush code
checksum sometimes means checksum string only and sometimes tuple (type, string)
to avoid confusion this commit changed all tuples into two separate variables
diff --git a/client/tools/rhnpush/connection.py b/client/tools/rhnpush/connection.py
index 4216ee3..d1c689b 100644
--- a/client/tools/rhnpush/connection.py
+++ b/client/tools/rhnpush/connection.py
@@ -169,7 +169,7 @@ class PackageUpload:
return self._response
- def upload(self, file, FileChecksum):
+ def upload(self, file, FileChecksumType, FileChecksum):
"""
Uploads a file.
Returns (http_error_code, error_message)
@@ -210,6 +210,7 @@ class PackageUpload:
self.nvra = nvra
# use the precomputed passed checksum
+ self.checksum_type = FileChecksumType
self.checksum = FileChecksum
# Set headers
@@ -222,11 +223,11 @@ class PackageUpload:
self.set_header("%s-%s" % (prefix, "Package-Release"),
nvra[2])
self.set_header("%s-%s" % (prefix, "Package-Arch"), nvra[3])
self.set_header("%s-%s" % (prefix, "Packaging"),
self.packaging)
- if self.checksum[0] == 'md5':
- self.set_header("%s-%s" % (prefix, "File-MD5sum"),
self.checksum[1])
+ if self.checksum_type == 'md5':
+ self.set_header("%s-%s" % (prefix, "File-MD5sum"),
self.checksum)
else:
- self.set_header("%s-%s" % (prefix, "File-Checksum-Type"),
self.checksum[0])
- self.set_header("%s-%s" % (prefix, "File-Checksum"),
self.checksum[1])
+ self.set_header("%s-%s" % (prefix, "File-Checksum-Type"),
self.checksum_type)
+ self.set_header("%s-%s" % (prefix, "File-Checksum"),
self.checksum)
self._response = self.send_http('POST', stream_body=f)
f.close()
@@ -246,7 +247,7 @@ class PackageUpload:
if status == 201:
# Created
return (status, "%s %s: %s-%s-%s.%s.rpm already uploaded" % (
- self.checksum[0], self.checksum[1],
+ self.checksum_type, self.checksum,
self.nvra[0], self.nvra[1], self.nvra[2], self.nvra[3]))
if status in (404, 409):
# Conflict
diff --git a/client/tools/rhnpush/rhnpush.py b/client/tools/rhnpush/rhnpush.py
index 13c24b9..29c357a 100755
--- a/client/tools/rhnpush/rhnpush.py
+++ b/client/tools/rhnpush/rhnpush.py
@@ -45,7 +45,7 @@ except ImportError:
from optik import Option, OptionParser
from rhn import rpclib
from spacewalk.common import rhn_mpm
-from spacewalk.common import checksum
+from spacewalk.common.checksum import getFileChecksum
import uploadLib
import rhnpush_v2
@@ -392,13 +392,12 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory
available" % pkg)
continue
- digest = (checksum_type,
- checksum.getFileChecksum(checksum_type, file=payload_stream))
+ checksum = getFileChecksum(checksum_type, file=payload_stream))
f.close()
for t in range(0, tries):
try:
- ret = self.package(pkg, digest)
+ ret = self.package(pkg, checksum_type, checksum)
if ret is None:
raise UploadError()
@@ -499,8 +498,8 @@ class UploadClass(uploadLib.UploadClass):
self.warn(2, "ERROR: %s: No such file or directory available" %
pkg)
continue
- digest_hash[pkg_key] = (checksum_type,
- checksum.getFileChecksum(checksum_type, file=payload_stream))
+ checksum = getFileChecksum(checksum_type, file=payload_stream)
+ digest_hash[pkg_key] = (checksum_type, checksum)
f.close()
for tag in ('name', 'version', 'release',
'epoch', 'arch'):
@@ -517,7 +516,8 @@ class UploadClass(uploadLib.UploadClass):
pkg_info['arch'] = 'nosrc'
else:
pkg_info['arch'] = 'src'
- pkg_info['checksum'] = digest_hash[pkg_key]
+ pkg_info['checksum_type'] = checksum_type
+ pkg_info['checksum'] = checksum
pkg_hash[pkg_key] = pkg_info
if self.options.nullorg:
@@ -553,7 +553,7 @@ class UploadClass(uploadLib.UploadClass):
return (checksum_data, pkg_hash, digest_hash)
- def package(self, package, FileChecksum):
+ def package(self, package, FileChecksumType, FileChecksum):
self.warn(1, "Uploading package %s" % package)
if not os.access(package, os.R_OK):
self.die(-1, "Could not read file %s" % package)
@@ -576,7 +576,7 @@ class UploadClass(uploadLib.UploadClass):
try:
if self.ping_status == 200:
- ret = self._push_package_v2(package, FileChecksum)
+ ret = self._push_package_v2(package, FileChecksumType, FileChecksum)
else:
ret = self._push_package_xmlrpc(package, h, packaging)
except UploadError, e:
@@ -606,7 +606,7 @@ class UploadClass(uploadLib.UploadClass):
return ret
- def _push_package_v2(self, package, FileChecksum):
+ def _push_package_v2(self, package, FileChecksumType, FileChecksum):
self.warn(1, "Using POST request")
pu = rhnpush_v2.PackageUpload(self.url_v2)
@@ -617,7 +617,7 @@ class UploadClass(uploadLib.UploadClass):
pu.set_force(self.options.force)
pu.set_null_org(self.options.nullorg)
- status, msgstr = pu.upload(package, FileChecksum)
+ status, msgstr = pu.upload(package, FileChecksumType, FileChecksum)
ret = {}
for tag in ('name', 'version', 'release',
'epoch', 'arch'):
@@ -626,6 +626,7 @@ class UploadClass(uploadLib.UploadClass):
val = ''
ret[tag] = val
+ ret['checksum_type'] = FileChecksumType
ret['checksum'] = FileChecksum
if status == 400:
# Bad request - something bad happened
diff --git a/client/tools/rhnpush/uploadLib.py b/client/tools/rhnpush/uploadLib.py
index 0fa466f..fe0e5ed 100644
--- a/client/tools/rhnpush/uploadLib.py
+++ b/client/tools/rhnpush/uploadLib.py
@@ -506,8 +506,8 @@ def _processFile(filename, relativeDir=None, source=None,
nosig=None):
# Rewind the file
f.seek(0, 0)
# Compute digest
- digest = (h.checksum_type(),
- checksum.getFileChecksum(h.checksum_type(), file=f))
+ checksum_type = h.checksum_type()
+ checksum = checksum.getFileChecksum(checksum_type, file=f)
f.close()
if h is None:
raise UploadError("%s is not a valid RPM file" % filename)
@@ -533,7 +533,8 @@ def _processFile(filename, relativeDir=None, source=None,
nosig=None):
# Build the header hash to be sent
hash = { 'header' : Binary(h.unload()),
- 'checksum' : digest,
+ 'checksum_type' : checksum_type,
+ 'checksum' : checksum,
'packageSize' : size,
'header_start' : header_start,
'header_end' : header_end}