Пример #1
0
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.now().strftime('%d_%m_%Y'))
    with open(os.path.join(os.path.dirname(__file__), logFileName),
              'a') as logFile:
        doLog('Startup deploy BDM Scripts ', logFile)

        zipfilename = os.path.join(os.path.dirname(__file__), 'bdmscripts.zip')
        zipf = zipfile.ZipFile(zipfilename, 'w', zipfile.ZIP_DEFLATED)
        zipdir(os.path.join(os.path.dirname(__file__), os.pardir), zipf)
        zipf.close()

        try:
            f = ftplib.FTP(DBRUC._ftpHOST, DBRUC._ftpLOGIN, DBRUC._ftpPASWD)
        except (socket.error, socket.gaierror), e:
            printAndLog('ERROR: cannot reach {}'.format(DBRUC._ftpHOST),
                        logFile)
        else:
            printAndLog('*** Connected to host {}'.format(DBRUC._ftpHOST),
                        logFile)

            ROOT = f.pwd()
            ###############################
            # deploy

            try:
                filename = 'bdmscripts.zip'
                srcInstallScript = os.path.join(os.path.dirname(__file__),
                                                'bdmScriptInstall.py')
                srcdataconfig = os.path.join(custom_config_dir,
                                             'databrugisconf.py')
                srcordoconfig = os.path.join(custom_config_dir, 'ordoconf.py')
Пример #2
0
            notifyFile.write("{} : {}\n".format(datetime.datetime.now(),
                                                myLine))


if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    mode = OCONF.getExecMode()
    dlevel = OCONF.getDebugLevel()
    OCONF.tokenFileWriteRunning(wfstepId)
    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            dbName = DBRUC._db_dbname
            printAndLog("Startup diffusion query FDW", logFile)

            conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                DBRUC._db_dbname, DBRUC._db_user, DBRUC._diff_db_host,
                DBRUC._db_password)

            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
                printAndLog("exit", logFile)
            else:
                conn = psycopg2.connect(conn_s)
                if dlevel == 'V':
                    printAndLog("Before wf_intextinter_1synchro", logFile)
                    cur = conn.cursor()
                    cur.execute(
                        "SELECT commonbrugis.wf_intextinter_1synchro()")
Пример #3
0
            notifyFile.write("{} : {}\n".format(datetime.datetime.now(),
                                                myLine))


if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    mode = OCONF.getExecMode()
    dlevel = OCONF.getDebugLevel()
    OCONF.tokenFileWriteRunning(wfstepId)
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))
    with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
        try:
            dbName = DBRUC._db_dbname
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog("Startup queryFDW", logFile)

            conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                dbName, DBRUC._db_user, DBRUC._prod_db_host,
                DBRUC._db_password)

            if dlevel == 'V':
                printAndLog("Connection string {}".format(conn_s), logFile)
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                conn = psycopg2.connect(conn_s)

                if dlevel == 'V':
                    printAndLog("After connect", logFile)
Пример #4
0
import shared.databrugisconf as DBRUC
import shared.ordoconf as OCONF

################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    mode = OCONF.getExecMode()
    dlevel = OCONF.getDebugLevel()
    OCONF.tokenFileWriteRunning(wfstepId)
    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog("Startup restore staging schemas", logFile)
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:

                conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                    DBRUC._db_dbname, DBRUC._db_user, DBRUC._staging_db_host,
                    DBRUC._db_password)

                if dlevel == 'V':
                    printAndLog("Connection string {}".format(conn_s), logFile)
                conn = psycopg2.connect(conn_s)
                cur = conn.cursor()

                for schem in DBRUC._staging_torestore_schemas:
Пример #5
0
################################################################################
if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    dlevel = OCONF.getDebugLevel()
    mode = OCONF.getExecMode()
    OCONF.tokenFileWriteRunning(wfstepId)
    # check for dbname
    dbname = DBRUC._db_dbname
    # check for schemaname
    schemas = DBRUC._diff_toharvest_schemas
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))
    with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
        try:
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog("Startup harvest.", logFile)
            nodename = platform.node()
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                for sch in schemas:
                    filename = "{}{}.backup".format(dbname, sch)
                    printAndLog("Export schema {}".format(sch), logFile)

                    fullpath = os.path.join(DBRUC._dbexportpath, filename)
                    if os.path.exists(fullpath):
                        if dlevel == 'V':
                            printAndLog(
                                "Cleaning {} of {}".format(
                                    DBRUC._dbexportpath, filename), logFile)
