making-with-code-cli 5.0.1__tar.gz → 5.0.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/PKG-INFO +1 -1
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/pyproject.toml +1 -1
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/mwc_backend.py +18 -14
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/__init__.py +3 -3
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/tasks.py +8 -9
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/update/__init__.py +17 -2
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/README.md +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/cli.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/curriculum.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/decorators.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/errors.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_backend/base_backend.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_wrapper.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/helpers.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/mwc_accounts_api.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/settings.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/styles.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/submit.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/assess.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/check/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/check/check_module.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/gitea_api/api.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/gitea_api/exceptions.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/log.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/patch.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/create.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/edit.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/section/show.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/setup.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/status.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/__init__.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/create.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student/update.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student_repo_functions.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/student_repos.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/update.py +0 -0
- {making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/version.py +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from .base_backend import GitBackend
|
|
2
|
-
from subprocess import run
|
|
2
|
+
from subprocess import run, CalledProcessError
|
|
3
|
+
import traceback
|
|
3
4
|
from pathlib import Path
|
|
4
5
|
from urllib.parse import urlparse
|
|
5
6
|
import click
|
|
@@ -8,7 +9,11 @@ import os
|
|
|
8
9
|
import requests
|
|
9
10
|
from making_with_code_cli.helpers import cd
|
|
10
11
|
from making_with_code_cli.styles import (
|
|
12
|
+
address,
|
|
11
13
|
confirm,
|
|
14
|
+
debug,
|
|
15
|
+
error,
|
|
16
|
+
info,
|
|
12
17
|
)
|
|
13
18
|
from making_with_code_cli.errors import (
|
|
14
19
|
MissingSetting,
|
|
@@ -40,26 +45,25 @@ class MWCBackend(GitBackend):
|
|
|
40
45
|
if (modpath / self.COMMIT_TEMPLATE).exists():
|
|
41
46
|
run(f"git config commit.template {self.COMMIT_TEMPLATE}", shell=True,
|
|
42
47
|
check=True, cwd=modpath)
|
|
43
|
-
run("uv venv", shell=True, check=True, cwd=modpath)
|
|
48
|
+
run("uv venv", shell=True, check=True, cwd=modpath, capture_output=True)
|
|
44
49
|
self.init_direnv(modpath)
|
|
45
50
|
|
|
46
51
|
def update(self, module, modpath, install=True):
|
|
47
52
|
if (modpath / ".git").is_dir():
|
|
48
53
|
with cd(modpath):
|
|
49
54
|
relpath = self.relative_path(modpath)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
click.echo(address(f"Checking {relpath} for updates.", preformatted=True))
|
|
56
|
+
gitresult = run("git pull", shell=True, check=True, capture_output=True,
|
|
57
|
+
text=True)
|
|
58
|
+
click.echo(info(gitresult.stdout))
|
|
59
|
+
if install and Path("pyproject.toml").exists():
|
|
60
|
+
result = run("uv sync", shell=True, capture_output=True, text=True, cwd=modpath)
|
|
61
|
+
if result.returncode != 0:
|
|
62
|
+
click.echo(debug("Error running uv sync:"))
|
|
63
|
+
click.echo(debug(result.stderr, preformatted=True))
|
|
64
|
+
click.echo(error(f"There was a problem updating {relpath}. Ask a teacher."))
|
|
65
|
+
else:
|
|
58
66
|
self.init_direnv(modpath)
|
|
59
|
-
click.echo(info(result.stdout, preformatted=True))
|
|
60
|
-
except CalledProcessError as e:
|
|
61
|
-
click.echo(error(f"There was a problem updating {relpath}. Ask a teacher."))
|
|
62
|
-
raise e
|
|
63
67
|
|
|
64
68
|
def init_direnv(self, modpath):
|
|
65
69
|
if not (modpath / ".envrc").exists():
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/__init__.py
RENAMED
|
@@ -95,9 +95,9 @@ def setup(ctx, config, debug, git_name, git_email, mwc_accounts_url):
|
|
|
95
95
|
if settings.get('mwc_accounts_url'):
|
|
96
96
|
click.echo(debug_fmt(f"Using custom MWC accounts server: {settings['mwc_accounts_url']}"))
|
|
97
97
|
click.echo(debug_fmt("MWC Accounts Server status:"))
|
|
98
|
-
click.echo(debug_fmt(str(status)))
|
|
99
|
-
click.echo(
|
|
100
|
-
click.echo(
|
|
98
|
+
click.echo(debug_fmt(str(status), preformatted=True))
|
|
99
|
+
click.echo(debug_fmt("MWC settings:"))
|
|
100
|
+
click.echo(debug_fmt(settings, preformatted=True))
|
|
101
101
|
write_settings(settings, config)
|
|
102
102
|
|
|
103
103
|
task_classes = [
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/setup/tasks.py
RENAMED
|
@@ -10,7 +10,7 @@ from making_with_code_cli.mwc_accounts_api import MWCAccountsAPI
|
|
|
10
10
|
from making_with_code_cli.styles import (
|
|
11
11
|
address,
|
|
12
12
|
question,
|
|
13
|
-
debug,
|
|
13
|
+
debug as debug_fmt,
|
|
14
14
|
confirm,
|
|
15
15
|
info,
|
|
16
16
|
success,
|
|
@@ -177,7 +177,7 @@ def get_mwc_rc_path():
|
|
|
177
177
|
xdg_config_home = Path(os.environ.get("XDG_CONFIG_HOME", Path.home() / ".config"))
|
|
178
178
|
return xdg_config_home / "mwc" / "shell_config.sh"
|
|
179
179
|
|
|
180
|
-
def platform_rc_file():
|
|
180
|
+
def platform_rc_file(debug=False):
|
|
181
181
|
shell = get_shell_name()
|
|
182
182
|
if shell == "zsh":
|
|
183
183
|
dothome = Path(os.environ.get("ZDOTDIR", Path.home()))
|
|
@@ -195,7 +195,7 @@ def platform_rc_file():
|
|
|
195
195
|
]
|
|
196
196
|
for sh, rc in candidates:
|
|
197
197
|
if shell == sh and rc.exists():
|
|
198
|
-
click.echo(
|
|
198
|
+
click.echo(debug_fmt(f"Shell identified as {sh}. Using {rc} as rc file."))
|
|
199
199
|
return rc
|
|
200
200
|
raise IOError("Can't find an rc file.")
|
|
201
201
|
|
|
@@ -230,13 +230,14 @@ class SetupTask:
|
|
|
230
230
|
|
|
231
231
|
def debug_log(self, message):
|
|
232
232
|
if self.debug:
|
|
233
|
-
click.echo(
|
|
233
|
+
click.echo(debug_fmt(message))
|
|
234
234
|
|
|
235
235
|
def executable_on_path(self, name):
|
|
236
236
|
return bool(run(f"which {name}", shell=True, capture_output=True).stdout)
|
|
237
237
|
|
|
238
238
|
class WriteMWCShellConfig(SetupTask):
|
|
239
239
|
description = "Write the MWC shell config file to ~/.config/mwc/shell_config.sh or XDG_CONFIG_HOME"
|
|
240
|
+
docs_url = "https://docs.makingwithcode.org/making-with-code-cli/students.html#configuration"
|
|
240
241
|
|
|
241
242
|
def is_complete(self):
|
|
242
243
|
p = get_mwc_rc_path()
|
|
@@ -253,7 +254,8 @@ class WriteMWCShellConfig(SetupTask):
|
|
|
253
254
|
"Generates the shell configuration file contents"
|
|
254
255
|
f = ""
|
|
255
256
|
shell = get_shell_name()
|
|
256
|
-
f += "# Making With Code RC File\n
|
|
257
|
+
f += "# Making With Code RC File\n"
|
|
258
|
+
f += f"# See {self.docs_url}\n\n"
|
|
257
259
|
f += "## Hook direnv into shell\n"
|
|
258
260
|
f += f'eval "$(direnv hook {shell})"\n\n'
|
|
259
261
|
|
|
@@ -278,13 +280,10 @@ class SourceMWCShellConfig(SetupTask):
|
|
|
278
280
|
return f"source {get_mwc_rc_path()}" in platform_rc_file().read_text()
|
|
279
281
|
|
|
280
282
|
def run_task(self):
|
|
281
|
-
rc_file = platform_rc_file()
|
|
283
|
+
rc_file = platform_rc_file(self.debug)
|
|
282
284
|
self.debug_log(f"Adding `mwc` path to {rc_file}")
|
|
283
285
|
with rc_file.open('a') as fh:
|
|
284
|
-
result = run("which mwc", shell=True, check=True, text=True, capture_output=True)
|
|
285
|
-
mwcpath = Path(result.stdout).parent
|
|
286
286
|
fh.write(f"\n# MAKING WITH CODE\n")
|
|
287
|
-
fh.write(f'export PATH="$PATH:{mwcpath}"\n')
|
|
288
287
|
fh.write(f"source {get_mwc_rc_path()}\n")
|
|
289
288
|
click.echo(info(f"Updated your shell login file ({rc_file}). You may need to close and reopen Terminal."))
|
|
290
289
|
|
|
@@ -2,7 +2,7 @@ import click
|
|
|
2
2
|
import traceback
|
|
3
3
|
from pathlib import Path
|
|
4
4
|
from subprocess import run
|
|
5
|
-
from making_with_code_cli.settings import read_settings
|
|
5
|
+
from making_with_code_cli.settings import read_settings, get_settings_path
|
|
6
6
|
from making_with_code_cli.curriculum import get_curriculum
|
|
7
7
|
from making_with_code_cli.git_backend import get_backend
|
|
8
8
|
from making_with_code_cli.mwc_accounts_api import MWCAccountsAPI
|
|
@@ -18,13 +18,19 @@ from making_with_code_cli.styles import (
|
|
|
18
18
|
|
|
19
19
|
@click.command()
|
|
20
20
|
@click.option("--config", help="Path to config file (default: ~/.mwc)")
|
|
21
|
-
|
|
21
|
+
@click.option("--debug", is_flag=True, help="Show debug-level output")
|
|
22
|
+
def update(config, debug):
|
|
22
23
|
"""Update the MWC work directory"""
|
|
23
24
|
settings = read_settings(config)
|
|
25
|
+
sp = get_settings_path(config)
|
|
26
|
+
if debug:
|
|
27
|
+
click.echo(debug_fmt(f"Reading settings from {sp}"))
|
|
24
28
|
if not settings:
|
|
25
29
|
click.echo(error(f"Please run mwc setup first."))
|
|
26
30
|
return
|
|
27
31
|
mwc_home = Path(settings["work_dir"])
|
|
32
|
+
if debug:
|
|
33
|
+
click.echo(debug_fmt(f"mwc home is {mwc_home}."))
|
|
28
34
|
if not mwc_home.exists():
|
|
29
35
|
mwc_home.mkdir(mode=WORK_DIR_PERMISSIONS, parents=True)
|
|
30
36
|
api = MWCAccountsAPI(settings.get('mwc_accounts_url'))
|
|
@@ -33,6 +39,15 @@ def update(config):
|
|
|
33
39
|
except api.RequestFailed as bad_token:
|
|
34
40
|
click.echo(error(f"Error logging into MWC accounts server. Please run mwc setup."))
|
|
35
41
|
return
|
|
42
|
+
if debug:
|
|
43
|
+
if settings.get('mwc_accounts_url'):
|
|
44
|
+
click.echo(debug_fmt(f"Using custom MWC accounts server: {settings['mwc_accounts_url']}"))
|
|
45
|
+
click.echo(debug_fmt("MWC Accounts Server status:"))
|
|
46
|
+
click.echo(debug_fmt(str(status), preformatted=True))
|
|
47
|
+
click.echo(debug_fmt("MWC settings:"))
|
|
48
|
+
click.echo(debug_fmt(settings, preformatted=True))
|
|
49
|
+
if len(status['student_section_memberships']) == 0:
|
|
50
|
+
click.echo(info("There are no updates to run because you are not a student in any courses."))
|
|
36
51
|
for course in status['student_section_memberships']:
|
|
37
52
|
curr = get_curriculum(course['curriculum_site_url'], course['course_name'])
|
|
38
53
|
git_backend = get_backend(curr['git_backend'])(settings)
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/curriculum.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/decorators.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/errors.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/git_wrapper.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/helpers.py
RENAMED
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/settings.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/styles.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/submit.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/__init__.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/assess.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/log.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/patch.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/setup.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/status.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/teach/update.py
RENAMED
|
File without changes
|
{making_with_code_cli-5.0.1 → making_with_code_cli-5.0.2}/src/making_with_code_cli/version.py
RENAMED
|
File without changes
|