diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index 4474b2594..e25039c0a 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -7,13 +7,14 @@ from dvc.runtime import Runtime from dvc.system import System from dvc.data_cloud import DataCloud -#FIXME add cmdline argument and config option for POOL_SIZE POOL_SIZE = 4 + class DataSyncError(DvcException): def __init__(self, msg): super(DataSyncError, self).__init__('Data sync error: {}'.format(msg)) + class CmdDataSync(CmdBase): def __init__(self, settings): super(CmdDataSync, self).__init__(settings) @@ -30,6 +31,9 @@ class CmdDataSync(CmdBase): pool = ThreadPool(processes=POOL_SIZE) targets = [] + if len(self.parsed_args.targets) == 0: + raise DataSyncError('Sync target is not specified') + for target in self.parsed_args.targets: if System.islink(target): targets.append(target) diff --git a/dvc/command/import_file.py b/dvc/command/import_file.py index 59f2f8a2c..93461ae45 100644 --- a/dvc/command/import_file.py +++ b/dvc/command/import_file.py @@ -14,6 +14,7 @@ from dvc.system import System from dvc.command.data_sync import POOL_SIZE from dvc.progress import Progress + class ImportFileError(DvcException): def __init__(self, msg): DvcException.__init__(self, 'Import file: {}'.format(msg)) @@ -36,7 +37,10 @@ class CmdImportFile(CmdBase): def run(self): targets = [] with DvcLock(self.is_locker, self.git): - output = self.parsed_args.output + output = self.get_output() + if not output: + return 1 + for input in self.parsed_args.input: if not os.path.isdir(input): targets.append((input, output)) @@ -60,6 +64,19 @@ class CmdImportFile(CmdBase): self.commit_if_needed(message) pass + def get_output(self): + output = self.parsed_args.output + + if len(output) > 0 and output[-1] == os.path.sep and not os.path.isdir(output): + Logger.error(u'Import error: output directory {} does not exist'.format(output)) + return None + + if type(self.parsed_args.input) == list and len(self.parsed_args.input) > 1 and not os.path.isdir(output): + Logger.error(u'Import error: output {} has to be directory for multiple file import'.format(output)) + return None + + return output + def import_and_commit_if_needed(self, input, output, lock=False, check_if_ready=True): if check_if_ready and not self.no_git_actions and not self.git.is_ready_to_go(): return 1 diff --git a/dvc/system.py b/dvc/system.py index 752545d31..43c52053a 100644 --- a/dvc/system.py +++ b/dvc/system.py @@ -82,9 +82,7 @@ class System(object): def get_long_path(path): """Convert short path to a full path. It is needed for Windows.""" if System.is_unix(): - print('======================11111111111111111111') return path - print('======================222222222222222222222') buffer = create_unicode_buffer(System.LONG_PATH_BUFFER_SIZE) get_long_path_name = windll.kernel32.GetLongPathNameW