-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckUpdateSACM211.py
61 lines (48 loc) · 1.81 KB
/
checkUpdateSACM211.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
#!/bin/env python
import pandas as pd
import cx_Oracle
from sacm.password import *
import sys
try:
conn = cx_Oracle.connect(databaseSCO)
cursor = conn.cursor()
except Exception as e:
print e
sys.exit(1)
def checkDB(uid=None,cursor=None):
sql = "select * from alma.xml_updates where asdm_uid = '%s' and elaboration like 'SACM-211'"%uid
#print sql
try:
cursor.execute(sql)
except Exception as e:
print e
sys.exit(1)
result = cursor.fetchall()
if len(result) > 0:
return True
else:
return False
image = pd.read_csv('releaseImage.txt',sep='|')
image['updated'] = image.apply(lambda x: checkDB(x['EB'], cursor) , axis = 1)
arcs = pd.read_csv('arcs.csv',sep = ' ', header= None)
arcs.columns = ['all']
arcs['code'],arcs['arc'] = zip(*arcs.apply(lambda x: x['all'].split('\t') , axis = 1 ))
df = pd.merge(image,arcs,left_on='CODE',right_on='code',how='inner')
df1 = df[['CODE','arc','SB','EB','updated']]
to_html = open('sacm211.html','w')
to_html.write('<html><head></head><body>'+df1.to_html(index=False,escape=False)+'</body></html>')
to_html.close()
f = open('point_zero_one.csv', 'r')
g = list()
foo = f.readlines()
for idx, i in enumerate(foo):
if 'uid' in i:
g.append((foo[idx].replace('\n','').split(' ')[0], foo[idx].replace('\n','').split(' ')[1], foo[idx].replace('\n','').split(' ')[2], foo[idx+1].replace('Max.Offset error:','').replace('\n','').replace(' ','')))
df = pd.DataFrame(g, columns=['uid','sb','code','error'])
df['updated'] = df.apply(lambda x: checkDB(x['uid'], cursor) , axis = 1)
df = df.sort(['code'])
df = df.reset_index(drop=True)
df1 = df[['code','sb','uid','updated']]
to_html = open('sacm211-all.html','w')
to_html.write('<html><head></head><body>'+df1.to_html(index=False,escape=False)+'</body></html>')
to_html.close()