Skip to content

Commit 8a00d19

Browse files
committed
Stored messages denoting update success or failure in variables to minimise repetition and enable ease of use in test suite; added comment for when an 'exit()' is not needed
1 parent 40397d3 commit 8a00d19

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/murfey/client/update.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
import murfey
1010
from murfey.util.api import url_path_for
1111

12+
# Standardised messages to print upon exit
13+
UPDATE_SUCCESS = "Murfey has been updated. Please restart Murfey."
14+
UPDATE_FAILURE = "Error occurred while updating Murfey."
15+
1216

1317
def check(api_base: ParseResult, install: bool = True, force: bool = False):
1418
"""
@@ -40,21 +44,20 @@ def check(api_base: ParseResult, install: bool = True, force: bool = False):
4044
)
4145
result = install_murfey(api_base, versions["server"])
4246
if result:
43-
print("\nMurfey has been updated. Please restart Murfey")
44-
exit()
47+
exit(UPDATE_SUCCESS)
4548
else:
46-
exit("Error occurred while updating Murfey")
49+
exit(UPDATE_FAILURE)
4750

4851
if versions["server"] != murfey.__version__:
4952
if force:
5053
result = install_murfey(api_base, versions["server"])
5154
if result:
52-
print("\nMurfey has been updated. Please restart Murfey")
53-
exit()
55+
exit(UPDATE_SUCCESS)
5456
else:
55-
exit("Error occurred while updating Murfey")
57+
exit(UPDATE_FAILURE)
5658
else:
57-
print("An update is available, install with 'murfey update'.")
59+
# Allow Murfey to start, but print an update prompt
60+
print("An update is available, install with 'murfey.client --update'.")
5861

5962

6063
def install_murfey(api_base: ParseResult, version: str) -> bool:

0 commit comments

Comments
 (0)