Пример #6
0
################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    dlevel = OCONF.getDebugLevel()
    mode = OCONF.getExecMode()
    OCONF.tokenFileWriteRunning(wfstepId)

    dbname = DBRUC._db_dbname
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))
    try:
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog('Startup dispatch ', logFile)
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                try:
                    f = ftplib.FTP(DBRUC._ftpHOST, DBRUC._ftpLOGIN,
                                   DBRUC._ftpPASWD)
                except (socket.error, socket.gaierror), e:
                    printAndLog('ERROR: cannot reach "%s"' % DBRUC._ftpHOST,
                                logFile)
                else:
                    printAndLog('*** Connected to host "%s"' % DBRUC._ftpHOST,
                                logFile)

                    ROOT = f.pwd()
Пример #7
0
from shared.printAndLog import printAndLog
import shared.databrugisconf as DBRUC
import shared.ordoconf as OCONF

################################################################################


if __name__ == "__main__":
	wfstepId = OCONF.getWorkflowID()
	dlevel = OCONF.getDebugLevel()
	mode = OCONF.getExecMode()
	OCONF.tokenFileWriteRunning(wfstepId)
	logFileName = "{}-{}.log".format(os.path.basename(__file__).replace('.py', ''),datetime.date.today().strftime('%d_%m_%Y'))
	try:
		with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
			printAndLog( "{} running".format(wfstepId),logFile)
			printAndLog('Startup ftp download', logFile)		
			if mode == "EMUL":
				printAndLog("EMULATION MODE", logFile)
			else:
				try:
					f = ftplib.FTP(DBRUC._ftpHOST, DBRUC._ftpLOGIN, DBRUC._ftpPASWD)
				except (socket.error, socket.gaierror), e:
					printAndLog('ERROR: cannot reach {} '.format(DBRUC._ftpHOST), logFile)
				else:
					printAndLog('*** Connected to host {} '.format(DBRUC._ftpHOST), logFile)
					ROOT = f.pwd()
		
					#########################################
					# Copy to prod
					dirn = DBRUC._dirDiff
Пример #8
0
        if len(res) < 1:
            return None
        else:
            return msgcontent
    except Exception:
        pass
    return None


if __name__ == "__main__":
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))
    with open(os.path.join(OCONF._ordopath, logFileName), 'a') as logFile:
        printAndLog("Start postMaster", logFile)

        ########################################
        # Retrieve all distributed TOKENS
        # Analyse content
        # 1° Check consitency (only one tokens replica should be done at the same time)
        # 2° Check for notification request.. (transit)
        # 3° Broadcast the token

        #########################################
        # set path
        dirndiff = "{}ordo/".format(OCONF._dirDiff)
        dirnstaging = "{}ordo/".format(OCONF._dirStaging)

        localDirn = "{}replica/".format(OCONF._ordopath)
Пример #9
0
            stateFile.write("{}\n".format(datetime.datetime.now()))
        else:
            stateFile.write("{} : {}\n".format(datetime.datetime.now(),
                                               myLine))


if __name__ == "__main__":
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))

    parentDir = os.path.join(os.path.dirname(__file__), os.pardir)
    print(parentDir)

    with open(os.path.join(OCONF._ordopath, logFileName), 'a') as logFile:
        printAndLog("Start Local Ordo on {}".format(LCONF._envName), logFile)

        csvpath = os.path.join(os.path.dirname(__file__), 'globalordo.csv')
        csvfile = open(csvpath)
        tokencontent = OCONF.parseTokenFile(OCONF._tokenFileName)

        printAndLog(
            "State is {} Step is {}".format(tokencontent['state'],
                                            tokencontent['step']), logFile)

        reader = csv.DictReader(csvfile)
        newstep = 'undefined'
        newstate = 'pending'

        ##############################################
        # Evaluation du next step sur base du step actif dans le fichier csv et de l'�tat actuel
Пример #10
0
from shared.rollingFile import rollingFile

