Move error message to a constant

This commit is contained in:
Aman Sharma
2019-11-13 23:55:39 +05:30
parent f6a6d2eef9
commit 1ca054c2fb
+8 -16
View File
@@ -16,6 +16,12 @@ from dvc.utils.compat import is_py3
DEFAULT_TIMEOUT = 5
ERROR_MESSAGE = (
"cannot perform the cmd since DVC is busy and locked. You can delete "
".dvc/lock to fix it, but first please make sure there's no other dvc "
"process ongoing by running: {blue}`ps xaf | grep dvc`{nc}."
).format(blue=colorama.Back.BLUE, nc=colorama.Back.RESET)
class LockError(DvcException):
"""Thrown when unable to acquire the lock for dvc repo."""
@@ -72,14 +78,7 @@ if is_py3:
try:
super(Lock, self).lock(timedelta(seconds=DEFAULT_TIMEOUT))
except flufl.lock.TimeOutError:
raise LockError(
"cannot perform the cmd since DVC is busy and "
"locked. You can delete .dvc/lock to fix it, but first "
"please make sure there's no other dvc process ongoing "
"by running: {blue}`ps xaf | grep dvc`{nc}.".format(
blue=colorama.Back.BLUE, nc=colorama.Back.RESET
)
)
raise LockError(ERROR_MESSAGE)
def _set_claimfile(self, pid=None):
super(Lock, self)._set_claimfile(pid)
@@ -124,14 +123,7 @@ else:
try:
self._lock = zc.lockfile.LockFile(self.lockfile)
except zc.lockfile.LockError:
raise LockError(
"cannot perform the cmd since DVC is busy and "
"locked. You can delete .dvc/lock to fix it, but first "
"please make sure there's no other dvc process ongoing "
"by running: {blue}`ps xaf | grep dvc`{nc}.".format(
blue=colorama.Back.BLUE, nc=colorama.Back.RESET
)
)
raise LockError(ERROR_MESSAGE)
def lock(self):
try: