-
Notifications
You must be signed in to change notification settings - Fork 0
/
rules_loader.py
91 lines (68 loc) · 2.38 KB
/
rules_loader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import subprocess
from pyscript.contextInitiator import ContextInitiator
from pyscript.dbOperator import DBOperator
# import csv
# import shlex
# import ibm_db
def sendEmail(errMsg):
print "message: " + errMsg
def sendMessageAndExit(msg, *cleanTmpFile):
sendEmail(msg)
for cmd in cleanTmpFile:
subprocess.call(cmd, shell=True)
sys.exit()
if __name__ == "__main__":
context = ContextInitiator()
needUncataDbAlia = context.getProperDict()['needUncataDbAlia']
needUncataDbNode = context.getProperDict()['needUncataDbNode']
if needUncataDbAlia == '1':
needUncataDbAlia = True
elif needUncataDbAlia == '0':
needUncataDbAlia = False
if needUncataDbNode == '1':
needUncataDbNode = True
elif needUncataDbNode == '0':
needUncataDbNode = False
cleanTmp = "rm " + context.getWorkingPath() + "/../sqls/tmp_*"
cleanTmp = ""
# create temp sql files
# batchId = str(uuid.uuid1())
dbOp = DBOperator()
msg = dbOp.connDbAndSSH()
if not msg.strip():
# makeSpace
# commandRes = dbOp.makeSpace()
# if commandRes.strip():
# sendMessageAndExit(commandRes, cleanTmp)
commandRes = dbOp.getSmrProCsvs()
if commandRes.strip():
sendMessageAndExit(commandRes, cleanTmp)
commandRes = dbOp.importCSVLocally()
if commandRes.strip():
sendMessageAndExit(commandRes, cleanTmp)
# commandRes = dbOp.transFilesViaSSH()
# if commandRes.strip():
# sendMessageAndExit(commandRes,cleanTmp)
# commandRes = dbOp.importCSVs()
# if commandRes.strip():
# sendMessageAndExit(commandRes,cleanTmp)
# commandRes = dbOp.getFilesViaSSH()
# if commandRes.strip():
# sendMessageAndExit(commandRes,cleanTmp)
# commandRes = dbOp.toDiffTable()
# if commandRes.strip():
# sendMessageAndExit(commandRes, cleanTmp)
commandRes = dbOp.backupAndSnyc()
if commandRes.strip():
sendMessageAndExit(commandRes,cleanTmp)
else:
sendMessageAndExit('connectFaild: ' + msg, cleanTmp)
# uncatlog remote db's node and alias
dbOp.uncataNodeAlia(needUncataDbNode, needUncataDbAlia)
# set Table Phase
context.setTablePhases()
# clean tmp files
sendMessageAndExit('success', cleanTmp)