diff --git a/dvc/lock.py b/dvc/lock.py index dc6c52b23..777afa031 100644 --- a/dvc/lock.py +++ b/dvc/lock.py @@ -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: