| 1 |
ninoborges |
8 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
MCP_Console
|
| 4 |
|
|
|
| 5 |
|
|
Created by
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
08.28.2010
|
| 8 |
|
|
|
| 9 |
|
|
This will be the interface to add, edit and archive cases.
|
| 10 |
|
|
|
| 11 |
|
|
Should this work as one large GUI and you pick the below or read from argv and let you
|
| 12 |
|
|
just call it with what you want, making these three look like separate apps.
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
"""
|
| 16 |
|
|
|
| 17 |
|
|
import MCP_Lib,os,shutil,ConcordanceHelperTools, time,directorySize2
|
| 18 |
|
|
|
| 19 |
|
|
class MainConsole:
|
| 20 |
|
|
def __init__(self):
|
| 21 |
|
|
## Gather the case list
|
| 22 |
|
|
|
| 23 |
|
|
print "connecting to matter tracking access db..."
|
| 24 |
|
|
## Production version
|
| 25 |
|
|
self.accessDB = MCP_Lib.AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
|
| 26 |
|
|
self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo()
|
| 27 |
nino.borges |
189 |
#responsibleCases,casesDir = MCP_Lib.GetCaseList('',self.accessDB)
|
| 28 |
|
|
myCases, officeCases, allCases,casesDir= MCP_Lib.GetCaseList('',self.accessDB)
|
| 29 |
ninoborges |
8 |
|
| 30 |
|
|
## Testing version
|
| 31 |
|
|
#self.accessDB = MCP_Lib.AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
|
| 32 |
|
|
#responsibleCases,casesDir = MCP_Lib.GetCaseList(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP",self.accessDB)
|
| 33 |
|
|
#self.tPMName, self.tPMID, self.tPMOffice = MCP_Lib.GetTPMInfo(r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Dev\Python\NinoCode\Active_prgs\Concordance\MCP")
|
| 34 |
|
|
|
| 35 |
|
|
print "connected to DB."
|
| 36 |
|
|
|
| 37 |
nino.borges |
189 |
self.responsibleCasesList = myCases
|
| 38 |
ninoborges |
8 |
self.casesDir = casesDir
|
| 39 |
|
|
|
| 40 |
|
|
|
| 41 |
|
|
def AddNewCase(self, caseName, clientMatter, chargable = False, reviewPlatform = "", responsibleProcessingVendor = "",
|
| 42 |
|
|
responsibleScanningVendor = "",responsibleHostingVendor = ""):
|
| 43 |
|
|
## Add the local folders The GUI should test that the clm is 10 digits and has hyphen.
|
| 44 |
|
|
template = os.path.join(self.casesDir,'_Template_')
|
| 45 |
|
|
new = os.path.join(self.casesDir, caseName + '_(%s)'%clientMatter)
|
| 46 |
|
|
if os.path.exists(new):
|
| 47 |
|
|
print "ERROR: This case already exists!!"
|
| 48 |
|
|
else:
|
| 49 |
|
|
#print template
|
| 50 |
|
|
#print new
|
| 51 |
|
|
os.mkdir(new)
|
| 52 |
|
|
for file in os.listdir(template):
|
| 53 |
|
|
shutil.copy2(os.path.join(template,file),new)
|
| 54 |
|
|
## Check the H drive for the supplemental folders and the matter folder, only if they select Concordance.
|
| 55 |
|
|
self.SetCaseNameAndCLM(caseName,clientMatter)
|
| 56 |
|
|
self.AddCaseToAccessDB(caseName,clientMatter)
|
| 57 |
|
|
|
| 58 |
|
|
def AddCaseToAccessDB(self, caseName, clientMatter):
|
| 59 |
|
|
## First test to see if it's already in the DB.
|
| 60 |
|
|
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 61 |
|
|
clientMatter = clientMatter.replace("-",".")
|
| 62 |
|
|
if clientMatter in fullClientMatterList:
|
| 63 |
|
|
print "This client matter already exists in the database. Skipping."
|
| 64 |
|
|
else:
|
| 65 |
|
|
print "New client matter. Adding."
|
| 66 |
|
|
self.accessDB.AddNewCase(caseName, clientMatter, self.tPMName,self.tPMID,responsibleOffice = self.tPMOffice)
|
| 67 |
|
|
print "Added!"
|
| 68 |
|
|
|
| 69 |
|
|
def EditCaseData(self,caseName,chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice, caseStatus):
|
| 70 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 71 |
|
|
clientMatter = clientMatter[:-1]
|
| 72 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 73 |
|
|
self.accessDB.UpdateChargable(clientMatter,chargeableBool)
|
| 74 |
|
|
self.accessDB.UpdateResponsibleAttorney(clientMatter,respAttorney)
|
| 75 |
|
|
self.accessDB.UpdateResponsibleParalegal(clientMatter,respParalegal)
|
| 76 |
|
|
self.accessDB.UpdateReviewPlatform(clientMatter,revPlatform)
|
| 77 |
|
|
self.accessDB.UpdateResponsibleTPM(clientMatter,respTPM)
|
| 78 |
|
|
self.accessDB.UpdatePrimaryOffice(clientMatter,respOffice)
|
| 79 |
|
|
self.accessDB.UpdateResponsibleVendors(clientMatter,respVendorTpl)
|
| 80 |
|
|
self.accessDB.UpdateCaseStatus(clientMatter, caseStatus)
|
| 81 |
|
|
|
| 82 |
|
|
def GetCaseData(self, caseName):
|
| 83 |
|
|
#use this to get the data on the selected case, to populate your GUI
|
| 84 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 85 |
|
|
clientMatter = clientMatter[:-1]
|
| 86 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 87 |
|
|
chargeableBool = self.accessDB.GetChargable(clientMatter)
|
| 88 |
|
|
respAttorney = self.accessDB.GetResponsibleAttorney(clientMatter)
|
| 89 |
|
|
respParalegal = self.accessDB.GetResponsibleParalegal(clientMatter)
|
| 90 |
|
|
respVendorTpl = self.accessDB.GetResponsibleVendorTpl(clientMatter)
|
| 91 |
|
|
revPlatform = self.accessDB.GetReviewPlatform(clientMatter)
|
| 92 |
|
|
respTPM = self.accessDB.GetResponsibleTPM(clientMatter)
|
| 93 |
|
|
respOffice = self.accessDB.GetPrimaryOffice(clientMatter)
|
| 94 |
|
|
caseStatus = self.accessDB.GetCaseStatus(clientMatter)
|
| 95 |
|
|
return (chargeableBool,respAttorney,respParalegal,respVendorTpl,revPlatform,respTPM,respOffice,caseStatus)
|
| 96 |
|
|
|
| 97 |
|
|
def AddProductionEntry(self, CLM,prodID,prodDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes):
|
| 98 |
|
|
"""This method adds one production entry to the case."""
|
| 99 |
|
|
errRpt = True
|
| 100 |
|
|
if CLM:
|
| 101 |
|
|
if prodID:
|
| 102 |
|
|
if prodDate:
|
| 103 |
|
|
if begBates:
|
| 104 |
|
|
if endBates:
|
| 105 |
|
|
if prodDocCount:
|
| 106 |
|
|
if prodPageCount:
|
| 107 |
|
|
if prodNotes:
|
| 108 |
|
|
self.accessDB.UpdateProductionDetail(CLM,prodID,prodDate,begBates,endBates,prodDocCount, prodPageCount, prodNotes)
|
| 109 |
|
|
errRpt = False
|
| 110 |
|
|
return errRpt
|
| 111 |
|
|
|
| 112 |
|
|
def AddDataUpload(self,CLM, reviewPlatform, reportSize):
|
| 113 |
|
|
"""This method will add one case upload."""
|
| 114 |
|
|
## TODO: one day change it so that copy up requst calls this instead
|
| 115 |
|
|
## of it being internal to that prog.
|
| 116 |
|
|
epoch = str(int(time.time()))
|
| 117 |
|
|
self.accessDB.UpdateCaseUpload(CLM,reviewPlatform,{epoch:(time.strftime('%m/%d/%Y'),reportSize)})
|
| 118 |
|
|
|
| 119 |
|
|
def RemoveDataUpload(self,CLM,UEPOCH):
|
| 120 |
|
|
"""This method calls DeleteCaseUpload and removes just one case upload. """
|
| 121 |
|
|
err = self.accessDB.DeleteCaseUpload(CLM,UEPOCH)
|
| 122 |
|
|
if err:
|
| 123 |
|
|
print "ERROR: An Error occured and this value was not removed!"
|
| 124 |
|
|
else:
|
| 125 |
|
|
print "%s Removed"% UEPOCH
|
| 126 |
|
|
|
| 127 |
|
|
def GetUploadData(self, caseName):
|
| 128 |
|
|
# Used to get upload data, on the selected case, to populate the upload dialog
|
| 129 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 130 |
|
|
clientMatter = clientMatter[:-1]
|
| 131 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 132 |
|
|
uploadList = self.accessDB.RetrieveUploadsByCLM(clientMatter)
|
| 133 |
|
|
return uploadList
|
| 134 |
|
|
|
| 135 |
|
|
def GetProductionData(self,caseName):
|
| 136 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 137 |
|
|
clientMatter = clientMatter[:-1]
|
| 138 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 139 |
|
|
productionList = self.accessDB.RetrieveProductionsByCLM(clientMatter)
|
| 140 |
|
|
return productionList
|
| 141 |
|
|
|
| 142 |
|
|
def GetProductionTotal(self,productionList):
|
| 143 |
|
|
"""Using the above productionList, this returns the total docs and pages produced"""
|
| 144 |
|
|
pgCountTotal = 0
|
| 145 |
|
|
docCountTotal = 0
|
| 146 |
|
|
for i in productionList:
|
| 147 |
|
|
pageCount = i[-2]
|
| 148 |
|
|
docCount = i[-3]
|
| 149 |
|
|
if 'None' in pageCount:
|
| 150 |
|
|
pass
|
| 151 |
|
|
else:
|
| 152 |
|
|
#print pageCount
|
| 153 |
|
|
pgCountTotal = pgCountTotal+int(pageCount)
|
| 154 |
|
|
if 'None' in pageCount:
|
| 155 |
|
|
pass
|
| 156 |
|
|
else:
|
| 157 |
|
|
#print docCount
|
| 158 |
|
|
docCountTotal = docCountTotal+int(docCount)
|
| 159 |
|
|
return pgCountTotal,docCountTotal
|
| 160 |
|
|
|
| 161 |
|
|
def ExportProductionDataToExcel(self,CaseName,pathToCSV):
|
| 162 |
|
|
"""Exports the production data to a csv file"""
|
| 163 |
|
|
productionList = self.GetProductionData(CaseName)
|
| 164 |
|
|
#print productionList
|
| 165 |
|
|
outputFile = open(pathToCSV,'w')
|
| 166 |
|
|
outputFile.write('Production ID,Production Date,Start Bates,End Bates,Document Count,Page Count,Notes\n')
|
| 167 |
|
|
for i in productionList:
|
| 168 |
|
|
for x in i:
|
| 169 |
|
|
outputFile.write(x+",")
|
| 170 |
|
|
outputFile.write("\n")
|
| 171 |
|
|
outputFile.close()
|
| 172 |
|
|
|
| 173 |
|
|
def GetUploadTotal(self,uploadList):
|
| 174 |
|
|
""" Using the above uploadList, this will return the total uploaded """
|
| 175 |
|
|
count = 0.
|
| 176 |
|
|
for i in uploadList:
|
| 177 |
|
|
size = i[-1]
|
| 178 |
|
|
|
| 179 |
|
|
if 'None' in size:
|
| 180 |
|
|
pass
|
| 181 |
|
|
else:
|
| 182 |
|
|
rawSize = directorySize2.prettyToUnpretty_Filesize(size)
|
| 183 |
|
|
count = count + rawSize
|
| 184 |
|
|
prettySizeFinal = directorySize2.pretty_filesize2(count)
|
| 185 |
|
|
return prettySizeFinal
|
| 186 |
|
|
|
| 187 |
|
|
def MakeCaseDormant(self, caseAndCLM):
|
| 188 |
|
|
"""Moves the case to the Dormant folder"""
|
| 189 |
|
|
print "Making %s case dormant..."
|
| 190 |
|
|
os.rename(os.path.join(self.casesDir,caseAndCLM),os.path.join(self.casesDir,os.path.join('zzzz_dormant_', caseAndCLM)))
|
| 191 |
|
|
print "Case has been archived."
|
| 192 |
|
|
|
| 193 |
|
|
|
| 194 |
nino.borges |
158 |
def ViewCaseNotes(self,caseName,office):
|
| 195 |
|
|
"""Trys to open the case notes file,in the case folder, for the active case, regardless who owns it."""
|
| 196 |
|
|
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 197 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 198 |
|
|
clientMatter = clientMatter[:-1]
|
| 199 |
|
|
if "." in clientMatter:
|
| 200 |
|
|
clientMatter = clientMatter.replace('.','-')
|
| 201 |
|
|
folderMatrix = {}
|
| 202 |
|
|
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 203 |
|
|
err = False
|
| 204 |
|
|
if caseFolderLocation:
|
| 205 |
|
|
if os.path.exists(caseFolderLocation):
|
| 206 |
|
|
for f in os.listdir(caseFolderLocation):
|
| 207 |
|
|
if "_(" in f:
|
| 208 |
|
|
folderClientMatter = f.split("_(")[1]
|
| 209 |
|
|
folderClientMatter = folderClientMatter[:-1]
|
| 210 |
|
|
folderMatrix[folderClientMatter] = f
|
| 211 |
|
|
try:
|
| 212 |
|
|
folderName = folderMatrix[clientMatter]
|
| 213 |
|
|
os.startfile(os.path.join(caseFolderLocation, folderName)+"/Gen_Notes.txt")
|
| 214 |
|
|
except:
|
| 215 |
|
|
err = True
|
| 216 |
|
|
else:
|
| 217 |
|
|
err = True
|
| 218 |
|
|
else:
|
| 219 |
|
|
print "A case folder for this case was not found."
|
| 220 |
|
|
err = True
|
| 221 |
|
|
return err
|
| 222 |
|
|
|
| 223 |
|
|
def ViewProdSpec(self,caseName,office):
|
| 224 |
|
|
"""Trys to open the prod spec file,in the case folder, for the active case, regardless who owns it."""
|
| 225 |
|
|
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 226 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 227 |
|
|
clientMatter = clientMatter[:-1]
|
| 228 |
|
|
if "." in clientMatter:
|
| 229 |
|
|
clientMatter = clientMatter.replace('.','-')
|
| 230 |
|
|
folderMatrix = {}
|
| 231 |
|
|
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 232 |
|
|
err = False
|
| 233 |
|
|
if caseFolderLocation:
|
| 234 |
|
|
if os.path.exists(caseFolderLocation):
|
| 235 |
|
|
for f in os.listdir(caseFolderLocation):
|
| 236 |
|
|
if "_(" in f:
|
| 237 |
|
|
folderClientMatter = f.split("_(")[1]
|
| 238 |
|
|
folderClientMatter = folderClientMatter[:-1]
|
| 239 |
|
|
folderMatrix[folderClientMatter] = f
|
| 240 |
|
|
try:
|
| 241 |
|
|
folderName = folderMatrix[clientMatter]
|
| 242 |
|
|
os.startfile(os.path.join(caseFolderLocation, folderName+"/Production_Spec.txt"))
|
| 243 |
|
|
except:
|
| 244 |
|
|
err = True
|
| 245 |
|
|
else:
|
| 246 |
|
|
err = True
|
| 247 |
|
|
else:
|
| 248 |
|
|
print "A case folder for this case was not found."
|
| 249 |
|
|
err = True
|
| 250 |
|
|
return err
|
| 251 |
|
|
|
| 252 |
nino.borges |
261 |
def OpenAlternateMediaFolder(self,caseName,office):
|
| 253 |
|
|
"""Trys to open the Alternate media folder, for the active case, regardless who owns it."""
|
| 254 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 255 |
|
|
clientMatter = clientMatter[:-1]
|
| 256 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 257 |
|
|
altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
|
| 258 |
|
|
err = False
|
| 259 |
|
|
if altMediaPath:
|
| 260 |
|
|
if os.path.exists(altMediaPath):
|
| 261 |
|
|
os.startfile(altMediaPath)
|
| 262 |
|
|
else:
|
| 263 |
|
|
print "An alternate media folder for this case was not found."
|
| 264 |
|
|
err = True
|
| 265 |
|
|
else:
|
| 266 |
|
|
err = True
|
| 267 |
|
|
return err
|
| 268 |
nino.borges |
265 |
|
| 269 |
|
|
def SetAlternateMediaFolder(self,caseName,altMediaPath):
|
| 270 |
|
|
"""Sets the alternate Media Path"""
|
| 271 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 272 |
|
|
clientMatter = clientMatter[:-1]
|
| 273 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 274 |
|
|
self.accessDB.UpdateAlternateMediaPath(clientMatter,altMediaPath)
|
| 275 |
nino.borges |
261 |
|
| 276 |
nino.borges |
269 |
def GetVendorFolders(self,caseName):
|
| 277 |
nino.borges |
271 |
"""Returns the current list of vendor folders, for one case"""
|
| 278 |
nino.borges |
269 |
clientMatter = caseName.split("_(")[1]
|
| 279 |
|
|
clientMatter = clientMatter[:-1]
|
| 280 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 281 |
|
|
vendorFolders = self.accessDB.GetVendorFolderPath(clientMatter)
|
| 282 |
nino.borges |
271 |
#print "V%s "%vendorFolders
|
| 283 |
nino.borges |
269 |
return vendorFolders
|
| 284 |
nino.borges |
271 |
|
| 285 |
|
|
def SetVendorFolders(self,caseName, vendorFolders):
|
| 286 |
|
|
"""Sets the Vendor Folder"""
|
| 287 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 288 |
|
|
clientMatter = clientMatter[:-1]
|
| 289 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 290 |
|
|
self.accessDB.UpdateVendorFolderPath(clientMatter,vendorFolders)
|
| 291 |
|
|
|
| 292 |
|
|
def GetVendorFoldersList(self):
|
| 293 |
|
|
"""Returns a list of all vendorFolders"""
|
| 294 |
|
|
## Change this so that it actually grabs the current ones from ln. Dont know if I should grab from a table in access.
|
| 295 |
|
|
vendorFolderList = ["None"]
|
| 296 |
|
|
for n in range(1,61):
|
| 297 |
|
|
vendorFolderList.append("mwevendor%0*d"%(2,n))
|
| 298 |
|
|
return vendorFolderList
|
| 299 |
nino.borges |
269 |
|
| 300 |
nino.borges |
262 |
def GetCasePathsData(self,caseName, office):
|
| 301 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 302 |
|
|
clientMatter = clientMatter[:-1]
|
| 303 |
|
|
clientMatter = clientMatter.replace('-','.')
|
| 304 |
|
|
altMediaPath = self.accessDB.GetAlternateMediaPath(clientMatter)
|
| 305 |
|
|
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 306 |
|
|
caseFolderLocation = os.path.join(caseFolderLocation,caseName)
|
| 307 |
|
|
return altMediaPath, caseFolderLocation
|
| 308 |
|
|
|
| 309 |
ninoborges |
8 |
def OpenCaseFolder(self,caseName,office):
|
| 310 |
|
|
"""Trys to open the case folder for the active case, regardless who owns it."""
|
| 311 |
|
|
caseFolderLocation = MCP_Lib.GetOtherCaseFolder(office)
|
| 312 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 313 |
|
|
clientMatter = clientMatter[:-1]
|
| 314 |
|
|
if "." in clientMatter:
|
| 315 |
|
|
clientMatter = clientMatter.replace('.','-')
|
| 316 |
|
|
folderMatrix = {}
|
| 317 |
|
|
#caseFolderLocation = os.path.join(caseFolderLocation,case)
|
| 318 |
|
|
err = False
|
| 319 |
|
|
if caseFolderLocation:
|
| 320 |
|
|
if os.path.exists(caseFolderLocation):
|
| 321 |
|
|
for f in os.listdir(caseFolderLocation):
|
| 322 |
|
|
if "_(" in f:
|
| 323 |
|
|
folderClientMatter = f.split("_(")[1]
|
| 324 |
|
|
folderClientMatter = folderClientMatter[:-1]
|
| 325 |
|
|
folderMatrix[folderClientMatter] = f
|
| 326 |
|
|
try:
|
| 327 |
|
|
folderName = folderMatrix[clientMatter]
|
| 328 |
|
|
os.startfile(os.path.join(caseFolderLocation, folderName))
|
| 329 |
|
|
except:
|
| 330 |
|
|
err = True
|
| 331 |
|
|
else:
|
| 332 |
|
|
err = True
|
| 333 |
|
|
else:
|
| 334 |
|
|
print "A case folder for this case was not found."
|
| 335 |
|
|
err = True
|
| 336 |
|
|
return err
|
| 337 |
|
|
|
| 338 |
|
|
|
| 339 |
|
|
def SetCaseNameAndCLM(self, newCaseName, newClientMatterNumber):
|
| 340 |
|
|
"""Used when setting up a new case. Should have both or nothing"""
|
| 341 |
|
|
self.caseName = newCaseName
|
| 342 |
|
|
self.clientMatter = newClientMatterNumber
|
| 343 |
|
|
#print self.clientMatter
|
| 344 |
|
|
|
| 345 |
|
|
def SetChargableCase(self, chargBool):
|
| 346 |
|
|
"""sets or clears the chargable case settings"""
|
| 347 |
|
|
pass
|
| 348 |
|
|
def SetResponsibleVendor(self, vendorInfo):
|
| 349 |
|
|
"""Sets the vendor name that is responsible for the case"""
|
| 350 |
|
|
pass
|
| 351 |
|
|
def SetReviewPlatform(self, reviewPlatform):
|
| 352 |
|
|
"""Sets the review platform chosen for this case"""
|
| 353 |
|
|
if reviewPlatform == "Concordance":
|
| 354 |
|
|
print "Concordance selected. Creating DIS directories..."
|
| 355 |
|
|
hDrivePath = ConcordanceHelperTools.ParseClientMatter(self.clientMatter)
|
| 356 |
|
|
os.mkdir(hDrivePath)
|
| 357 |
|
|
print "Matter folder created."
|
| 358 |
|
|
os.mkdir(os.path.join(hDrivePath,'Match'))
|
| 359 |
|
|
os.mkdir(os.path.join(hDrivePath,'Tag_Databases'))
|
| 360 |
|
|
print "Supplemental folders created."
|
| 361 |
|
|
print "DIS directories done!"
|
| 362 |
|
|
|
| 363 |
|
|
|
| 364 |
|
|
|
| 365 |
|
|
def SyncWithAccessDB(self,case = 'ALL'):
|
| 366 |
|
|
"""Syncs your cases with the access database. This might only get run once when you first install
|
| 367 |
|
|
the program though..."""
|
| 368 |
|
|
## So this syncs 'your' databases only. even though you are looking at a list of eeryone's databases
|
| 369 |
|
|
## it will only sync yours. even if you did an upload for another tpm, that wouldnt get synced unles
|
| 370 |
|
|
## the owner did a sync all. for 2 way sync to work, you should check, in access, that they have the case name
|
| 371 |
|
|
## (with no funky characters) populated, before they run this for the first time.
|
| 372 |
|
|
if case == 'ALL':
|
| 373 |
|
|
## verify that all your cases are up there, if not add it. but have support for cases where is should be
|
| 374 |
|
|
## yours but is assigned to someone else...
|
| 375 |
|
|
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 376 |
|
|
myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
|
| 377 |
|
|
myLocalClientMatterList = []
|
| 378 |
|
|
|
| 379 |
|
|
## Sync cases from my local to access
|
| 380 |
|
|
for case in self.responsibleCasesList:
|
| 381 |
|
|
localCaseName,clientMatter = case.split("_(")
|
| 382 |
|
|
clientMatter = clientMatter.replace(")","")
|
| 383 |
|
|
clientMatter = clientMatter.replace("-",".")
|
| 384 |
|
|
myLocalClientMatterList.append(clientMatter)
|
| 385 |
|
|
for clm in myLocalClientMatterList:
|
| 386 |
|
|
if clm in myAccessClientMatterList:
|
| 387 |
|
|
print "%s exists"% clm
|
| 388 |
|
|
elif clm in fullClientMatterList:
|
| 389 |
|
|
print "%s cant be added to your cases because it's owned by someone else..."% clm
|
| 390 |
|
|
else:
|
| 391 |
|
|
print "%s does not exist in the database. Adding it..."% clm
|
| 392 |
|
|
self.AddCaseToAccessDB(localCaseName,clientMatter)
|
| 393 |
|
|
|
| 394 |
|
|
## Sync cases from Access to my local
|
| 395 |
|
|
|
| 396 |
|
|
|
| 397 |
|
|
uploadReportMatrix = {}
|
| 398 |
|
|
for caseName in self.responsibleCasesList:
|
| 399 |
|
|
print "now processing %s"% caseName
|
| 400 |
|
|
casePath = os.path.join(self.casesDir,caseName)
|
| 401 |
|
|
if os.path.exists(os.path.join(casePath,"UploadReport.txt")):
|
| 402 |
|
|
print "yup"
|
| 403 |
|
|
caseUploadContents = open(os.path.join(casePath,"UploadReport.txt")).readlines()
|
| 404 |
|
|
clientMatter = caseName.split("_(")[1]
|
| 405 |
|
|
clientMatter = clientMatter.replace(")","")
|
| 406 |
|
|
clientMatter = clientMatter.replace("-",".")
|
| 407 |
|
|
for i in caseUploadContents:
|
| 408 |
|
|
i = i.replace("\n","")
|
| 409 |
|
|
i = i.replace(" | ","|")
|
| 410 |
|
|
try:
|
| 411 |
|
|
uploadReportMatrix[clientMatter].append(("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3]))
|
| 412 |
|
|
except:
|
| 413 |
|
|
uploadReportMatrix[clientMatter] = [("%s"%i.split("|")[0],"%s"%i.split("|")[1],"%s"%i.split("|")[2],"%s"%i.split("|")[3])]
|
| 414 |
|
|
#print uploadReportMatrix
|
| 415 |
|
|
|
| 416 |
|
|
accessMyCaseUploads = self.accessDB.RetrieveMyCaseUploads('09756')
|
| 417 |
|
|
for x in uploadReportMatrix.keys():
|
| 418 |
|
|
localCaseUploadList = uploadReportMatrix[x]
|
| 419 |
|
|
tempMatrix = {}
|
| 420 |
|
|
try:
|
| 421 |
|
|
accessCaseUploadList = accessMyCaseUploads[x]
|
| 422 |
|
|
#print accessCaseUploadList
|
| 423 |
|
|
for y in localCaseUploadList:
|
| 424 |
|
|
epoch = y[0]
|
| 425 |
|
|
if int(epoch) > 1298462400:
|
| 426 |
|
|
#print epoch
|
| 427 |
|
|
reviewPlatform = y[1]
|
| 428 |
|
|
reportSize = y[3]
|
| 429 |
|
|
#print "."
|
| 430 |
|
|
#print accessCaseUploadList
|
| 431 |
|
|
if epoch in accessCaseUploadList:
|
| 432 |
|
|
print "%s, in the %s case, is already in there, skipping."%(y,x)
|
| 433 |
|
|
else:
|
| 434 |
|
|
print "%s, in the %s case, is missing. Will be added..."%(y,x)
|
| 435 |
|
|
date = y[2]
|
| 436 |
|
|
date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
|
| 437 |
|
|
|
| 438 |
|
|
self.accessDB.UpdateCaseUpload(x,reviewPlatform,{epoch:(date,reportSize)})
|
| 439 |
|
|
#tempMatrix[epoch] = [platform,(date,size)]
|
| 440 |
|
|
else:
|
| 441 |
|
|
#print "This entry is pre cutover"
|
| 442 |
|
|
pass
|
| 443 |
|
|
except KeyError:
|
| 444 |
|
|
print "nothing for this one"
|
| 445 |
|
|
for z in localCaseUploadList:
|
| 446 |
|
|
print "%s, in the %s case, is missing. Will be added..."%(z,x)
|
| 447 |
|
|
date = z[0]
|
| 448 |
|
|
date = "%s/%s/%s"%(date[4:6],date[6:],date[:4])
|
| 449 |
|
|
#try:
|
| 450 |
|
|
# tempMatrix[date].append(z[1])
|
| 451 |
|
|
#except:
|
| 452 |
|
|
# tempMatrix[date] = [z[1]]
|
| 453 |
|
|
#print tempMatrix
|
| 454 |
|
|
#if tempMatrix:
|
| 455 |
|
|
# #print tempMatrix
|
| 456 |
|
|
# self.accessDB.UpdateCaseUpload(x,'Concordance DIS', tempMatrix)
|
| 457 |
|
|
#pass
|
| 458 |
|
|
|
| 459 |
|
|
|
| 460 |
|
|
#print myLocalClientMatterList
|
| 461 |
|
|
## verify that all of your uploads are up there, if not, add it.
|
| 462 |
|
|
self.accessDB.CloseAccessConnection()
|
| 463 |
|
|
|
| 464 |
|
|
else:
|
| 465 |
|
|
fullClientMatterList = self.accessDB.RetrieveAllCaseList()
|
| 466 |
|
|
myAccessClientMatterList = self.accessDB.RetrieveMyCaseList(self.tPMID)
|
| 467 |
|
|
|
| 468 |
|
|
|