ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/Trunk/MCP_Lib.py
Revision: 578
Committed: Thu Mar 26 13:49:38 2015 UTC (11 years ago) by nino.borges
Content type: text/x-python
File size: 58176 byte(s)
Log Message:
update before leaving

File Contents

# Content
1 """
2
3 MCP_Lib
4
5 Created by
6 Emanuel Borges
7 10.25.2010
8
9 This wil be the main library for the MCP aplications. Shared methods will be
10 kept here. Version informaiton for the entire MCP program will be kept here to.
11
12 """
13
14 import os,sys, win32com.client,ConcordanceHelperTools,subprocess,ftplib,NinoGenTools, win32com.decimal_23
15
16 def GetCaseList(sys_Overwrite ="", accessConnectionObj = None):
17 """ Main method to parse and return usable lists of cases. returns list of my cases, office cases and all cases.
18 also returns the cases directory."""
19 #print os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")
20 if sys_Overwrite:
21 casesDir = open(os.path.join(sys_Overwrite,"settings.sys")).readline().replace("\n","")
22 else:
23 casesDir = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readline().replace("\n","")
24 #casesDir = r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Documents\Cases"
25 responsibleCases = []
26 activeCases = []
27 officeCases = []
28 allCases = []
29 casePathStyleMatrix = {}
30 tPMName,tPMID,nul = GetTPMInfo()
31 if accessConnectionObj:
32 accessDB = accessConnectionObj
33 else:
34 print "connecting to matter tracking access db..."
35 ## Production version
36 accessDB = AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
37
38 ## Testing version
39 #accessDB = AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
40 print "connected to DB."
41 officeList = GetFullOfficeList()
42
43 cliMatList = []
44 for office in officeList:
45 cliMatList.extend(accessDB.RetrieveOfficeCaseList(office))
46 cliMatList.sort()
47 for cliMat in cliMatList:
48 caseName = accessDB.GetCaseName(cliMat)
49 casePathStyle = accessDB.GetCasePathStyle(cliMat)
50
51 cliMat = cliMat.replace(".","-")
52
53 allCases.append('%s_(%s)'%(caseName,cliMat))
54
55 if not casePathStyle:
56 casePathStyle = None
57 #casePathStyleMatrix['%s_(%s)'%(caseName,cliMat)] = casePathStyle
58 casePathStyleMatrix['%s'%cliMat] = casePathStyle
59
60 if tPMName == 'ANALYST':
61 casesDir = None
62 officeCases = allCases
63 responsibleCases = allCases
64 activeCases = allCases
65 else:
66 myMatterList = accessDB.RetrieveMyCaseList(tPMID)
67 myActiveMatterList = accessDB.RetrieveMyActiveCaseList(tPMID)
68 for file in os.listdir(casesDir):
69 if os.path.isdir(os.path.join(casesDir,file)):
70 if file == "_Template_":
71 pass
72 elif file == "zzzz_dormant_":
73 pass
74 else:
75 officeCases.append(file)
76 ## if the case's matter is in my matter list, also append to responsibleCases
77 clientMatter = file.split("_(")[1]
78 clientMatter = clientMatter[:-1]
79 clientMatter = clientMatter.replace('-','.')
80 if clientMatter in myMatterList:
81 responsibleCases.append(file)
82 if clientMatter in myActiveMatterList:
83 activeCases.append(file)
84 responsibleCases.sort()
85 activeCases.sort()
86 officeCases.sort()
87 return responsibleCases, activeCases, officeCases, allCases, casesDir,casePathStyleMatrix
88
89 def GetTPMInfo(sys_Overwrite = ""):
90 """ Main method to parse and return the TMP and the Employee ID"""
91 if sys_Overwrite:
92 syscaseDir,tPMName, tPMID,office = open(os.path.join(sys_Overwrite,"settings.sys")).readlines()
93 else:
94 syscaseDir,tPMName, tPMID,office = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
95
96 #syscaseDir,tPMName, tPMID = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
97 tPMName = tPMName.replace("\n","")
98 tPMID = tPMID.replace("\n","")
99 office = office.replace("\n","")
100 return tPMName, tPMID, office
101
102 def GetFullOfficeList():
103 """Simply returns a list of all of the offices."""
104 officeList = ['Boston','Brussels','Chicago','Huston','London','Los Angeles','Miami','Moscow','Munich','New York',
105 'Orange County','Rome','San Diego','Silicon Valley','Washington, D.C.']
106 return officeList
107
108 def GetOtherCaseFolder(office):
109 """This method will return the case folder for cases that you dont own"""
110 ## So this is in two places that I now have to maintian... not sure I like that.
111 caseFolderMatrix={'Boston':r"\\bstads01\app\Manny\Cases",
112 'Chicago':r"\\chiads01\data\CLI\Litigation_Support\MCP\Cases",
113 'Los Angeles':r"\\lasads01\data\Cli\_Lit_Support\MCP",
114 'New York':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
115 'Miami':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
116 'Orange County':r"\\lasads01\data\Cli\_Lit_Support\MCP",
117 'San Diego':r"\\lasads01\data\Cli\_Lit_Support\MCP",
118 'Silicon Valley':r"\\lasads01\data\Cli\_Lit_Support\MCP",
119 'Washington, D.C.':r"\\wdcads01\data\Cli\_Lit_Support\MCP\Cases"}
120 try:
121 location = caseFolderMatrix[office]
122 except:
123 location = None
124 return location
125 def CreateCasePathStyleFolders(platform,clientMatter):
126 """This method will create the "new style" case folder paths for a case on IDS"""
127 ## make sure that the CLMFolderPath exists, else make the folders needed to make it exist.
128 CLMFolderPath = ConcordanceHelperTools.ParseClientMatterRemote(clientMatter)
129
130 expeObj = ExpeDatConnection(platform)
131
132 ## Test each folder, and subfolder, on the new style spec to see if they are there, if not create them.
133 newStyleFolderPathList = [
134 "Productions\\MWE_Client\\Backloads",
135 "Productions\\MWE_Client\\Exports",
136 "Productions\\Other_Party",
137 "Review_Docs\\Hard_Copy",
138 "Review_Docs\\Loose",
139 "Review_Docs\\Processed_Data",
140 "Review_Docs\\TIFs",
141 "Working"
142 ]
143 for pathPart in newStyleFolderPathList:
144 newLocation = os.path.join(CLMFolderPath,pathPart)
145 pathExists = expeObj.TestPath(newLocation)
146 tempPath = newLocation
147 pathRemainingList = []
148 while pathExists == False:
149 tempPath, tempPart = os.path.split(tempPath)
150 pathRemainingList.append(tempPart)
151 pathExists = expeObj.TestPath(tempPath)
152 if pathRemainingList:
153 pathRemainingList.reverse()
154 #print pathRemainingList
155 for pathPiece in pathRemainingList:
156 tempPath = os.path.join(tempPath,pathPiece)
157 expeObj.CreateNewPath(tempPath)
158 print "DEBUG: testing password file"
159 pathExists = expeObj.TestPath(os.path.join(CLMFolderPath,"Productions\\MWE_Client\\Exports\\_passwords.txt"))
160 if pathExists:
161 print "DEBUG: file already exists"
162 else:
163 pw_file = open(os.path.join(os.getenv('TEMP'),"_passwords.txt"),'w')
164 pw_file.close()
165 expeObj.CopyToLN(os.path.join(os.getenv('TEMP'),"_passwords.txt",),os.path.join(CLMFolderPath,"Productions\\MWE_Client\\Exports"))
166
167
168 def GetArchiveFileTypeList():
169 """Returns a list of extensions of archive type files"""
170 return [".ZIP", ".RAR",".TAR",".7Z"]
171
172 def GetMCPVersion():
173 """Returns the current version of the entire MCP program set"""
174 return 'v 1.9.0 beta .07'
175
176
177 class AccessDBConnection:
178 def __init__(self, accessDB):
179 daoEngine = win32com.client.Dispatch('DAO.DBEngine.36')
180 self.daoDB = daoEngine.OpenDatabase(accessDB)
181
182 def MakeNewRSConnection(self, table, specialSelect = "*", specialWhere="" ):
183 """ This method will make a new RS connection for either reading or writing."""
184 if specialWhere:
185 statement = "SELECT %s FROM %s WHERE %s"%(specialSelect,table, specialWhere)
186 else:
187 statement = "SELECT %s FROM %s"%(specialSelect,table)
188 daoRSObj = self.daoDB.OpenRecordset(statement)
189 return daoRSObj
190
191 def CloseAccessConnection(self):
192 """This closes the entire connection and not just the RS"""
193 self.daoDB.Close()
194
195 def RetrieveAllTPMMatrix(self):
196 """Retrieves a dictionary of all TPMs and their offices. {TPM:(timekeeperID,OfficeLocation)}"""
197 daoRSObj = self.MakeNewRSConnection('tbl_Ref_Employee', specialWhere = "staffCategory = 'TPM'")
198 daoRSObj.MoveLast()
199 fullCount = daoRSObj.RecordCount
200 daoRSObj.MoveFirst()
201
202 tpmDict = {}
203 for i in range(fullCount):
204 tpmDict[daoRSObj.Fields('TPMName').Value] = (daoRSObj.Fields('TimekeeperID').Value,daoRSObj.Fields('OfficeLocation').Value)
205 daoRSObj.MoveNext()
206 daoRSObj.Close()
207 return tpmDict
208
209 def RetrieveAllCaseListMatrix(self):
210 """Retrieves all of the cases in the database regardless of assignment but in matrix format
211 where the CLM is matched to yes/no if they use the new case structure..(client matter list)"""
212 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
213 daoRSObj.MoveLast()
214 fullCount = daoRSObj.RecordCount
215 daoRSObj.MoveFirst()
216
217 accessDBCLMListMatrix = {}
218 for i in range(fullCount):
219 newCasePathStyle = daoRSObj.Fields('CasePathFolderStyle').Value
220 if newCasePathStyle:
221 pass
222 else:
223 newCasePathStyle = None
224 accessDBCLMListMatrix[daoRSObj.Fields('ClientMatterNum').Value] = newCasePathStyle
225 daoRSObj.MoveNext()
226 daoRSObj.Close()
227 return accessDBCLMListMatrix
228
229
230 def RetrieveAllCaseList(self):
231 """Retrieves all of the cases in the database regardless of assignment.(client matter list)"""
232 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
233 daoRSObj.MoveLast()
234 fullCount = daoRSObj.RecordCount
235 daoRSObj.MoveFirst()
236
237 accessDBCLMList = []
238 for i in range(fullCount):
239 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
240 daoRSObj.MoveNext()
241 daoRSObj.Close()
242 return accessDBCLMList
243
244 def RetrieveUnassignedCaseList(self):
245 """Retrieves all unassigned cases.(client matter list)"""
246 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
247 daoRSObj.MoveLast()
248 fullCount = daoRSObj.RecordCount
249 daoRSObj.MoveFirst()
250 ## Remove this once these are cleaned up
251 goneList = ['13140','12026','11679','13306','11777','09566','13935']
252 accessDBCLMList = []
253 for i in range(fullCount):
254 respTPM = daoRSObj.Fields('empID').Value
255 if respTPM:
256 if respTPM in goneList:
257 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
258 else:
259 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
260 daoRSObj.MoveNext()
261 daoRSObj.Close()
262 return accessDBCLMList
263
264 def RetrieveMyCaseList(self, empID):
265 """Retrieves just 1 employees case list (client matter list)"""
266 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "empID = '%s'"%empID)
267 daoRSObj.MoveLast()
268 fullCount = daoRSObj.RecordCount
269 daoRSObj.MoveFirst()
270
271 accessDBCLMList = []
272 for i in range(fullCount):
273 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
274 daoRSObj.MoveNext()
275 daoRSObj.Close()
276 return accessDBCLMList
277
278 def RetrieveMyActiveCaseList(self,empID):
279 """Retrieves only the Active cases for just 1 employees case list (client matter list)"""
280 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "empID = '%s' and ProjectStatus = 'Active'"%empID)
281 daoRSObj.MoveLast()
282 fullCount = daoRSObj.RecordCount
283 daoRSObj.MoveFirst()
284
285 accessDBCLMList = []
286 for i in range(fullCount):
287 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
288 daoRSObj.MoveNext()
289 daoRSObj.Close()
290 return accessDBCLMList
291
292
293 def RetrieveOfficeCaseList(self, primaryOffice):
294 """Retrieves the case list for an entire office. Note, a case can be owned by a TPM in another office but
295 the primary office might still be an office that that TPM does not work for. Also people are not always
296 good about updating the primary office...(client matter list)"""
297 accessDBCLMList = []
298 try:
299 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "PrimaryOffice = '%s'"%primaryOffice)
300 daoRSObj.MoveLast()
301 fullCount = daoRSObj.RecordCount
302 daoRSObj.MoveFirst()
303
304
305 for i in range(fullCount):
306 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
307 daoRSObj.MoveNext()
308 daoRSObj.Close()
309 except:
310 pass
311 return accessDBCLMList
312
313 def RetrieveProductionsByCLM(self,CLM):
314 """This will retrieve a FULL production matrix for a specific clm"""
315 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
316 "ProductionID,ProductionComplDate, BegBates,EndBates,ProdDocCount,ProdPageCount,Notes,ProducedTo,ProductionMedia,ProductionSource,RequestedBy,ProductionDate,ProductionMediaPassword",
317 specialWhere = "ClientMatterNum='%s' ORDER BY ProductionComplDate"%CLM)
318 try:
319 ## Getting an exception that I cant capture when table is empty.
320 ## this will test and return empty if empty, until I can figure out a better test.
321 daoRSObj.MoveLast()
322 tableHasData = True
323 except:
324 tableHasData = False
325 productionList = []
326 productionMatrix = {}
327 if tableHasData:
328 fullCount = daoRSObj.RecordCount
329 daoRSObj.MoveFirst()
330 for i in range(fullCount):
331 try:
332 pgCount = str(int(daoRSObj.Fields('ProdPageCount').Value))
333 except:
334 pgCount = '0'
335 try:
336 docCount = str(int(daoRSObj.Fields('ProdDocCount').Value))
337 except:
338 docCount = '0'
339 grouping = str(daoRSObj.Fields('ProducedTo').Value)
340 if grouping:
341 pass
342 else:
343 grouping = 'default'
344 if grouping in productionMatrix.keys():
345 productionMatrix[grouping].append((str(daoRSObj.Fields('ProductionID').Value),
346 str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
347 str(daoRSObj.Fields('ProductionDate').Value).split(' ')[0],
348 str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
349 docCount,pgCount,
350 str(daoRSObj.Fields('ProducedTo').Value),
351 str(daoRSObj.Fields('RequestedBy').Value),
352 str(daoRSObj.Fields('ProductionMedia').Value),
353 str(daoRSObj.Fields('ProductionMediaPassword').Value),
354 str(daoRSObj.Fields('ProductionSource').Value),
355 str(daoRSObj.Fields('Notes').Value)))
356 else:
357 productionMatrix[grouping] = [(str(daoRSObj.Fields('ProductionID').Value),
358 str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
359 str(daoRSObj.Fields('ProductionDate').Value).split(' ')[0],
360 str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
361 docCount,pgCount,
362 str(daoRSObj.Fields('ProducedTo').Value),
363 str(daoRSObj.Fields('RequestedBy').Value),
364 str(daoRSObj.Fields('ProductionMedia').Value),
365 str(daoRSObj.Fields('ProductionMediaPassword').Value),
366 str(daoRSObj.Fields('ProductionSource').Value),
367 str(daoRSObj.Fields('Notes').Value))]
368 #productionList.append((str(daoRSObj.Fields('ProductionID').Value),
369 # str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
370 # str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
371 # docCount,pgCount,
372 # str(daoRSObj.Fields('Notes').Value)))
373 daoRSObj.MoveNext()
374 #print len(productionList)
375 daoRSObj.Close()
376 return productionMatrix
377
378
379 def RetrieveUploadsByCLM(self, CLM):
380 """This will retrieve a FULL upload matrix for a specific clm. This wil also pick the best Size (gb,mb,kb), since it's just for display."""
381 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity',
382 "UEPOCH,ReviewPlatform,DataLoadDate,DataLoadedGB,DataLoadedMB,DataLoadedKB",
383 specialWhere = "ClientMatterNum='%s'"%CLM)
384 try:
385 ## Getting an exception that I cant capture when table is empty.
386 ## this will test and return empty if empty, until I can figure out a better test.
387 daoRSObj.MoveLast()
388 tableHasData = True
389 except:
390 tableHasData = False
391 caseUploadList = []
392 if tableHasData:
393 fullCount = daoRSObj.RecordCount
394 daoRSObj.MoveFirst()
395
396 for i in range(fullCount):
397 if daoRSObj.Fields('DataLoadedKB').Value:
398 size = str(daoRSObj.Fields('DataLoadedKB').Value) + ' KB'
399 elif daoRSObj.Fields('DataLoadedMB').Value:
400 size = str(daoRSObj.Fields('DataLoadedMB').Value) + ' MB'
401 else:
402 size = str(daoRSObj.Fields('DataLoadedGB').Value) + ' GB'
403
404 caseUploadList.append((str(daoRSObj.Fields('UEPOCH').Value),daoRSObj.Fields('ReviewPlatform').Value,
405 str(daoRSObj.Fields('DataLoadDate').Value).split(' ')[0],size))
406 daoRSObj.MoveNext()
407 daoRSObj.Close()
408 return caseUploadList
409
410 def RetrieveOfficeUploads(self, primaryOffice):
411 """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
412 myClientMatterList = self.RetrieveOfficeCaseList(primaryOffice)
413 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
414 daoRSObj.MoveLast()
415 fullCount = daoRSObj.RecordCount
416 daoRSObj.MoveFirst()
417
418 caseUploadMatrix = {}
419 for i in range(fullCount):
420 currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
421 if currentClientMatter in myClientMatterList:
422 epoch = str(daoRSObj.Fields('UEPOCH').Value)
423 try:
424 caseUploadMatrix[currentClientMatter].append(epoch)
425 except:
426 caseUploadMatrix[currentClientMatter] = [epoch]
427 daoRSObj.MoveNext()
428 daoRSObj.Close()
429 return caseUploadMatrix
430
431 def RetrieveMyCaseUploads(self,empID):
432 """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
433 myClientMatterList = self.RetrieveMyCaseList(empID)
434 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
435 daoRSObj.MoveLast()
436 fullCount = daoRSObj.RecordCount
437 daoRSObj.MoveFirst()
438
439 caseUploadMatrix = {}
440 for i in range(fullCount):
441 currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
442 if currentClientMatter in myClientMatterList:
443 epoch = daoRSObj.Fields('UEPOCH').Value
444 if epoch:
445 epoch = str(epoch)
446 if '.' in epoch:
447 epoch = epoch.split('.')[0]
448
449 try:
450 caseUploadMatrix[currentClientMatter].append(epoch)
451 except:
452 caseUploadMatrix[currentClientMatter] = [epoch]
453 #loadedDate = daoRSObj.Fields('DataLoadDate').Value
454 #loadedDate = str(loadedDate.Format('%Y%m%d'))
455 #loadedSize =daoRSObj.Fields('DataLoadedGB').Value
456 #loadedSizeType = " GB"
457 #
458 #if loadedSize:
459 # ## If the GB loaded size exists, use that.
460 # pass
461 #else:
462 # ## if it does not, use the MB loaded field.
463 # loadedSize =daoRSObj.Fields('DataLoadedMB').Value
464 # loadedSizeType = " MB"
465 #loadedSize = str(loadedSize)
466 #if "." in loadedSize:
467 # loadedSize = loadedSize[:loadedSize.index('.')+3]
468 #try:
469 # caseUploadMatrix[currentClientMatter].append((loadedDate,loadedSize+loadedSizeType))
470 #except:
471 # caseUploadMatrix[currentClientMatter] = [(loadedDate,loadedSize+loadedSizeType)]
472 daoRSObj.MoveNext()
473 daoRSObj.Close()
474 return caseUploadMatrix
475
476 def AddNewCase(self, caseName, CLM, TPM_Name, empID, chargable = False, reviewPlatform = "", responsibleVendor = "", responsibleOffice = ""):
477 """Adds a new case in the access DB."""
478 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
479 daoRSObj.AddNew()
480 daoRSObj.Fields('ClientMatterNum').Value = CLM
481 daoRSObj.Fields('CaseName').Value = caseName
482 daoRSObj.Fields('EmpID').Value = empID
483 daoRSObj.Fields('TPM').Value = TPM_Name
484 daoRSObj.Fields('PrimaryOffice').Value = responsibleOffice
485 daoRSObj.Update()
486 daoRSObj.Close()
487
488 ## Per aaron, add to two other tables
489 clientNumber = CLM.split('.')[0]
490 daoRSObj = self.MakeNewRSConnection('tbl_Ref_Client')
491 try:
492 daoRSObj.AddNew()
493 daoRSObj.Fields('ClientNum').Value = clientNumber
494 daoRSObj.Update()
495 except:
496 pass
497 daoRSObj.Close()
498
499 daoRSObj = self.MakeNewRSConnection('tbl_Ref_ClientMatter')
500 try:
501 daoRSObj.AddNew()
502 daoRSObj.Fields('ClientNum').Value = clientNumber
503 daoRSObj.Fields('ClientMatterNum').Value = CLM
504 daoRSObj.Update()
505 except:
506 pass
507 daoRSObj.Close()
508
509 ## These below make their own record sets.
510 if chargable:
511 ## change this one aaron adds it.
512 pass
513 if reviewPlatform:
514 self.UpdateReviewPlatform(CLM, reviewPlatform)
515 if responsibleVendor:
516 self.UpdateResponsibleVendor(CLM,responsibleVendor)
517
518
519
520 def UpdateChargable(self, CLM, chargable):
521 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
522 daoRSObj.Edit()
523 daoRSObj.Fields('BillableMatter').Value = chargable
524 daoRSObj.Update()
525 daoRSObj.Close()
526
527 def GetChargable(self,CLM):
528 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
529 chargable = daoRSObj.Fields('BillableMatter').Value
530 daoRSObj.Close()
531 return chargable
532
533 def UpdateDisclosureLetter(self,CLM, letterSaved, pathToLetter):
534 """Allows you to check or uncheck the state of the disclosure letter and the link to it."""
535 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
536 daoRSObj.Edit()
537 daoRSObj.Fields('DisclosureLetterSaved').Value = letterSaved
538 daoRSObj.Fields('LinktoDisclosureLetter').Value = pathToLetter
539 daoRSObj.Update()
540 daoRSObj.Close()
541
542 def GetDisclosureLetter(self, CLM):
543 """Returns the state of the saved letter and the path to the disclosure letter"""
544 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
545 letterSaved = daoRSObj.Fields('DisclosureLetterSaved').Value
546 pathToLetter = daoRSObj.Fields('LinktoDisclosureLetter').Value
547 #pathToLetter = "foo"
548 #print letterSaved
549 daoRSObj.Close()
550 return letterSaved,pathToLetter
551
552 def UpdateReviewPlatform(self, CLM, reviewPlatform):
553 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
554 daoRSObj.Edit()
555 daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
556 daoRSObj.Update()
557 daoRSObj.Close()
558
559 def GetReviewPlatform(self,CLM):
560 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
561 platform = daoRSObj.Fields('ReviewPlatform').Value
562 daoRSObj.Close()
563 return platform
564
565 def UpdateResponsibleVendors(self, CLM,responsibleVendorTpl):
566 """VendorTpl should be a tuple of (processing,scanning,hosting) with None if you dont have it"""
567 processingVendor, scanningVendor, hostingVendor = responsibleVendorTpl
568 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
569 if processingVendor:
570 daoRSObj.Edit()
571 daoRSObj.Fields('ProcessingVendor').Value = processingVendor
572 daoRSObj.Update()
573 if scanningVendor:
574 daoRSObj.Edit()
575 daoRSObj.Fields('ScanningVendor').Value = scanningVendor
576 daoRSObj.Update()
577 if hostingVendor:
578 daoRSObj.Edit()
579 daoRSObj.Fields('HostingVendor').Value = hostingVendor
580 daoRSObj.Update()
581 daoRSObj.Close()
582
583 def GetResponsibleVendorTpl(self, CLM):
584 """Returns a tuple of (processing,scanning,hosting) with None if you dont have it"""
585 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
586 processingVendor = daoRSObj.Fields('ProcessingVendor').Value
587 scanningVendor = daoRSObj.Fields('ScanningVendor').Value
588 hostingVendor = daoRSObj.Fields('HostingVendor').Value
589 daoRSObj.Close()
590 tmpTpl = (processingVendor,scanningVendor,hostingVendor)
591 return tmpTpl
592
593 def UpdateCaseUpload(self, CLM, reviewPlatform, uploadMatrix):
594 """Format for matrix is epoch is key and uploads are in a tpl. (12/23/2010,49MB) Date format is mm/dd/yyyy"""
595 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
596
597 ## Dont for get to convert the date first somewhere.
598 for i in uploadMatrix.keys():
599 (date, size) = uploadMatrix[i]
600 daoRSObj.AddNew()
601 daoRSObj.Fields('ClientMatterNum').Value = CLM
602 daoRSObj.Fields('UEPOCH').Value = i
603 daoRSObj.Fields('DataLoadDate').Value = date
604 daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
605
606 if "GB" in size:
607 daoRSObj.Fields('dataLoadedGB').Value = float(size.replace("GB",""))
608 elif "MB" in size:
609 daoRSObj.Fields('dataLoadedMB').Value = float(size.replace("MB",""))
610 else:
611 if "bytes" in size:
612 size = "1 KB"
613 daoRSObj.Fields('DataLoadedKB').Value = float(size.replace("KB",""))
614 daoRSObj.Update()
615 daoRSObj.Close()
616
617 def DeleteCaseUpload(self,CLM,UEPOCH):
618 """This method will let you delete a single case upload but only if it was added by the MCP.
619 i.e has a UEPOCH"""
620 ## When calling UEPOCHs, dont put it in a ''
621 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity', specialWhere = "UEPOCH=%s"%UEPOCH)
622 ## WHERE AND is not working so I'm going to have to WHERE for the UEPOCH and then do a quick search for the CLM, to be safe.
623 daoRSObj.MoveLast()
624 recordCount = daoRSObj.RecordCount
625 daoRSObj.MoveFirst()
626 ## This wont allow you to delete if there are multiple records with same UEPOCH
627 if recordCount == 1:
628 val2 = daoRSObj.Fields('ClientMatterNum').Value
629 if val2 == CLM:
630 daoRSObj.Delete()
631 errorRpt = False
632 else:
633 errorRpt = True
634 else:
635 errorRpt = True
636 daoRSObj.Close()
637 #print errorRpt
638 return errorRpt
639
640 def GetProducedToEntities(self,CLM):
641 """This will return, for a specific matter, a list of the current 'produced to' options, as kind of a history. """
642 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
643 specialWhere = "ClientMatterNum='%s'"%CLM)
644 prodToList = []
645 try:
646 daoRSObj.MoveLast()
647 tableHasData = True
648 except:
649 tableHasData = False
650 productionMatrix = {}
651 if tableHasData:
652 fullCount = daoRSObj.RecordCount
653 daoRSObj.MoveFirst()
654 for i in range(fullCount):
655 if daoRSObj.Fields('ProducedTo').Value:
656 productionMatrix[daoRSObj.Fields('ProducedTo').Value] = 1
657 daoRSObj.MoveNext()
658 prodToList = productionMatrix.keys()
659 daoRSObj.Close()
660 return prodToList
661
662 def GetProductionRequestedByNames(self,CLM):
663 """This will return, for a specific matter, a list of the current 'production requested by names, as kind of a history. """
664 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
665 specialWhere = "ClientMatterNum='%s'"%CLM)
666 reqByList = []
667 try:
668 daoRSObj.MoveLast()
669 tableHasData = True
670 except:
671 tableHasData = False
672 reqByMatrix = {}
673 if tableHasData:
674 fullCount = daoRSObj.RecordCount
675 daoRSObj.MoveFirst()
676 for i in range(fullCount):
677 if daoRSObj.Fields('RequestedBy').Value:
678 reqByMatrix[daoRSObj.Fields('RequestedBy').Value] = 1
679 daoRSObj.MoveNext()
680 reqByList = reqByMatrix.keys()
681 daoRSObj.Close()
682 return reqByList
683
684 def UpdateProductionDetail(self, CLM, prodID, prodProcessedDate, begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword):
685 """This method will let you add an entire produciton record to the production table. All fields are manadatory.
686 the date is in mm/dd/yyyy format."""
687 try:
688 testdaoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail', specialSelect ="ProductionID",specialWhere = "ClientMatterNum='%s'"%CLM)
689 testdaoRSObj.MoveLast()
690 testRecordCount = testdaoRSObj.RecordCount
691 testdaoRSObj.MoveFirst()
692 prodList = []
693 if testRecordCount:
694 for i in range(testRecordCount):
695 prodList.append(testdaoRSObj.Fields('ProductionID').Value)
696 testdaoRSObj.MoveNext()
697 testdaoRSObj.Close()
698 #print testRecordCount
699 #print prodList
700 if prodID in prodList:
701 prodIncrement = NinoGenTools.Counter(1)
702 prodID = prodID+ "_"+"%0*d"%(4,prodIncrement.count)
703 prodIncrement.inc()
704 while prodID in prodList:
705 prodID = prodID[:-4] +"%0*d"%(4,prodIncrement.count)
706 prodIncrement.inc()
707 except:
708 pass
709
710 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail')
711 daoRSObj.AddNew()
712 daoRSObj.Fields('ClientMatterNum').Value = CLM
713 daoRSObj.Fields('ProductionID').Value = prodID
714 daoRSObj.Fields('ProductionComplDate').Value = prodProcessedDate
715 daoRSObj.Fields('BegBates').Value = begBates
716 daoRSObj.Fields('EndBates').Value = endBates
717 daoRSObj.Fields('ProdDocCount').Value = prodDocCount
718 daoRSObj.Fields('ProdPageCount').Value = prodPageCount
719 daoRSObj.Fields('Notes').Value = prodNotes
720 daoRSObj.Fields('ProducedTo').Value =prodTo
721 daoRSObj.Fields('ProductionMedia').Value =prodMedia
722 daoRSObj.Fields('ProductionSource').Value =prodSource
723 daoRSObj.Fields('RequestedBy').Value =prodReqBy
724 daoRSObj.Fields('ProductionDate').Value =prodSentDate
725 daoRSObj.Fields('ProductionMediaPassword').Value =prodMediaPassword
726
727 daoRSObj.Update()
728 daoRSObj.Close()
729
730 def UpdateResponsibleAttorney(self, CLM, responsibleAttny):
731 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
732 daoRSObj.Edit()
733 daoRSObj.Fields('PrimaryAttorneyContact').Value = responsibleAttny
734 daoRSObj.Update()
735 daoRSObj.Close()
736
737 def GetResponsibleAttorney(self, CLM):
738 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
739 val = daoRSObj.Fields('PrimaryAttorneyContact').Value
740 daoRSObj.Close()
741 return val
742
743 def UpdateOtherAttorneys(self,CLM, otherAttorneysList):
744 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
745 daoRSObj.Edit()
746 ## add this when aaron adds it.
747 daoRSObj.Update()
748 daoRSObj.Close()
749
750 def UpdateResponsibleParalegal(self,CLM, responsibleParalegal):
751 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
752 daoRSObj.Edit()
753 daoRSObj.Fields('ParalegalContact').Value = responsibleParalegal
754 daoRSObj.Update()
755 daoRSObj.Close()
756
757 def GetResponsibleParalegal(self,CLM):
758 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
759 val = daoRSObj.Fields('ParalegalContact').Value
760 daoRSObj.Close()
761 return val
762
763 def UpdatePrimaryOffice(self,CLM, primaryOffice):
764 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
765 daoRSObj.Edit()
766 daoRSObj.Fields('PrimaryOffice').Value = primaryOffice
767 daoRSObj.Update()
768 daoRSObj.Close()
769
770 def GetPrimaryOffice(self,CLM):
771 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
772 val = daoRSObj.Fields('PrimaryOffice').Value
773 daoRSObj.Close()
774 return val
775
776 def UpdateResponsibleTPM(self, CLM, tPMName,empID):
777 """Format should be last, first"""
778 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
779 daoRSObj.Edit()
780 daoRSObj.Fields('TPM').Value = tPMName
781 daoRSObj.Fields('EmpID').Value = empID
782 daoRSObj.Update()
783 daoRSObj.Close()
784
785 def GetResponsibleTPM(self,CLM):
786 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
787 val = daoRSObj.Fields('TPM').Value
788 daoRSObj.Close()
789 return val
790
791 def GetCasePathStyle(self,CLM):
792 """Returns teh case path style as a OLD/NEW/None denoting if this case uses the new folder pathing"""
793 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
794 val = daoRSObj.Fields('CasePathFolderStyle').Value
795 daoRSObj.Close()
796 return val
797
798 def UpdateCasePathStyle(self,CLM,style):
799 """Update the case path style as OLD/NEW/None to denote if this case uses the new folder pathing"""
800 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
801 daoRSObj.Edit()
802 daoRSObj.Fields('CasePathFolderStyle').Value = style
803 daoRSObj.Update()
804 daoRSObj.Close()
805
806 def GetCaseStatus(self,CLM):
807 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
808 val = daoRSObj.Fields('ProjectStatus').Value
809 daoRSObj.Close()
810 return val
811
812 def UpdateCaseStatus(self,CLM,status):
813 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
814 daoRSObj.Edit()
815 daoRSObj.Fields('ProjectStatus').Value = status
816 daoRSObj.Update()
817 daoRSObj.Close()
818
819 def GetCaseName(self,CLM):
820 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
821 val = daoRSObj.Fields('CaseName').Value
822 daoRSObj.Close()
823 return val
824
825 def UpdateCaseName(self,CLM,caseName):
826 """This is just the internal name for the case"""
827 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
828 daoRSObj.Edit()
829 daoRSObj.Fields('CaseName').Value = caseName
830 daoRSObj.Update()
831 daoRSObj.Close()
832
833 def UpdateClientMatterNum(self,oldCLM,newCLM):
834 """Changes the client matter number for a case"""
835 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%oldCLM)
836 daoRSObj.Edit()
837 daoRSObj.Fields('ClientMatterNum').Value = newCLM
838 daoRSObj.Update()
839 daoRSObj.Close()
840
841 def GetAlternateMediaPath(self,CLM):
842 """Returns the alternate media path"""
843 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
844 val = daoRSObj.Fields('AlternateMediaPath').Value
845 daoRSObj.Close()
846 return val
847
848 def UpdateAlternateMediaPath(self,CLM,alternateMediaPath):
849 """Updates the alternate Media Path in the db"""
850 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
851 daoRSObj.Edit()
852 daoRSObj.Fields('AlternateMediaPath').Value = alternateMediaPath
853 daoRSObj.Update()
854 daoRSObj.Close()
855
856 def GetVendorFolderPath(self,CLM):
857 """Returns the vendor Folder path"""
858 try:
859 daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath', specialWhere = "ClientMatterNum='%s'"%CLM)
860 val = daoRSObj.Fields('VendorFolderPath').Value
861 daoRSObj.Close()
862 except:
863 val = None
864 return val
865
866 def UpdateVendorFolderPath(self,CLM,vendorFolderPath):
867 """Updates the Vendor Folder Path in the db"""
868 #print vendorFolderPath
869 try:
870 daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath', specialWhere = "ClientMatterNum='%s'"%CLM)
871 daoRSObj.Edit()
872 except:
873 daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath')
874 daoRSObj.Edit()
875 daoRSObj.Fields('ClientMatterNum').Value = CLM
876 daoRSObj.Fields('VendorFolderPath').Value = vendorFolderPath
877 daoRSObj.Update()
878 daoRSObj.Close()
879
880 def GetUploadCostRate(self,CLM):
881 """Returns the upload cost for a case"""
882 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
883 val = daoRSObj.Fields('UploadCost_GB').Value
884 daoRSObj.Close()
885 return val
886
887 def UpdateUploadCostRate(self,CLM, uploadCost):
888 """Updates the upload cost for a case"""
889 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
890 daoRSObj.Edit()
891 daoRSObj.Fields('UploadCost_GB').Value = uploadCost
892 daoRSObj.Update()
893 daoRSObj.Close()
894
895 def GetStorageCostRate(self,CLM):
896 """Returns the Storage cost for a case"""
897 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
898 val = daoRSObj.Fields('StorageCost_GB').Value
899 daoRSObj.Close()
900 return val
901
902 def UpdateStorageCostRate(self,CLM, storageCost):
903 """Updates the upload cost for a case"""
904 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
905 daoRSObj.Edit()
906 daoRSObj.Fields('StorageCost_GB').Value = storageCost
907 daoRSObj.Update()
908 daoRSObj.Close()
909
910 def GetAnalyticsCostRate(self,CLM):
911 """Returns the Analytics cost for a case"""
912 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
913 val = daoRSObj.Fields('AnalyticsCost_GB').Value
914 daoRSObj.Close()
915 return val
916
917 def UpdateAnalyticsCostRate(self,CLM, analyticsCost):
918 """Updates the Analytics cost for a case"""
919 if analyticsCost == 'None':
920 pass
921 else:
922 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
923 daoRSObj.Edit()
924 daoRSObj.Fields('AnalyticsCost_GB').Value = analyticsCost
925 daoRSObj.Update()
926 daoRSObj.Close()
927
928 def GetTiffingCostRate(self,CLM):
929 """Returns the Tiffing cost for a case"""
930 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
931 val = daoRSObj.Fields('TiffingCost_GB').Value
932 daoRSObj.Close()
933 return val
934
935 def UpdateTiffingCostRate(self,CLM, tiffingCost):
936 """Updates the Tiffing cost for a case"""
937 if tiffingCost == 'None':
938 pass
939 else:
940 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
941 daoRSObj.Edit()
942 daoRSObj.Fields('TiffingCost_GB').Value = tiffingCost
943 daoRSObj.Update()
944 daoRSObj.Close()
945
946 def GetMweProcessingCostRate(self,CLM):
947 """Returns the MweProcessing cost for a case"""
948 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
949 val = daoRSObj.Fields('MweProcessingCost_GB').Value
950 daoRSObj.Close()
951 return val
952
953 def UpdateMweProcessingCostRate(self,CLM, mweProcessingCost):
954 """Updates the MweProcessing cost for a case"""
955 if mweProcessingCost == 'None':
956 pass
957 else:
958 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
959 daoRSObj.Edit()
960 daoRSObj.Fields('MweProcessingCost_GB').Value = mweProcessingCost
961 daoRSObj.Update()
962 daoRSObj.Close()
963
964 def GetOcrCostRate(self,CLM):
965 """Returns the Ocr cost for a case"""
966 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
967 val = daoRSObj.Fields('OcrCost_Page').Value
968 daoRSObj.Close()
969 return val
970
971 def UpdateOcrCostRate(self,CLM, ocrCost):
972 """Updates the Ocr cost for a case"""
973 if ocrCost == 'None':
974 pass
975 else:
976 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
977 daoRSObj.Edit()
978 daoRSObj.Fields('OcrCost_Page').Value = ocrCost
979 daoRSObj.Update()
980 daoRSObj.Close()
981
982 def GetDefaultUploadCostRate(self, platform = "Relativity"):
983 """Returns the current default upload cost"""
984 if platform == "Relativity":
985 cost = "50"
986 else:
987 cost = "50"
988 return cost
989
990 def GetDefaultStorageCostRate(self, platform = "Relativity"):
991 """Returns the current default upload cost"""
992 if platform == "Relativity":
993 cost = "20"
994 else:
995 cost = "20"
996 return cost
997
998 def GetDefaultOcrCostRate(self, platform = "Relativity"):
999 """Returns the current default storage cost"""
1000 if platform == "Relativity":
1001 cost = ".025"
1002 else:
1003 cost = ".025"
1004 return cost
1005
1006 def GetDefaultTiffingCostRate(self, platform = "Relativity"):
1007 """Returns the current default upload cost"""
1008 if platform == "Relativity":
1009 cost = "400"
1010 else:
1011 cost = "400"
1012 return cost
1013
1014 def GetDefaultAnalyticsCostRate(self, platform = "Relativity"):
1015 """Returns the current default upload cost"""
1016 if platform == "Relativity":
1017 cost = "100"
1018 else:
1019 cost = "100"
1020 return cost
1021
1022 def GetDefaultMweProcessingCostRate(self, platform = "Relativity"):
1023 """Returns the current default upload cost"""
1024 if platform == "Relativity":
1025 cost = "50"
1026 else:
1027 cost = "50"
1028 return cost
1029
1030 class ExpeDatConnection:
1031 def __init__(self, platform):
1032 if platform == "Relativity":
1033 self.initialPath = "Relativity"
1034 #self.userName = "eborges"
1035 else:
1036 self.initialPath = "Concordance Data"
1037 #self.userName = "eborgesc"
1038
1039 self.userName = "eborges"
1040 #self.hostName = "@mweftp.litigation.lexisnexis.com"
1041 self.hostName = "@transfer.mcdermottdiscovery.com"
1042 self.userPassword = "9atrEFeh"
1043 #self.exeLocation = r"C:\Documents and Settings\eborges\My Documents\MyDownloads\ExpDat\movedat.exe"
1044 #win7ExpdtPath = os.path.join(os.getenv('USERPROFILE'),'appdata/local/ExpDat')
1045 win7ExpdtPath = r"C:\McDermott-Discovery\ExpDat"
1046 if os.path.exists(win7ExpdtPath):
1047 self.exeLocation = os.path.join(win7ExpdtPath,'movedat.exe')
1048 else:
1049 self.exeLocation = r"C:\Program Files\ExpDat\movedat.exe"
1050
1051 def ListDir(self,path):
1052 """Returns the contents of a directory. returns files, dirs."""
1053 print "debug: listing dir"
1054 path = os.path.join(self.initialPath,path)
1055 args = [self.exeLocation,"-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
1056 fnull = open(os.devnull, 'w')
1057 process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
1058 rawFileList,errCode =process.communicate()
1059 rawFileList = rawFileList.split("\n")
1060 fileList = []
1061 dirList = []
1062 if rawFileList:
1063 for i in rawFileList:
1064 if i:
1065 i = i.split(" ")[-1]
1066 if i[-1] == "/":
1067 dirList.append(i)
1068 else:
1069 fileList.append(i)
1070 fnull.close()
1071 print "debug: dir listed."
1072 return fileList, dirList
1073
1074 def ExpeDatWalk(self,top, topdown=True, onerror=None):
1075 """
1076 Generator that yields tuples of (root, dirs, nondirs).
1077 """
1078 ## Here I'm creating a generator like os.walk
1079
1080 # Make the FTP object's current directory to the top dir.
1081 #ftp.cwd(top)
1082
1083 # We may not have read permission for top, in which case we can't
1084 # get a list of the files the directory contains. os.path.walk
1085 # always suppressed the exception then, rather than blow up for a
1086 # minor reason when (say) a thousand readable directories are still
1087 # left to visit. That logic is copied here.
1088 #try:
1089 nondirs,dirs = self.ListDir(top)
1090 #except os.error, err:
1091 # if onerror is not None:
1092 # onerror(err)
1093 # return
1094
1095 if topdown:
1096 yield top, dirs, nondirs
1097 for entry in dirs:
1098 #dname = entry[0]
1099 dname = entry
1100 path = os.path.join(top, dname)
1101 print path
1102 #if entry[-1] is None: # not a link
1103 for x in self.ExpeDatWalk(path, topdown, onerror):
1104 yield x
1105 if not topdown:
1106 yield top, dirs, nondirs
1107
1108
1109 def GatherFullDirListMatrix(self,vendorFolder):
1110 """Returns a matrix of a list path, with all the files and dirs in a vendor folder"""
1111 ## UPDATE TO USE GENERATOR ABOVE INSTEAD
1112 fileList,dirList = self.ListDir(vendorFolder)
1113 folderMatrix = []
1114 currentPath = vendorFolder
1115 for indFile in fileList:
1116 folderMatrix.append(indFile)
1117 #while dirList:
1118 for dir in dirList:
1119 #print dir
1120 newPath = os.path.join(currentPath, dir)
1121 print currentPath
1122 subFileList,subDirList = self.ListDir(newPath)
1123 newList = []
1124 for indFile in subFileList:
1125 newList.append(indFile)
1126 #print indFile
1127 folderMatrix.append([dir,newList])
1128 #print folderMatrix
1129 #while dirList:
1130 return folderMatrix
1131
1132 def GatherSize(self,path):
1133 """Returns the size of a given path or archive"""
1134 extension = os.path.splitext(path)[1]
1135 path = os.path.join(self.initialPath,path)
1136 #path = self.initialPath + "/" + path
1137 if extension.upper() == '.ZIP':
1138 args = [self.exeLocation,"-D","-K","%s:%s%s:%s=zipsize"%(self.userName,self.userPassword,self.hostName,path)]
1139 fnull = open(os.devnull, 'w')
1140 process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
1141 rawFileSize,errCode =process.communicate()
1142 elif extension == "":
1143 args = [self.exeLocation,"-K","%s:%s%s:%s=*lr"%(self.userName,self.userPassword,self.hostName,path)]
1144 #print args
1145 fnull = open(os.devnull, 'w')
1146 process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
1147 rawDirList,errCode =process.communicate()
1148 rawDirList = rawDirList.split("\n")
1149 rawFileSize = 0
1150 for line in rawDirList[1:]:
1151 #print "Debug:" + line
1152 if line:
1153 size = line.split("\t")[1]
1154 itemType = line.split("\t")[3]
1155 if itemType == "F":
1156 rawFileSize = rawFileSize + int(size,16)
1157 else:
1158 args = [self.exeLocation,"-K","%s:%s%s:%s=*ls"%(self.userName,self.userPassword,self.hostName,path)]
1159 #print args
1160 fnull = open(os.devnull, 'w')
1161 process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
1162 rawDirList,errCode =process.communicate()
1163 #print rawDirList
1164 #outputFile = open(r"c:\test.txt",'w')
1165 #outputFile.writelines(rawDirList)
1166 #outputFile.close()
1167
1168 rawDirList = rawDirList.split("\n")[1]
1169 #print rawDirList
1170 rawFileSize = 0
1171 if rawDirList:
1172 #print "Debug:" + rawDirList
1173 size = rawDirList.split("\t")[1]
1174 rawFileSize = int(size,16)
1175 fnull.close()
1176 if rawFileSize:
1177 print "size is %s"%rawFileSize
1178 else:
1179 rawFileSize = False
1180 return rawFileSize
1181
1182 def TestPath(self,path):
1183 """Tests to see if path already exists"""
1184 #print "debug: Testing path"
1185 path = os.path.join(self.initialPath,path)
1186 args = [self.exeLocation,"-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
1187 #print args
1188 fnull = open(os.devnull, 'w')
1189 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
1190 fnull.close()
1191 if errCode == 0:
1192 return True
1193 if errCode == 25:
1194 return False
1195 else:
1196 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
1197 #print "debug: Testing path done."
1198
1199 def CreateNewPath(self,path):
1200 """Creates a new path on the LN system"""
1201 path = os.path.join(self.initialPath,path)
1202 #print "debug: creating new path %s"% path
1203 args = [self.exeLocation,"-n","-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
1204 fnull = open(os.devnull, 'w')
1205 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
1206 fnull.close()
1207 #return errCode
1208 if errCode == 0:
1209 return True
1210 if errCode == 34:
1211 ## Path already exists
1212 return False
1213 else:
1214 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
1215 #print "debug: new path created."
1216
1217 def MoveOnLN(self,absSourcePathAndFile,targetDirAndFile):
1218 """Performs a move from LN to LN"""
1219 targetDirAndFile = os.path.join(self.initialPath,targetDirAndFile)
1220 print targetDirAndFile
1221 absSourcePathAndFile = os.path.join(self.initialPath,absSourcePathAndFile)
1222 print absSourcePathAndFile
1223 #targetDir = targetDir + "\\"
1224 args = [self.exeLocation,"-m","-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,absSourcePathAndFile),"%s"%targetDirAndFile]
1225 fnull = open(os.devnull, 'w')
1226 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
1227 fnull.close()
1228 #return errCode
1229 if errCode == 0:
1230 return True
1231 if errCode == 34:
1232 ## Path already exists
1233 return False
1234 else:
1235 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
1236
1237 def CopyToLN(self,absSourcePathAndFile,targetDir):
1238 """copies absPath to LN. targetDir should be a dir not a file."""
1239 ## Expedat requires that if it's a target dir, you end it in a trailing slash
1240 targetDir = os.path.join(self.initialPath,targetDir)
1241 targetDir = targetDir + "\\"
1242 args = [self.exeLocation,"-K",absSourcePathAndFile,"%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,targetDir)]
1243 fnull = open(os.devnull, 'w')
1244 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
1245 fnull.close()
1246 #return errCode
1247 if errCode == 0:
1248 return True
1249 if errCode == 25:
1250 """The target path does not exist"""
1251 return False
1252 elif errCode == 29:
1253 """The source file or path does not exist"""
1254 return False
1255 else:
1256 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
1257
1258 class MweFtpConnection:
1259 def __init__(self):
1260 self.userName = "eborges"
1261 self.hostName = "disftp.mwe.com"
1262 self.userPassword = "rever78"
1263 self.connection = ftplib.FTP_TLS(self.hostName)
1264 self.connection.login(self.userName,self.userPassword)
1265 self.connection.prot_p()
1266
1267 def TestPath(self,path):
1268 startDir = self.connection.pwd()
1269 try:
1270 self.connection.cwd(path)
1271 sucess = True
1272 except:
1273 sucess = False
1274 self.connection.cwd(startDir)
1275 return sucess
1276
1277 def CreateNewPath(self,path):
1278 self.connection.mkd(path)
1279
1280 def CopyToDis(self,absSourcePathAndFile,targetDir):
1281 startDir = self.connection.pwd()
1282 fileName = os.path.split(absSourcePathAndFile)[1]
1283 self.connection.cwd(targetDir)
1284 activePackage = open(absSourcePathAndFile,'rb')
1285 self.connection.storbinary("STOR %s"%fileName,activePackage)
1286 activePackage.close()
1287 self.connection.cwd(startDir)
1288
1289 def CloseConnection(self):
1290 self.connection.close()