Skip to content

Commit

Permalink
Implemented the functions to read more info from package_info file
Browse files Browse the repository at this point in the history
  • Loading branch information
mvanbaak committed Jan 27, 2022
1 parent e99d58d commit c91597f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
8 changes: 8 additions & 0 deletions bazarr/api/system/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@
class SystemStatus(Resource):
@authenticate
def get(self):
package_version = ''
if 'BAZARR_PACKAGE_VERSION' in os.environ:
package_version = os.environ['BAZARR_PACKAGE_VERSION']
if 'BAZARR_PACKAGE_AUTHOR' in os.environ and os.environ['BAZARR_PACKAGE_AUTHOR'] != '':
package_version = f'{package_version} by {os.environ["BAZARR_PACKAGE_AUTHOR"]}'

system_status = {}
system_status.update({'bazarr_version': os.environ["BAZARR_VERSION"]})
system_status.update({'package_version': package_version})
system_status.update({'sonarr_version': get_sonarr_info.version()})
system_status.update({'radarr_version': get_radarr_info.version()})
system_status.update({'operating_system': platform.platform()})
system_status.update({'python_version': platform.python_version()})
system_status.update({'bazarr_directory': os.path.dirname(os.path.dirname(__file__))})
system_status.update({'bazarr_config_directory': args.config_dir})
system_status.update({'start_time': startTime})

return jsonify(data=system_status)
13 changes: 11 additions & 2 deletions bazarr/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ def is_virtualenv():
with open(os.path.join(args.config_dir, 'config', 'config.ini'), 'w+') as handle:
settings.write(handle)

# make sure settings.general.branch is properly set when running inside a docker container
# Read package_info (if exists) to override some settings by package maintainers
# This file can also provide some info about the package version and author
package_info_file = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'package_info')
if os.path.isfile(package_info_file):
try:
Expand All @@ -132,13 +133,21 @@ def is_virtualenv():
for line in lines:
splitted_lines += line.split(r'\n')
for line in splitted_lines:
splitted_line = line.split('=')
splitted_line = line.split('=', 1)
if len(splitted_line) == 2:
package_info[splitted_line[0].lower()] = splitted_line[1].replace('\n', '')
else:
continue
# package author can force a branch to follow
if 'branch' in package_info:
settings.general.branch = package_info['branch']
# package author can disable update
if package_info.get('updatemethod', '') == 'External':
os.environ['BAZARR_UPDATE_ALLOWED'] = '0'
os.environ['BAZARR_UPDATE_MESSAGE'] = package_info.get('updatemethodmessage', '')
# package author can provide version and contact info
os.environ['BAZARR_PACKAGE_VERSION'] = package_info.get('packageversion', '')
os.environ['BAZARR_PACKAGE_AUTHOR'] = package_info.get('packageauthor', '')
except Exception:
pass
else:
Expand Down
1 change: 1 addition & 0 deletions frontend/src/@types/system.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ declare namespace System {
bazarr_directory: string;
bazarr_version: string;
operating_system: string;
package_version: string;
python_version: string;
radarr_version: string;
sonarr_version: string;
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/pages/System/Status/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@ const SystemStatusView: FunctionComponent<Props> = () => {
<CRow title="Bazarr Version">
<span>{status?.bazarr_version}</span>
</CRow>
{status?.package_version !== "" && (
<CRow title="Package Version">
<span>{status?.package_version}</span>
</CRow>
)}
<CRow title="Sonarr Version">
<span>{status?.sonarr_version}</span>
</CRow>
Expand Down

0 comments on commit c91597f

Please sign in to comment.