From 22dc546997a8c4a813f3a8c7390b892b56588e38 Mon Sep 17 00:00:00 2001 From: Dylan Lloyd Date: Sun, 19 Feb 2012 19:09:23 -0500 Subject: [PATCH] moved management tools to their own repository, dylansserver-management --- publish_notes.py | 41 ----------------------------------------- publish_projects.py | 34 ---------------------------------- 2 files changed, 75 deletions(-) delete mode 100755 publish_notes.py delete mode 100755 publish_projects.py diff --git a/publish_notes.py b/publish_notes.py deleted file mode 100755 index 4b711d9..0000000 --- a/publish_notes.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python2 - -NOTES_DIRECTORY = '/home/dylan/docs/notes' - -import os -import time -import MySQLdb as db -import ConfigParser - -config = ConfigParser.RawConfigParser() -config.read('/etc/dylansserver.ini') -domain = config.get('database', 'domain') -user = config.get('database', 'user') -password = config.get('database', 'password').replace('"', '') -database = config.get('database', 'database') -cursor = db.connect(domain, user, password, database).cursor() - -notes = os.listdir(NOTES_DIRECTORY) - -sql = "SELECT title FROM notes" -cursor.execute(sql) -results = cursor.fetchall() -existing_titles = [] -for row in results: - existing_titles.append(row[0]) - -for note in notes: - if note[:1] == '.': continue - if note == 'index.php' or note == 'notes.php': continue - url = note[:note.index('.')] - f = open(os.path.join(NOTES_DIRECTORY, note)) - title = str(f.readline()[:-1]) - date_posted = time.strptime(str(f.readline()[:-1]), "%Y/%m/%d %I:%M%p") - text = ''.join(f.readlines()) #converts list to single string - if title in existing_titles: continue - sql = "INSERT INTO notes (date_posted, url, title, text)\ - VALUES(\"%s\", \"%s\", \"%s\", \"%s\")"\ - % (time.strftime("%Y/%m/%d %I:%M:00", date_posted), url, title, db.escape_string(text)) - - print sql - #cursor.execute(sql) diff --git a/publish_projects.py b/publish_projects.py deleted file mode 100755 index 14a5772..0000000 --- a/publish_projects.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/python - -PROJECTS_DIRECTORY = '/home/dylan/docs/projects' - -import os -import time -import MySQLdb as db -import ConfigParser - -config = ConfigParser.RawConfigParser() -config.read('/etc/dylanstestserver.ini') -domain = config.get('database', 'domain') -user = config.get('database', 'user') -password = config.get('database', 'password').replace('"', '') -database = config.get('database', 'database') -cursor = db.connect(domain, user, password, database).cursor() - -notes = os.listdir(PROJECTS_DIRECTORY) - -sql = "SELECT title FROM projects" -cursor.execute(sql) -results = cursor.fetchall() -existing_titles = [] -for row in results: - existing_titles.append(row[0]) - -for note in notes: - if (note[:1] == '.'): continue - title = note[:note.index('.')] - f = open(os.path.join(PROJECTS_DIRECTORY, note)) - if title in existing_titles: continue - text = f.read() - cursor.execute("INSERT INTO projects (title, text)\ - VALUES (%s, %s)", (title, text)) -- 2.30.2