2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2026-04-01 12:31:51 +01:00

stop print msgs in utils and models

This commit is contained in:
2026-02-09 16:10:52 +00:00
parent b5d20373b0
commit 23619f3175
3 changed files with 41 additions and 37 deletions

View File

@@ -247,7 +247,7 @@ def parse_aliases(aliasfile):
filepath = Path(settings.EXPOWEB) / "cave_data" / aliasfile
if not filepath.is_file():
message = f' ** {filepath} is not a file.'
print(message)
# print(message)
return [(None, None)]
try:
with open(filepath, "r") as aliasfile:
@@ -266,14 +266,14 @@ def parse_aliases(aliasfile):
key, sep, target = l.partition(' ')
if len(key) == 0 or len(target) == 0:
message = f' ** Parsing failure for {line}'
print(message)
# print(message)
continue
# print(f"{key} => {target}")
aliases.append((key,target))
except:
message = f' ** Cannot open {filepath} for text file reading even though it is a file.'
print(message)
# print(message)
return [(None, None)], "Fail on file reading"
return aliases, report
@@ -321,10 +321,10 @@ def shared_use_machine(request):
if not (cookie_txt := request.COOKIES.get(PUBLIC_LAPTOP_COOKIE_NAME, "")):
return False
elif cookie_txt == PUBLIC_LAPTOP_COOKIE_TEXT:
print(f" - shared use cookie exists, and has expected value: '{cookie_txt}'")
# print(f" - shared use cookie exists, and has expected value: '{cookie_txt}'")
return True
else:
print(f" - shared use cookie exists, but has wrong value: '{cookie_txt}' not '{PUBLIC_LAPTOP_COOKIE_TEXT}'")
# print(f" - shared use cookie exists, but has wrong value: '{cookie_txt}' not '{PUBLIC_LAPTOP_COOKIE_TEXT}'")
return True
def get_cookie(request):
@@ -360,7 +360,7 @@ def git_string(author_string):
if editor.startswith("_"):
editor = "X" + editor
editor += f" <{editor}@potatohut.expo>"
print(f"++ Not git-compatible author string '{author_string}', replacing as '{editor}'")
# print(f"++ Not git-compatible author string '{author_string}', replacing as '{editor}'")
return editor
def git_add(filename, cwd, commands=[]):
@@ -370,7 +370,7 @@ def git_add(filename, cwd, commands=[]):
# what is the purpose of this 'git diff' ? Assumed to be a fossil.
# it sometimes crashes with return code 129: wrong arguments.
print(f"git diff {filename} in {cwd}")
# print(f"git diff {filename} in {cwd}")
cmd_diff = [git, "diff"]
commands.append(cmd_diff)
cp_diff = subprocess.run(cmd_diff, cwd=cwd, capture_output=True, text=True)
@@ -396,20 +396,21 @@ def git_commit(cwd, message, editor, commands=[]):
"""Commits whatever has been Staged by git in this directory 'cwd'
"""
git = settings.GIT
print(f"git commit in {cwd}")
# print(f"git commit in {cwd}")
if socket.gethostname() != EXPOSERVER:
message += f" - on dev machine '{socket.gethostname()}'"
elif settings.DEVSERVER:
message += " - on a dev machine using 'runserver'"
print(f"..{message=}\n..{editor=}")
# print(f"..{message=}\n..{editor=}")
cmd_commit = [git, "commit", "-m", message, "--author", f"{editor}"]
commands.append(cmd_commit)
print(commands)
# print(commands)
try:
cp_commit = subprocess.run(cmd_commit, cwd=cwd, capture_output=True, text=True)
except Exception as e:
print(e)
pass
# print(e)
# This produces return code = 1 if it commits OK, but when the local repo still needs to be pushed to origin/repo
# which will be the case when running a test troggle system on a development machine
@@ -421,7 +422,7 @@ def git_commit(cwd, message, editor, commands=[]):
"nothing to commit, working tree clean"
):
msgdata = f'--Ask a nerd to fix this problem in git_commit().\n--{cp_commit.stderr}\n--"{cp_commit.stdout}"\n--return code:{str(cp_commit.returncode)}'
print(msgdata)
# print(msgdata)
raise WriteAndCommitError(
f"Error code with git on server in this directory: {cwd}. Edits saved, added to git, but NOT committed.\n\n"
+ msgdata
@@ -450,11 +451,11 @@ def add_commit(fname, message, editor):
except subprocess.SubprocessError:
msg = f"CANNOT git ADD or COMMIT on server for this file {filename}.\nSubprocess error: {commands}\nEdits probably not saved.\nAsk a nerd to fix this."
print(msg)
# print(msg)
raise WriteAndCommitError(msg)
def write_binary_file(filepath, content):
print(f"write_binary_file: {filepath}")
# print(f"write_binary_file: {filepath}")
write_files([(filepath, content, "")]) # null encoding does "wb"
def ensure_dir_exists(filepath):