################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    dlevel = OCONF.getDebugLevel()
    mode = OCONF.getExecMode()
    OCONF.tokenFileWriteRunning(wfstepId)
    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))

        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog("Startup cleanup publish schemas", logFile)
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                ##########################
                # Backup Publish
                filename = '{}{}.backup'.format(DBRUC._db_dbname,
                                                'brugis_publish')
                fullpath = os.path.join(DBRUC._backuppath, filename)
                cmd1 = "pg_dump --host {} --port 5432 --username {} --no-password  --format custom --blobs --encoding UTF8 --schema {} --file {}".format(
                    DBRUC._diff_db_host, DBRUC._db_userdump, 'brugis_publish',
                    fullpath)
                printAndLog("Dump {}".format(fullpath), logFile)

                os.system(cmd1)
Пример #11
0
import shared.ordoconf as OCONF

################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    mode = OCONF.getExecMode()
    dlevel = OCONF.getDebugLevel()
    OCONF.tokenFileWriteRunning(wfstepId)
    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            dbName = DBRUC._db_dbname
            printAndLog("{} running".format(wfstepId), logFile)
            printAndLog("Startup queryFDW", logFile)

            conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                dbName, DBRUC._db_user, DBRUC._prod_db_host,
                DBRUC._db_password)

            if dlevel == 'V':
                printAndLog("Connection string {}".format(conn_s), logFile)
            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
                OCONF.tokenFileWriteDone(wfstepId)
                exit()
            conn = psycopg2.connect(conn_s)

            if dlevel == 'V':
Пример #12
0
from shared.printAndLog import printAndLog

################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    dlevel = OCONF.getDebugLevel()
    mode = OCONF.getExecMode()
    OCONF.tokenFileWriteRunning(wfstepId)

    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            printAndLog("Startup restore diffusion schemas", logFile)
            conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                DBRUC._db_dbname, DBRUC._db_user, DBRUC._diff_db_host,
                DBRUC._db_password)

            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                conn = psycopg2.connect(conn_s)
                cur = conn.cursor()

                # Check that all expected files are present
                for schem in DBRUC._diff_torestore_schemas:
                    filename = '{}{}.backup'.format(DBRUC._db_dbname, schem)
                    fullpath = os.path.join(DBRUC._backuppath, filename)
                    if not os.path.exists(fullpath):
Пример #13
0
# -*- coding: latin_1 -*-
# State machine entry point
import os
import sys
import datetime

sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir))

import shared.ordoconf as OCONF
from shared.printAndLog import printAndLog

if __name__ == '__main__':
    logFileName = os.path.basename(__file__).replace('py', 'log')
    logFileName = "{}-{}.log".format(
        os.path.basename(__file__).replace('.py', ''),
        datetime.date.today().strftime('%d_%m_%Y'))

    with open(os.path.join(OCONF._ordopath, logFileName), 'w') as logFile:
        try:
            printAndLog("Exec Startup", logFile)
            ################
            ## Just ask transit
            tokenfile = open(OCONF._tokenFileName, 'w')
            tokenfile.write("DUMMY,done")
            tokenfile.close()

            printAndLog("Startup Done", logFile)
        except:
            pass
Пример #14
0
import shared.databrugisconf as DBRUC
import shared.ordoconf as OCONF

################################################################################

if __name__ == "__main__":
    wfstepId = OCONF.getWorkflowID()
    dlevel = OCONF.getDebugLevel()
    mode = OCONF.getExecMode()
    OCONF.tokenFileWriteRunning(wfstepId)
    try:
        logFileName = "{}-{}.log".format(
            os.path.basename(__file__).replace('.py', ''),
            datetime.date.today().strftime('%d_%m_%Y'))
        with open(os.path.join(DBRUC._mailDir, logFileName), 'a') as logFile:
            printAndLog("{} running".format(wfstepId), logFile)
            dbName = DBRUC._db_dbname
            printAndLog("Startup restore prod schemas", logFile)

            conn_s = "dbname='{}' user='******' host='{}' password='******'".format(
                dbName, DBRUC._db_user, DBRUC._prod_db_host,
                DBRUC._db_password)

            if mode == "EMUL":
                printAndLog("EMULATION MODE", logFile)
            else:
                printAndLog("Try connect", logFile)
                conn = psycopg2.connect(conn_s)
                cur = conn.cursor()

                # Check that all expected files are present