| 1 |
ninoborges |
8 |
## PS_Admin.py
|
| 2 |
|
|
## This program will be the central location for all of my Practice Support programs. This way Wanda and Steve
|
| 3 |
|
|
## will be able to use these program even when I'm not here. It will be in a NoteBook motif with each tab
|
| 4 |
|
|
## allowing the use of one of the many programs.
|
| 5 |
|
|
## EBorges
|
| 6 |
|
|
## 06.23.03
|
| 7 |
|
|
|
| 8 |
|
|
import Pmw, Wanda, os
|
| 9 |
|
|
from Tkinter import LEFT, RIGHT, BOTTOM, TOP, YES, BOTH
|
| 10 |
|
|
from tkFileDialog import asksaveasfilename
|
| 11 |
|
|
from tkMessageBox import showinfo
|
| 12 |
|
|
from tkDirectoryChooser import Chooser
|
| 13 |
|
|
|
| 14 |
|
|
def Main():
|
| 15 |
|
|
root = Pmw.initialise()
|
| 16 |
|
|
MainNb = Pmw.NoteBook(root)
|
| 17 |
|
|
MainNb.pack()
|
| 18 |
|
|
# <----Catalogue Files Section---->
|
| 19 |
|
|
catfilesTab = MainNb.add('Catalogue Files')
|
| 20 |
|
|
groupCatFiles = Pmw.Group(catfilesTab, tag_text = 'Gather all files and create a catalogue')
|
| 21 |
|
|
groupCatFiles.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
|
| 22 |
|
|
reportFileField = Pmw.EntryField(groupCatFiles.interior(), labelpos = 'w', label_text = 'End Results File: ')
|
| 23 |
|
|
catDirField = Pmw.EntryField(groupCatFiles.interior(), labelpos = 'w', label_text = 'Root Directory to Scan: ')
|
| 24 |
|
|
filesButtonBox = Pmw.ButtonBox(groupCatFiles.interior(), orient = 'vertical')
|
| 25 |
|
|
filesButtonBox.pack(side = RIGHT, anchor='n', padx = 1, pady = 5)
|
| 26 |
|
|
filesButtonBox.add('Browse File',command = (lambda reportFileFieldOBJ = reportFileField, Type = 'file':
|
| 27 |
|
|
CF_UpdateField(reportFileFieldOBJ,Type)))
|
| 28 |
|
|
filesButtonBox.add('Browse Dir', command = (lambda reportFileFieldOBJ = catDirField, Type = 'dir':
|
| 29 |
|
|
CF_UpdateField(reportFileFieldOBJ,Type)))
|
| 30 |
|
|
reportFileField.pack(padx = 3, pady = 10, anchor="w")
|
| 31 |
|
|
catDirField.pack(padx = 3, pady = 10, anchor="w")
|
| 32 |
|
|
catfilesButtonBox = Pmw.ButtonBox(groupCatFiles.interior())
|
| 33 |
|
|
catfilesButtonBox.pack(side = BOTTOM, anchor = 'e',pady = 20, padx = 20)
|
| 34 |
|
|
catfilesButtonBox.add(' Ok ', command = (lambda cf_MainDirOBJ = catDirField, cf_ReportFileOBJ = reportFileField:
|
| 35 |
|
|
CatalogueFiles(cf_MainDirOBJ, cf_ReportFileOBJ)))
|
| 36 |
|
|
catfilesButtonBox.add(' Cancel ', command = root.destroy)
|
| 37 |
|
|
catfilesButtonBox.add(' Info ', command = CF_Info)
|
| 38 |
|
|
catfilesButtonBox.alignbuttons()
|
| 39 |
|
|
# <----Catalogue Files Section END---->
|
| 40 |
|
|
|
| 41 |
|
|
# <----About Section---->
|
| 42 |
|
|
About = MainNb.add('About')
|
| 43 |
|
|
copyRightText = copyRightInfo()
|
| 44 |
|
|
groupA = Pmw.Group(About, tag_text = 'About PS Admin')
|
| 45 |
|
|
groupA.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
|
| 46 |
|
|
copyRight = Pmw.LabeledWidget(groupA.interior(), labelpos = 'w',label_text = copyRightText)
|
| 47 |
|
|
copyRight.pack()
|
| 48 |
|
|
# <----About Section END---->
|
| 49 |
|
|
root.title('PS Admin v0.02')
|
| 50 |
|
|
root.mainloop()
|
| 51 |
|
|
|
| 52 |
|
|
# <---Catalogue Files Functions--->
|
| 53 |
|
|
def CF_Info():
|
| 54 |
|
|
Message = """This program will create an Excel spreadsheet cataloguing
|
| 55 |
|
|
every file type from the Top level directory that you select. The
|
| 56 |
|
|
spreadsheet with contain results like "Doc files = 500" ect.\n\nFrom the main
|
| 57 |
|
|
window select the "End Results File" which is the Excel spread sheet that
|
| 58 |
|
|
the program will write the catalogue to.\n\nAlso select the "Root Dir to
|
| 59 |
|
|
scan" which is the starting point that the program will scan from. The
|
| 60 |
|
|
program will scan every subdirectory under this "Root" directory."""
|
| 61 |
|
|
showinfo(title = 'Catalogue Files Info', message = Message)
|
| 62 |
|
|
def CF_UpdateField(entryOBJ,Type):
|
| 63 |
|
|
if Type == 'file':
|
| 64 |
|
|
savefile = asksaveasfilename()
|
| 65 |
|
|
entryOBJ.setentry(savefile)
|
| 66 |
|
|
if Type == 'dir':
|
| 67 |
|
|
directory = Chooser().show()
|
| 68 |
|
|
entryOBJ.setentry(directory)
|
| 69 |
|
|
|
| 70 |
|
|
def CatalogueFiles(cf_MainDirOBJ, cf_ReportFileOBJ):
|
| 71 |
|
|
workDir = os.getenv('TEMP')
|
| 72 |
|
|
workDir = workDir + '\\' + 'Wanda'
|
| 73 |
|
|
Wanda.ClearWorkDir(workDir)
|
| 74 |
|
|
cf_MainDir = cf_MainDirOBJ.get()
|
| 75 |
|
|
cf_ReportFile = cf_ReportFileOBJ.get()
|
| 76 |
|
|
print "Now scaning directories and cataloging files...\n"
|
| 77 |
|
|
os.path.walk(cf_MainDir,Wanda.CatalogueDir,workDir)
|
| 78 |
|
|
Wanda.ReportFindings(workDir,cf_ReportFile)
|
| 79 |
|
|
|
| 80 |
|
|
# <---Catalogue Files Functions END--->
|
| 81 |
|
|
|
| 82 |
|
|
def Working(whatImDoing):
|
| 83 |
|
|
pass
|
| 84 |
|
|
|
| 85 |
|
|
def copyRightInfo():
|
| 86 |
|
|
mainText = """PS_Admin.exe
|
| 87 |
|
|
|
| 88 |
|
|
Version 0.12
|
| 89 |
|
|
Copyright (C) 2002 Emanuel Borges
|
| 90 |
|
|
All Rights Reserved
|
| 91 |
|
|
|
| 92 |
|
|
This software is released under the terms of the GPL. Which states
|
| 93 |
|
|
that you can Copy, Distribute and even modify this code as long as
|
| 94 |
|
|
you never redistribute the original or modified code as closed source.
|
| 95 |
|
|
|
| 96 |
|
|
For information about this program or to report bugs contact:
|
| 97 |
|
|
Emanuel Borges
|
| 98 |
|
|
email: Eaborges@hotmail.com
|
| 99 |
|
|
"""
|
| 100 |
|
|
return mainText
|
| 101 |
|
|
|
| 102 |
|
|
if __name__ == '__main__':
|
| 103 |
|
|
Main() |