| 1 |
## This program will remove the contents of a directory on every app share and then replace
|
| 2 |
## those contents with a text file explaining the change.
|
| 3 |
#EBorges
|
| 4 |
#06.14.02
|
| 5 |
|
| 6 |
import os, sys, shutil
|
| 7 |
from lgflcntr import getoffice
|
| 8 |
|
| 9 |
def CleanOut(Directory, ReplacementFile):
|
| 10 |
FilesList = os.listdir(Directory)
|
| 11 |
print "!!!!WARNING!!!!\n You are About to delete the following files:\n", FilesList
|
| 12 |
print
|
| 13 |
print "and replace them with this text file:\n", ReplacementFile
|
| 14 |
print
|
| 15 |
raw_input('If you are sure that this is correct, Press any key.')
|
| 16 |
for file in FilesList:
|
| 17 |
Path = Directory +"\\"+ file
|
| 18 |
print "removing", Path
|
| 19 |
os.remove(Path)
|
| 20 |
shutil.copy(ReplacementFile,Directory)
|
| 21 |
|
| 22 |
if __name__ == "__main__":
|
| 23 |
print len(sys.argv)
|
| 24 |
if len(sys.argv) < 2:
|
| 25 |
Directory = raw_input('From Y:\\app\\update\\. What Directory would you like cleaned out? ')
|
| 26 |
ReplacementFile = raw_input("""You should leave a text file here to tell them\n
|
| 27 |
why this change was made. Where is this file? """)
|
| 28 |
else:
|
| 29 |
Directory = sys.argv[1]
|
| 30 |
ReplacementFile = sys.argv[2]
|
| 31 |
AppServers = getoffice()
|
| 32 |
for server in AppServers:
|
| 33 |
CurServer = "\\\%s\\app\\update\\" % server
|
| 34 |
Dir = CurServer + Directory
|
| 35 |
CleanOut(Dir, ReplacementFile)
|