ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/MCP_Lib.py
Revision: 151
Committed: Thu Oct 4 20:13:58 2012 UTC (13 years, 5 months ago) by nino.borges
Content type: text/x-python
File size: 29989 byte(s)
Log Message:
Changed MCP version to .17 and changed compression options in MCP_Copyup.

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,subprocess,ftplib,NinoGenTools
15
16 def GetCaseList(sys_Overwrite ="", accessConnectionObj = None):
17 """ Main method to parse and return a usable list of cases."""
18 #print os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")
19 if sys_Overwrite:
20 casesDir = open(os.path.join(sys_Overwrite,"settings.sys")).readline().replace("\n","")
21 else:
22 casesDir = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readline().replace("\n","")
23 #casesDir = r"C:\Documents and Settings\eborges\My Documents\My Dropbox\Documents\Cases"
24 responsibleCases = []
25 tPMName,nul,nul = GetTPMInfo()
26 if tPMName == 'ANALYST':
27 if accessConnectionObj:
28 accessDB = accessConnectionObj
29 else:
30 print "connecting to matter tracking access db..."
31 ## Production version
32 accessDB = AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
33
34 ## Testing version
35 #accessDB = AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
36 print "connected to DB."
37 officeList = GetFullOfficeList()
38 casesDir = None
39 cliMatList = []
40 for office in officeList:
41 cliMatList.extend(accessDB.RetrieveOfficeCaseList(office))
42 cliMatList.sort()
43 for cliMat in cliMatList:
44 caseName = accessDB.GetCaseName(cliMat)
45 responsibleCases.append('%s_(%s)'%(caseName,cliMat))
46 else:
47 for file in os.listdir(casesDir):
48 if os.path.isdir(os.path.join(casesDir,file)):
49 if file == "_Template_":
50 pass
51 elif file == "zzzz_dormant_":
52 pass
53 else:
54 responsibleCases.append(file)
55 return responsibleCases, casesDir
56
57 def GetTPMInfo(sys_Overwrite = ""):
58 """ Main method to parse and return the TMP and the Employee ID"""
59 if sys_Overwrite:
60 syscaseDir,tPMName, tPMID,office = open(os.path.join(sys_Overwrite,"settings.sys")).readlines()
61 else:
62 syscaseDir,tPMName, tPMID,office = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
63
64 #syscaseDir,tPMName, tPMID = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
65 tPMName = tPMName.replace("\n","")
66 tPMID = tPMID.replace("\n","")
67 office = office.replace("\n","")
68 return tPMName, tPMID, office
69
70 def GetFullOfficeList():
71 """Simply returns a list of all of the offices."""
72 officeList = ['Boston','Brussels','Chicago','Huston','London','Los Angeles','Miami','Moscow','Munich','New York',
73 'Orange County','Rome','San Diego','Silicon Valley','Washington, D.C.']
74 return officeList
75
76 def GetOtherCaseFolder(office):
77 """This method will return the case folder for cases that you dont own"""
78 ## So this is in two places that I now have to maintian... not sure I like that.
79 caseFolderMatrix={'Boston':r"\\bstads01\app\Manny\Cases",
80 'Chicago':r"\\chiads01\data\CLI\Litigation_Support\MCP\Cases",
81 'Los Angeles':r"\\lasads01\data\Cli\_Lit_Support\MCP",
82 'New York':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
83 'Miami':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
84 'Orange County':r"\\lasads01\data\Cli\_Lit_Support\MCP",
85 'San Diego':r"\\lasads01\data\Cli\_Lit_Support\MCP",
86 'Silicon Valley':r"\\lasads01\data\Cli\_Lit_Support\MCP",
87 'Washington, D.C.':r"\\wdcads01\data\Cli\_MCP\Cases"}
88 try:
89 location = caseFolderMatrix[office]
90 except:
91 location = None
92 return location
93
94 def GetMCPVersion():
95 """Returns the current version of the entire MCP program set"""
96 return 'v .17'
97
98
99 class AccessDBConnection:
100 def __init__(self, accessDB):
101 daoEngine = win32com.client.Dispatch('DAO.DBEngine.36')
102 self.daoDB = daoEngine.OpenDatabase(accessDB)
103
104 def MakeNewRSConnection(self, table, specialSelect = "*", specialWhere="" ):
105 """ This method will make a new RS connection for either reading or writing."""
106 if specialWhere:
107 statement = "SELECT %s FROM %s WHERE %s"%(specialSelect,table, specialWhere)
108 else:
109 statement = "SELECT %s FROM %s"%(specialSelect,table)
110 daoRSObj = self.daoDB.OpenRecordset(statement)
111 return daoRSObj
112
113 def CloseAccessConnection(self):
114 """This closes the entire connection and not just the RS"""
115 self.daoDB.Close()
116
117 def RetrieveAllCaseList(self):
118 """Retrieves all of the cases in the database regardless of assignment.(client matter list)"""
119 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
120 daoRSObj.MoveLast()
121 fullCount = daoRSObj.RecordCount
122 daoRSObj.MoveFirst()
123
124 accessDBCLMList = []
125 for i in range(fullCount):
126 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
127 daoRSObj.MoveNext()
128 daoRSObj.Close()
129 return accessDBCLMList
130
131 def RetrieveMyCaseList(self, empID):
132 """Retrieves just 1 employees case list (client matter list)"""
133 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "empID = '%s'"%empID)
134 daoRSObj.MoveLast()
135 fullCount = daoRSObj.RecordCount
136 daoRSObj.MoveFirst()
137
138 accessDBCLMList = []
139 for i in range(fullCount):
140 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
141 daoRSObj.MoveNext()
142 daoRSObj.Close()
143 return accessDBCLMList
144
145 def RetrieveOfficeCaseList(self, primaryOffice):
146 """Retrieves the case list for an entire office. Note, a case can be owned by a TPM in another office but
147 the primary office might still be an office that that TPM does not work for. Also people are not always
148 good about updating the primary office...(client matter list)"""
149 accessDBCLMList = []
150 try:
151 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "PrimaryOffice = '%s'"%primaryOffice)
152 daoRSObj.MoveLast()
153 fullCount = daoRSObj.RecordCount
154 daoRSObj.MoveFirst()
155
156
157 for i in range(fullCount):
158 accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
159 daoRSObj.MoveNext()
160 daoRSObj.Close()
161 except:
162 pass
163 return accessDBCLMList
164
165 def RetrieveProductionsByCLM(self,CLM):
166 """This will retrieve a FULL production matrix for a specific clm"""
167 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
168 "ProductionID,ProductionComplDate, BegBates,EndBates,ProdDocCount,ProdPageCount,Notes",
169 specialWhere = "ClientMatterNum='%s' ORDER BY ProductionComplDate"%CLM)
170 try:
171 ## Getting an exception that I cant capture when table is empty.
172 ## this will test and return empty if empty, until I can figure out a better test.
173 daoRSObj.MoveLast()
174 tableHasData = True
175 except:
176 tableHasData = False
177 productionList = []
178 if tableHasData:
179 fullCount = daoRSObj.RecordCount
180 daoRSObj.MoveFirst()
181 for i in range(fullCount):
182 try:
183 pgCount = str(int(daoRSObj.Fields('ProdPageCount').Value))
184 except:
185 pgCount = '0'
186 try:
187 docCount = str(int(daoRSObj.Fields('ProdDocCount').Value))
188 except:
189 docCount = '0'
190 productionList.append((str(daoRSObj.Fields('ProductionID').Value),
191 str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
192 str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
193 docCount,pgCount,
194 str(daoRSObj.Fields('Notes').Value)))
195 daoRSObj.MoveNext()
196 print len(productionList)
197 daoRSObj.Close()
198 return productionList
199
200
201 def RetrieveUploadsByCLM(self, CLM):
202 """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."""
203 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity',
204 "UEPOCH,ReviewPlatform,DataLoadDate,DataLoadedGB,DataLoadedMB,DataLoadedKB",
205 specialWhere = "ClientMatterNum='%s'"%CLM)
206 try:
207 ## Getting an exception that I cant capture when table is empty.
208 ## this will test and return empty if empty, until I can figure out a better test.
209 daoRSObj.MoveLast()
210 tableHasData = True
211 except:
212 tableHasData = False
213 caseUploadList = []
214 if tableHasData:
215 fullCount = daoRSObj.RecordCount
216 daoRSObj.MoveFirst()
217
218 for i in range(fullCount):
219 if daoRSObj.Fields('DataLoadedKB').Value:
220 size = str(daoRSObj.Fields('DataLoadedKB').Value) + ' KB'
221 elif daoRSObj.Fields('DataLoadedMB').Value:
222 size = str(daoRSObj.Fields('DataLoadedMB').Value) + ' MB'
223 else:
224 size = str(daoRSObj.Fields('DataLoadedGB').Value) + ' GB'
225
226 caseUploadList.append((str(daoRSObj.Fields('UEPOCH').Value),daoRSObj.Fields('ReviewPlatform').Value,
227 str(daoRSObj.Fields('DataLoadDate').Value).split(' ')[0],size))
228 daoRSObj.MoveNext()
229 daoRSObj.Close()
230 return caseUploadList
231
232 def RetrieveOfficeUploads(self, primaryOffice):
233 """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
234 myClientMatterList = self.RetrieveOfficeCaseList(primaryOffice)
235 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
236 daoRSObj.MoveLast()
237 fullCount = daoRSObj.RecordCount
238 daoRSObj.MoveFirst()
239
240 caseUploadMatrix = {}
241 for i in range(fullCount):
242 currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
243 if currentClientMatter in myClientMatterList:
244 epoch = str(daoRSObj.Fields('UEPOCH').Value)
245 try:
246 caseUploadMatrix[currentClientMatter].append(epoch)
247 except:
248 caseUploadMatrix[currentClientMatter] = [epoch]
249 daoRSObj.MoveNext()
250 daoRSObj.Close()
251 return caseUploadMatrix
252
253 def RetrieveMyCaseUploads(self,empID):
254 """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
255 myClientMatterList = self.RetrieveMyCaseList(empID)
256 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
257 daoRSObj.MoveLast()
258 fullCount = daoRSObj.RecordCount
259 daoRSObj.MoveFirst()
260
261 caseUploadMatrix = {}
262 for i in range(fullCount):
263 currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
264 if currentClientMatter in myClientMatterList:
265 epoch = daoRSObj.Fields('UEPOCH').Value
266 if epoch:
267 epoch = str(epoch)
268 if '.' in epoch:
269 epoch = epoch.split('.')[0]
270
271 try:
272 caseUploadMatrix[currentClientMatter].append(epoch)
273 except:
274 caseUploadMatrix[currentClientMatter] = [epoch]
275 #loadedDate = daoRSObj.Fields('DataLoadDate').Value
276 #loadedDate = str(loadedDate.Format('%Y%m%d'))
277 #loadedSize =daoRSObj.Fields('DataLoadedGB').Value
278 #loadedSizeType = " GB"
279 #
280 #if loadedSize:
281 # ## If the GB loaded size exists, use that.
282 # pass
283 #else:
284 # ## if it does not, use the MB loaded field.
285 # loadedSize =daoRSObj.Fields('DataLoadedMB').Value
286 # loadedSizeType = " MB"
287 #loadedSize = str(loadedSize)
288 #if "." in loadedSize:
289 # loadedSize = loadedSize[:loadedSize.index('.')+3]
290 #try:
291 # caseUploadMatrix[currentClientMatter].append((loadedDate,loadedSize+loadedSizeType))
292 #except:
293 # caseUploadMatrix[currentClientMatter] = [(loadedDate,loadedSize+loadedSizeType)]
294 daoRSObj.MoveNext()
295 daoRSObj.Close()
296 return caseUploadMatrix
297
298 def AddNewCase(self, caseName, CLM, TPM_Name, empID, chargable = False, reviewPlatform = "", responsibleVendor = "", responsibleOffice = ""):
299 """Adds a new case in the access DB."""
300 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
301 daoRSObj.AddNew()
302 daoRSObj.Fields('ClientMatterNum').Value = CLM
303 daoRSObj.Fields('CaseName').Value = caseName
304 daoRSObj.Fields('EmpID').Value = empID
305 daoRSObj.Fields('TPM').Value = TPM_Name
306 daoRSObj.Fields('PrimaryOffice').Value = responsibleOffice
307 daoRSObj.Update()
308 daoRSObj.Close()
309
310 ## Per aaron, add to two other tables
311 clientNumber = CLM.split('.')[0]
312 daoRSObj = self.MakeNewRSConnection('tbl_Ref_Client')
313 try:
314 daoRSObj.AddNew()
315 daoRSObj.Fields('ClientNum').Value = clientNumber
316 daoRSObj.Update()
317 except:
318 pass
319 daoRSObj.Close()
320
321 daoRSObj = self.MakeNewRSConnection('tbl_Ref_ClientMatter')
322 try:
323 daoRSObj.AddNew()
324 daoRSObj.Fields('ClientNum').Value = clientNumber
325 daoRSObj.Fields('ClientMatterNum').Value = CLM
326 daoRSObj.Update()
327 except:
328 pass
329 daoRSObj.Close()
330
331 ## These below make their own record sets.
332 if chargable:
333 ## change this one aaron adds it.
334 pass
335 if reviewPlatform:
336 self.UpdateReviewPlatform(CLM, reviewPlatform)
337 if responsibleVendor:
338 self.UpdateResponsibleVendor(CLM,responsibleVendor)
339
340
341
342 def UpdateChargable(self, CLM, chargable):
343 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
344 daoRSObj.Edit()
345 daoRSObj.Fields('BillableMatter').Value = chargable
346 daoRSObj.Update()
347 daoRSObj.Close()
348
349 def GetChargable(self,CLM):
350 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
351 chargable = daoRSObj.Fields('BillableMatter').Value
352 daoRSObj.Close()
353 return chargable
354
355 def UpdateReviewPlatform(self, CLM, reviewPlatform):
356 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
357 daoRSObj.Edit()
358 daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
359 daoRSObj.Update()
360 daoRSObj.Close()
361
362 def GetReviewPlatform(self,CLM):
363 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
364 platform = daoRSObj.Fields('ReviewPlatform').Value
365 daoRSObj.Close()
366 return platform
367
368 def UpdateResponsibleVendors(self, CLM,responsibleVendorTpl):
369 """VendorTpl should be a tuple of (processing,scanning,hosting) with None if you dont have it"""
370 processingVendor, scanningVendor, hostingVendor = responsibleVendorTpl
371 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
372 if processingVendor:
373 daoRSObj.Edit()
374 daoRSObj.Fields('ProcessingVendor').Value = processingVendor
375 daoRSObj.Update()
376 if scanningVendor:
377 daoRSObj.Edit()
378 daoRSObj.Fields('ScanningVendor').Value = scanningVendor
379 daoRSObj.Update()
380 if hostingVendor:
381 daoRSObj.Edit()
382 daoRSObj.Fields('HostingVendor').Value = hostingVendor
383 daoRSObj.Update()
384 daoRSObj.Close()
385
386 def GetResponsibleVendorTpl(self, CLM):
387 """Returns a tuple of (processing,scanning,hosting) with None if you dont have it"""
388 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
389 processingVendor = daoRSObj.Fields('ProcessingVendor').Value
390 scanningVendor = daoRSObj.Fields('ScanningVendor').Value
391 hostingVendor = daoRSObj.Fields('HostingVendor').Value
392 daoRSObj.Close()
393 tmpTpl = (processingVendor,scanningVendor,hostingVendor)
394 return tmpTpl
395
396 def UpdateCaseUpload(self, CLM, reviewPlatform, uploadMatrix):
397 """Format for matrix is epoch is key and uploads are in a tpl. (12/23/2010,49MB) Date format is mm/dd/yyyy"""
398 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
399
400 ## Dont for get to convert the date first somewhere.
401 for i in uploadMatrix.keys():
402 (date, size) = uploadMatrix[i]
403 daoRSObj.AddNew()
404 daoRSObj.Fields('ClientMatterNum').Value = CLM
405 daoRSObj.Fields('UEPOCH').Value = i
406 daoRSObj.Fields('DataLoadDate').Value = date
407 daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
408 if "GB" in size:
409 daoRSObj.Fields('dataLoadedGB').Value = float(size.replace("GB",""))
410 elif "MB" in size:
411 daoRSObj.Fields('dataLoadedMB').Value = float(size.replace("MB",""))
412 else:
413 daoRSObj.Fields('DataLoadedKB').Value = float(size.replace("KB",""))
414 daoRSObj.Update()
415 daoRSObj.Close()
416
417 def DeleteCaseUpload(self,CLM,UEPOCH):
418 """This method will let you delete a single case upload but only if it was added by the MCP.
419 i.e has a UEPOCH"""
420 ## When calling UEPOCHs, dont put it in a ''
421 daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity', specialWhere = "UEPOCH=%s"%UEPOCH)
422 ## 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.
423 daoRSObj.MoveLast()
424 recordCount = daoRSObj.RecordCount
425 daoRSObj.MoveFirst()
426 ## This wont allow you to delete if there are multiple records with same UEPOCH
427 if recordCount == 1:
428 val2 = daoRSObj.Fields('ClientMatterNum').Value
429 if val2 == CLM:
430 daoRSObj.Delete()
431 errorRpt = False
432 else:
433 errorRpt = True
434 else:
435 errorRpt = True
436 daoRSObj.Close()
437 #print errorRpt
438 return errorRpt
439
440 def UpdateProductionDetail(self, CLM, prodID, prodDate, begBates,endBates,prodDocCount, prodPageCount, prodNotes):
441 """This method will let you add an entire produciton record to the production table. All fields are manadatory.
442 the date is in mm/dd/yyyy format."""
443 try:
444 testdaoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail', specialSelect ="ProductionID",specialWhere = "ClientMatterNum='%s'"%CLM)
445 testdaoRSObj.MoveLast()
446 testRecordCount = testdaoRSObj.RecordCount
447 testdaoRSObj.MoveFirst()
448 prodList = []
449 if testRecordCount:
450 for i in range(testRecordCount):
451 prodList.append(testdaoRSObj.Fields('ProductionID').Value)
452 testdaoRSObj.MoveNext()
453 testdaoRSObj.Close()
454 #print testRecordCount
455 #print prodList
456 if prodID in prodList:
457 prodIncrement = NinoGenTools.Counter(1)
458 prodID = prodID+ "_"+"%0*d"%(4,prodIncrement.count)
459 prodIncrement.inc()
460 while prodID in prodList:
461 prodID = prodID[:-4] +"%0*d"%(4,prodIncrement.count)
462 prodIncrement.inc()
463 except:
464 pass
465
466 daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail')
467 daoRSObj.AddNew()
468 daoRSObj.Fields('ClientMatterNum').Value = CLM
469 daoRSObj.Fields('ProductionID').Value = prodID
470 daoRSObj.Fields('ProductionComplDate').Value = prodDate
471 daoRSObj.Fields('BegBates').Value = begBates
472 daoRSObj.Fields('EndBates').Value = endBates
473 daoRSObj.Fields('ProdDocCount').Value = prodDocCount
474 daoRSObj.Fields('ProdPageCount').Value = prodPageCount
475 daoRSObj.Fields('Notes').Value = prodNotes
476
477 daoRSObj.Update()
478 daoRSObj.Close()
479
480 def UpdateResponsibleAttorney(self, CLM, responsibleAttny):
481 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
482 daoRSObj.Edit()
483 daoRSObj.Fields('PrimaryAttorneyContact').Value = responsibleAttny
484 daoRSObj.Update()
485 daoRSObj.Close()
486
487 def GetResponsibleAttorney(self, CLM):
488 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
489 val = daoRSObj.Fields('PrimaryAttorneyContact').Value
490 daoRSObj.Close()
491 return val
492
493 def UpdateOtherAttorneys(self,CLM, otherAttorneysList):
494 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
495 daoRSObj.Edit()
496 ## add this when aaron adds it.
497 daoRSObj.Update()
498 daoRSObj.Close()
499
500 def UpdateResponsibleParalegal(self,CLM, responsibleParalegal):
501 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
502 daoRSObj.Edit()
503 daoRSObj.Fields('ParalegalContact').Value = responsibleParalegal
504 daoRSObj.Update()
505 daoRSObj.Close()
506
507 def GetResponsibleParalegal(self,CLM):
508 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
509 val = daoRSObj.Fields('ParalegalContact').Value
510 daoRSObj.Close()
511 return val
512
513 def UpdatePrimaryOffice(self,CLM, primaryOffice):
514 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
515 daoRSObj.Edit()
516 daoRSObj.Fields('PrimaryOffice').Value = primaryOffice
517 daoRSObj.Update()
518 daoRSObj.Close()
519
520 def GetPrimaryOffice(self,CLM):
521 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
522 val = daoRSObj.Fields('PrimaryOffice').Value
523 daoRSObj.Close()
524 return val
525
526 def UpdateResponsibleTPM(self, CLM, tPMName):
527 """Format should be last, first"""
528 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
529 daoRSObj.Edit()
530 daoRSObj.Fields('TPM').Value = tPMName
531 daoRSObj.Update()
532 daoRSObj.Close()
533
534 def GetResponsibleTPM(self,CLM):
535 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
536 val = daoRSObj.Fields('TPM').Value
537 daoRSObj.Close()
538 return val
539
540 def GetCaseStatus(self,CLM):
541 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
542 val = daoRSObj.Fields('ProjectStatus').Value
543 daoRSObj.Close()
544 return val
545
546 def UpdateCaseStatus(self,CLM,status):
547 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
548 daoRSObj.Edit()
549 daoRSObj.Fields('ProjectStatus').Value = status
550 daoRSObj.Update()
551 daoRSObj.Close()
552
553 def GetCaseName(self,CLM):
554 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
555 val = daoRSObj.Fields('CaseName').Value
556 daoRSObj.Close()
557 return val
558
559 def UpdateCaseName(self,CLM,caseName):
560 """This is just the internal name for the case"""
561 daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
562 daoRSObj.Edit()
563 daoRSObj.Fields('CaseName').Value = caseName
564 daoRSObj.Update()
565 daoRSObj.Close()
566
567 class ExpeDatConnection:
568 def __init__(self, platform):
569 if platform == "Relativity":
570 self.initialPath = "Relativity"
571 #self.userName = "eborges"
572 else:
573 self.initialPath = "Concordance Data"
574 #self.userName = "eborgesc"
575
576 self.userName = "eborges"
577 self.hostName = "@mweftp.litigation.lexisnexis.com"
578 self.userPassword = "9atrEFeh"
579 #self.exeLocation = r"C:\Documents and Settings\eborges\My Documents\MyDownloads\ExpDat\movedat.exe"
580 self.exeLocation = r"C:\Program Files\ExpDat\movedat.exe"
581
582 def TestPath(self,path):
583 """Tests to see if path already exists"""
584 path = os.path.join(self.initialPath,path)
585 args = [self.exeLocation,"%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
586 fnull = open(os.devnull, 'w')
587 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
588 fnull.close()
589 if errCode == 0:
590 return True
591 if errCode == 25:
592 return False
593 else:
594 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
595
596 def CreateNewPath(self,path):
597 """Creates a new path on the LN system"""
598 path = os.path.join(self.initialPath,path)
599 args = [self.exeLocation,"-n","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
600 fnull = open(os.devnull, 'w')
601 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
602 fnull.close()
603 #return errCode
604 if errCode == 0:
605 return True
606 if errCode == 34:
607 ## Path already exists
608 return False
609 else:
610 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
611
612 def CopyToLN(self,absSourcePathAndFile,targetDir):
613 """copies absPath to LN. targetDir should be a dir not a file."""
614 ## Expedat requires that if it's a target dir, you end it in a trailing slash
615 targetDir = os.path.join(self.initialPath,targetDir)
616 targetDir = targetDir + "\\"
617 args = [self.exeLocation,absSourcePathAndFile,"%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,targetDir)]
618 fnull = open(os.devnull, 'w')
619 errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
620 fnull.close()
621 #return errCode
622 if errCode == 0:
623 return True
624 if errCode == 25:
625 """The target path does not exist"""
626 return False
627 elif errCode == 29:
628 """The source file or path does not exist"""
629 return False
630 else:
631 print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
632
633 class MweFtpConnection:
634 def __init__(self):
635 self.userName = "eborges"
636 self.hostName = "disftp.mwe.com"
637 self.userPassword = "rever78"
638 self.connection = ftplib.FTP_TLS(self.hostName)
639 self.connection.login(self.userName,self.userPassword)
640 self.connection.prot_p()
641
642 def TestPath(self,path):
643 startDir = self.connection.pwd()
644 try:
645 self.connection.cwd(path)
646 sucess = True
647 except:
648 sucess = False
649 self.connection.cwd(startDir)
650 return sucess
651
652 def CreateNewPath(self,path):
653 self.connection.mkd(path)
654
655 def CopyToDis(self,absSourcePathAndFile,targetDir):
656 startDir = self.connection.pwd()
657 fileName = os.path.split(absSourcePathAndFile)[1]
658 self.connection.cwd(targetDir)
659 activePackage = open(absSourcePathAndFile,'rb')
660 self.connection.storbinary("STOR %s"%fileName,activePackage)
661 activePackage.close()
662 self.connection.cwd(startDir)
663
664 def CloseConnection(self):
665 self.connection.close()