Ejemplo n.º 1
0
#!/usr/bin/python

import sch_client
import json
import cx_Oracle
import os
from datetime import datetime
from copy import copy

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, "sync_push_banner")
sch_client.printme("------ Begin sync_push_banner ------")
config = json.load(open(os.path.join(__location__, "config.json")))
api = sch_client.API(config["uri"], config["key"], config["secret"])
connection = cx_Oracle.connect(config["db_connection"])
cursor = connection.cursor()
verbose = False

# Proxy for SPRIDEN table in Banner. View containing relevant students
resident_select = """
SELECT * FROM acadmgr.sch_student_demo WHERE acadmgr.sch_student_demo.STUDENTID = $%$id$%$
"""

room_assignment_dates_select = """
SELECT * FROM SLRASCD WHERE SLRASCD_TERM_CODE = $%$TERM$%$ AND SLRASCD_ASCD_CODE = $%$ASSIGN_CODE$%$
"""

meal_assignment_dates_select = """
SELECT * FROM SLRMSCD WHERE SLRMSCD_TERM_CODE = $%$TERM$%$ AND SLRMSCD_MSCD_CODE = $%$ASSIGN_CODE$%$
"""
Ejemplo n.º 2
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os


__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_pull')
sch_client.printme('------ Begin sync_pull ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
sql = open(os.path.join(__location__, config['pull_sql'])).read()
columns = json.load(open(os.path.join(__location__, config['pull_map'])))
api = sch_client.API(config['uri'], config['key'], config['secret'])

dbms = config['dbms'] if 'dbms' in config else 'odbc'
if dbms == 'oracle':
    import cx_Oracle
    connection = cx_Oracle.connect(config['db_connection'])
else:
    connection = pyodbc.connect(config['db_connection'])


def execute_pull(api, conn, query, params, columns, batch_size=10):
    cursor = conn.cursor()

    if dbms == 'oracle':
        query, query_params = sch_client.prepare_query(query, params, ':0')
        cursor.execute(query, query_params)
    else:
Ejemplo n.º 3
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os
from collections import defaultdict
from copy import copy

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_push_jenzabar')
sch_client.printme('------ Begin sync_push_jenzabar ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
api = sch_client.API(config['uri'], config['key'], config['secret'])
connection = pyodbc.connect(config['db_connection'])
cursor = connection.cursor()
verbose = False

room_assign_update = """
UPDATE ROOM_ASSIGN
SET ID_NUM = $%$id$%$,
    ASSIGN_DTE = $%$assign_time$%$,
    JOB_TIME = GETDATE(),
    JOB_NAME = 'sch.import_residency',
    USER_NAME = 'SCH',
    ROOM_ASSIGN_STS = 'A',
    ROOM_TYPE = $%$ROOM_TYPE$%$
WHERE SESS_CDE = $%$SESS_CDE$%$
AND BLDG_LOC_CDE = $%$BLDG_LOC_CDE$%$
AND BLDG_CDE = $%$BLDG_CDE$%$
AND ROOM_CDE = $%$ROOM_CDE$%$
Ejemplo n.º 4
0
#!/usr/bin/python

import sch_client
import json
import pyodbc
import os

__location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__)))
sch_client.init_logging(__location__, 'sync_push_powercampus')
sch_client.printme('------ Begin sync_push_powercampus ------')
config = json.load(open(os.path.join(__location__, 'config.json')))
api = sch_client.API(config['uri'], config['key'], config['secret'])
connection = pyodbc.connect(config['db_connection'])
cursor = connection.cursor()
verbose = False

residency_select = """
SELECT RESIDENT_COMMUTER, DORM_CAMPUS, DORM_BUILDING, DORM_ROOM, DORM_PLAN
FROM Residency
WHERE PEOPLE_CODE_ID = $%$id$%$
AND ACADEMIC_YEAR = $%$ACADEMIC_YEAR$%$
AND ACADEMIC_TERM = $%$ACADEMIC_TERM$%$
AND ACADEMIC_SESSION = $%$ACADEMIC_SESSION$%$
"""

residency_update = """
UPDATE Residency
SET DORM_CAMPUS = $%$DORM_CAMPUS$%$,
 RESIDENT_COMMUTER = $%$RESIDENT_COMMUTER$%$,
 DORM_PLAN = $%$DORM_PLAN$%$,
 DORM_BUILDING = $%$DORM_BUILDING$%$,
Ejemplo n.º 5
0
        return resident

    num_updated, num_skipped, missing_records, principals_updated = sch_client.set_residents_batch(api, iterate, columns, {}, 10)

    num_deactivated = 0
    if deactivate_missing:
        for instance in instances:
            instance_id = instance['id']
            if instance_id in resident_ids and len(resident_ids[instance_id]) > 0:
                del instance['id']
                api.printme("deactivating records for", ' ')
                for key in instance['key']:
                    api.printme(key + "='" + instance['key'][key], "' ")
                api.printme()

                result = api.set_residents_inactive(resident_ids[instance_id], instance['key'])
                num_deactivated += result['updated']

    api.printme("Records updated: " + str(num_updated))
    api.printme("Records skipped: " + str(num_skipped))
    api.printme("Records deactivated: " + str(num_deactivated))
    sch_client.printme("SSO principals updated: " + str(principals_updated))
    if len(missing_records) > 0:
        api.printme("Missing records:")
        for model, conditions in missing_records.items():
            api.printme("  " + model, ": ")
            for field, value in conditions.items():
                api.printme(field + " = '" + value, "' ")
            api.printme()
api.printme('------ End csv_import ------')