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

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     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     unLockedDBMatrix = {}
25    
26     ## walk
27     for root, dirs, files in os.walk(startDir):
28     ## enumerate
29     dbList = ConcordanceHelperTools.EnumerateConcordanceDatabases(root,files)
30     for dbName in dbList:
31     db = ConcordanceCOMLib.ConcordanceConnection(os.path.join(root,dbName))
32     db_testLock = db.ConcordObj.LockDatabase(db.DBHandle)
33    
34     ## test for reindex
35     if db_testLock:
36     ## reindex
37     print "%s Database has people in it. Skipping."% dbName
38    
39     else:
40     print "%s Database is available!! Checking to see if it already has your fields"% dbName
41    
42     dbFieldList = db.pyReturnPrettyFieldList()
43     for i in testFieldList:
44     if i in dbFieldList:
45     pass
46     else:
47     try:
48     unLockedDBMatrix[os.path.join(root,dbName)].append(i)
49     except:
50     unLockedDBMatrix[os.path.join(root,dbName)] = [i,]
51    
52     db.pyCloseDatabase()
53     db = ""
54     print "Here are a list of admin-able databases in this dir:"
55     for i in unLockedDBMatrix:
56     print "%s needs to be added to %s"%(str(unLockedDBMatrix[i]),i)