Skip to content

Commit a1a4ca8

Browse files
committed
deploy: 5a50609
1 parent a6a4405 commit a1a4ca8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

hands_on/add_files.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import os
2+
import subprocess
3+
from sys import exit
4+
from typing import List, Optional
5+
6+
__requires_git__ = True
7+
__requires_github__ = False
8+
9+
10+
def run_command(command: List[str], verbose: bool) -> Optional[str]:
11+
try:
12+
result = subprocess.run(
13+
command,
14+
capture_output=True,
15+
text=True,
16+
check=True,
17+
)
18+
if verbose:
19+
print(result.stdout)
20+
return result.stdout
21+
except subprocess.CalledProcessError as e:
22+
if verbose:
23+
print(e.stderr)
24+
exit(1)
25+
26+
27+
def download(verbose: bool):
28+
os.makedirs("things")
29+
os.chdir("things")
30+
run_command(["git", "init", "--initial-branch=main"], verbose)

new-hands-on.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def get_exercise_config() -> HandsOnConfig:
4040

4141

4242
def create_download_py_file(config: HandsOnConfig) -> None:
43-
with open(f"{config.hands_on_name}.py", "w") as download_script_file:
43+
with open(
44+
f"{config.hands_on_name.replace('-', '_')}.py", "w"
45+
) as download_script_file:
4446
download_script = f"""
4547
import subprocess
4648
from sys import exit

0 commit comments

Comments
 (0)