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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
also I'd rename 'is_required' to 'state', since it isn't a bool