Hello When trying to run spacecmd export_configchannel on a channel that contained a symlink, I noticed that the functionality is broken. In export_configchannel_getdetails, the test for binary files catches symlinks and then it goes downhill from there. The attached patch solves the problem (or at least so I hope) by reorganizing the test.
-- David Juran Sr. Consultant Red Hat +46-725-345801
diff --git a/spacecmd/src/lib/configchannel.py b/spacecmd/src/lib/configchannel.py index 36ea376..80a4965 100644 --- a/spacecmd/src/lib/configchannel.py +++ b/spacecmd/src/lib/configchannel.py @@ -845,25 +845,7 @@ def export_configchannel_getdetails(self, channel): # string "macro-start-delimiter" Y N # string "macro-end-delimiter" Y N for f in fileinfo: - # If we're using a recent API version files exported with no contents - # i.e binary or non-xml encodable ascii files can be exported as - # base64 encoded - if not f.has_key('contents'): - if not self.check_api_version('11.1'): - logging.warning("File %s could not be exported " % f['path'] +\ - "with this API version(needs base64 encoding)") - else: - logging.info("File %s could not be exported as" % f['path'] +\ - " text...getting base64 encoded version") - b64f = self.client.configchannel.getEncodedFileRevision(\ - self.session, channel, f['path'], f['revision']) - f['contents'] = b64f['contents'] - f['contents_enc64'] = b64f['contents_enc64'] - for k in [ 'channel', 'revision', 'creation', 'modified', \ - 'permissions_mode', 'binary', 'md5' ]: - if f.has_key(k): - del f[k] if f['type'] == 'symlink': for k in [ 'contents', 'owner', 'group', 'permissions', \ 'macro-start-delimiter', 'macro-end-delimiter' ]: @@ -874,6 +856,27 @@ def export_configchannel_getdetails(self, channel): del f['target_path'] f['permissions'] = str(f['permissions']) + + # If we're using a recent API version files exported with no contents + # i.e binary or non-xml encodable ascii files can be exported as + # base64 encoded + if not f.has_key('contents'): + if not self.check_api_version('11.1'): + logging.warning("File %s could not be exported " % f['path'] +\ + "with this API version(needs base64 encoding)") + else: + logging.info("File %s could not be exported as" % f['path'] +\ + " text...getting base64 encoded version") + b64f = self.client.configchannel.getEncodedFileRevision(\ + self.session, channel, f['path'], f['revision']) + f['contents'] = b64f['contents'] + f['contents_enc64'] = b64f['contents_enc64'] + + for k in [ 'channel', 'revision', 'creation', 'modified', \ + 'permissions_mode', 'binary', 'md5' ]: + if f.has_key(k): + del f[k] + details['files'] = fileinfo return details
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Spacewalk-devel mailing list Spacewalk-devel@redhat.com https://www.redhat.com/mailman/listinfo/spacewalk-devel