-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add zypper arguments to snapshot description #315
base: master
Are you sure you want to change the base?
add zypper arguments to snapshot description #315
Conversation
update scripts/zypp-plugin.py to extend the snapshot description with zypper cmdline arguments when zypp is run from zypper. could be made universal by parsing TransactionStepList, maybe
example output from snapper list: |
That is a really good idea.
|
scripts/zypp-plugin.py
Outdated
@@ -153,7 +159,7 @@ def PLUGINBEGIN(self, headers, body): | |||
|
|||
logging.debug("headers: %s" % headers) | |||
|
|||
self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid())) | |||
self.description = "zypp(%s) %s" % (basename(readlink("/proc/%d/exe" % getppid())), self.zypper_arguments()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFIAS the description has a trailing whitespace if it's not from zypper. That's not nice.
In general the patch looks OK. But from my experience the command line for zypper can be very long (spanning several lines) and that will make the output of snapper unreadable (see #268). Could you make adding the arguments optional (controlled via zypp-plugin.conf)? |
Instead of loosing information I'd rather fix #268 instead. |
only append zypper command line arguments to the snapshot description if <zypper-extended-description enabled="true"> is set inside <description> in <snapper-zypp-plugin-conf>. set the element inside zypper-extended-description to N in order to cut the zypper commandline description after N chars. defaults to 0 (unlimited output). <description> <zypper-extended-description enabled="true">32</zypper-extended-description> </description>
ok, I tried to make the required changes |
eliminate trailing whitespace in description when basename is not zypper
data/zypp-plugin.conf
Outdated
@@ -17,7 +17,7 @@ | |||
</solvables> | |||
|
|||
<!-- Set enabled to "true" in order to save zypper commandline arguments in snapshot descriptions. | |||
By default output the arguments (not including zypp(zypper) ) is truncated to 32 chars. Set to 0 for unlimited output. --> | |||
by default argoments following zypp(zypper) are truncated at 32 chars. change to 0 for unlimited output --> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo in arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks
scripts/zypp-plugin.py
Outdated
@@ -56,6 +56,9 @@ class Config: | |||
|
|||
def __init__(self): | |||
self.solvables = [] | |||
self.zypper_extended_description = [] | |||
self.zypper_extended_description.append("false") | |||
self.zypper_extended_description.append("0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use an array to store two values of different type and meaning. Just use e.g. self.zypper_extended_description_enable = false
and self.zypper_extended_description_length = 0
.
scripts/zypp-plugin.py
Outdated
self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid())) | ||
if config.zypper_extended_description[0] != "true": | ||
self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid())) | ||
elif config.zypper_extended_description[0] == "true": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simple else
is enough here.
scripts/zypp-plugin.py
Outdated
if config.zypper_extended_description[0] != "true": | ||
self.description = "zypp(%s)" % basename(readlink("/proc/%d/exe" % getppid())) | ||
elif config.zypper_extended_description[0] == "true": | ||
self.description = "zypp(%s)%s" % (basename(readlink("/proc/%d/exe" % getppid())), self.zypper_arguments()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The basename(readlink(...
code is twice here. You could do something like:
self.description = basename(readlink("/proc/%d/exe" % getppid()))
if zypper_extended_description_enabled
self.description.append(self.zypper_arguments())
ok, thanks for the suggestions |
scripts/zypp-plugin.py
Outdated
@@ -56,6 +56,8 @@ class Config: | |||
|
|||
def __init__(self): | |||
self.solvables = [] | |||
self.self.zypper_extended_description_enabled = "false" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use False
. Python has booleans.
scripts/zypp-plugin.py
Outdated
loggin.error("unknown extended-config enabled attribute %s" % description_enabled) | ||
continue | ||
if description_enabled == "true": | ||
self.zypper_extended_description_enabled = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use True
.
scripts/zypp-plugin.py
Outdated
argument = " " + " ".join(open("/proc/%s/cmdline" % getppid()).read().split('\x00')[1:]) | ||
else: | ||
return "" | ||
if config.zypper_extended_description_length == "0": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just plain 0
.
try: | ||
for tmp3 in dom.getElementsByTagName("description"): | ||
for tmp4 in tmp3.getElementsByTagName("zypper-extended-description"): | ||
string_size = tmp4.childNodes[0].data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert to int here instead of below.
were the required fixes ok? |
update scripts/zypp-plugin.py to extend the snapshot description with zypper cmdline arguments when zypp is run from zypper. could be made universal by parsing TransactionStepList, maybe