ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Concordance/ConcordanceBatchTestLockAndField.py
Revision: 186
Committed: Thu Nov 1 15:07:13 2012 UTC (13 years, 4 months ago) by nino.borges
Content type: text/x-python
File size: 2719 byte(s)
Log Message:
added iproHelpertools to toolbox

File Contents

# User Rev Content
1 ninoborges 8 """
2    
3     ConcordanceBatchTestLockAndField
4    
5     Created by
6     Emanuel Borges
7     04.11.2012
8    
9     This program will, running across a directory of concordance databases, check to see if the database has
10     people in it or can be opened in admin only mode. After determning this, it also checks to see if it has the
11     field that you are trying to add. It returns a list of admin-able databases
12    
13     """
14    
15     import ConcordanceHelperTools, ConcordanceCOMLib, os, sys
16    
17    
18     if __name__ == '__main__':
19     #sys.path[0] = r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\ConcordanceExtension\v8\Unstable\pyb_files\mwe"
20 nino.borges 186 #startDir = r"H:\03\037\37354873\OLD"
21     #testFieldList = ['PRIV_HIST','ADMIN_BEGNO','ADMIN_ENDNO']
22     startDir = r"H:\03\039\39323308"
23     testFieldList = ['PRODBEG_GJ','PRODEND_GJ','PRODNOTES_GJ','PRODDATE_GJ']
24 ninoborges 8 unLockedDBMatrix = {}
25 nino.borges 186 unadminable = []
26 ninoborges 8
27     ## walk
28     for root, dirs, files in os.walk(startDir):
29     ## enumerate
30     dbList = ConcordanceHelperTools.EnumerateConcordanceDatabases(root,files)
31     for dbName in dbList:
32 nino.borges 186 ## Test for the stupid md5 hash looking databases.
33     if dbName[:2] == "C-":
34     pass
35 ninoborges 8 else:
36 nino.borges 186 db = ConcordanceCOMLib.ConcordanceConnection(os.path.join(root,dbName))
37     db_testLock = db.ConcordObj.LockDatabase(db.DBHandle)
38     print "Checking to see if %s already has your fields"% dbName
39 ninoborges 8 dbFieldList = db.pyReturnPrettyFieldList()
40     for i in testFieldList:
41     if i in dbFieldList:
42     pass
43     else:
44 nino.borges 186 print "This database is missing the fields. Testing to see if it's adminable."
45     if db_testLock:
46     print "Database has people in it. Skipping."% dbName
47     unadminable.append(dbName)
48     else:
49     print "Adminable. Adding to list."
50     try:
51     unLockedDBMatrix[os.path.join(root,dbName)].append(i)
52     except:
53     unLockedDBMatrix[os.path.join(root,dbName)] = [i,]
54    
55     db.pyCloseDatabase()
56     db = ""
57 ninoborges 8 print "Here are a list of admin-able databases in this dir:"
58     for i in unLockedDBMatrix:
59 nino.borges 186 print "%s needs to be added to %s"%(str(unLockedDBMatrix[i]),i)
60     print ""
61     print "these are databases that need the fields but are unadminable...:"
62     for x in unadminable:
63     print x