Created
March 18, 2015 19:26
-
-
Save adam-stokes/94dd3787372c72d37c41 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update(self): | |
for cc in self.controller.charm_classes(): | |
if self.machine: | |
if not satisfies(self.machine, cc.constraints)[0] \ | |
or not self.controller.is_assigned(cc, self.machine): | |
self.remove_service_widget(cc) | |
continue | |
if self.unplaced_only: | |
n_units = self.controller.machine_count_for_charm(cc) | |
if n_units == cc.required_num_units() \ | |
and cc not in self.controller.unplaced_services: | |
self.remove_service_widget(cc) | |
continue | |
is_required = self.controller.get_charm_state(cc)[0] | |
print(is_required) | |
if self.show_type == 'required': | |
if is_required[0] != CharmState.REQUIRED: | |
self.remove_service_widget(cc) | |
continue | |
elif self.show_type == 'non-required': | |
if is_required[0] == CharmState.REQUIRED: | |
self.remove_service_widget(cc) | |
continue | |
if not cc.allow_multi_units and \ | |
cc not in self.controller.unplaced_services: | |
self.remove_service_widget(cc) | |
continue | |
sw = self.find_service_widget(cc) | |
if sw is None: | |
sw = self.add_service_widget(cc) | |
sw.update() |
also I'd rename 'is_required' to 'state', since it isn't a bool
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
in line 17 you're getting just the state from the tuple with the [0] at the end, then in line 20 you're trying to subscript a CharmState enum. you only need one of those subsets. (same issue with 24 as 20)