mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 23:09:35 +01:00
Extract run() to utils
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import sys
|
||||
import os
|
||||
from shutil import copyfile
|
||||
import re
|
||||
@@ -10,6 +9,7 @@ from dvc.cmd_data_sync import sizeof_fmt
|
||||
from dvc.logger import Logger
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.state_file import StateFile
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class DataImportError(NeatLynxException):
|
||||
@@ -138,10 +138,5 @@ class CmdDataImport(CmdBase):
|
||||
f.write(chunk)
|
||||
return
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
sys.exit(CmdDataImport().run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdDataImport())
|
||||
|
||||
@@ -6,6 +6,7 @@ from boto.s3.connection import S3Connection
|
||||
from dvc.cmd_base import CmdBase
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.logger import Logger
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class DataRemoveError(NeatLynxException):
|
||||
@@ -129,9 +130,4 @@ class CmdDataRemove(CmdBase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
try:
|
||||
sys.exit(CmdDataRemove().run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdDataRemove())
|
||||
|
||||
@@ -6,6 +6,7 @@ from boto.s3.connection import S3Connection
|
||||
from dvc.cmd_base import CmdBase
|
||||
from dvc.logger import Logger
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class DataSyncError(NeatLynxException):
|
||||
@@ -113,9 +114,4 @@ class CmdDataSync(CmdBase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
try:
|
||||
sys.exit(CmdDataSync().run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdDataSync())
|
||||
|
||||
+2
-7
@@ -1,11 +1,11 @@
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from dvc.cmd_base import CmdBase
|
||||
from dvc.logger import Logger
|
||||
from dvc.config import Config
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class InitError(NeatLynxException):
|
||||
@@ -114,10 +114,5 @@ SecurityGroup = dvc-group'''
|
||||
|
||||
Logger.printing('Directory {} was added to .gitignore file'.format(cache_dir_name))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
CmdInit().run()
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdInit())
|
||||
|
||||
+2
-6
@@ -8,6 +8,7 @@ from dvc.logger import Logger
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.path.data_path import NotInDataDirError
|
||||
from dvc.state_file import StateFile
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class ReproError(NeatLynxException):
|
||||
@@ -166,9 +167,4 @@ class ReproChange(object):
|
||||
return self.reproduce_data_file()
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
try:
|
||||
sys.exit(CmdRepro().run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdRepro())
|
||||
|
||||
+2
-7
@@ -9,6 +9,7 @@ from dvc.logger import Logger
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.repository_change import RepositoryChange
|
||||
from dvc.state_file import StateFile
|
||||
from dvc.utils import run
|
||||
|
||||
|
||||
class RunError(NeatLynxException):
|
||||
@@ -174,10 +175,4 @@ class CmdRun(CmdBase):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
import sys
|
||||
|
||||
try:
|
||||
sys.exit(CmdRun().run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
run(CmdRun())
|
||||
|
||||
+13
-1
@@ -1,3 +1,6 @@
|
||||
from dvc.exceptions import NeatLynxException
|
||||
from dvc.logger import Logger
|
||||
|
||||
|
||||
def cached_property(f):
|
||||
def get(self):
|
||||
@@ -11,4 +14,13 @@ def cached_property(f):
|
||||
x = self._property_cache[f] = f(self)
|
||||
return x
|
||||
|
||||
return property(get)
|
||||
return property(get)
|
||||
|
||||
|
||||
def run(cmd):
|
||||
import sys
|
||||
try:
|
||||
sys.exit(cmd.run())
|
||||
except NeatLynxException as e:
|
||||
Logger.error(e)
|
||||
sys.exit(1)
|
||||
@@ -1,13 +1,8 @@
|
||||
from unittest import TestCase
|
||||
import os
|
||||
import shutil
|
||||
|
||||
from dvc.cmd_data_remove import CmdDataRemove, DataRemoveError
|
||||
from dvc.config import ConfigI
|
||||
from dvc.path.data_path import NotInDataDirError, DataFilePathError, DataPath
|
||||
from dvc.git_wrapper import GitWrapperI
|
||||
from dvc.path.path_factory import PathFactory
|
||||
from tests.basic_env import BasicEnvironment, DirHierarchyEnvironment
|
||||
from dvc.path.data_path import DataFilePathError
|
||||
from tests.basic_env import DirHierarchyEnvironment
|
||||
|
||||
|
||||
class TestCmdDataRemove(DirHierarchyEnvironment):
|
||||
|
||||
Reference in New Issue
Block a user