mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-12-21 23:00:38 -08:00
@@ -188,7 +188,8 @@ def list_plugins(args, config, pattern='*'):
|
|||||||
"""
|
"""
|
||||||
found = False
|
found = False
|
||||||
|
|
||||||
line = "|{name:^{width}}|{version:^9}|{enabled:^10}|{status:^15}|"
|
# MODIFIED: Added {author} placeholder
|
||||||
|
line = "|{name:^{width}}|{version:^9}|{enabled:^10}|{status:^15}|{author:^22}|"
|
||||||
|
|
||||||
available = _get_available()
|
available = _get_available()
|
||||||
installed = _get_installed(config)
|
installed = _get_installed(config)
|
||||||
@@ -201,8 +202,9 @@ def list_plugins(args, config, pattern='*'):
|
|||||||
print('Maybe try: sudo pwnagotchi plugins update')
|
print('Maybe try: sudo pwnagotchi plugins update')
|
||||||
return 1
|
return 1
|
||||||
max_len = max(map(len, max_len_list))
|
max_len = max(map(len, max_len_list))
|
||||||
header = line.format(name='Plugin', width=max_len, version='Version', enabled='Active', status='Status')
|
# MODIFIED: Added author to the header format
|
||||||
line_length = max(max_len, len('Plugin')) + len(header) - len('Plugin') - 12 # lol
|
header = line.format(name='Plugin', width=max_len, version='Version', enabled='Active', status='Status', author='Author')
|
||||||
|
line_length = len(header) - 10 # Adjusted for new column length
|
||||||
|
|
||||||
print('-' * line_length)
|
print('-' * line_length)
|
||||||
print(header)
|
print(header)
|
||||||
@@ -225,17 +227,19 @@ def list_plugins(args, config, pattern='*'):
|
|||||||
status = "installed (^)"
|
status = "installed (^)"
|
||||||
|
|
||||||
enabled = 'enabled' if (plugin in config['main']['plugins'] and
|
enabled = 'enabled' if (plugin in config['main']['plugins'] and
|
||||||
'enabled' in config['main']['plugins'][plugin] and
|
'enabled' in config['main']['plugins'][plugin] and
|
||||||
config['main']['plugins'][plugin]['enabled']) else 'disabled'
|
config['main']['plugins'][plugin]['enabled']) else 'disabled'
|
||||||
|
|
||||||
print(line.format(name=plugin, width=max_len, version='.'.join(installed_version), enabled=enabled, status=status))
|
# MODIFIED: Added author=_extract_author(filename) to the print format
|
||||||
|
print(line.format(name=plugin, width=max_len, version='.'.join(installed_version), enabled=enabled, status=status, author=_extract_author(filename)))
|
||||||
|
|
||||||
for plugin in sorted(available_not_installed):
|
for plugin in sorted(available_not_installed):
|
||||||
if not fnmatch(plugin, pattern):
|
if not fnmatch(plugin, pattern):
|
||||||
continue
|
continue
|
||||||
found = True
|
found = True
|
||||||
available_version = _extract_version(available[plugin])
|
available_version = _extract_version(available[plugin])
|
||||||
print(line.format(name=plugin, width=max_len, version='.'.join(available_version), enabled='-', status='available'))
|
# MODIFIED: Added author=_extract_author(available[plugin]) to the print format
|
||||||
|
print(line.format(name=plugin, width=max_len, version='.'.join(available_version), enabled='-', status='available', author=_extract_author(available[plugin])))
|
||||||
|
|
||||||
print('-' * line_length)
|
print('-' * line_length)
|
||||||
|
|
||||||
@@ -256,6 +260,22 @@ def _extract_version(filename):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
# NEW FUNCTION ADDED
|
||||||
|
def _extract_author(filename):
|
||||||
|
"""
|
||||||
|
Extracts the author from a python file
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
with open(filename, 'rt', errors='ignore') as f:
|
||||||
|
plugin_content = f.read()
|
||||||
|
m = re.search(r'__author__[\t ]*=[\t ]*[\'\"]([^\"\']+)', plugin_content)
|
||||||
|
if m:
|
||||||
|
return m.groups()[0]
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return 'n/a' # Return 'n/a' if author not found
|
||||||
|
|
||||||
|
|
||||||
def _get_available():
|
def _get_available():
|
||||||
"""
|
"""
|
||||||
Get all availaible plugins
|
Get all availaible plugins
|
||||||
@@ -413,4 +433,3 @@ def update(config):
|
|||||||
logging.error('Error while updating plugins: %s', ex)
|
logging.error('Error while updating plugins: %s', ex)
|
||||||
rc = 1
|
rc = 1
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user