-
Notifications
You must be signed in to change notification settings - Fork 12
CFE-3635: Prototyped dnf_appstream custom promise type #117
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
base: master
Are you sure you want to change the base?
Conversation
larsewi
left a comment
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.
GJ 🚀
I wasn't looking at the ticket prior to implementation, likely missing things. Ticket: CFE-3653
- Improve state validation error message. - Move validation to attribute validators. - Simplify state checking logic. - Use info logging for repairs. - Remove redundant try/except blocks. - Add test and documentation files.
af7b8f4 to
568afb1
Compare
larsewi
left a comment
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.
Some comments 😉
Added ability to reset/default a module as well as specify "default" for the profile or stream.
|
ok @larsewi 🫣 |
2c33c57 to
a1d6535
Compare
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.
Getting closer 😉 Please format with black and run a linter like pyright or similar
| profile = attributes.get("profile", None) | ||
|
|
||
| try: | ||
| from libdnf.module import ModulePackageContainer |
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.
libdnf.module.ModulePackageContainer imported but never used
| base.read_all_repos() | ||
|
|
||
| # Fill the sack (package database) | ||
| base.fill_sack(load_system_repo='auto') |
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.
Assigning string to an argument of type bool
| base.fill_sack(load_system_repo='auto') | ||
|
|
||
| # Get ModulePackageContainer from sack | ||
| if hasattr(base.sack, '_moduleContainer'): |
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.
| if hasattr(base.sack, '_moduleContainer'): | |
| if hasattr(base.sack, '_moduleContainer'): | |
| assert base.sack is not None |
if you are certain that it is not None. Otherwise, check for None
| f"dot, and dash characters are allowed." | ||
| ) | ||
|
|
||
| def validate_promise(self, promiser, attributes, meta): |
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.
Parameter 4 name mismatch: base parameter is named "metadata", override parameter is named "meta".
| def validate_promise(self, promiser, attributes, meta): | |
| def validate_promise(self, promiser, attributes, metadata): |
|
|
||
| self._validate_module_name(promiser) | ||
|
|
||
| def evaluate_promise(self, promiser, attributes, meta): |
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.
Parameter 4 name mismatch: base parameter is named "metadata", override parameter is named "meta".
| def evaluate_promise(self, promiser, attributes, meta): | |
| def validate_promise(self, promiser, attributes, metadata): |
| else: | ||
| self.log_error(f"Failed to enable module {module_name}:{target_stream}") | ||
| return Result.NOT_KEPT | ||
| except Exception as e: |
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.
What exception do you expect here? Please don't handle all exceptions.
| else: | ||
| self.log_error(f"Failed to disable module {module_name}") | ||
| return Result.NOT_KEPT | ||
| except Exception as e: |
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.
What exception do you expect here? Please don't handle all exceptions.
| if not profile: | ||
| profile = self._get_default_profile(mpc, module_name, stream) | ||
|
|
||
| if not profile: |
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.
| if not profile: | |
| profile = self._get_default_profile(mpc, module_name, stream) | |
| if not profile: | |
| if not profile: | |
| profile = self._get_default_profile(mpc, module_name, stream) |
| try: | ||
| base.remove(pkg) | ||
| # dnf.exceptions.Error catches package not installed, etc. | ||
| except dnf.exceptions.Error as e: |
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.
exceptions is not a known attribute of module dnf
| # state => "default"; | ||
| # } | ||
|
|
||
| import dnf |
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.
Missing import
| import dnf | |
| import dnf | |
| import dnf.exceptions |
I wasn't looking at the ticket prior to implementation, likely missing things.
Ticket: CFE-3635