mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-06 07:18:28 +01:00
25 lines
675 B
Python
25 lines
675 B
Python
from dvc.exceptions import DvcException
|
|
from dvc.command.base import CmdBase
|
|
|
|
|
|
class CmdLockBase(CmdBase):
|
|
def run(self, unlock=False):
|
|
for target in self.args.targets:
|
|
try:
|
|
self.project.lock_stage(target, unlock=unlock)
|
|
except DvcException as ex:
|
|
msg = 'Failed to {}lock \'{}\''.format('un' if unlock else '', target)
|
|
self.project.logger.error(msg, ex)
|
|
return 1
|
|
return 0
|
|
|
|
|
|
class CmdLock(CmdLockBase):
|
|
def run(self):
|
|
return super(CmdLock, self).run(False)
|
|
|
|
|
|
class CmdUnlock(CmdLockBase):
|
|
def run(self):
|
|
return super(CmdUnlock, self).run(True)
|