From 9fa43ae1558f3f74a9fa9c37aa9351b4dedf852d Mon Sep 17 00:00:00 2001 From: Lars Lingner Date: Thu, 20 Nov 2014 14:33:37 +0100 Subject: [PATCH 1/3] fix indention, so maps actually getting inserted --- update.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/update.py b/update.py index 3aa22bd..0211da1 100644 --- a/update.py +++ b/update.py @@ -66,18 +66,18 @@ def copytree(src, dst, symlinks = False, ignore = None): f.write(" "+str(i+1)+": "+groups[i]['group_name']+" \n") f.write("}") #delete groups from database - cur2.execute("select * from workspaces where name=?",(m['ws_name'],)) - ws = cur2.fetchone() - if not ws: - print("Adding workspace to the database...") - cur2.execute("insert into workspaces(name) values(?)",(m['ws_name'],)) - ws_id = cur2.lastrowid - else: - ws_id = ws['id'] - - print("Adding map to the database...") - cur2.execute("insert into maps(name, workspace_id, type) values(?, ?, ?)",(m['map_name'], ws_id, m['map_type'],)) - con2.commit() + cur2.execute("select * from workspaces where name=?",(m['ws_name'],)) + ws = cur2.fetchone() + if not ws: + print("Adding workspace to the database...") + cur2.execute("insert into workspaces(name) values(?)",(m['ws_name'],)) + ws_id = cur2.lastrowid + else: + ws_id = ws['id'] + + print("Adding map to the database...") + cur2.execute("insert into maps(name, workspace_id, type) values(?, ?, ?)",(m['map_name'], ws_id, m['map_type'],)) + con2.commit() if con: con.close() From 5e398352515b99437720d58e025bfa7f31a112fb Mon Sep 17 00:00:00 2001 From: Lars Lingner Date: Fri, 5 Dec 2014 15:37:39 +0100 Subject: [PATCH 2/3] Update requirements.txt fixture 1.6 isn't available atm --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index dae2994..5ddcb01 100644 --- a/requirements.txt +++ b/requirements.txt @@ -11,7 +11,7 @@ WebOb==1.2.3 alembic==0.4.2 argparse==1.2.1 cryptacular==1.4.1 -fixture==1.6 +fixture==1.5 flake8==2.0 ipython==0.13.1 mccabe==0.2 From 0e59495115238393693800ec6d5f0a056377a8a7 Mon Sep 17 00:00:00 2001 From: Lars Lingner Date: Fri, 5 Dec 2014 16:54:46 +0100 Subject: [PATCH 3/3] Update update.py added better exception handling --- update.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/update.py b/update.py index 0211da1..ed59845 100644 --- a/update.py +++ b/update.py @@ -49,7 +49,7 @@ def copytree(src, dst, symlinks = False, ignore = None): if not os.path.exists(pathMap): copytree(pathOldMap, pathMap) else: - raise "The directory "+pathMap+" already exists" + raise Exception("The directory "+pathMap+" already exists") cur.execute('select * from groups where map_id=? order by group_index',(m['map_id'],)) groups = cur.fetchall()