Skip to content

Commit 0167ccf

Browse files
committed
[staging-intervention] Use new utils
1 parent ceb604c commit 0167ccf

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

staging_intervention/download.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,5 @@
1-
import os
2-
import pathlib
3-
import subprocess
4-
import textwrap
5-
from sys import exit
6-
from typing import List, Optional
7-
8-
9-
def run_command(command: List[str], verbose: bool) -> Optional[str]:
10-
try:
11-
result = subprocess.run(
12-
command,
13-
capture_output=True,
14-
text=True,
15-
check=True,
16-
)
17-
if verbose:
18-
print(result.stdout)
19-
return result.stdout
20-
except subprocess.CalledProcessError as e:
21-
if verbose:
22-
print(e.stderr)
23-
exit(1)
24-
25-
26-
def create_or_update_file(
27-
filepath: str | pathlib.Path, contents: Optional[str] = None
28-
) -> None:
29-
if os.path.dirname(filepath) != "":
30-
os.makedirs(os.path.dirname(filepath), exist_ok=True)
31-
if contents is None:
32-
open(filepath, "a").close()
33-
else:
34-
with open(filepath, "w") as file:
35-
file.write(textwrap.dedent(contents).lstrip())
1+
from exercise_utils.file import create_or_update_file
2+
from exercise_utils.git import add
363

374

385
def setup(verbose: bool = False):
@@ -49,4 +16,4 @@ def setup(verbose: bool = False):
4916
for member in crew:
5017
create_or_update_file(member)
5118

52-
run_command(["git", "add", "."], verbose)
19+
add(["."], verbose)

0 commit comments

Comments
 (0)