X-Git-Url: https://disinclined.org/git/?a=blobdiff_plain;f=publish_projects.py;fp=publish_projects.py;h=6e538d965777242d03cc0fd3d24758633257b48b;hb=75e132f05e9b46a388c2ca3a23e30e57e9d9bc3f;hp=7e5535ce40b1b3d0bd4fcd26da236ed0c1a2c144;hpb=e8fefa2acfe3b545f0e6874f7761fe1d9edbeaaf;p=dylansserver.git diff --git a/publish_projects.py b/publish_projects.py index 7e5535c..6e538d9 100755 --- a/publish_projects.py +++ b/publish_projects.py @@ -1,5 +1,7 @@ #!/usr/bin/python +PROJECTS_DIRECTORY = '/home/dylan/docs/projects' + import os import time import MySQLdb as db @@ -11,10 +13,9 @@ domain = config.get('database', 'domain') user = config.get('database', 'user') password = config.get('database', 'password').replace('"', '') database = config.get('database', 'database') -print domain, user, password, 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) @@ -25,7 +26,7 @@ for row in results: for note in notes: 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)\