java/code
by Tomas Lestach
java/code/src/com/redhat/rhn/frontend/action/systems/SystemListHelper.java | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit 208b4aeeabee6f7f4bb95abce4da71189869dfdf
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Thu May 17 10:19:04 2012 +0200
822237 - there're no help pages in Spacewalk
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/SystemListHelper.java b/java/code/src/com/redhat/rhn/frontend/action/systems/SystemListHelper.java
index 03aa10e..93994bc 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/systems/SystemListHelper.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/SystemListHelper.java
@@ -79,6 +79,9 @@ public class SystemListHelper {
img.setAttribute("src", "/img/icon_checkin.gif");
img.setAttribute("alt", message);
img.setAttribute("title", message);
+ if (makeLinks) {
+ makeLinks = ConfigDefaults.get().isDocAvailable();
+ }
}
else if (SystemManager.isKickstarting(user,
new Long(next.getId().longValue()))) {
@@ -170,6 +173,9 @@ public class SystemListHelper {
lockedImg.setAttribute("alt", message);
lockedImg.setAttribute("title", message);
if (makeLinks) {
+ makeLinks = ConfigDefaults.get().isDocAvailable();
+ }
+ if (makeLinks) {
lockedUrl.addBody(lockedImg);
statusDisplay = statusDisplay + lockedUrl.render();
}
12 years
Changes to 'refs/tags/spacewalk-java-1.8.69-1'
by Tomas Lestach
Tag 'spacewalk-java-1.8.69-1' created by Tomas Lestach <tlestach(a)redhat.com> at 2012-05-16 15:21 +0000
Tagging package [spacewalk-java] version [1.8.69-1] in directory [java/].
Changes since spacewalk-pylint-0.4-1:
Tomas Lestach (2):
736661 - prevent system.config.createOrUpdatePath causing deadlock
Automatic commit of package [spacewalk-java] release [1.8.69-1].
---
java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java | 1
java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java | 38 ++++++----
java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java | 11 +-
java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java | 18 ++++
java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java | 23 ++++++
java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java | 12 +++
java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java | 11 ++
java/spacewalk-java.spec | 5 +
rel-eng/packages/spacewalk-java | 2
9 files changed, 101 insertions(+), 20 deletions(-)
---
12 years
2 commits - java/code java/spacewalk-java.spec rel-eng/packages
by Tomas Lestach
java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java | 1
java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java | 38 ++++++----
java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java | 11 +-
java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java | 18 ++++
java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java | 23 ++++++
java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java | 12 +++
java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java | 11 ++
java/spacewalk-java.spec | 5 +
rel-eng/packages/spacewalk-java | 2
9 files changed, 101 insertions(+), 20 deletions(-)
New commits:
commit 4d964bba463c099371bd4b3e584d563c9380db47
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Wed May 16 17:21:46 2012 +0200
Automatic commit of package [spacewalk-java] release [1.8.69-1].
diff --git a/java/spacewalk-java.spec b/java/spacewalk-java.spec
index 9c3f835..37232a2 100644
--- a/java/spacewalk-java.spec
+++ b/java/spacewalk-java.spec
@@ -22,7 +22,7 @@ Name: spacewalk-java
Summary: Spacewalk Java site packages
Group: Applications/Internet
License: GPLv2
-Version: 1.8.68
+Version: 1.8.69
Release: 1%{?dist}
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
@@ -607,6 +607,9 @@ fi
%{jardir}/postgresql-jdbc.jar
%changelog
+* Wed May 16 2012 Tomas Lestach <tlestach(a)redhat.com> 1.8.69-1
+- 736661 - prevent system.config.createOrUpdatePath causing deadlock
+
* Mon May 14 2012 Tomas Lestach <tlestach(a)redhat.com> 1.8.68-1
- remove empty test quota stuff
- remove remained usage of OrgQuota class
diff --git a/rel-eng/packages/spacewalk-java b/rel-eng/packages/spacewalk-java
index 6b2905a..0f52191 100644
--- a/rel-eng/packages/spacewalk-java
+++ b/rel-eng/packages/spacewalk-java
@@ -1 +1 @@
-1.8.68-1 java/
+1.8.69-1 java/
commit ad44c766557d33af310858bf60246b8774451dbe
Author: Tomas Lestach <tlestach(a)redhat.com>
Date: Tue May 15 11:36:19 2012 +0200
736661 - prevent system.config.createOrUpdatePath causing deadlock
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java b/java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java
index abc3eec..318d8ce 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigRevision.java
@@ -17,6 +17,7 @@ package com.redhat.rhn.domain.config;
import com.redhat.rhn.domain.BaseDomainHelper;
import com.redhat.rhn.domain.user.User;
import com.redhat.rhn.domain.user.UserFactory;
+
import java.util.Date;
/**
diff --git a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
index c983b00..d54a24d 100644
--- a/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/config/ConfigurationFactory.java
@@ -197,8 +197,9 @@ public class ConfigurationFactory extends HibernateFactory {
* attached to it. config files also used stored procedures for
* insertions, so we can't simply ask hibernate to save it for us.
* @param revision the new ConfigRevision we want to store.
+ * @return returns revision id
*/
- public static void saveNewConfigRevision(ConfigRevision revision) {
+ public static Long saveNewConfigRevision(ConfigRevision revision) {
//This is designed to catch some of the cases in which the config file
//was not saved before the config revision.
//There is still the possibility that the config file hasn't been committed to
@@ -242,7 +243,7 @@ public class ConfigurationFactory extends HibernateFactory {
Map result = m.execute(inParams, outParams);
- revision.setId((Long)result.get("configRevisionId"));
+ return (Long) result.get("configRevisionId");
}
private static void save(ConfigChannel channel) {
@@ -293,12 +294,14 @@ public class ConfigurationFactory extends HibernateFactory {
* use a stored procedure for inserting, we have to decide whether to
* insert or update here. If the revision's id is null, we insert.
* @param revision The revision to save or update
+ * @return returns config revision (with set id)
*/
- public static void commit(ConfigRevision revision) {
+ public static ConfigRevision commit(ConfigRevision revision) {
ConfigFile file = revision.getConfigFile();
commit(file);
if (revision.getId() == null) {
- saveNewConfigRevision(revision);
+ Long revId = saveNewConfigRevision(revision);
+ revision = (ConfigRevision) getSession().get(ConfigRevision.class, revId);
file.setLatestConfigRevision(revision);
//and now we have to save the file again
//it would be nice to save it only once, but we require the file id
@@ -329,6 +332,7 @@ public class ConfigurationFactory extends HibernateFactory {
// And now, because saveNewConfigRevision doesn't store -every-thing
// about a revision, we have to commit it -again-. Sigh. See BZ212236
save(revision);
+ return revision;
}
/**
@@ -809,6 +813,23 @@ public class ConfigurationFactory extends HibernateFactory {
content.setModified(new Date());
content.setFileSize(size);
+ byte[] foo = bytesFromStream(stream, size);
+ content.setContents(foo);
+ Checksum newChecksum = ChecksumFactory.safeCreate(MD5Crypt.md5Hex(foo), "md5");
+ content.setChecksum(newChecksum);
+ content.setBinary(isBinary);
+ content.setDelimStart(delimStart);
+ content.setDelimEnd(delimEnd);
+ return content;
+ }
+
+ /**
+ * Convert input stream to byte array
+ * @param stream input stream
+ * @param size stream size
+ * @return byte array
+ */
+ public static byte[] bytesFromStream(InputStream stream, Long size) {
byte[] foo = new byte[size.intValue()];
try {
//this silly bit of logic is to ensure that we read as much from the file
@@ -827,14 +848,7 @@ public class ConfigurationFactory extends HibernateFactory {
throw new RuntimeException("IOException while reading config content from" +
" input stream!");
}
-
- content.setContents(foo);
- Checksum newChecksum = ChecksumFactory.safeCreate(MD5Crypt.md5Hex(foo), "md5");
- content.setChecksum(newChecksum);
- content.setBinary(isBinary);
- content.setDelimStart(delimStart);
- content.setDelimEnd(delimEnd);
- return content;
+ return foo;
}
private static Map getMaxRevisionForFile(ConfigFile file) {
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java b/java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java
index a51418d..067dd69 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/ConfigFileBuilder.java
@@ -153,6 +153,10 @@ public class ConfigFileBuilder {
revision.setChangedById(user.getId());
}
else {
+ if ((prevRevision != null) &&
+ form.matchesRevision(prevRevision)) {
+ return prevRevision;
+ }
revision = manager.createNewRevision(
user, form.getContentStream(), cf,
form.getContentSize());
@@ -177,14 +181,9 @@ public class ConfigFileBuilder {
revision.setRevision(Long.parseLong(form.getRevNumber()));
}
- if (!onCreate && revision.matches(prevRevision)) {
- ConfigurationFactory.removeConfigRevision(revision, user.getOrg().getId());
- return prevRevision;
- }
// Committing the revision commits the file for us (which commits the
// Channel, so everybody's pointers get updated...)
- ConfigurationFactory.commit(revision);
- return (ConfigRevision) ConfigurationFactory.reload(revision);
+ return ConfigurationFactory.commit(revision);
}
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java
index 53cedc7..a3a7d37 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/BinaryFileData.java
@@ -14,9 +14,13 @@
*/
package com.redhat.rhn.manager.configuration.file;
+import com.redhat.rhn.common.util.MD5Crypt;
import com.redhat.rhn.common.validator.ValidatorResult;
+import com.redhat.rhn.domain.common.Checksum;
+import com.redhat.rhn.domain.common.ChecksumFactory;
import com.redhat.rhn.domain.config.ConfigFileType;
import com.redhat.rhn.domain.config.ConfigRevision;
+import com.redhat.rhn.domain.config.ConfigurationFactory;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -129,4 +133,18 @@ public class BinaryFileData extends ConfigFileData {
append("Size", getContentSize());
return builder.toString();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean matchesRevision(ConfigRevision cRevision) {
+ if (!super.matchesRevision(cRevision)) {
+ return Boolean.FALSE;
+ }
+ byte[] bContent = ConfigurationFactory.bytesFromStream(getContents(),
+ getContentSize());
+ Checksum checksum = ChecksumFactory.safeCreate(MD5Crypt.md5Hex(bContent), "md5");
+ return checksum.equals(cRevision.getConfigContent().getChecksum());
+ }
}
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
index 5da6d17..3d9726f 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/ConfigFileData.java
@@ -422,4 +422,27 @@ public abstract class ConfigFileData {
public void setRevNumber(String revNumberIn) {
this.revNumber = revNumberIn;
}
+
+ /**
+ * @param cRevision config revision
+ * @return true if mathces the config revision
+ */
+ public boolean matchesRevision(ConfigRevision cRevision) {
+ if (cRevision == null) {
+ return Boolean.FALSE;
+ }
+ ConfigInfo cInfo = cRevision.getConfigInfo();
+ ConfigInfo ci = ConfigurationFactory.lookupConfigInfoById(cInfo.getId());
+ String cfdSelinuxCtx = getSelinuxCtx();
+ String crSelinuxCtx = cInfo.getSelinuxCtx();
+
+ return getType().equals(cRevision.getConfigFileType()) &&
+ getPath().equals(
+ cRevision.getConfigFile().getConfigFileName().getPath()) &&
+ getOwner().equals(cInfo.getUsername()) &&
+ getGroup().equals(cInfo.getGroupname()) &&
+ getPermissions().equals(cInfo.getFilemode().toString()) &&
+ ((StringUtils.isEmpty(cfdSelinuxCtx) && StringUtils.isEmpty(crSelinuxCtx)) ||
+ cfdSelinuxCtx.equals(crSelinuxCtx));
+ }
}
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java
index d7d8afd..7a94f25 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/SymlinkData.java
@@ -19,6 +19,7 @@ import com.redhat.rhn.common.validator.ValidatorException;
import com.redhat.rhn.common.validator.ValidatorResult;
import com.redhat.rhn.domain.config.ConfigFileType;
import com.redhat.rhn.domain.config.ConfigInfo;
+import com.redhat.rhn.domain.config.ConfigRevision;
import com.redhat.rhn.domain.config.ConfigurationFactory;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
import com.redhat.rhn.manager.configuration.ConfigurationValidation;
@@ -108,4 +109,15 @@ public class SymlinkData extends DirectoryData {
throw new ValidatorException(result);
}
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean matchesRevision(ConfigRevision cRevision) {
+ if (!super.matchesRevision(cRevision)) {
+ return Boolean.FALSE;
+ }
+ return getTargetPath().equals(cRevision.getConfigInfo().getTargetFileName());
+ }
}
diff --git a/java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java b/java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java
index ec3ee26..432e522 100644
--- a/java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java
+++ b/java/code/src/com/redhat/rhn/manager/configuration/file/TextFileData.java
@@ -143,4 +143,15 @@ public class TextFileData extends ConfigFileData {
append("Contents", getContents());
return builder.toString();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean matchesRevision(ConfigRevision cRevision) {
+ if (!super.matchesRevision(cRevision)) {
+ return Boolean.FALSE;
+ }
+ return getContents().equals(cRevision.getConfigContent().getContentsString());
+ }
}
12 years
Changes to 'refs/tags/spacewalk-pylint-0.4-1'
by Miroslav Suchý
Tag 'spacewalk-pylint-0.4-1' created by Miroslav Suchý <msuchy(a)redhat.com> at 2012-05-16 15:19 +0000
Tagging package [spacewalk-pylint] version [0.4-1] in directory [spacewalk/pylint/].
Changes since spacewalk-utils-1.8.13-1:
Miroslav Suchý (4):
Spacewalk is released under GPLv2, lets stick to it
800899 - include license file
800899 - consistently use macros
Automatic commit of package [spacewalk-pylint] release [0.4-1].
---
rel-eng/packages/spacewalk-pylint | 2
spacewalk/pylint/LICENSE | 339 +++++++++++++++++++++++++++++++++
spacewalk/pylint/spacewalk-pylint.spec | 15 -
3 files changed, 350 insertions(+), 6 deletions(-)
---
12 years
4 commits - rel-eng/packages spacewalk/pylint
by Miroslav Suchý
rel-eng/packages/spacewalk-pylint | 2
spacewalk/pylint/LICENSE | 339 +++++++++++++++++++++++++++++++++
spacewalk/pylint/spacewalk-pylint.spec | 15 -
3 files changed, 350 insertions(+), 6 deletions(-)
New commits:
commit 0c4674eef1df2f66248b6d7d25c24eea33d83e43
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed May 16 17:19:25 2012 +0200
Automatic commit of package [spacewalk-pylint] release [0.4-1].
diff --git a/rel-eng/packages/spacewalk-pylint b/rel-eng/packages/spacewalk-pylint
index d96e32f..2b79513 100644
--- a/rel-eng/packages/spacewalk-pylint
+++ b/rel-eng/packages/spacewalk-pylint
@@ -1 +1 @@
-0.3-1 spacewalk/pylint/
+0.4-1 spacewalk/pylint/
diff --git a/spacewalk/pylint/spacewalk-pylint.spec b/spacewalk/pylint/spacewalk-pylint.spec
index dd9ca71..fc0e18b 100644
--- a/spacewalk/pylint/spacewalk-pylint.spec
+++ b/spacewalk/pylint/spacewalk-pylint.spec
@@ -1,5 +1,5 @@
Name: spacewalk-pylint
-Version: 0.3
+Version: 0.4
Release: 1%{?dist}
Summary: Pylint configuration for spacewalk python packages
@@ -50,6 +50,11 @@ rm -rf %{buildroot}
%doc LICENSE
%changelog
+* Wed May 16 2012 Miroslav Suchý <msuchy(a)redhat.com> 0.4-1
+- 800899 - consistently use macros
+- 800899 - include license file
+- Spacewalk is released under GPLv2, lets stick to it
+
* Wed Mar 07 2012 Miroslav Suchý 0.3-1
- add man page
- Description lines must not exceed 80 characters
commit be1c65bb3eba13869f30bbd48e27eb9bdffb79b6
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed May 16 17:15:07 2012 +0200
800899 - consistently use macros
diff --git a/spacewalk/pylint/spacewalk-pylint.spec b/spacewalk/pylint/spacewalk-pylint.spec
index 0da5481..dd9ca71 100644
--- a/spacewalk/pylint/spacewalk-pylint.spec
+++ b/spacewalk/pylint/spacewalk-pylint.spec
@@ -29,7 +29,7 @@ packages.
a2x -d manpage -f manpage spacewalk-pylint.8.asciidoc
%install
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
install -d -m 755 %{buildroot}/%{_bindir}
install -p -m 755 spacewalk-pylint %{buildroot}/%{_bindir}/
install -d -m 755 %{buildroot}/%{_sysconfdir}
@@ -39,7 +39,7 @@ install -m 644 spacewalk-pylint.8 %{buildroot}/%{_mandir}/man8
%clean
-rm -rf $RPM_BUILD_ROOT
+rm -rf %{buildroot}
%files
commit 129488411489ea3308d7ac4804973160121679c9
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed May 16 17:10:50 2012 +0200
800899 - include license file
diff --git a/spacewalk/pylint/LICENSE b/spacewalk/pylint/LICENSE
new file mode 100644
index 0000000..d511905
--- /dev/null
+++ b/spacewalk/pylint/LICENSE
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/spacewalk/pylint/spacewalk-pylint.spec b/spacewalk/pylint/spacewalk-pylint.spec
index 5f39f85..0da5481 100644
--- a/spacewalk/pylint/spacewalk-pylint.spec
+++ b/spacewalk/pylint/spacewalk-pylint.spec
@@ -47,7 +47,7 @@ rm -rf $RPM_BUILD_ROOT
%{_bindir}/spacewalk-pylint
%config(noreplace) %{_sysconfdir}/spacewalk-pylint.rc
%doc %{_mandir}/man8/spacewalk-pylint.8*
-
+%doc LICENSE
%changelog
* Wed Mar 07 2012 Miroslav Suchý 0.3-1
commit 532b45fbee0efce675dd56af9ef69030449f93f0
Author: Miroslav Suchý <msuchy(a)redhat.com>
Date: Wed May 16 17:08:45 2012 +0200
Spacewalk is released under GPLv2, lets stick to it
diff --git a/spacewalk/pylint/spacewalk-pylint.spec b/spacewalk/pylint/spacewalk-pylint.spec
index aecad80..5f39f85 100644
--- a/spacewalk/pylint/spacewalk-pylint.spec
+++ b/spacewalk/pylint/spacewalk-pylint.spec
@@ -4,7 +4,7 @@ Release: 1%{?dist}
Summary: Pylint configuration for spacewalk python packages
Group: Development/Debuggers
-License: GPLv2+
+License: GPLv2
URL: https://fedorahosted.org/spacewalk
Source0: https://fedorahosted.org/releases/s/p/spacewalk/%{name}-%{version}.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
12 years
Changes to 'refs/tags/spacewalk-utils-1.8.13-1'
by Michael Mraka
Tag 'spacewalk-utils-1.8.13-1' created by Michael Mraka <michael.mraka(a)redhat.com> at 2012-05-16 14:51 +0000
Tagging package [spacewalk-utils] version [1.8.13-1] in directory [utils/].
Changes since spacecmd-1.8.7-1:
Michael Mraka (2):
added version for scientific linux default channel mapping
Automatic commit of package [spacewalk-utils] release [1.8.13-1].
---
rel-eng/packages/spacewalk-utils | 2 +-
utils/spacewalk-common-channels.ini | 1 +
utils/spacewalk-utils.spec | 5 ++++-
3 files changed, 6 insertions(+), 2 deletions(-)
---
12 years
rel-eng/packages utils/spacewalk-utils.spec
by Michael Mraka
rel-eng/packages/spacewalk-utils | 2 +-
utils/spacewalk-utils.spec | 5 ++++-
2 files changed, 5 insertions(+), 2 deletions(-)
New commits:
commit ad31039512a548e9c00111a59502951f1e517066
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed May 16 16:51:31 2012 +0200
Automatic commit of package [spacewalk-utils] release [1.8.13-1].
diff --git a/rel-eng/packages/spacewalk-utils b/rel-eng/packages/spacewalk-utils
index ba02d65..064264c 100644
--- a/rel-eng/packages/spacewalk-utils
+++ b/rel-eng/packages/spacewalk-utils
@@ -1 +1 @@
-1.8.12-1 utils/
+1.8.13-1 utils/
diff --git a/utils/spacewalk-utils.spec b/utils/spacewalk-utils.spec
index 95b2f74..37be859 100644
--- a/utils/spacewalk-utils.spec
+++ b/utils/spacewalk-utils.spec
@@ -1,7 +1,7 @@
%define rhnroot %{_prefix}/share/rhn
Name: spacewalk-utils
-Version: 1.8.12
+Version: 1.8.13
Release: 1%{?dist}
Summary: Utilities that may be run against a Spacewalk server.
@@ -87,6 +87,9 @@ spacewalk-pylint $RPM_BUILD_ROOT%{rhnroot}
%changelog
+* Wed May 16 2012 Michael Mraka <michael.mraka(a)redhat.com> 1.8.13-1
+- added version for scientific linux default channel mapping
+
* Thu May 10 2012 Jan Pazdziora 1.8.12-1
- The plan_table is not part of our schema, do not dump it.
12 years
utils/spacewalk-common-channels.ini
by Michael Mraka
utils/spacewalk-common-channels.ini | 1 +
1 file changed, 1 insertion(+)
New commits:
commit fe1d4f62dddecffb81ff4a6ec30b9d068ecd9e51
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed May 16 13:17:02 2012 +0200
added version for scientific linux default channel mapping
diff --git a/utils/spacewalk-common-channels.ini b/utils/spacewalk-common-channels.ini
index ccee5b4..cee0fa6 100644
--- a/utils/spacewalk-common-channels.ini
+++ b/utils/spacewalk-common-channels.ini
@@ -94,6 +94,7 @@ gpgkey_url = http://ftp.scientificlinux.org/linux/scientific/6/i386/os/RPM-GPG-K
gpgkey_id = 9B1FD350
gpgkey_fingerprint = E2E5 CBB5 6E19 960F F509 6994 915D 75E0 9B1F D350
yumrepo_url = http://ftp.scientificlinux.org/linux/scientific/6/%(arch)s/os/
+dist_map_release = 6.2
[scientific6-updates-fast]
label = %(base_channel)s-updates-fast
12 years
Changes to 'refs/tags/spacecmd-1.8.7-1'
by aparsons
Tag 'spacecmd-1.8.7-1' created by Aron Parsons <aronparsons(a)gmail.com> at 2012-05-16 00:34 +0000
Tagging package [spacecmd] version [1.8.7-1] in directory [spacecmd/].
Changes since spacecmd-1.8.6-1:
Aron Parsons (1):
Automatic commit of package [spacecmd] release [1.8.7-1].
Joerg Steffens (5):
print return values
add do_SPACEWALKCOMPONENT_diff functions
bugfix: remove reference to stage function
bugfix and comment clarification
changed get_string_diff_dicts to better fitting replacement method
---
rel-eng/packages/spacecmd | 2
spacecmd/spacecmd.spec | 9 +
spacecmd/src/bin/spacecmd | 3
spacecmd/src/lib/activationkey.py | 123 ++++++++++++++++++-----
spacecmd/src/lib/configchannel.py | 130 +++++++++++++++++++-----
spacecmd/src/lib/kickstart.py | 190 +++++++++++++++++++++++++-----------
spacecmd/src/lib/shell.py | 13 ++
spacecmd/src/lib/softwarechannel.py | 70 +++++++++++++
spacecmd/src/lib/utils.py | 86 ++++++++++++++++
9 files changed, 512 insertions(+), 114 deletions(-)
---
12 years
6 commits - rel-eng/packages spacecmd/spacecmd.spec spacecmd/src
by aparsons
rel-eng/packages/spacecmd | 2
spacecmd/spacecmd.spec | 9 +
spacecmd/src/bin/spacecmd | 3
spacecmd/src/lib/activationkey.py | 123 ++++++++++++++++++-----
spacecmd/src/lib/configchannel.py | 130 +++++++++++++++++++-----
spacecmd/src/lib/kickstart.py | 190 +++++++++++++++++++++++++-----------
spacecmd/src/lib/shell.py | 13 ++
spacecmd/src/lib/softwarechannel.py | 70 +++++++++++++
spacecmd/src/lib/utils.py | 86 ++++++++++++++++
9 files changed, 512 insertions(+), 114 deletions(-)
New commits:
commit fa6ad3b77cd477f0be624238b7a584099f8ea9bb
Author: Aron Parsons <aronparsons(a)gmail.com>
Date: Tue May 15 20:34:35 2012 -0400
Automatic commit of package [spacecmd] release [1.8.7-1].
diff --git a/rel-eng/packages/spacecmd b/rel-eng/packages/spacecmd
index c3d69a5..c131680 100644
--- a/rel-eng/packages/spacecmd
+++ b/rel-eng/packages/spacecmd
@@ -1 +1 @@
-1.8.6-1 spacecmd/
+1.8.7-1 spacecmd/
diff --git a/spacecmd/spacecmd.spec b/spacecmd/spacecmd.spec
index 471f6e7..ea5ba9f 100644
--- a/spacecmd/spacecmd.spec
+++ b/spacecmd/spacecmd.spec
@@ -4,7 +4,7 @@
%endif
Name: spacecmd
-Version: 1.8.6
+Version: 1.8.7
Release: 1%{?dist}
Summary: Command-line interface to Spacewalk and Satellite servers
@@ -61,6 +61,13 @@ touch %{buildroot}/%{python_sitelib}/spacecmd/__init__.py
%doc %{_mandir}/man1/spacecmd.1.gz
%changelog
+* Tue May 15 2012 Aron Parsons <aronparsons(a)gmail.com> 1.8.7-1
+- changed get_string_diff_dicts to better fitting replacement method
+- bugfix and comment clarification
+- bugfix: remove reference to stage function
+- add do_SPACEWALKCOMPONENT_diff functions
+- print return values
+
* Tue May 15 2012 Steven Hardy <shardy(a)redhat.com> 1.8.6-1
- spacecmd bugfix : system_comparewithchannel filter system packagelist
- spacecmd bugfix : argument validation needed for configchannel_addfile
commit a4775c036aa20d3925a99ec0faaf88b31f038d92
Author: Joerg Steffens <joerg.steffens(a)dass-it.de>
Date: Sun May 13 14:22:46 2012 +0200
changed get_string_diff_dicts to better fitting replacement method
Signed-off-by: Aron Parsons <aronparsons(a)gmail.com>
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index 942b9f3..c9d4c4a 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -22,8 +22,9 @@
# NOTE: the 'self' variable is an instance of SpacewalkShell
import logging, os, pickle, re, readline, shlex, sys, time, xmlrpclib
+from collections import deque
from datetime import datetime, timedelta
-from difflib import unified_diff, SequenceMatcher
+from difflib import unified_diff
from optparse import OptionParser
from tempfile import mkstemp
from textwrap import wrap
@@ -634,30 +635,54 @@ def json_read_from_file(filename):
print "could not open file %s for reading, check permissions?" % filename
return None
-def get_string_diff_dicts( string1, string2 ):
+
+def get_string_diff_dicts( string1, string2, sep="-" ):
+ """
+ compares two strings and determine, if one string can be transformed into the other by simple string replacements.
+
+ If these strings are closly related, it returns two dictonaries of regular expressions.
+
+ The first dictionary can be used to transfrom type 1 strings into type 2 strings.
+ The second dictionary vice versa.
+
+ These replacements blocks must be separated by "-".
+
+ Example:
+ string1: rhel6-x86_64-dev-application1
+ string2: rhel6-x86_64-qas-application1
+
+ Result:
+ dict1: {'(^|-)dev(-|$)': '\\1DIFF(dev|qas)\\2'}
+ dict2: {'(^|-)qas(-|$)': '\\1DIFF(dev|qas)\\2'}
+ """
replace1 = {}
replace2 = {}
- s = SequenceMatcher(None, string1, string2)
- for tag, i1a, i1b, i2a, i2b in s.get_opcodes():
- sub1=string1[i1a:i1b]
- sub2=string2[i2a:i2b]
- if tag == "equal":
+
+ if string1 == string2:
+ logging.info( "Skipping usage of common strings: both strings are equal" )
+ return [None,None]
+ substrings1 = deque( string1.split(sep) )
+ substrings2 = deque( string2.split(sep) )
+
+ while substrings1 and substrings2:
+ sub1 = substrings1.popleft()
+ sub2 = substrings2.popleft()
+ if sub1 == sub2:
# equal, nothing to do
pass
- elif tag == "replace":
- replace1[sub1] = "DIFF("+sub1+"|"+sub2+")"
- replace2[sub2] = "DIFF("+sub1+"|"+sub2+")"
else:
- # "insert" or "delete"
- # can't handle this
- logging.debug( "Too many differences between " + string1 + " and " + string2 + ". Skipping usage of common strings." )
- return [None,None]
+ # TODO: replace only if len(sub1) == len(sub2) ?
+ replace1['(^|-)' + sub1 + '(-|$)'] = r'\1' + "DIFF("+sub1+"|"+sub2+")" + r'\2'
+ replace2['(^|-)' + sub2 + '(-|$)'] = r'\1' + "DIFF("+sub1+"|"+sub2+")" + r'\2'
+ if substrings1 or substrings2:
+ logging.info( "Skipping usage of common strings: number of substrings differ" )
+ return [None,None]
return [replace1,replace2]
def replace( line, replacedict ):
if replacedict:
for source in replacedict:
- line = line.replace( source, replacedict[source] )
+ line = re.sub( source, replacedict[source], line )
return line
def get_normalized_text( text, replacedict=None, excludes=None ):
commit 4e1a95dd88007ec9be12ab0eaa246c287dfb57dd
Author: Joerg Steffens <joerg.steffens(a)dass-it.de>
Date: Sat May 12 23:42:24 2012 +0200
bugfix and comment clarification
Signed-off-by: Aron Parsons <aronparsons(a)gmail.com>
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index 0a7c4c5..942b9f3 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -650,7 +650,6 @@ def get_string_diff_dicts( string1, string2 ):
else:
# "insert" or "delete"
# can't handle this
- #logging.debug( "will not handle differences " + sub1 + sub2 )
logging.debug( "Too many differences between " + string1 + " and " + string2 + ". Skipping usage of common strings." )
return [None,None]
return [replace1,replace2]
@@ -661,14 +660,14 @@ def replace( line, replacedict ):
line = line.replace( source, replacedict[source] )
return line
-def get_normalized_text( text, replacedict=None, excludes=_DIFF_EXCLUDES ):
+def get_normalized_text( text, replacedict=None, excludes=None ):
# parts of the data inside the spacewalk component information
- # is not relevant for showing real differences between two instances.
- # Therefore parts of the data will be modified before the real diff:
+ # are not really differences between two instances.
+ # Therefore parts of the data will be modified before the diff:
# - specific lines, starting with a defined keyword, will be excluded
# - specific character sequences will be replaced with the same text in both instances.
# Example:
- # we want to compare two activationkeys from different stages:
+ # we want to compare two related activationkeys:
# "1-rhel6-x86_64-dev" and "1-rhel6-x86_64-prd"
# ("dev" for "development" and "prd" for "production").
# We assume that the "dev" activationkey "1-rhel6-x86_64-dev"
commit f5a1c71592bd45a246c018d80a0df0faf0cb13d4
Author: Joerg Steffens <joerg.steffens(a)dass-it.de>
Date: Sat May 12 23:41:45 2012 +0200
bugfix: remove reference to stage function
Signed-off-by: Aron Parsons <aronparsons(a)gmail.com>
diff --git a/spacecmd/src/lib/configchannel.py b/spacecmd/src/lib/configchannel.py
index b2849d8..9a27d04 100644
--- a/spacecmd/src/lib/configchannel.py
+++ b/spacecmd/src/lib/configchannel.py
@@ -1169,7 +1169,7 @@ def do_configchannel_diff(self, args):
(args, options) = parse_arguments(args, options)
if len(args) != 1 and len(args) != 2:
- self.help_stage_configchannel_diff()
+ self.help_configchannel_diff()
return
source_channel = args[0]
commit b61b93388a33577ccc659060bfffeb0a7f50518f
Author: Joerg Steffens <joerg.steffens(a)dass-it.de>
Date: Thu May 10 21:21:08 2012 +0200
add do_SPACEWALKCOMPONENT_diff functions
Signed-off-by: Aron Parsons <aronparsons(a)gmail.com>
diff --git a/spacecmd/src/lib/activationkey.py b/spacecmd/src/lib/activationkey.py
index 2910333..41406ee 100644
--- a/spacecmd/src/lib/activationkey.py
+++ b/spacecmd/src/lib/activationkey.py
@@ -743,6 +743,7 @@ def do_activationkey_details(self, args):
add_separator = False
+ result = []
for key in args:
try:
details = self.client.activationkey.getDetails(self.session,
@@ -780,46 +781,47 @@ def do_activationkey_details(self, args):
if add_separator: print self.SEPARATOR
add_separator = True
- print 'Key: %s' % details.get('key')
- print 'Description: %s' % details.get('description')
- print 'Universal Default: %s' % details.get('universal_default')
- print 'Usage Limit: %s' % details.get('usage_limit')
- print 'Deploy Config Channels: %s' % config_channel_deploy
+ result.append( 'Key: %s' % details.get('key') )
+ result.append( 'Description: %s' % details.get('description') )
+ result.append( 'Universal Default: %s' % details.get('universal_default') )
+ result.append( 'Usage Limit: %s' % details.get('usage_limit') )
+ result.append( 'Deploy Config Channels: %s' % config_channel_deploy )
- print
- print 'Software Channels'
- print '-----------------'
- print details.get('base_channel_label')
+ result.append( '' )
+ result.append( 'Software Channels' )
+ result.append( '-----------------' )
+ result.append( details.get('base_channel_label') )
for channel in sorted(details.get('child_channel_labels')):
- print ' |-- %s' % channel
+ result.append( ' |-- %s' % channel )
- print
- print 'Configuration Channels'
- print '----------------------'
+ result.append( '' )
+ result.append( 'Configuration Channels' )
+ result.append( '----------------------' )
for channel in config_channels:
- print channel.get('label')
+ result.append( channel.get('label') )
- print
- print 'Entitlements'
- print '------------'
- print '\n'.join(sorted(details.get('entitlements')))
+ result.append( '' )
+ result.append( 'Entitlements' )
+ result.append( '------------' )
+ result.append( '\n'.join(sorted(details.get('entitlements'))) )
- print
- print 'System Groups'
- print '-------------'
- print '\n'.join(sorted(groups))
+ result.append( '' )
+ result.append( 'System Groups' )
+ result.append( '-------------' )
+ result.append( '\n'.join(sorted(groups)) )
- print
- print 'Packages'
- print '--------'
+ result.append( '' )
+ result.append( 'Packages' )
+ result.append( '--------' )
for package in sorted(details.get('packages')):
name = package.get('name')
if package.get('arch'):
name += '.%s' % package.get('arch')
- print name
+ result.append( name )
+ return result
####################
@@ -1357,4 +1359,73 @@ def do_activationkey_clone(self, args):
logging.error("Failed to clone %s to %s" % \
(ak, keydetails['key']))
+####################
+# activationkey helper
+
+def is_activationkey( self, name ):
+ if not name: return
+ return name in self.do_activationkey_list( name, True )
+
+def check_activationkey( self, name ):
+ if not name:
+ logging.error( "no activationkey label given" )
+ return False
+ if not self.is_activationkey( name ):
+ logging.error( "invalid activationkey label " + name )
+ return False
+ return True
+
+def dump_activationkey(self, name, replacedict=None, excludes=[ "Universal Default:" ]):
+ content = self.do_activationkey_details( name )
+
+ content = get_normalized_text( content, replacedict=replacedict, excludes=excludes )
+
+ return content
+
+####################
+
+def help_activationkey_diff(self):
+ print 'activationkeyt_diff: diff activationkeys'
+ print ''
+ print 'usage: activationkey_diff SOURCE_ACTIVATIONKEY TARGET_ACTIVATIONKEY'
+
+def complete_activationkey_diff(self, text, line, beg, end):
+ parts = shlex.split(line)
+ if line[-1] == ' ': parts.append('')
+ args = len(parts)
+
+ if args == 2:
+ return tab_completer(self.do_activationkey_list('', True), text)
+ if args == 3:
+ return tab_completer(self.do_activationkey_list('', True), text)
+ return []
+
+def do_activationkey_diff(self, args):
+ options = []
+
+ (args, options) = parse_arguments(args, options)
+
+ if len(args) != 1 and len(args) != 2:
+ self.help_activationkey_diff()
+ return
+
+ source_channel = args[0]
+ if not self.check_activationkey( source_channel ): return
+
+ target_channel = None
+ if len(args) == 2:
+ target_channel = args[1]
+ elif hasattr( self, "do_activationkey_getcorresponding" ):
+ # can a corresponding channel name be found automatically?
+ target_channel=self.do_activationkey_getcorresponding( source_channel )
+ if not self.check_activationkey( target_channel ): return
+
+ source_replacedict, target_replacedict = get_string_diff_dicts( source_channel, target_channel )
+
+ source_data = self.dump_activationkey( source_channel, source_replacedict )
+ target_data = self.dump_activationkey( target_channel, target_replacedict )
+
+ return diff( source_data, target_data, source_channel, target_channel )
+
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/configchannel.py b/spacecmd/src/lib/configchannel.py
index 723e8ca..b2849d8 100644
--- a/spacecmd/src/lib/configchannel.py
+++ b/spacecmd/src/lib/configchannel.py
@@ -153,32 +153,35 @@ def do_configchannel_filedetails(self, args):
# grab the first item since we only do one file
details = results[0]
- print 'Path: %s' % details.get('path')
- print 'Type: %s' % details.get('type')
- print 'Revision: %i' % details.get('revision')
- print 'Created: %s' % details.get('creation')
- print 'Modified: %s' % details.get('modified')
+ result = []
+ result.append( 'Path: %s' % details.get('path') )
+ result.append( 'Type: %s' % details.get('type') )
+ result.append( 'Revision: %i' % details.get('revision') )
+ result.append( 'Created: %s' % details.get('creation') )
+ result.append( 'Modified: %s' % details.get('modified') )
if details.get('type') == 'symlink':
- print
- print 'Target Path: %s' % details.get('target_path')
+ result.append( '' )
+ result.append( 'Target Path: %s' % details.get('target_path') )
else:
- print
- print 'Owner: %s' % details.get('owner')
- print 'Group: %s' % details.get('group')
- print 'Mode: %s' % details.get('permissions_mode')
+ result.append( '' )
+ result.append( 'Owner: %s' % details.get('owner') )
+ result.append( 'Group: %s' % details.get('group') )
+ result.append( 'Mode: %s' % details.get('permissions_mode') )
- print 'SELinux Context: %s' % details.get('selinux_ctx')
+ result.append( 'SELinux Context: %s' % details.get('selinux_ctx') )
if details.get('type') == 'file':
- print 'MD5: %s' % details.get('md5')
- print 'Binary: %s' % details.get('binary')
+ result.append( 'MD5: %s' % details.get('md5') )
+ result.append( 'Binary: %s' % details.get('binary') )
if not details.get('binary'):
- print
- print 'Contents'
- print '--------'
- print details.get('contents')
+ result.append( '' )
+ result.append( 'Contents' )
+ result.append( '--------' )
+ result.append( details.get('contents') )
+
+ return result
####################
@@ -289,6 +292,7 @@ def do_configchannel_details(self, args):
add_separator = False
+ result = []
for channel in args:
details = self.client.configchannel.getDetails(self.session,
channel)
@@ -299,15 +303,16 @@ def do_configchannel_details(self, args):
if add_separator: print self.SEPARATOR
add_separator = True
- print 'Label: %s' % details.get('label')
- print 'Name: %s' % details.get('name')
- print 'Description: %s' % details.get('description')
+ result.append( 'Label: %s' % details.get('label') )
+ result.append( 'Name: %s' % details.get('name') )
+ result.append( 'Description: %s' % details.get('description') )
- print
- print 'Files'
- print '-----'
+ result.append( '' )
+ result.append( 'Files' )
+ result.append( '-----' )
for f in files:
- print f.get('path')
+ result.append( f.get('path') )
+ return result
####################
@@ -1110,4 +1115,79 @@ def do_configchannel_clone(self, args):
logging.error("Failed to clone %s to %s" % \
(cc, ccdetails['label']))
+####################
+# configchannel helper
+
+def is_configchannel( self, name ):
+ if not name: return
+ return name in self.do_configchannel_list( name, True )
+
+def check_configchannel( self, name ):
+ if not name:
+ logging.error( "no configchannel given" )
+ return False
+ if not self.is_configchannel( name ):
+ logging.error( "invalid configchannel label " + name )
+ return False
+ return True
+
+def dump_configchannel_filedetails(self, name, filename):
+ content = self.do_configchannel_filedetails( name +" "+ filename )
+ return content
+
+def dump_configchannel(self, name, replacedict=None, excludes=[ "Revision:", "Created:", "Modified:" ]):
+ content = self.do_configchannel_details( name )
+
+ for filename in self.do_configchannel_listfiles(name, True):
+ content.extend( self.dump_configchannel_filedetails(name, filename) )
+
+ content = get_normalized_text( content, replacedict=replacedict, excludes=excludes )
+
+ return content
+
+####################
+
+def help_configchannel_diff(self):
+ print 'configchannel_diff: diff between config channels'
+ print ''
+ print 'usage: configchannel_diff SOURCE_CHANNEL TARGET_CHANNEL'
+
+def complete_configchannel_diff(self, text, line, beg, end):
+ parts = shlex.split(line)
+ if line[-1] == ' ': parts.append('')
+ args = len(parts)
+
+ if args == 2:
+ return tab_completer(self.do_configchannel_list('', True), text)
+ if args == 3:
+ return tab_completer(self.do_configchannel_list('', True), text)
+ return []
+
+def do_configchannel_diff(self, args):
+ options = []
+
+ (args, options) = parse_arguments(args, options)
+
+ if len(args) != 1 and len(args) != 2:
+ self.help_stage_configchannel_diff()
+ return
+
+ source_channel = args[0]
+ if not self.check_configchannel( source_channel ): return
+
+ target_channel = None
+ if len(args) == 2:
+ target_channel = args[1]
+ elif hasattr( self, "do_configchannel_getcorresponding" ):
+ # can a corresponding channel name be found automatically?
+ target_channel=self.do_configchannel_getcorresponding( source_channel )
+ if not self.check_configchannel( target_channel ): return
+
+ source_replacedict, target_replacedict = get_string_diff_dicts( source_channel, target_channel )
+
+ source_data = self.dump_configchannel( source_channel, source_replacedict )
+ target_data = self.dump_configchannel( target_channel, target_replacedict )
+
+ return diff( source_data, target_data, source_channel, target_channel )
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/kickstart.py b/spacecmd/src/lib/kickstart.py
index fb51df5..ef622ec 100644
--- a/spacecmd/src/lib/kickstart.py
+++ b/spacecmd/src/lib/kickstart.py
@@ -287,8 +287,11 @@ def do_kickstart_details(self, args):
self.client.kickstart.profile.keys.getActivationKeys(self.session,
label)
- variables = self.client.kickstart.profile.getVariables(self.session,
- label)
+ try:
+ variables = self.client.kickstart.profile.getVariables(self.session,
+ label)
+ except:
+ variables = []
tree = \
self.client.kickstart.tree.getDetails(self.session,
@@ -336,100 +339,103 @@ def do_kickstart_details(self, args):
scripts = self.client.kickstart.profile.listScripts(self.session,
label)
- print 'Name: %s' % kickstart.get('name')
- print 'Label: %s' % kickstart.get('label')
- print 'Tree: %s' % kickstart.get('tree_label')
- print 'Active: %s' % kickstart.get('active')
- print 'Advanced: %s' % kickstart.get('advanced_mode')
- print 'Org Default: %s' % kickstart.get('org_default')
+ result = []
+ result.append( 'Name: %s' % kickstart.get('name') )
+ result.append( 'Label: %s' % kickstart.get('label') )
+ result.append( 'Tree: %s' % kickstart.get('tree_label') )
+ result.append( 'Active: %s' % kickstart.get('active') )
+ result.append( 'Advanced: %s' % kickstart.get('advanced_mode') )
+ result.append( 'Org Default: %s' % kickstart.get('org_default') )
- print
- print 'Configuration Management: %s' % config_manage
- print 'Remote Commands: %s' % remote_commands
+ result.append( '' )
+ result.append( 'Configuration Management: %s' % config_manage )
+ result.append( 'Remote Commands: %s' % remote_commands )
- print
- print 'Software Channels'
- print '-----------------'
- print base_channel.get('label')
+ result.append( '' )
+ result.append( 'Software Channels' )
+ result.append( '-----------------' )
+ result.append( base_channel.get('label') )
for channel in sorted(child_channels):
- print ' |-- %s' % channel
+ result.append( ' |-- %s' % channel )
if len(advanced_options):
- print
- print 'Advanced Options'
- print '----------------'
+ result.append( '' )
+ result.append( 'Advanced Options' )
+ result.append( '----------------' )
for o in sorted(advanced_options, key=itemgetter('name')):
if o.get('arguments'):
- print '%s %s' % (o.get('name'), o.get('arguments'))
+ result.append( '%s %s' % (o.get('name'), o.get('arguments')) )
if len(custom_options):
- print
- print 'Custom Options'
- print '--------------'
+ result.append( '' )
+ result.append( 'Custom Options' )
+ result.append( '--------------' )
for o in sorted(custom_options, key=itemgetter('arguments')):
- print re.sub('\n', '', o.get('arguments'))
+ result.append( re.sub('\n', '', o.get('arguments')) )
if len(partitions):
- print
- print 'Partitioning'
- print '------------'
- print '\n'.join(partitions)
+ result.append( '' )
+ result.append( 'Partitioning' )
+ result.append( '------------' )
+ result.append( '\n'.join(partitions) )
- print
- print 'Software'
- print '--------'
- print '\n'.join(software)
+ result.append( '' )
+ result.append( 'Software' )
+ result.append( '--------' )
+ result.append( '\n'.join(software) )
if len(act_keys):
- print
- print 'Activation Keys'
- print '---------------'
+ result.append( '' )
+ result.append( 'Activation Keys' )
+ result.append( '---------------' )
for k in sorted(act_keys, key=itemgetter('key')):
- print k.get('key')
+ result.append( k.get('key') )
if len(crypto_keys):
- print
- print 'Crypto Keys'
- print '-----------'
+ result.append( '' )
+ result.append( 'Crypto Keys' )
+ result.append( '-----------' )
for k in sorted(crypto_keys, key=itemgetter('description')):
- print k.get('description')
+ result.append( k.get('description') )
if len(file_preservations):
- print
- print 'File Preservations'
- print '------------------'
+ result.append( '' )
+ result.append( 'File Preservations' )
+ result.append( '------------------' )
for fp in sorted(file_preservations, key=itemgetter('name')):
- print fp.get('name')
+ result.append( fp.get('name') )
for profile_name in sorted(fp.get('file_names')):
- print ' |-- %s' % profile_name
+ result.append( ' |-- %s' % profile_name )
if len(variables):
- print
- print 'Variables'
- print '---------'
+ result.append( '' )
+ result.append( 'Variables' )
+ result.append( '---------' )
for k in sorted(variables.keys()):
- print '%s = %s' % (k, str(variables[k]))
+ result.append( '%s = %s' % (k, str(variables[k])) )
if len(scripts):
- print
- print 'Scripts'
- print '-------'
+ result.append( '' )
+ result.append( 'Scripts' )
+ result.append( '-------' )
add_separator = False
for s in scripts:
- if add_separator: print self.SEPARATOR
+ if add_separator: result.append( self.SEPARATOR )
add_separator = True
- print 'Type: %s' % s.get('script_type')
- print 'Chroot: %s' % s.get('chroot')
+ result.append( 'Type: %s' % s.get('script_type') )
+ result.append( 'Chroot: %s' % s.get('chroot') )
if s.get('interpreter'):
- print 'Interpreter: %s' % s.get('interpreter')
+ result.append( 'Interpreter: %s' % s.get('interpreter') )
- print
- print s.get('contents')
+ result.append( '' )
+ result.append( s.get('contents') )
+
+ return result
####################
@@ -2136,4 +2142,72 @@ def import_kickstart_fromdetails(self, ksdetails):
ksdetails['post_kopts'])
return True
+####################
+# kickstart helper
+
+def is_kickstart( self, name ):
+ if not name: return
+ return name in self.do_kickstart_list( name, True )
+
+def check_kickstart( self, name ):
+ if not name:
+ logging.error( "no kickstart label given" )
+ return False
+ if not self.is_kickstart( name ):
+ logging.error( "invalid kickstart label " + name )
+ return False
+ return True
+
+def dump_kickstart(self, name, replacedict=None, excludes=[ "Org Default:" ]):
+ content = self.do_kickstart_details( name )
+
+ content = get_normalized_text( content, replacedict=replacedict, excludes=excludes )
+
+ return content
+
+####################
+
+def help_kickstart_diff(self):
+ print 'kickstart_diff: diff kickstart files'
+ print ''
+ print 'usage: kickstart_diff SOURCE_CHANNEL TARGET_CHANNEL'
+
+def complete_kickstart_diff(self, text, line, beg, end):
+ parts = shlex.split(line)
+ if line[-1] == ' ': parts.append('')
+ args = len(parts)
+
+ if args == 2:
+ return tab_completer(self.do_kickstart_list('', True), text)
+ if args == 3:
+ return tab_completer(self.do_kickstart_list('', True), text)
+ return []
+
+def do_kickstart_diff(self, args):
+ options = []
+
+ (args, options) = parse_arguments(args, options)
+
+ if len(args) != 1 and len(args) != 2:
+ self.help_kickstart_diff()
+ return
+
+ source_channel = args[0]
+ if not self.check_kickstart( source_channel ): return
+
+ target_channel = None
+ if len(args) == 2:
+ target_channel = args[1]
+ elif hasattr( self, "do_kickstart_getcorresponding" ):
+ # can a corresponding channel name be found automatically?
+ target_channel=self.do_kickstart_getcorresponding( source_channel)
+ if not self.check_kickstart( target_channel ): return
+
+ source_replacedict, target_replacedict = get_string_diff_dicts( source_channel, target_channel )
+
+ source_data = self.dump_kickstart( source_channel, source_replacedict )
+ target_data = self.dump_kickstart( target_channel, target_replacedict )
+
+ return diff( source_data, target_data, source_channel, target_channel )
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/softwarechannel.py b/spacecmd/src/lib/softwarechannel.py
index 48ddc0c..a4e0598 100644
--- a/spacecmd/src/lib/softwarechannel.py
+++ b/spacecmd/src/lib/softwarechannel.py
@@ -1399,7 +1399,7 @@ def do_softwarechannel_regenerateyumcache(self, args):
if not len(args):
self.help_softwarechannel_regenerateyumcache()
return
-
+
# allow globbing of software channel names
channels = filter_results(self.do_softwarechannel_list('', True), args)
@@ -1407,4 +1407,72 @@ def do_softwarechannel_regenerateyumcache(self, args):
logging.debug('Regenerating YUM cache for %s' % channel)
self.client.channel.software.regenerateYumCache(self.session, channel)
+####################
+# softwarechannel helper
+
+def is_softwarechannel( self, name ):
+ if not name: return
+ return name in self.do_softwarechannel_list( name, True )
+
+def check_softwarechannel( self, name ):
+ if not name:
+ logging.error( "no softwarechannel label given" )
+ return False
+ if not self.is_softwarechannel( name ):
+ logging.error( "invalid softwarechannel label " + name )
+ return False
+ return True
+
+def dump_softwarechannel(self, name, replacedict=None, excludes=[]):
+ content = self.do_softwarechannel_listallpackages( name, doreturn=True )
+
+ content = get_normalized_text( content, replacedict=replacedict, excludes=excludes )
+
+ return content
+
+####################
+
+def help_softwarechannel_diff(self):
+ print 'softwarechannel_diff: diff softwarechannel files'
+ print ''
+ print 'usage: softwarechannel_diff SOURCE_CHANNEL TARGET_CHANNEL'
+
+def complete_softwarechannel_diff(self, text, line, beg, end):
+ parts = shlex.split(line)
+ if line[-1] == ' ': parts.append('')
+ args = len(parts)
+
+ if args == 2:
+ return tab_completer(self.do_softwarechannel_list('', True), text)
+ if args == 3:
+ return tab_completer(self.do_softwarechannel_list('', True), text)
+ return []
+
+def do_softwarechannel_diff(self, args):
+ options = []
+
+ (args, options) = parse_arguments(args, options)
+
+ if len(args) != 1 and len(args) != 2:
+ self.help_softwarechannel_diff()
+ return
+
+ source_channel = args[0]
+ if not self.check_softwarechannel( source_channel ): return
+
+ target_channel = None
+ if len(args) == 2:
+ target_channel = args[1]
+ elif hasattr( self, "do_softwarechannel_getcorresponding" ):
+ # can a corresponding channel name be found automatically?
+ target_channel=self.do_softwarechannel_getcorresponding( source_channel)
+ if not self.check_softwarechannel( target_channel ): return
+
+ # softwarechannel do not contain references to other components,
+ # therefore there is no need to use replace dicts
+ source_data = self.dump_softwarechannel( source_channel, None )
+ target_data = self.dump_softwarechannel( target_channel, None )
+
+ return diff( source_data, target_data, source_channel, target_channel )
+
# vim:ts=4:expandtab:
diff --git a/spacecmd/src/lib/utils.py b/spacecmd/src/lib/utils.py
index 6292f5a..0a7c4c5 100644
--- a/spacecmd/src/lib/utils.py
+++ b/spacecmd/src/lib/utils.py
@@ -23,6 +23,7 @@
import logging, os, pickle, re, readline, shlex, sys, time, xmlrpclib
from datetime import datetime, timedelta
+from difflib import unified_diff, SequenceMatcher
from optparse import OptionParser
from tempfile import mkstemp
from textwrap import wrap
@@ -633,6 +634,67 @@ def json_read_from_file(filename):
print "could not open file %s for reading, check permissions?" % filename
return None
+def get_string_diff_dicts( string1, string2 ):
+ replace1 = {}
+ replace2 = {}
+ s = SequenceMatcher(None, string1, string2)
+ for tag, i1a, i1b, i2a, i2b in s.get_opcodes():
+ sub1=string1[i1a:i1b]
+ sub2=string2[i2a:i2b]
+ if tag == "equal":
+ # equal, nothing to do
+ pass
+ elif tag == "replace":
+ replace1[sub1] = "DIFF("+sub1+"|"+sub2+")"
+ replace2[sub2] = "DIFF("+sub1+"|"+sub2+")"
+ else:
+ # "insert" or "delete"
+ # can't handle this
+ #logging.debug( "will not handle differences " + sub1 + sub2 )
+ logging.debug( "Too many differences between " + string1 + " and " + string2 + ". Skipping usage of common strings." )
+ return [None,None]
+ return [replace1,replace2]
+
+def replace( line, replacedict ):
+ if replacedict:
+ for source in replacedict:
+ line = line.replace( source, replacedict[source] )
+ return line
+
+def get_normalized_text( text, replacedict=None, excludes=_DIFF_EXCLUDES ):
+ # parts of the data inside the spacewalk component information
+ # is not relevant for showing real differences between two instances.
+ # Therefore parts of the data will be modified before the real diff:
+ # - specific lines, starting with a defined keyword, will be excluded
+ # - specific character sequences will be replaced with the same text in both instances.
+ # Example:
+ # we want to compare two activationkeys from different stages:
+ # "1-rhel6-x86_64-dev" and "1-rhel6-x86_64-prd"
+ # ("dev" for "development" and "prd" for "production").
+ # We assume that the "dev" activationkey "1-rhel6-x86_64-dev"
+ # has references to other "dev" components,
+ # while the "prd" activationkey "1-rhel6-x86_64-prd"
+ # has references to other "prd" components.
+ # Therefore we replace all occurrences of "dev" in "1-rhel6-x86_64-dev"
+ # and all occurrences of "prd" in "1-rhel6-x86_64-prd"
+ # with the common string "DIFF(dev|prd)".
+ # What differences are to be replaced is guessed
+ # from the name differences of there components.
+ # This will not work always, but it help in a lot of cases.
+
+ normalized_text = []
+ if text:
+ for string in text:
+ for line in string.split( "\n" ):
+ if not excludes or not line.startswith( tuple(excludes) ):
+ normalized_text.append( replace( line, replacedict ) )
+ else:
+ logging.debug( "excluding line: " + line )
+ return normalized_text
+
+def diff( source_data, target_data, source_channel, target_channel ):
+ return unified_diff( source_data, target_data, source_channel, target_channel )
+
def file_needs_b64_enc(self, contents):
# Used to check if files (config files primarily) need base64 encoding
commit ca0f6922df50666512c9b516a0026da4669f8da3
Author: Joerg Steffens <joerg.steffens(a)dass-it.de>
Date: Thu May 10 21:21:08 2012 +0200
print return values
Signed-off-by: Aron Parsons <aronparsons(a)gmail.com>
diff --git a/spacecmd/src/bin/spacecmd b/spacecmd/src/bin/spacecmd
index 6b11f5b..29970ab 100755
--- a/spacecmd/src/bin/spacecmd
+++ b/spacecmd/src/bin/spacecmd
@@ -122,7 +122,8 @@ if __name__ == '__main__':
command += ' %s' % ' '.join("'%s'" % s for s in args[1:])
# run the command
- shell.onecmd(shell.precmd(command))
+ precmd = shell.precmd(command)
+ shell.print_result(shell.onecmd( precmd ), precmd)
except KeyboardInterrupt:
print
print 'User Interrupt'
diff --git a/spacecmd/src/lib/shell.py b/spacecmd/src/lib/shell.py
index c8829bc..351cd9a 100644
--- a/spacecmd/src/lib/shell.py
+++ b/spacecmd/src/lib/shell.py
@@ -188,7 +188,18 @@ class SpacewalkShell(Cmd):
# update the prompt with the SSM size
- def postcmd(self, stop, line):
+ def postcmd(self, cmdresult, cmd):
+ self.print_result( cmdresult, cmd )
self.prompt = re.sub('##', str(len(self.ssm)), self.prompt_template)
+ def print_result( self, cmdresult, cmd ):
+ logging.debug( cmd + ": " + repr(cmdresult) )
+ if cmd:
+ try:
+ for i in cmdresult:
+ print i
+ except TypeError:
+ pass
+
+
# vim:ts=4:expandtab:
12 years