Files
dvc/dvc/command/status.py
T
Ruslan Kuprieiev 71fef4d857 dvc: add basic 'dvc status'
(dvc) ➜  myrepo git:(master) ✗ dvc status
foo.dvc
        outs
                changed:  foo
foo2.dvc
        outs
                changed:  foo2
        deps
                changed:  foo1
foo1.dvc
        outs
                changed:  foo1
        deps
                changed:  foo

(dvc) ➜  myrepo git:(master) ✗ dvc status --cloud

        new:      c1/57a79031e1c40f85931829bc5fc552

Signed-off-by: Ruslan Kuprieiev <[email protected]>
2018-03-16 10:58:09 +02:00

37 lines
1.1 KiB
Python

import os
import dvc.cloud.base as cloud
from dvc.command.data_sync import CmdDataBase
class CmdDataStatus(CmdDataBase):
STATUS_LEN = 10
STATUS_INDENT = '\t'
def _normalize(self, s):
s+=':'
if len(s) >= self.STATUS_LEN:
return s
return s + (self.STATUS_LEN - len(s))*' '
def _show(self, status, indent=0):
ind = indent * self.STATUS_INDENT
for key, value in status.items():
if isinstance(value, dict):
self.project.logger.info('{}{}'.format(ind, key))
self._show(value, indent+1)
else:
self.project.logger.info('{}{}{}'.format(ind, self._normalize(value), key))
def do_run(self, target=None):
indent = 1 if self.args.cloud else 0
try:
status = self.project.status(target=target, jobs=self.args.jobs, cloud=self.args.cloud)
self._show(status, indent)
except Exception as exc:
self.project.logger.error('Failed to obtain data status', exc)
return 1
return 0