MCPcopy
hub / github.com/saltstack/salt / search

Method search

salt/utils/win_update.py:584–648  ·  view source on GitHub ↗

Search for either a single update or a specific list of updates. GUIDs are searched first, then KB numbers, and finally Titles. Args: search_string (str, list): The search string to use to find the update. This can be the GUID or

(self, search_string)

Source from the content-addressed store, hash-verified

582 return updates
583
584 def search(self, search_string):
585 """
586 Search for either a single update or a specific list of updates. GUIDs
587 are searched first, then KB numbers, and finally Titles.
588
589 Args:
590
591 search_string (str, list):
592 The search string to use to find the update. This can be the
593 GUID or KB of the update (preferred). It can also be the full
594 Title of the update or any part of the Title. A partial Title
595 search is less specific and can return multiple results.
596
597 Returns:
598 Updates: An instance of Updates with the results of the search
599
600 Code Example:
601
602 .. code-block:: python
603
604 import salt.utils.win_update
605 wua = salt.utils.win_update.WindowsUpdateAgent()
606
607 # search for a single update and show its details
608 updates = wua.search('KB3194343')
609 updates.list()
610
611 # search for a list of updates and show their details
612 updates = wua.search(['KB3195432', '12345678-abcd-1234-abcd-1234567890ab'])
613 updates.list()
614 """
615 updates = Updates()
616 found = updates.updates
617
618 if isinstance(search_string, str):
619 search_string = [search_string]
620
621 if isinstance(search_string, int):
622 search_string = [str(search_string)]
623
624 for update in self._updates:
625
626 for find in search_string:
627
628 # Search by GUID
629 if find == update.Identity.UpdateID:
630 found.Add(update)
631 continue
632
633 # Search by KB
634 if find in ["KB" + item for item in update.KBArticleIDs]:
635 found.Add(update)
636 continue
637
638 # Search by KB without the KB in front
639 if find in [item for item in update.KBArticleIDs]:
640 found.Add(update)
641 continue

Callers 15

getFunction · 0.95
downloadFunction · 0.95
installFunction · 0.95
uninstallFunction · 0.95
installedFunction · 0.95
removedFunction · 0.95
uptodateFunction · 0.95
check_module_indexesFunction · 0.45
parse_pytest_failuresFunction · 0.45
pr_failuresFunction · 0.45

Calls 2

UpdatesClass · 0.70
AddMethod · 0.45

Tested by 15

test_commitMethod · 0.36
test_wheelFunction · 0.36
test_eggFunction · 0.36
test_a_leader_is_electedFunction · 0.36
_testrpm_signedFunction · 0.36
test_version_parsingFunction · 0.36