Example #1
0
from ersatzpg import ersatz
import non_pages_conf
import os, re, subprocess
os.chdir('non')
webpages = [d for d in os.listdir('.') if re.match(r'nonwebpages\d\d+', d)]
webpages.sort()
for w in webpages:
    print w
    for k, v in non_pages_conf.ERSATZPG_CONFIG['tables'].iteritems():
        v['filename'] = '/home/gaertner/code/candclass/non/{webpages}'.format(
            webpages=w)
    ersatz.new_process_copies(non_pages_conf)

    pipe = subprocess.Popen(['mv', w, 'done_non' + w[-2:]],
                            stdin=subprocess.PIPE)
    pipe.wait()
from ersatzpg import ersatz
import frame_pages_conf
import os, re, subprocess, time
os.chdir('basic')
webpages = [d for d in os.listdir('.') if re.match(r'webpages\d\d+',d)]
webpages.sort()
for w in webpages:
    print w
    for k,v in frame_pages_conf.ERSATZPG_CONFIG['tables'].iteritems():
        v['filename'] = '/home/gaertner/code/candclass/basic/{webpages}'.format(webpages=w)
    t = time.time()
    ersatz.new_process_copies(frame_pages_conf)
    print "Processed {w} in {t} seconds".format(w=w,t=(time.time()-t))

    pipe = subprocess.Popen(['mv',w,'done'+w[-2:]],stdin=subprocess.PIPE)
    pipe.wait()

from ersatzpg import ersatz
import non_pages_conf
import os, re, subprocess
os.chdir('non')
webpages = [d for d in os.listdir('.') if re.match(r'nonwebpages\d\d+',d)]
webpages.sort()
for w in webpages:
    print w
    for k,v in non_pages_conf.ERSATZPG_CONFIG['tables'].iteritems():
        v['filename'] = '/home/gaertner/code/candclass/non/{webpages}'.format(webpages=w)
    ersatz.new_process_copies(non_pages_conf)

    pipe = subprocess.Popen(['mv',w,'done_non'+w[-2:]],stdin=subprocess.PIPE)
    pipe.wait()
Example #4
0
                }
        elif state=='election':
            bipbuild_conf.ERSATZPG_CONFIG['tables'] = {
                    'election':bipbuild_conf.ELECTION_IMPORT,
                    }
        else:
            bipbuild_conf.ERSATZPG_CONFIG['tables']={
                    'candidate':bipbuild_conf.CANDIDATE_IMPORT,
                    'contest':bipbuild_conf.CONTEST_IMPORT,
                    'candidate_in_contest':bipbuild_conf.CANDIDATE_IN_CONTEST_IMPORT,
                    'electoral_district':bipbuild_conf.ELECTORAL_DISTRICT_IMPORT,
                    #'referendum':REFERENDUM_IMPORT,
                    #'ballot_response':BALLOT_RESPONSE_IMPORT,
                    }

        ersatz.new_process_copies(bipbuild_conf, connection)
        for table_name in bipbuild_conf.ERSATZPG_CONFIG['tables']:
            if table_name == 'candidate_in_contest':
                continue
            FIELDS = bipbuild_conf.__dict__[table_name.upper()+'_FIELDS']
            ufields = OrderedDict(FIELDS)
            ufields.pop('updated')
            ufields = ','.join('{u}={table_name}_import.{u}'.format(u=u,table_name=table_name) for u in ufields)
            test_fields = OrderedDict(FIELDS)
            test_fields.pop('updated')
            test_fields.pop('identifier')
            actual_table = bipbuild_conf.__dict__[table_name.upper()+'_ACTUAL']
            for lfd in actual_table['long_fields']:
                test_fields.pop(lfd['real'])
            test_fields = ' or '.join('{table_name}_{source}_{election}.{u} IS DISTINCT FROM {table_name}_import.{u}'.format(u=u,source=source[table_name],election=election,table_name=table_name) for u in test_fields)
            update_timestamp = 'update {table_name}_{source}_{election} set updated={table_name}_import.updated from {table_name}_import where {table_name}_{source}_{election}.identifier = {table_name}_import.identifier and ({conditions});'.format(source=source[table_name], election=election ,conditions=test_fields,table_name=table_name)