|
23 | 23 | from subprocess import PIPE, STDOUT, call, run
|
24 | 24 |
|
25 | 25 | import attr
|
| 26 | +from click import BadParameter |
26 | 27 | from werkzeug.utils import cached_property
|
27 | 28 |
|
28 | 29 | from renku import errors
|
@@ -96,12 +97,15 @@ def has_external_storage(self):
|
96 | 97 |
|
97 | 98 | def init_external_storage(self, force=False):
|
98 | 99 | """Initialize the external storage for data."""
|
99 |
| - call( |
100 |
| - self._CMD_STORAGE_INSTALL + (['--force'] if force else []), |
101 |
| - stdout=PIPE, |
102 |
| - stderr=STDOUT, |
103 |
| - cwd=str(self.path.absolute()), |
104 |
| - ) |
| 100 | + try: |
| 101 | + call( |
| 102 | + self._CMD_STORAGE_INSTALL + (['--force'] if force else []), |
| 103 | + stdout=PIPE, |
| 104 | + stderr=STDOUT, |
| 105 | + cwd=str(self.path.absolute()), |
| 106 | + ) |
| 107 | + except (KeyboardInterrupt, OSError) as e: |
| 108 | + raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e)) |
105 | 109 |
|
106 | 110 | def init_repository(self, name=None, force=False):
|
107 | 111 | """Initialize a local Renku repository."""
|
@@ -132,22 +136,29 @@ def track_paths_in_storage(self, *paths):
|
132 | 136 | # TODO create configurable filter and follow .gitattributes
|
133 | 137 | track_paths.append(str(path))
|
134 | 138 |
|
135 |
| - call( |
136 |
| - self._CMD_STORAGE_TRACK + track_paths, |
137 |
| - stdout=PIPE, |
138 |
| - stderr=STDOUT, |
139 |
| - cwd=str(self.path), |
140 |
| - ) |
| 139 | + if track_paths: |
| 140 | + try: |
| 141 | + call( |
| 142 | + self._CMD_STORAGE_TRACK + track_paths, |
| 143 | + stdout=PIPE, |
| 144 | + stderr=STDOUT, |
| 145 | + cwd=str(self.path), |
| 146 | + ) |
| 147 | + except (KeyboardInterrupt, OSError) as e: |
| 148 | + raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e)) |
141 | 149 |
|
142 | 150 | @ensure_external_storage
|
143 | 151 | def untrack_paths_from_storage(self, *paths):
|
144 | 152 | """Untrack paths from the external storage."""
|
145 |
| - call( |
146 |
| - self._CMD_STORAGE_UNTRACK + list(paths), |
147 |
| - stdout=PIPE, |
148 |
| - stderr=STDOUT, |
149 |
| - cwd=str(self.path), |
150 |
| - ) |
| 153 | + try: |
| 154 | + call( |
| 155 | + self._CMD_STORAGE_UNTRACK + list(paths), |
| 156 | + stdout=PIPE, |
| 157 | + stderr=STDOUT, |
| 158 | + cwd=str(self.path), |
| 159 | + ) |
| 160 | + except (KeyboardInterrupt, OSError) as e: |
| 161 | + raise BadParameter('Couldn\'t run \'git lfs\':\n{0}'.format(e)) |
151 | 162 |
|
152 | 163 | @ensure_external_storage
|
153 | 164 | def pull_paths_from_storage(self, *paths):
|
|
0 commit comments