Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- import datetime
- import pymssql
- server = "192.168.10.113"
- user ="sa"
- password ="vtm"
- conn = pymssql.connect(server, user, password, "vtm_cls")
- print("실행 %s"%(datetime.datetime.now()))
- cursor = conn.cursor()
- S_StartEventTime = re.compile('StartTime:[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}')
- S_ENDEventTime = re.compile('StopTime:[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}')
- S_station = re.compile('Station:[0-9]*')
- S_Switch = re.compile('Switch:[0-9]*')
- S_Agent = re.compile('Agent:[0-9]*')
- S_CallID = re.compile('CallID:[0-9]*')
- S_CallIndex = re.compile('CallIndex:[0-9]*')
- S_PhoneNumber = re.compile('PhoneNumber:[0-9]*')
- S_Option1 = re.compile('Option1:[0-9]*')
- S_Option2 = re.compile('Option2:[0-9]*')
- S_Option3 = re.compile('Option3:[0-9]*')
- S_Option4 = re.compile('Option4:[0-9]*')
- S_Option5 = re.compile('Option5:[0-9]*')
- S_Option6 = re.compile('Option6:[0-9]*')
- S_Option7 = re.compile('Option7:[0-9]*')
- S_Option8 = re.compile('Option8:[0-9]*')
- S_Option9 = re.compile('Option9:[0-9]*')
- S_Option10 = re.compile('Option10:[0-9]*')
- S_Option11 = re.compile('Option11:[0-9]*')
- S_Option12 = re.compile('Option12:[0-9]*')
- S_Option13 = re.compile('Option13:[0-9]*')
- S_Option14 = re.compile('Option14:[0-9]*')
- S_Option15 = re.compile('Option15:[0-9]*')
- S_Option16 = re.compile('Option16:[0-9]*')
- S_Option17 = re.compile('Option17:[0-9]*')
- S_Option18 = re.compile('Option18:[0-9]*')
- S_Option19 = re.compile('Option19:[0-9]*')
- S_Option20 = re.compile('Option20:[0-9]*')
- S_logger = re.compile('Logger:[0-9]*')
- S_channel=re.compile('Channel:[0-9]*')
- S_Direction=re.compile('Direction:[a-z,A-Z]*')
- S_Status=re.compile('Status:[a-z,A-Z]*')
- try:
- f=open('calllink_call_20150727.log','r')
- call=open('ServerCALL_%s.txt'%(datetime.datetime.now()), 'w')
- data=f.read()
- f.close()
- for line in data.strip().splitlines():
- if line.strip():
- ServerCALL = re.search('REPORTED',line)
- try:
- Start_Time = S_StartEventTime.search(line).group().split('StartTime:')[1]
- except:
- Start_Time = ''
- try:
- Stop_Time = S_ENDEventTime.search(line).group().split('StopTime:')[1]
- except:
- Stop_Time = ''
- try:
- Rec_Start_Time =S_StartEventTime.search(line).group().split('StartTime:')[1]
- except:
- Rec_Start_Time = ''
- try:
- Duration = 0
- except:
- Duration = 0
- try:
- Station = S_station.search(line).group().split(':')[1].split(',')[0]
- except:
- Station = ''
- try:
- Trunk = ''
- except:
- Trunk = ''
- try:
- Trunk_Label = ''
- except:
- Trunk_Label = ''
- try:
- Direction =S_Direction.search(line).group().split(':')[1].split(',')[0]
- except:
- Direction = ''
- try:
- Logger = S_logger.search(line).group().split(':')[1]
- except:
- Logger = 0
- try:
- Channel = S_channel.search(line).group().split(':')[1]
- except:
- Channel = 0
- try:
- Agent_ID = S_Agent.search(line).group().split(':')[1]
- except:
- Agent_ID = 0
- try:
- Agent_Name = ''
- except:
- Agent_Name = ''
- try:
- UserID = 0
- except:
- UserID = 0
- try:
- Comment = ''
- except:
- Comment = ''
- try:
- Flags = 0
- except:
- Flags = 0
- try:
- Status = S_Status.search(line).group().split(':')[1].split(',')[0]
- except:
- Status = ''
- try:
- Unit = 0
- except:
- Unit = 0
- try:
- Phone_Number = S_PhoneNumber.search(line).group().split(':')[1]
- except:
- Phone_Number = ''
- try:
- Dialed_In = ''
- except:
- Dialed_In = ''
- try:
- Call_ID = S_CallID.search(line).group().split(':')[1]
- except:
- Call_ID = 0
- try:
- # Call_Index = S_CallIndex.search(line).group().split(':')[1]
- Call_Index = 0
- except:
- Call_Index = 0
- try:
- Device = ''
- except:
- Device = ''
- try:
- Department = ''
- except:
- Department = ''
- try:
- Cls_Call_Id = 0
- except:
- Cls_Call_Id = 0
- try:
- Locked = ''
- except:
- Locked = ''
- try:
- QA = 0
- except:
- QA = 0
- try:
- QA_Program = ''
- except:
- QA_Program = ''
- try:
- Rec_Program = ''
- except:
- Rec_Program = ''
- try:
- Rec_Initiator = ''
- except:
- Rec_Initiator = ''
- try:
- Evaluated = 0
- except:
- Evaluated = 0
- try:
- Recorded = ''
- except:
- Recorded = ''
- try:
- CompoundID = 0
- except:
- CompoundID = 0
- try:
- Optional1 = S_Option1.search(line).group().split(':')[1]
- except:
- Optional1 = ''
- try:
- Optional2 = S_Option2.search(line).group().split(':')[1]
- except:
- Optional2 = ''
- try:
- Optional3 = S_Option3.search(line).group().split(':')[1]
- except:
- Optional3 = ''
- try:
- Optional4 = S_Option4.search(line).group().split(':')[1]
- except:
- Optional4 = ''
- try:
- Optional5 = S_Option5.search(line).group().split(':')[1]
- except:
- Optional5 = ''
- try:
- Optional6 = S_Option6.search(line).group().split(':')[1]
- except:
- Optional6 = ''
- try:
- Optional7 = S_Option7.search(line).group().split(':')[1]
- except:
- Optional7 = ''
- try:
- Optional8 = S_Option8.search(line).group().split(':')[1]
- except:
- Optional8 = ''
- try:
- Optional9 = S_Option9.search(line).group().split(':')[1]
- except:
- Optional9 = ''
- try:
- Optional10 = S_Option10.search(line).group().split(':')[1]
- except:
- Optional10 = ''
- try:
- Optional11 = S_Option11.search(line).group().split(':')[1]
- except:
- Optional11 = ''
- try:
- Optional12 = S_Option12.search(line).group().split(':')[1]
- except:
- Optional12 = ''
- try:
- Optional13 = S_Option13.search(line).group().split(':')[1]
- except:
- Optional13 = ''
- try:
- Optional14 = S_Option14.search(line).group().split(':')[1]
- except:
- Optional14 = ''
- try:
- Optional15 = S_Option15.search(line).group().split(':')[1]
- except:
- Optional15 = ''
- try:
- Optional16 = S_Option16.search(line).group().split(':')[1]
- except:
- Optional16 = ''
- try:
- Optional17 = ''
- except:
- Optional17 = S_Option17.search(line).group().split(':')[1]
- try:
- Optional18 = ''
- except:
- Optional18 = S_Option18.search(line).group().split(':')[1]
- try:
- Optional19 = ''
- except:
- Optional19 = S_Option19.search(line).group().split(':')[1]
- try:
- Optional20 = ''
- except:
- Optional20 = S_Option20.search(line).group().split(':')[1]
- try:
- TagStartTime = ''
- except:
- TagStartTime = ''
- try:
- TagEndTime = ''
- except:
- TagEndTime = ''
- try:
- TagStartTime2 = ''
- except:
- TagStartTime2 = ''
- try:
- TagEndTime2 = ''
- except:
- TagEndTime2 = ''
- try:
- TagStartTime3 = ''
- except:
- TagStartTime3 = ''
- try:
- TagEndTime3 = ''
- except:
- TagEndTime3 = ''
- try:
- EvaluatorID = 0
- except:
- EvaluatorID = 0
- try:
- StoragePath = ''
- except:
- StoragePath = ''
- try:
- nDiskSpaceSize = ''
- except:
- nDiskSpaceSize = ''
- try:
- StorageName = ''
- except:
- StorageName = ''
- try:
- cSLAVIPath = ''
- except:
- cSLAVIPath = ''
- try:
- iSLID = 0
- except:
- iSLID = 0
- try:
- iSLAVIExist = 0
- except:
- iSLAVIExist = 0
- try:
- cslstoragepath = ''
- except:
- cslstoragepath = ''
- try:
- cSLStorageName = ''
- except:
- cSLStorageName = ''
- try:
- iSLDiskSpaceSize = 0
- except:
- iSLDiskSpaceSize = 0
- try:
- iSLFlags = 0
- except:
- iSLFlags = 0
- if ServerCALL:
- call.write(line + "\n")
- cursor.execute("""
- INSERT INTO vtm_cls.dbo.CALL_0081
- (Start_Time, Stop_Time, Rec_Start_Time, Duration, Station, Trunk, Trunk_Label, Direction, Logger, Channel, Agent_ID, Agent_Name, UserID, Comment, Flags, Status, Unit, Phone_Number, Dialed_In, Call_ID, Call_Index, Device, Department, Cls_Call_Id, Locked, QA, QA_Program, Rec_Program, Rec_Initiator, Evaluated, Recorded, CompoundID, Optional1, Optional2, Optional3, Optional4, Optional5, Optional6, Optional7, Optional8, Optional9, Optional10, Optional11, Optional12, Optional13, Optional14, Optional15, Optional16, Optional17, Optional18, Optional19, Optional20, TagStartTime, TagEndTime, TagStartTime2, TagEndTime2, TagStartTime3, TagEndTime3, EvaluatorID, StoragePath, nDiskSpaceSize, StorageName, cSLAVIPath, iSLID, iSLAVIExist, cslstoragepath, cSLStorageName, iSLDiskSpaceSize, iSLFlags)
- VALUES(%(start_time)s,%(stop_Time)s, %(rec_start_time)s, %(duration)d, %(station)s, %(trunk)s, %(trunk_label)s, %(direction)s, %(logger)d, %(channel)d, %(agent_id)d, %(agent_name)s, %(userid)d, %(comment)s, %(flags)s, %(status)s, %(unit)d, %(phone_number)s, %(dialed_in)s, %(call_id)d, %(call_index)d, %(device)s, %(department)s, %(cls_call_id)d, %(locked)s, %(qa)d, %(qa_program)s, %(rec_program)s, %(rec_initiator)s, %(evaluated)d, %(recorded)s, %(compoundid)d, %(optional1)s, %(optional2)s, %(optional3)s, %(optional4)s, %(optional5)s, %(optional6)s, %(optional7)s, %(optional8)s, %(optional9)s, %(optional10)s, %(optional11)s, %(optional12)s, %(optional13)s, %(optional14)s, %(optional15)s, %(optional16)s, %(optional17)s, %(optional18)s, %(optional19)s, %(optional20)s, %(tagstarttime)s, %(tagendtime)s, %(tagstarttime2)s, %(tagendtime2)s, %(tagstarttime3)s, %(tagendtime3)s, %(evaluatorid)d, %(storagepath)s,%(ndiskspacesize)d,%(storagename)s,%(cslavipath)s,%(islid)d,%(islaviexist)d, %(Cslstoragepath)s,%(cslstoragename)s,%(isldiskspacesize)d, %(islflags)d);
- """, {'start_time': Start_Time, 'stop_Time': Stop_Time, 'rec_start_time': Rec_Start_Time,
- 'duration': Duration, 'station': Station, 'trunk': Trunk, 'trunk_label': Trunk_Label,
- 'direction': Direction, 'logger': Logger, 'channel': Channel, 'agent_id': Agent_ID,
- 'agent_name': Agent_Name, 'userid': UserID, 'comment': Comment, 'flags': Flags,
- 'status': Status, 'unit': Unit, 'phone_number': Phone_Number, 'dialed_in': Dialed_In,
- 'call_id': Call_ID, 'call_index': Call_Index, 'device': Device,
- 'department': Department, 'cls_call_id': Cls_Call_Id, 'locked': Locked, 'qa': QA,
- 'qa_program': QA_Program, 'rec_program': Rec_Program, 'rec_initiator': Rec_Initiator,
- 'evaluated': Evaluated, 'recorded': Recorded, 'compoundid': CompoundID,
- 'optional1': Optional1, 'optional2': Optional2, 'optional3': Optional3,
- 'optional4': Optional4, 'optional5': Optional5, 'optional6': Optional6,
- 'optional7': Optional7, 'optional8': Optional8, 'optional9': Optional9,
- 'optional10': Optional10, 'optional11': Optional11, 'optional12': Optional12,
- 'optional13': Optional13, 'optional14': Optional14, 'optional15': Optional15,
- 'optional16': Optional16, 'optional17': Optional17, 'optional18': Optional18,
- 'optional19': Optional19, 'optional20': Optional20, 'tagstarttime': TagStartTime,
- 'tagendtime': TagEndTime, 'tagstarttime2': TagStartTime2, 'tagendtime2': TagEndTime2,
- 'tagstarttime3': TagStartTime3, 'tagendtime3': TagEndTime3,
- 'evaluatorid': EvaluatorID, 'storagepath': StoragePath,
- 'ndiskspacesize': nDiskSpaceSize, 'storagename': StorageName,
- 'cslavipath': cSLAVIPath, 'islid': iSLID, 'islaviexist': iSLAVIExist,
- 'Cslstoragepath': cslstoragepath, 'cslstoragename': cSLStorageName,
- 'isldiskspacesize': iSLDiskSpaceSize, 'islflags': iSLFlags})
- conn.commit()
- else:
- continue
- finally:
- cursor.execute("""UPDATE vtm_cls.dbo.CALL_0081 SET [Duration]=DATEDIFF(ss,[Start_Time],[Stop_Time])""")
- conn.commit()
- call.close()
- conn.close()
- print("완료 %s"%(datetime.datetime.now()))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement