| 1 |
ninoborges |
8 |
"""Concordance COM"""
|
| 2 |
|
|
|
| 3 |
|
|
|
| 4 |
|
|
|
| 5 |
|
|
#these next 2 line is for forcing early binding when on another machine. ie. compiled
|
| 6 |
|
|
##from win32com.client import gencache
|
| 7 |
|
|
##gencache.EnsureModule('{3F0C36C7-3ED6-4675-975F-0AEC07E16B2E}', 0, 1, 0)
|
| 8 |
|
|
|
| 9 |
|
|
from win32com.client import Dispatch
|
| 10 |
|
|
|
| 11 |
|
|
o=Dispatch("ConcordanceServer")
|
| 12 |
|
|
#key = "9fc78546-3044-459f-a1ff-4932ad81b4a4:McDermott Will & Emery LLP"
|
| 13 |
|
|
#lkey = 2187594483l
|
| 14 |
|
|
# These next two keys are lower than the 32bit unsigned limit in python. That's why the top one didnt work.
|
| 15 |
|
|
key = "026d8a96-1b1e-4d35-b961-50fbca8b9748:McDermottWillEmery"
|
| 16 |
|
|
lkey = 1686351150
|
| 17 |
|
|
|
| 18 |
|
|
# Unlock server and check response
|
| 19 |
|
|
lockResponse = o.UnlockServer(key,lkey)
|
| 20 |
|
|
>>> lockResponse
|
| 21 |
|
|
1
|
| 22 |
|
|
|
| 23 |
|
|
# Open a db now that its unlocked.
|
| 24 |
|
|
db,dbError = o.OpenEx(r"\\ercdis12\admin\Share\Manny\WIP\Testing\Cowco.dcb","","")
|
| 25 |
|
|
|
| 26 |
|
|
# Moving around
|
| 27 |
|
|
>>> err = o.First(db, 0)
|
| 28 |
|
|
>>> err
|
| 29 |
|
|
0
|
| 30 |
|
|
|
| 31 |
|
|
>>> o.Next(db, 0)
|
| 32 |
|
|
0
|
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
# Tagging current record.
|
| 36 |
|
|
>>> o.TagEx(db, "", 0)
|
| 37 |
|
|
0
|
| 38 |
|
|
>>> o.Next(db, 0)
|
| 39 |
|
|
0
|
| 40 |
|
|
>>> o.TagEx(db, "Privileged", 0)
|
| 41 |
|
|
0
|
| 42 |
|
|
>>> o.Next(db, 0)
|
| 43 |
|
|
0
|
| 44 |
|
|
# This one actually made a new tag, since one didnt exist in the db.
|
| 45 |
|
|
>>> o.TagEx(db, "Sept", 0)
|
| 46 |
|
|
0
|
| 47 |
|
|
|
| 48 |
|
|
# Close DB and test
|
| 49 |
|
|
>>> o.Close(db)
|
| 50 |
|
|
0
|
| 51 |
|
|
>>> o.
|
| 52 |
|
|
>>> o.Next(db, 0)
|
| 53 |
|
|
-1
|
| 54 |
|
|
|
| 55 |
|
|
# Getting the value of a named field
|
| 56 |
|
|
>>> o.GetFieldEx(db,0, "NATIVEFILE",0,0)
|
| 57 |
|
|
(u'\\\\ercdis12\\e\\C_d\\54168090\\Native\\001\\BAIN000001.ppt', 51)
|
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
# Rewriting hyperlink checker.
|
| 61 |
|
|
>>> o.First(db,0)
|
| 62 |
|
|
0
|
| 63 |
|
|
>>> for i in range(14):
|
| 64 |
|
|
... link, code = o.GetFieldEx(db,0, "NATIVEFILE",0,0)
|
| 65 |
|
|
... if os.path.exists(link):
|
| 66 |
|
|
... print "yep"
|
| 67 |
|
|
... else:
|
| 68 |
|
|
... print "nope"
|
| 69 |
|
|
... response = o.Next(db, 0)
|
| 70 |
|
|
|
| 71 |
|
|
|
| 72 |
|
|
# Or better
|
| 73 |
|
|
>>> o.First(db,0)
|
| 74 |
|
|
0
|
| 75 |
|
|
>>> for i in range(14):
|
| 76 |
|
|
... link, code = o.GetFieldEx(db,0, "NATIVEFILE",0,0)
|
| 77 |
|
|
... if os.path.exists(link):
|
| 78 |
|
|
... o.TagEx(db,"Working",0)
|
| 79 |
|
|
... else:
|
| 80 |
|
|
... o.TagEx(db,"Broken",0)
|
| 81 |
|
|
... response = o.Next(db, 0)
|
| 82 |
|
|
... |