Skip to content

Commit

Permalink
Move error message to a constant
Browse files Browse the repository at this point in the history
  • Loading branch information
algomaster99 committed Nov 13, 2019
1 parent f6a6d2e commit 1ca054c
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions dvc/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

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."""
Expand Down Expand Up @@ -72,14 +78,7 @@ def lock(self):
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)
Expand Down Expand Up @@ -124,14 +123,7 @@ def _do_lock(self):
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:
Expand Down

0 comments on commit 1ca054c

Please sign in to comment.