MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / execute

Method execute

keepercommander/commands/utils.py:1594–1645  ·  view source on GitHub ↗
(self, params, **kwargs)

Source from the content-addressed store, hash-verified

1592 return False
1593
1594 def execute(self, params, **kwargs):
1595 version_details = is_up_to_date_version(params)
1596 is_verbose = kwargs.get('verbose', False)
1597 show_packages = kwargs.get('packages', False)
1598
1599 this_app_version = __version__
1600
1601 if version_details.get('is_up_to_date') is None:
1602 this_app_version = f'{this_app_version} (Current version)'
1603
1604 if not is_verbose:
1605 print('{0}: {1}'.format('Commander Version', this_app_version))
1606 else:
1607 print('{0:>20s}: {1}'.format('Commander Version', this_app_version))
1608 print("{0:>20s}: {1}".format('API Client Version', rest_api.CLIENT_VERSION))
1609 print('{0:>20s}: {1}'.format('Python Version', sys.version.replace("\n", "")))
1610 print('{0:>20s}: {1}'.format('Operating System', loginv3.CommonHelperMethods.get_os() + '(' + platform.release() + ')'))
1611 print('{0:>20s}: {1}'.format('Working directory', os.getcwd()))
1612 print('{0:>20s}: {1}'.format('Package directory', os.path.dirname(api.__file__)))
1613 print('{0:>20s}: {1}'.format('Config. File', params.config_filename))
1614 print('{0:>20s}: {1}'.format('Executable', sys.executable))
1615
1616 if logging.getLogger().isEnabledFor(logging.DEBUG) or show_packages:
1617 import importlib.metadata
1618 dist = importlib.metadata.packages_distributions()
1619 packages = {}
1620 for pack in dist.values():
1621 if isinstance(pack, list) and len(pack) > 0:
1622 name = pack[0]
1623 if name in packages:
1624 continue
1625 try:
1626 version = importlib.metadata.version(name)
1627 packages[name] = version
1628 except Exception as e:
1629 logging.debug('Get package %s version error: %s', name, e)
1630 installed_packages_list = [f'{x[0]}=={x[1]}' for x in packages.items()]
1631 installed_packages_list.sort(key=lambda x: x.lower())
1632 print('{0:>20s}: {1}'.format('Packages', installed_packages_list))
1633
1634 if version_details.get('is_up_to_date') is None:
1635 logging.debug("It appears that Commander is up to date")
1636 elif not version_details.get('is_up_to_date'):
1637
1638 latest_version = version_details.get('current_github_version')
1639
1640 print((bcolors.WARNING +
1641 'Latest Commander Version: %s\n'
1642 'You can download the current version at: %s \n' + bcolors.ENDC)
1643 % (latest_version, version_details.get('new_version_download_url')))
1644 if is_binary_app():
1645 print("Installation path: {0} ".format(sys._MEIPASS))
1646
1647
1648class KeepAliveCommand(Command):

Callers

nothing calls this directly

Calls 7

is_up_to_date_versionFunction · 0.85
is_binary_appFunction · 0.85
getMethod · 0.80
formatMethod · 0.80
get_osMethod · 0.80
versionMethod · 0.80
debugMethod · 0.45

Tested by

no test coverage detected