disinclined.org
/
git
/
dylansserver.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'dev' into live
[dylansserver.git]
/
publish_projects.py
diff --git
a/publish_projects.py
b/publish_projects.py
index
da77e39
..
14a5772
100755
(executable)
--- a/
publish_projects.py
+++ b/
publish_projects.py
@@
-1,5
+1,7
@@
#!/usr/bin/python
#!/usr/bin/python
+PROJECTS_DIRECTORY = '/home/dylan/docs/projects'
+
import os
import time
import MySQLdb as db
import os
import time
import MySQLdb as db
@@
-13,7
+15,7
@@
password = config.get('database', 'password').replace('"', '')
database = config.get('database', 'database')
cursor = db.connect(domain, user, password, database).cursor()
database = config.get('database', 'database')
cursor = db.connect(domain, user, password, database).cursor()
-notes = os.listdir(
'projects'
)
+notes = os.listdir(
PROJECTS_DIRECTORY
)
sql = "SELECT title FROM projects"
cursor.execute(sql)
sql = "SELECT title FROM projects"
cursor.execute(sql)
@@
-23,9
+25,10
@@
for row in results:
existing_titles.append(row[0])
for note in notes:
existing_titles.append(row[0])
for note in notes:
+ if (note[:1] == '.'): continue
title = note[:note.index('.')]
title = note[:note.index('.')]
- f = open(os.path.join(
'projects'
, note))
+ f = open(os.path.join(
PROJECTS_DIRECTORY
, note))
if title in existing_titles: continue
text = f.read()
cursor.execute("INSERT INTO projects (title, text)\
if title in existing_titles: continue
text = f.read()
cursor.execute("INSERT INTO projects (title, text)\
- VALUES (%s, %s)", (title, text))
+
VALUES (%s, %s)", (title, text))