ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Nav_update.py
Revision: 8
Committed: Sat May 5 04:21:19 2012 UTC (13 years, 10 months ago) by ninoborges
Content type: text/x-python
File size: 4458 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 ##Norton Antivirus definitions updater.
2     ##This program will automate the task of updating the virus defs on windows95 machines
3     #EBorges
4     #1.10.02
5    
6     from win32com.client import Dispatch
7     from win32com.client import constants
8     from lgflcntr import getoffice
9     import os, sys, string, time, shutil
10    
11     def main():
12     ver=sys.argv [1]
13     print "Updating the Virus Definitions to", ver
14     VirusUpdater()
15     IpfUpdater(ver)
16     contents = TodayUpdater(ver)
17     Tester()
18     Replicator()
19     #print "The replicator is off. Please replicate the nav and today.bat file manually."
20     newcontents = ""
21     for x in contents:
22     newcontents = newcontents + x
23     OutlookUpdater(newcontents)
24     print "done!"
25    
26     def VirusUpdater():
27     files=os.listdir('U:\\NAV_DEFS\\source')
28     for x in files:
29     os.remove('U:\\NAV_DEFS\\source\\'+ x)
30     #os.execl('\\\security\\virdefs\\newdefs.exe',' /EXTRACT u:\\nav_defs\\source')
31     ##The above replaces the Nav_update.py process with the execl... one
32     os.system('\\\security\\vir_defs\\newdefs.exe /EXTRACT u:\\nav_defs\\source')
33     ##This one does not. It runs it and waits.
34    
35     def IpfUpdater(ver):
36     f=open('U:\\NAV_DEFS\\NAV_Defs.ipf','r')
37     contents=f.readlines()
38     f.close()
39     version = " Value=" + ver + "\n"
40     contents[43] = version
41     f=open('U:\\NAV_DEFS\\NAV_Defs.ipf','w')
42     f.writelines(contents)
43     f.close()
44     os.system('"C:\\Program Files\\Microsoft SMS Installer\\SMSINS32.EXE" /C U:\\NAV_DEFS\\NAV_Defs.ipf')
45    
46     def Replicator():
47     appservers = getoffice()
48     for x in appservers:
49     #print "Replicating Nav_defs.exe to",x
50     #shutil.copy('U:\\NAV_DEFS\\NAV_Defs.exe', '\\\%s\\app\\update\\'%x)
51     os.system('robocopy U:\\NAV_DEFS\\ \\\%s\\app\\update\\ NAV_Defs.EXE /ETA /V'%x)
52     for y in appservers:
53     #print "Replicating Today.bat to",y
54     #shutil.copy('Y:\\update\\today.bat', '\\\%s\\app\\update\\'%y)
55     os.system('robocopy y:\\update\\ \\\%s\\app\\update\\ today.bat /ETA /V'%y)
56     print "Replication complete"
57    
58     def TodayUpdater(ver):
59     #f=open('Y:\\update\\today.bat','r')
60     f=open('U:\\nino\\Active SMS Installer Files\\TODAY_BAT\\today.bat','r')
61     contents = f.readlines()
62     f.close()
63     pos = -2
64     for x in contents:
65     res = string.find(x,'Updates Norton Anti-Virus definition files.')
66     pos = pos + 1
67     if res > -1:
68     break
69     pos2 = pos + 11
70     contents = contents[pos:pos2]
71     firstdate = time.strftime("%m\\%d\\%y")
72     seconddate = time.strftime("%m%d%y")
73     contents[0] = contents[0][:17] + firstdate + "\n" + contents[0][26:]
74     contents[3] = contents[3][0] + seconddate + "a" + "\n"
75     contents[4] = contents[4][:15] + ver + "\n"
76     newcontents = contents
77     f=open('U:\\NAV_DEFS\\today.txt','w')
78     f.writelines(contents)
79     f.close()
80     print "Please update the Today.bat file with the following:"
81     os.system('Notepad.exe u:\\NAV_DEFS\\today.txt')
82     os.system('Notepad.exe U:\\nino\\Active SMS Installer Files\\TODAY_BAT\\today.bat')
83     return newcontents
84    
85     def OutlookUpdater(newcontents):
86     o=Dispatch('Outlook.Application.9')
87     namespace = o.GetNamespace("Mapi")
88     folder = namespace.Folders.Item("Public Folders").Folders.Item("All Public Folders").Folders.Item("Departments / Practice Groups").Folders.Item("Information Technology").Folders.Item("IT Calendar")
89     appointment = folder.Items.Add(constants.olAppointmentItem)
90     appointment.Subject = "TODAY.BAT: d/l new virus definitions"
91     appointment.Location = "Windows 9x Workstations"
92     appointment.Start = time.strftime("%m %d, %Y %I:%M %p")
93     appointment.End = time.strftime("%m %d, %Y %I:%M %p")
94     newcontents = "Here is the text of the change: \n \n" + newcontents
95     appointment.Body = newcontents
96     appointment.Save()
97    
98     def Tester():
99     print "Replicating Nav_defs.exe to ANXFNB for testing"
100     #shutil.copy('U:\\NAV_DEFS\\NAV_Defs.EXE', 'Y:\\update\\')
101     os.system('robocopy U:\\NAV_DEFS\\ Y:\\update\\ NAV_Defs.EXE /ETA /V')
102     os.system('robocopy "U:\\nino\\Active SMS Installer Files\\TODAY_BAT\\" Y:\\update\\ Today.bat /ETA /V')
103     good = ""
104     while good <> "y":
105     good = raw_input("Test files are now in place. \nPlease boot up your test machine and verify.\nType y when finished.")
106    
107     if __name__ == '__main__':
108     main()