# Path: common/db.py
# def user_db_prefix():
# def database_name(domain, family):
# def use_db(conn, domain, family, cursor_class = None):
# def create_conn(**kwargs):
#     def __init__(self, db_name):
#     def open(self):
#     def close(self):
# def connection(db_obj):
# class UserDb(object):
# 
# Path: jobs/sge_jobs.py
# class DbJob(db.UserDb):
#     def __init__(self):
#     def get_job_table(self, state_filter, limit = 50, offset = 0,
#                       cmd_filter = None):
#     def get_accounting_table(self, limit = 50, offset = 0, job_ids = None):
#     def pending_request(self, limit = 16, offset = 0):
#     def _add_request(self, jobname, run_cmd, args, max_vmem, cpu_bound, force):
#     def add_request(self, jobname, run_cmd, args,  max_vmem,
#                     cpu_bound = True, force = False):
#     def exec_request(self, r):
#     def run_batch(self, nr_running, limit = 16):
#     def _exec_check(self, request):
#     def check_running(self):
#     def search_accounting(self, jobs, last_time_day = 2):
#     def update_accounting(self):
# def quote_arg(arg):
# def job_cmdline_arg(request, cmd):
# def sge_cmdline_arg(request):


import sys
import os
import hashlib
import MySQLdb
from common import db
from ws_namespaces import index as index, namespaces as namespaces
from jobs import sge_jobs
        'ru',
        'sv',
        ]
)

# FIXME: move that to db.py
def open_db(domain, family, cursor_class = None):
    conn = db.create_conn(domain = domain, family = family)
    cursor = db.use_db(conn, domain, family, cursor_class)

    return conn, cursor

def close_db(conn, cursor):
    if cursor:
        cursor.close()
    if conn:
        conn.close()

def index_ns_nr(lang):
    ns_name = index['wikisource'][lang]
    ns_nr = namespaces['wikisource'][lang][ns_name]

    return ns_nr

def add_hocr_request(lang, book, force = False):
    job_req = {
        'jobname' : 'hocr',
        'run_cmd' : 'python',
        'args' : [
            os.path.expanduser('~/phe/hocr/hocr.py'),

# Path: common/db.py
# def user_db_prefix():
# def database_name(domain, family):
# def use_db(conn, domain, family, cursor_class = None):
# def create_conn(**kwargs):
#     def __init__(self, db_name):
#     def open(self):
#     def close(self):
# def connection(db_obj):
# class UserDb(object):
# 
# Path: jobs/sge_jobs.py
# class DbJob(db.UserDb):
#     def __init__(self):
#     def get_job_table(self, state_filter, limit = 50, offset = 0,
#                       cmd_filter = None):
#     def get_accounting_table(self, limit = 50, offset = 0, job_ids = None):
#     def pending_request(self, limit = 16, offset = 0):
#     def _add_request(self, jobname, run_cmd, args, max_vmem, cpu_bound, force):
#     def add_request(self, jobname, run_cmd, args,  max_vmem,
#                     cpu_bound = True, force = False):
#     def exec_request(self, r):
#     def run_batch(self, nr_running, limit = 16):
#     def _exec_check(self, request):
#     def check_running(self):
#     def search_accounting(self, jobs, last_time_day = 2):
#     def update_accounting(self):
# def quote_arg(arg):
# def job_cmdline_arg(request, cmd):
# def sge_cmdline_arg(request):


# Path: hocr/hocr_request.py
import sys
import os
import hashlib
import MySQLdb
from common import db
from ws_namespaces import index as index, namespaces as namespaces
from jobs import sge_jobs

        'ru',
        'sv',
        ]
)

# FIXME: move that to db.py
def open_db(domain, family, cursor_class = None):
    conn = db.create_conn(domain = domain, family = family)
    cursor = db.use_db(conn, domain, family, cursor_class)

    return conn, cursor

def close_db(conn, cursor):
    if cursor:
        cursor.close()
    if conn:
        conn.close()

def index_ns_nr(lang):
    ns_name = index['wikisource'][lang]
    ns_nr = namespaces['wikisource'][lang][ns_name]

    return ns_nr

def add_hocr_request(lang, book, force = False):
    job_req = {
        'jobname' : 'hocr',
        'run_cmd' : 'python',
        'args' : [
            os.path.expanduser('~/phe/hocr/hocr.py'),

            '-lang:' + lang,