Last week I needed to feed jobs defined in an internal web interface to the computation engine. Below is the code I wrote, which looks at the MySQL table for the defined jobs, and executes a command line code. Can it be done better? let me know.
Let's import the necessary libraries first:
#!/usr/bin/python
import sys, os, time
from time import gmtime, strftime
import string
import MySQLdb as mdb
import atexit
import threading
import subprocess
import shlex
Next, define how to connect to mysql:
# Connect to DB -----------
db_host = "127.0.0.1"
db_db = "test"
db_user = "root"
db_password = "tooth"
con = mdb.connect(db_host, db_user,
db_password, db_db);
app_path = "/Users/danialt/software/"
db_port = 3306
pr = {}
Continue reading →