ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/CleanOut_Share.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: 1334 byte(s)
Log Message:
Initial Import

File Contents

# User Rev Content
1 ninoborges 8 ## 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)