Skip to content
This repository was archived by the owner on Jun 30, 2024. It is now read-only.

Commit 5c09db5

Browse files
committed
Fix: syntax errors in insert statements
1 parent bb6dcc7 commit 5c09db5

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

rsmanage/rsmanage.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import sys
22
from pathlib import Path
33

4+
from zmq import PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE
5+
46
# Launch into the Docker container before attempting imports that are only installed there. (If Docker isn't installed, we assume the current venv already contains the necessary packages.)
57
wd = (Path(__file__).parents[1]).resolve()
68
sys.path.extend([str(wd / "docker"), str(wd / "tests")])
@@ -1094,7 +1096,7 @@ def addbookauthor(config, book, author, github):
10941096
f"""select * from courses where course_name = '{book}' and base_course='{book}'"""
10951097
).first()
10961098
if res:
1097-
click.echo(f"Warning - Book {book} already exists")
1099+
click.echo(f"Warning - Book {book} already exists in courses table")
10981100
# Create an entry in courses (course_name, term_start_date, institution, base_course, login_required, allow_pairs, student_price, downloads_enabled, courselevel, newserver)
10991101
if not res:
11001102
res = engine.execute(
@@ -1112,25 +1114,27 @@ def addbookauthor(config, book, author, github):
11121114
'T')
11131115
"""
11141116
)
1117+
else:
1118+
# Try to deduce the github url from the working directory
1119+
if not github:
1120+
github = f"https://github.com/RunestoneInteractive/{book}.git"
11151121

11161122
# Create an entry in book (document_id, github_url)
11171123
try:
11181124
res = engine.execute(
11191125
f"""insert into book
11201126
(document_id, github_url)
11211127
values ( '{book}', '{github}' )
1122-
)
11231128
"""
11241129
)
1125-
except:
1126-
click.echo("Book already exists")
1130+
except Exception as e:
1131+
click.echo(f"Book already exists in book table {e}")
11271132
# create an entry in book_author (author, book)
11281133
try:
11291134
res = engine.execute(
11301135
f"""insert into book_author
11311136
(author, book)
11321137
values ( '{author}', '{book}' )
1133-
)
11341138
"""
11351139
)
11361140
except:

0 commit comments

Comments
 (0)