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: 454
Committed: Wed Sep 11 18:57:31 2013 UTC (12 years, 6 months ago) by nino.borges
Content type: text/x-python
Original Path: Python/NinoCode/Active_prgs/MCP/MCP_Lib.py
File size: 46708 byte(s)
Log Message:
Added a new view called My Active Cases, filtering the case list to only show your active cases for all modules.

File Contents

# User Rev Content
1 ninoborges 8 """
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 nino.borges 321 import os,sys, win32com.client,subprocess,ftplib,NinoGenTools, win32com.decimal_23
15 ninoborges 8
16     def GetCaseList(sys_Overwrite ="", accessConnectionObj = None):
17 nino.borges 189 """ 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 ninoborges 8 #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 nino.borges 454 activeCases = []
27 nino.borges 189 officeCases = []
28     allCases = []
29     tPMName,tPMID,nul = GetTPMInfo()
30     if accessConnectionObj:
31     accessDB = accessConnectionObj
32     else:
33     print "connecting to matter tracking access db..."
34     ## Production version
35     accessDB = AccessDBConnection(r"\\chiads01\app\DS_CaseTrack\TPM_CaseTracking.mdb")
36    
37     ## Testing version
38     #accessDB = AccessDBConnection(r"W:\Manny\testing\TPM_CaseTracking.mdb")
39     print "connected to DB."
40     officeList = GetFullOfficeList()
41    
42     cliMatList = []
43     for office in officeList:
44     cliMatList.extend(accessDB.RetrieveOfficeCaseList(office))
45     cliMatList.sort()
46     for cliMat in cliMatList:
47     caseName = accessDB.GetCaseName(cliMat)
48     allCases.append('%s_(%s)'%(caseName,cliMat))
49    
50 ninoborges 8 if tPMName == 'ANALYST':
51     casesDir = None
52 nino.borges 189 officeCases = allCases
53     responsibleCases = allCases
54 nino.borges 454 activeCases = allCases
55 ninoborges 8 else:
56 nino.borges 189 myMatterList = accessDB.RetrieveMyCaseList(tPMID)
57 nino.borges 454 myActiveMatterList = accessDB.RetrieveMyActiveCaseList(tPMID)
58 ninoborges 8 for file in os.listdir(casesDir):
59     if os.path.isdir(os.path.join(casesDir,file)):
60     if file == "_Template_":
61     pass
62     elif file == "zzzz_dormant_":
63     pass
64     else:
65 nino.borges 189 officeCases.append(file)
66     ## if the case's matter is in my matter list, also append to responsibleCases
67     clientMatter = file.split("_(")[1]
68     clientMatter = clientMatter[:-1]
69     clientMatter = clientMatter.replace('-','.')
70     if clientMatter in myMatterList:
71     responsibleCases.append(file)
72 nino.borges 454 if clientMatter in myActiveMatterList:
73     activeCases.append(file)
74     return responsibleCases, activeCases, officeCases, allCases, casesDir
75 ninoborges 8
76     def GetTPMInfo(sys_Overwrite = ""):
77     """ Main method to parse and return the TMP and the Employee ID"""
78     if sys_Overwrite:
79     syscaseDir,tPMName, tPMID,office = open(os.path.join(sys_Overwrite,"settings.sys")).readlines()
80     else:
81     syscaseDir,tPMName, tPMID,office = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
82    
83     #syscaseDir,tPMName, tPMID = open(os.path.join(os.path.dirname(os.path.abspath(sys.argv[0])),"settings.sys")).readlines()
84     tPMName = tPMName.replace("\n","")
85     tPMID = tPMID.replace("\n","")
86     office = office.replace("\n","")
87     return tPMName, tPMID, office
88    
89     def GetFullOfficeList():
90     """Simply returns a list of all of the offices."""
91     officeList = ['Boston','Brussels','Chicago','Huston','London','Los Angeles','Miami','Moscow','Munich','New York',
92     'Orange County','Rome','San Diego','Silicon Valley','Washington, D.C.']
93     return officeList
94    
95     def GetOtherCaseFolder(office):
96     """This method will return the case folder for cases that you dont own"""
97     ## So this is in two places that I now have to maintian... not sure I like that.
98     caseFolderMatrix={'Boston':r"\\bstads01\app\Manny\Cases",
99     'Chicago':r"\\chiads01\data\CLI\Litigation_Support\MCP\Cases",
100     'Los Angeles':r"\\lasads01\data\Cli\_Lit_Support\MCP",
101     'New York':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
102     'Miami':r"\\nykads01\data\cli\LitSupport\MCP\Cases",
103     'Orange County':r"\\lasads01\data\Cli\_Lit_Support\MCP",
104     'San Diego':r"\\lasads01\data\Cli\_Lit_Support\MCP",
105     'Silicon Valley':r"\\lasads01\data\Cli\_Lit_Support\MCP",
106     'Washington, D.C.':r"\\wdcads01\data\Cli\_MCP\Cases"}
107     try:
108     location = caseFolderMatrix[office]
109     except:
110     location = None
111     return location
112    
113 nino.borges 266 def GetArchiveFileTypeList():
114     """Returns a list of extensions of archive type files"""
115     return [".ZIP", ".RAR",".TAR",".7Z"]
116    
117 ninoborges 8 def GetMCPVersion():
118     """Returns the current version of the entire MCP program set"""
119 nino.borges 303 return 'v 1.8.0'
120 ninoborges 8
121    
122     class AccessDBConnection:
123     def __init__(self, accessDB):
124     daoEngine = win32com.client.Dispatch('DAO.DBEngine.36')
125     self.daoDB = daoEngine.OpenDatabase(accessDB)
126    
127     def MakeNewRSConnection(self, table, specialSelect = "*", specialWhere="" ):
128     """ This method will make a new RS connection for either reading or writing."""
129     if specialWhere:
130     statement = "SELECT %s FROM %s WHERE %s"%(specialSelect,table, specialWhere)
131     else:
132     statement = "SELECT %s FROM %s"%(specialSelect,table)
133     daoRSObj = self.daoDB.OpenRecordset(statement)
134     return daoRSObj
135    
136     def CloseAccessConnection(self):
137     """This closes the entire connection and not just the RS"""
138     self.daoDB.Close()
139    
140     def RetrieveAllCaseList(self):
141     """Retrieves all of the cases in the database regardless of assignment.(client matter list)"""
142     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
143     daoRSObj.MoveLast()
144     fullCount = daoRSObj.RecordCount
145     daoRSObj.MoveFirst()
146    
147     accessDBCLMList = []
148     for i in range(fullCount):
149     accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
150     daoRSObj.MoveNext()
151     daoRSObj.Close()
152     return accessDBCLMList
153    
154     def RetrieveMyCaseList(self, empID):
155     """Retrieves just 1 employees case list (client matter list)"""
156     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "empID = '%s'"%empID)
157     daoRSObj.MoveLast()
158     fullCount = daoRSObj.RecordCount
159     daoRSObj.MoveFirst()
160    
161     accessDBCLMList = []
162     for i in range(fullCount):
163     accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
164     daoRSObj.MoveNext()
165     daoRSObj.Close()
166     return accessDBCLMList
167    
168 nino.borges 454 def RetrieveMyActiveCaseList(self,empID):
169     """Retrieves only the Active cases for just 1 employees case list (client matter list)"""
170     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "empID = '%s' and ProjectStatus = 'Active'"%empID)
171     daoRSObj.MoveLast()
172     fullCount = daoRSObj.RecordCount
173     daoRSObj.MoveFirst()
174    
175     accessDBCLMList = []
176     for i in range(fullCount):
177     accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
178     daoRSObj.MoveNext()
179     daoRSObj.Close()
180     return accessDBCLMList
181    
182    
183 ninoborges 8 def RetrieveOfficeCaseList(self, primaryOffice):
184     """Retrieves the case list for an entire office. Note, a case can be owned by a TPM in another office but
185     the primary office might still be an office that that TPM does not work for. Also people are not always
186     good about updating the primary office...(client matter list)"""
187     accessDBCLMList = []
188     try:
189     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "PrimaryOffice = '%s'"%primaryOffice)
190     daoRSObj.MoveLast()
191     fullCount = daoRSObj.RecordCount
192     daoRSObj.MoveFirst()
193    
194    
195     for i in range(fullCount):
196     accessDBCLMList.append(daoRSObj.Fields('ClientMatterNum').Value)
197     daoRSObj.MoveNext()
198     daoRSObj.Close()
199     except:
200     pass
201     return accessDBCLMList
202    
203     def RetrieveProductionsByCLM(self,CLM):
204     """This will retrieve a FULL production matrix for a specific clm"""
205     daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
206 nino.borges 321 "ProductionID,ProductionComplDate, BegBates,EndBates,ProdDocCount,ProdPageCount,Notes,ProducedTo,ProductionMedia,ProductionSource,RequestedBy,ProductionDate,ProductionMediaPassword",
207 ninoborges 8 specialWhere = "ClientMatterNum='%s' ORDER BY ProductionComplDate"%CLM)
208     try:
209     ## Getting an exception that I cant capture when table is empty.
210     ## this will test and return empty if empty, until I can figure out a better test.
211     daoRSObj.MoveLast()
212     tableHasData = True
213     except:
214     tableHasData = False
215     productionList = []
216 nino.borges 321 productionMatrix = {}
217 ninoborges 8 if tableHasData:
218     fullCount = daoRSObj.RecordCount
219     daoRSObj.MoveFirst()
220     for i in range(fullCount):
221     try:
222     pgCount = str(int(daoRSObj.Fields('ProdPageCount').Value))
223     except:
224     pgCount = '0'
225     try:
226     docCount = str(int(daoRSObj.Fields('ProdDocCount').Value))
227     except:
228     docCount = '0'
229 nino.borges 321 grouping = str(daoRSObj.Fields('ProducedTo').Value)
230     if grouping:
231     pass
232     else:
233     grouping = 'default'
234     if grouping in productionMatrix.keys():
235     productionMatrix[grouping].append((str(daoRSObj.Fields('ProductionID').Value),
236 ninoborges 8 str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
237 nino.borges 321 str(daoRSObj.Fields('ProductionDate').Value).split(' ')[0],
238 ninoborges 8 str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
239     docCount,pgCount,
240 nino.borges 321 str(daoRSObj.Fields('ProducedTo').Value),
241     str(daoRSObj.Fields('RequestedBy').Value),
242     str(daoRSObj.Fields('ProductionMedia').Value),
243     str(daoRSObj.Fields('ProductionMediaPassword').Value),
244     str(daoRSObj.Fields('ProductionSource').Value),
245 ninoborges 8 str(daoRSObj.Fields('Notes').Value)))
246 nino.borges 321 else:
247     productionMatrix[grouping] = [(str(daoRSObj.Fields('ProductionID').Value),
248     str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
249     str(daoRSObj.Fields('ProductionDate').Value).split(' ')[0],
250     str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
251     docCount,pgCount,
252     str(daoRSObj.Fields('ProducedTo').Value),
253     str(daoRSObj.Fields('RequestedBy').Value),
254     str(daoRSObj.Fields('ProductionMedia').Value),
255     str(daoRSObj.Fields('ProductionMediaPassword').Value),
256     str(daoRSObj.Fields('ProductionSource').Value),
257     str(daoRSObj.Fields('Notes').Value))]
258     #productionList.append((str(daoRSObj.Fields('ProductionID').Value),
259     # str(daoRSObj.Fields('ProductionComplDate').Value).split(' ')[0],
260     # str(daoRSObj.Fields('BegBates').Value),str(daoRSObj.Fields('EndBates').Value),
261     # docCount,pgCount,
262     # str(daoRSObj.Fields('Notes').Value)))
263 ninoborges 8 daoRSObj.MoveNext()
264 nino.borges 321 #print len(productionList)
265 ninoborges 8 daoRSObj.Close()
266 nino.borges 321 return productionMatrix
267 ninoborges 8
268    
269     def RetrieveUploadsByCLM(self, CLM):
270     """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."""
271     daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity',
272     "UEPOCH,ReviewPlatform,DataLoadDate,DataLoadedGB,DataLoadedMB,DataLoadedKB",
273     specialWhere = "ClientMatterNum='%s'"%CLM)
274     try:
275     ## Getting an exception that I cant capture when table is empty.
276     ## this will test and return empty if empty, until I can figure out a better test.
277     daoRSObj.MoveLast()
278     tableHasData = True
279     except:
280     tableHasData = False
281     caseUploadList = []
282     if tableHasData:
283     fullCount = daoRSObj.RecordCount
284     daoRSObj.MoveFirst()
285    
286     for i in range(fullCount):
287     if daoRSObj.Fields('DataLoadedKB').Value:
288     size = str(daoRSObj.Fields('DataLoadedKB').Value) + ' KB'
289     elif daoRSObj.Fields('DataLoadedMB').Value:
290     size = str(daoRSObj.Fields('DataLoadedMB').Value) + ' MB'
291     else:
292     size = str(daoRSObj.Fields('DataLoadedGB').Value) + ' GB'
293    
294     caseUploadList.append((str(daoRSObj.Fields('UEPOCH').Value),daoRSObj.Fields('ReviewPlatform').Value,
295     str(daoRSObj.Fields('DataLoadDate').Value).split(' ')[0],size))
296     daoRSObj.MoveNext()
297     daoRSObj.Close()
298     return caseUploadList
299    
300     def RetrieveOfficeUploads(self, primaryOffice):
301     """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
302     myClientMatterList = self.RetrieveOfficeCaseList(primaryOffice)
303     daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
304     daoRSObj.MoveLast()
305     fullCount = daoRSObj.RecordCount
306     daoRSObj.MoveFirst()
307    
308     caseUploadMatrix = {}
309     for i in range(fullCount):
310     currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
311     if currentClientMatter in myClientMatterList:
312     epoch = str(daoRSObj.Fields('UEPOCH').Value)
313     try:
314     caseUploadMatrix[currentClientMatter].append(epoch)
315     except:
316     caseUploadMatrix[currentClientMatter] = [epoch]
317     daoRSObj.MoveNext()
318     daoRSObj.Close()
319     return caseUploadMatrix
320    
321     def RetrieveMyCaseUploads(self,empID):
322     """This only returns a matrix of clm{[EPOCH]}, since there isnt a reason to sync uploads from access"""
323     myClientMatterList = self.RetrieveMyCaseList(empID)
324     daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
325     daoRSObj.MoveLast()
326     fullCount = daoRSObj.RecordCount
327     daoRSObj.MoveFirst()
328    
329     caseUploadMatrix = {}
330     for i in range(fullCount):
331     currentClientMatter = daoRSObj.Fields('ClientMatterNum').Value
332     if currentClientMatter in myClientMatterList:
333     epoch = daoRSObj.Fields('UEPOCH').Value
334     if epoch:
335     epoch = str(epoch)
336     if '.' in epoch:
337     epoch = epoch.split('.')[0]
338    
339     try:
340     caseUploadMatrix[currentClientMatter].append(epoch)
341     except:
342     caseUploadMatrix[currentClientMatter] = [epoch]
343     #loadedDate = daoRSObj.Fields('DataLoadDate').Value
344     #loadedDate = str(loadedDate.Format('%Y%m%d'))
345     #loadedSize =daoRSObj.Fields('DataLoadedGB').Value
346     #loadedSizeType = " GB"
347     #
348     #if loadedSize:
349     # ## If the GB loaded size exists, use that.
350     # pass
351     #else:
352     # ## if it does not, use the MB loaded field.
353     # loadedSize =daoRSObj.Fields('DataLoadedMB').Value
354     # loadedSizeType = " MB"
355     #loadedSize = str(loadedSize)
356     #if "." in loadedSize:
357     # loadedSize = loadedSize[:loadedSize.index('.')+3]
358     #try:
359     # caseUploadMatrix[currentClientMatter].append((loadedDate,loadedSize+loadedSizeType))
360     #except:
361     # caseUploadMatrix[currentClientMatter] = [(loadedDate,loadedSize+loadedSizeType)]
362     daoRSObj.MoveNext()
363     daoRSObj.Close()
364     return caseUploadMatrix
365    
366     def AddNewCase(self, caseName, CLM, TPM_Name, empID, chargable = False, reviewPlatform = "", responsibleVendor = "", responsibleOffice = ""):
367     """Adds a new case in the access DB."""
368     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData')
369     daoRSObj.AddNew()
370     daoRSObj.Fields('ClientMatterNum').Value = CLM
371     daoRSObj.Fields('CaseName').Value = caseName
372     daoRSObj.Fields('EmpID').Value = empID
373     daoRSObj.Fields('TPM').Value = TPM_Name
374     daoRSObj.Fields('PrimaryOffice').Value = responsibleOffice
375     daoRSObj.Update()
376     daoRSObj.Close()
377    
378     ## Per aaron, add to two other tables
379     clientNumber = CLM.split('.')[0]
380     daoRSObj = self.MakeNewRSConnection('tbl_Ref_Client')
381     try:
382     daoRSObj.AddNew()
383     daoRSObj.Fields('ClientNum').Value = clientNumber
384     daoRSObj.Update()
385     except:
386     pass
387     daoRSObj.Close()
388    
389     daoRSObj = self.MakeNewRSConnection('tbl_Ref_ClientMatter')
390     try:
391     daoRSObj.AddNew()
392     daoRSObj.Fields('ClientNum').Value = clientNumber
393     daoRSObj.Fields('ClientMatterNum').Value = CLM
394     daoRSObj.Update()
395     except:
396     pass
397     daoRSObj.Close()
398    
399     ## These below make their own record sets.
400     if chargable:
401     ## change this one aaron adds it.
402     pass
403     if reviewPlatform:
404     self.UpdateReviewPlatform(CLM, reviewPlatform)
405     if responsibleVendor:
406     self.UpdateResponsibleVendor(CLM,responsibleVendor)
407    
408    
409    
410     def UpdateChargable(self, CLM, chargable):
411     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
412     daoRSObj.Edit()
413     daoRSObj.Fields('BillableMatter').Value = chargable
414     daoRSObj.Update()
415     daoRSObj.Close()
416    
417     def GetChargable(self,CLM):
418     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
419     chargable = daoRSObj.Fields('BillableMatter').Value
420     daoRSObj.Close()
421     return chargable
422 nino.borges 321
423     def UpdateDisclosureLetter(self,CLM, letterSaved, pathToLetter):
424     """Allows you to check or uncheck the state of the disclosure letter and the link to it."""
425     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
426     daoRSObj.Edit()
427     daoRSObj.Fields('DisclosureLetterSaved').Value = letterSaved
428     daoRSObj.Fields('LinktoDisclosureLetter').Value = pathToLetter
429     daoRSObj.Update()
430     daoRSObj.Close()
431 ninoborges 8
432 nino.borges 321 def GetDisclosureLetter(self, CLM):
433     """Returns the state of the saved letter and the path to the disclosure letter"""
434     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
435     letterSaved = daoRSObj.Fields('DisclosureLetterSaved').Value
436     pathToLetter = daoRSObj.Fields('LinktoDisclosureLetter').Value
437     #pathToLetter = "foo"
438     #print letterSaved
439     daoRSObj.Close()
440     return letterSaved,pathToLetter
441    
442 ninoborges 8 def UpdateReviewPlatform(self, CLM, reviewPlatform):
443     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
444     daoRSObj.Edit()
445     daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
446     daoRSObj.Update()
447     daoRSObj.Close()
448    
449     def GetReviewPlatform(self,CLM):
450     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
451     platform = daoRSObj.Fields('ReviewPlatform').Value
452     daoRSObj.Close()
453     return platform
454    
455     def UpdateResponsibleVendors(self, CLM,responsibleVendorTpl):
456     """VendorTpl should be a tuple of (processing,scanning,hosting) with None if you dont have it"""
457     processingVendor, scanningVendor, hostingVendor = responsibleVendorTpl
458     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
459     if processingVendor:
460     daoRSObj.Edit()
461     daoRSObj.Fields('ProcessingVendor').Value = processingVendor
462     daoRSObj.Update()
463     if scanningVendor:
464     daoRSObj.Edit()
465     daoRSObj.Fields('ScanningVendor').Value = scanningVendor
466     daoRSObj.Update()
467     if hostingVendor:
468     daoRSObj.Edit()
469     daoRSObj.Fields('HostingVendor').Value = hostingVendor
470     daoRSObj.Update()
471     daoRSObj.Close()
472    
473     def GetResponsibleVendorTpl(self, CLM):
474     """Returns a tuple of (processing,scanning,hosting) with None if you dont have it"""
475     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
476     processingVendor = daoRSObj.Fields('ProcessingVendor').Value
477     scanningVendor = daoRSObj.Fields('ScanningVendor').Value
478     hostingVendor = daoRSObj.Fields('HostingVendor').Value
479     daoRSObj.Close()
480     tmpTpl = (processingVendor,scanningVendor,hostingVendor)
481     return tmpTpl
482    
483     def UpdateCaseUpload(self, CLM, reviewPlatform, uploadMatrix):
484     """Format for matrix is epoch is key and uploads are in a tpl. (12/23/2010,49MB) Date format is mm/dd/yyyy"""
485     daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity')
486    
487     ## Dont for get to convert the date first somewhere.
488     for i in uploadMatrix.keys():
489     (date, size) = uploadMatrix[i]
490     daoRSObj.AddNew()
491     daoRSObj.Fields('ClientMatterNum').Value = CLM
492     daoRSObj.Fields('UEPOCH').Value = i
493     daoRSObj.Fields('DataLoadDate').Value = date
494     daoRSObj.Fields('ReviewPlatform').Value = reviewPlatform
495 nino.borges 453
496 ninoborges 8 if "GB" in size:
497     daoRSObj.Fields('dataLoadedGB').Value = float(size.replace("GB",""))
498     elif "MB" in size:
499     daoRSObj.Fields('dataLoadedMB').Value = float(size.replace("MB",""))
500     else:
501 nino.borges 453 if "bytes" in size:
502     size = "1 KB"
503 ninoborges 8 daoRSObj.Fields('DataLoadedKB').Value = float(size.replace("KB",""))
504     daoRSObj.Update()
505     daoRSObj.Close()
506    
507     def DeleteCaseUpload(self,CLM,UEPOCH):
508     """This method will let you delete a single case upload but only if it was added by the MCP.
509     i.e has a UEPOCH"""
510     ## When calling UEPOCHs, dont put it in a ''
511     daoRSObj = self.MakeNewRSConnection('tbl_ClientDataQuantity', specialWhere = "UEPOCH=%s"%UEPOCH)
512     ## 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.
513     daoRSObj.MoveLast()
514     recordCount = daoRSObj.RecordCount
515     daoRSObj.MoveFirst()
516     ## This wont allow you to delete if there are multiple records with same UEPOCH
517     if recordCount == 1:
518     val2 = daoRSObj.Fields('ClientMatterNum').Value
519     if val2 == CLM:
520     daoRSObj.Delete()
521     errorRpt = False
522     else:
523     errorRpt = True
524     else:
525     errorRpt = True
526     daoRSObj.Close()
527     #print errorRpt
528     return errorRpt
529 nino.borges 321
530     def GetProducedToEntities(self,CLM):
531     """This will return, for a specific matter, a list of the current 'produced to' options, as kind of a history. """
532     daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
533     specialWhere = "ClientMatterNum='%s'"%CLM)
534     prodToList = []
535     try:
536     daoRSObj.MoveLast()
537     tableHasData = True
538     except:
539     tableHasData = False
540     productionMatrix = {}
541     if tableHasData:
542     fullCount = daoRSObj.RecordCount
543     daoRSObj.MoveFirst()
544     for i in range(fullCount):
545     if daoRSObj.Fields('ProducedTo').Value:
546     productionMatrix[daoRSObj.Fields('ProducedTo').Value] = 1
547     daoRSObj.MoveNext()
548     prodToList = productionMatrix.keys()
549     daoRSObj.Close()
550     return prodToList
551    
552     def GetProductionRequestedByNames(self,CLM):
553     """This will return, for a specific matter, a list of the current 'production requested by names, as kind of a history. """
554     daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail',
555     specialWhere = "ClientMatterNum='%s'"%CLM)
556     reqByList = []
557     try:
558     daoRSObj.MoveLast()
559     tableHasData = True
560     except:
561     tableHasData = False
562     reqByMatrix = {}
563     if tableHasData:
564     fullCount = daoRSObj.RecordCount
565     daoRSObj.MoveFirst()
566     for i in range(fullCount):
567     if daoRSObj.Fields('RequestedBy').Value:
568     reqByMatrix[daoRSObj.Fields('RequestedBy').Value] = 1
569     daoRSObj.MoveNext()
570     reqByList = reqByMatrix.keys()
571     daoRSObj.Close()
572     return reqByList
573 ninoborges 8
574 nino.borges 321 def UpdateProductionDetail(self, CLM, prodID, prodProcessedDate, begBates,endBates,prodDocCount, prodPageCount, prodNotes, prodTo, prodMedia,prodSource,prodReqBy,prodSentDate,prodMediaPassword):
575 ninoborges 8 """This method will let you add an entire produciton record to the production table. All fields are manadatory.
576     the date is in mm/dd/yyyy format."""
577     try:
578     testdaoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail', specialSelect ="ProductionID",specialWhere = "ClientMatterNum='%s'"%CLM)
579     testdaoRSObj.MoveLast()
580     testRecordCount = testdaoRSObj.RecordCount
581     testdaoRSObj.MoveFirst()
582     prodList = []
583     if testRecordCount:
584     for i in range(testRecordCount):
585     prodList.append(testdaoRSObj.Fields('ProductionID').Value)
586     testdaoRSObj.MoveNext()
587     testdaoRSObj.Close()
588     #print testRecordCount
589     #print prodList
590     if prodID in prodList:
591     prodIncrement = NinoGenTools.Counter(1)
592     prodID = prodID+ "_"+"%0*d"%(4,prodIncrement.count)
593     prodIncrement.inc()
594     while prodID in prodList:
595     prodID = prodID[:-4] +"%0*d"%(4,prodIncrement.count)
596     prodIncrement.inc()
597     except:
598     pass
599    
600     daoRSObj = self.MakeNewRSConnection('Tbl_MatterProductionDetail')
601     daoRSObj.AddNew()
602     daoRSObj.Fields('ClientMatterNum').Value = CLM
603     daoRSObj.Fields('ProductionID').Value = prodID
604 nino.borges 321 daoRSObj.Fields('ProductionComplDate').Value = prodProcessedDate
605 ninoborges 8 daoRSObj.Fields('BegBates').Value = begBates
606     daoRSObj.Fields('EndBates').Value = endBates
607     daoRSObj.Fields('ProdDocCount').Value = prodDocCount
608     daoRSObj.Fields('ProdPageCount').Value = prodPageCount
609     daoRSObj.Fields('Notes').Value = prodNotes
610 nino.borges 321 daoRSObj.Fields('ProducedTo').Value =prodTo
611     daoRSObj.Fields('ProductionMedia').Value =prodMedia
612     daoRSObj.Fields('ProductionSource').Value =prodSource
613     daoRSObj.Fields('RequestedBy').Value =prodReqBy
614     daoRSObj.Fields('ProductionDate').Value =prodSentDate
615     daoRSObj.Fields('ProductionMediaPassword').Value =prodMediaPassword
616 ninoborges 8
617     daoRSObj.Update()
618     daoRSObj.Close()
619    
620     def UpdateResponsibleAttorney(self, CLM, responsibleAttny):
621     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
622     daoRSObj.Edit()
623     daoRSObj.Fields('PrimaryAttorneyContact').Value = responsibleAttny
624     daoRSObj.Update()
625     daoRSObj.Close()
626    
627     def GetResponsibleAttorney(self, CLM):
628     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
629     val = daoRSObj.Fields('PrimaryAttorneyContact').Value
630     daoRSObj.Close()
631     return val
632    
633     def UpdateOtherAttorneys(self,CLM, otherAttorneysList):
634     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
635     daoRSObj.Edit()
636     ## add this when aaron adds it.
637     daoRSObj.Update()
638     daoRSObj.Close()
639    
640     def UpdateResponsibleParalegal(self,CLM, responsibleParalegal):
641     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
642     daoRSObj.Edit()
643     daoRSObj.Fields('ParalegalContact').Value = responsibleParalegal
644     daoRSObj.Update()
645     daoRSObj.Close()
646    
647     def GetResponsibleParalegal(self,CLM):
648     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
649     val = daoRSObj.Fields('ParalegalContact').Value
650     daoRSObj.Close()
651     return val
652    
653     def UpdatePrimaryOffice(self,CLM, primaryOffice):
654     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
655     daoRSObj.Edit()
656     daoRSObj.Fields('PrimaryOffice').Value = primaryOffice
657     daoRSObj.Update()
658     daoRSObj.Close()
659    
660     def GetPrimaryOffice(self,CLM):
661     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
662     val = daoRSObj.Fields('PrimaryOffice').Value
663     daoRSObj.Close()
664     return val
665    
666     def UpdateResponsibleTPM(self, CLM, tPMName):
667     """Format should be last, first"""
668     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
669     daoRSObj.Edit()
670     daoRSObj.Fields('TPM').Value = tPMName
671     daoRSObj.Update()
672     daoRSObj.Close()
673    
674     def GetResponsibleTPM(self,CLM):
675     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
676     val = daoRSObj.Fields('TPM').Value
677     daoRSObj.Close()
678     return val
679    
680     def GetCaseStatus(self,CLM):
681     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
682     val = daoRSObj.Fields('ProjectStatus').Value
683     daoRSObj.Close()
684     return val
685    
686     def UpdateCaseStatus(self,CLM,status):
687     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
688     daoRSObj.Edit()
689     daoRSObj.Fields('ProjectStatus').Value = status
690     daoRSObj.Update()
691     daoRSObj.Close()
692    
693     def GetCaseName(self,CLM):
694     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
695     val = daoRSObj.Fields('CaseName').Value
696     daoRSObj.Close()
697     return val
698    
699     def UpdateCaseName(self,CLM,caseName):
700     """This is just the internal name for the case"""
701     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
702     daoRSObj.Edit()
703     daoRSObj.Fields('CaseName').Value = caseName
704     daoRSObj.Update()
705     daoRSObj.Close()
706 nino.borges 343
707     def UpdateClientMatterNum(self,oldCLM,newCLM):
708     """Changes the client matter number for a case"""
709     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%oldCLM)
710     daoRSObj.Edit()
711     daoRSObj.Fields('ClientMatterNum').Value = newCLM
712     daoRSObj.Update()
713     daoRSObj.Close()
714 ninoborges 8
715 nino.borges 232 def GetAlternateMediaPath(self,CLM):
716     """Returns the alternate media path"""
717     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
718     val = daoRSObj.Fields('AlternateMediaPath').Value
719     daoRSObj.Close()
720     return val
721    
722     def UpdateAlternateMediaPath(self,CLM,alternateMediaPath):
723     """Updates the alternate Media Path in the db"""
724     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
725     daoRSObj.Edit()
726     daoRSObj.Fields('AlternateMediaPath').Value = alternateMediaPath
727     daoRSObj.Update()
728     daoRSObj.Close()
729    
730     def GetVendorFolderPath(self,CLM):
731     """Returns the vendor Folder path"""
732     try:
733     daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath', specialWhere = "ClientMatterNum='%s'"%CLM)
734     val = daoRSObj.Fields('VendorFolderPath').Value
735     daoRSObj.Close()
736     except:
737     val = None
738     return val
739    
740     def UpdateVendorFolderPath(self,CLM,vendorFolderPath):
741     """Updates the Vendor Folder Path in the db"""
742 nino.borges 303 #print vendorFolderPath
743     try:
744     daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath', specialWhere = "ClientMatterNum='%s'"%CLM)
745     daoRSObj.Edit()
746     except:
747     daoRSObj = self.MakeNewRSConnection('tbl_VendorFolderPath')
748     daoRSObj.Edit()
749     daoRSObj.Fields('ClientMatterNum').Value = CLM
750 nino.borges 232 daoRSObj.Fields('VendorFolderPath').Value = vendorFolderPath
751     daoRSObj.Update()
752     daoRSObj.Close()
753 nino.borges 303
754     def GetUploadCostRate(self,CLM):
755     """Returns the upload cost for a case"""
756     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
757     val = daoRSObj.Fields('UploadCost_GB').Value
758     daoRSObj.Close()
759     return val
760 nino.borges 232
761 nino.borges 303 def UpdateUploadCostRate(self,CLM, uploadCost):
762     """Updates the upload cost for a case"""
763     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
764     daoRSObj.Edit()
765     daoRSObj.Fields('UploadCost_GB').Value = uploadCost
766     daoRSObj.Update()
767     daoRSObj.Close()
768    
769     def GetStorageCostRate(self,CLM):
770     """Returns the Storage cost for a case"""
771     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
772     val = daoRSObj.Fields('StorageCost_GB').Value
773     daoRSObj.Close()
774     return val
775    
776     def UpdateStorageCostRate(self,CLM, storageCost):
777     """Updates the upload cost for a case"""
778     daoRSObj = self.MakeNewRSConnection('tbl_MatterTrackingData', specialWhere = "ClientMatterNum='%s'"%CLM)
779     daoRSObj.Edit()
780     daoRSObj.Fields('StorageCost_GB').Value = storageCost
781     daoRSObj.Update()
782     daoRSObj.Close()
783    
784     def GetDefaultUploadCostRate(self, platform = "Relativity"):
785     """Returns the current default upload cost"""
786     if platform == "Relativity":
787     cost = "50"
788     else:
789     cost = "50"
790     return cost
791    
792     def GetDefaultStorageCostRate(self, platform = "Relativity"):
793     """Returns the current default storage cost"""
794     if platform == "Relativity":
795     cost = "20"
796     else:
797     cost = "20"
798     return cost
799    
800 ninoborges 8 class ExpeDatConnection:
801     def __init__(self, platform):
802     if platform == "Relativity":
803     self.initialPath = "Relativity"
804     #self.userName = "eborges"
805     else:
806     self.initialPath = "Concordance Data"
807     #self.userName = "eborgesc"
808    
809     self.userName = "eborges"
810 nino.borges 446 #self.hostName = "@mweftp.litigation.lexisnexis.com"
811 nino.borges 453 self.hostName = "@transfer.mcdermottdiscovery.com"
812 ninoborges 8 self.userPassword = "9atrEFeh"
813     #self.exeLocation = r"C:\Documents and Settings\eborges\My Documents\MyDownloads\ExpDat\movedat.exe"
814     self.exeLocation = r"C:\Program Files\ExpDat\movedat.exe"
815    
816 nino.borges 203 def ListDir(self,path):
817     """Returns the contents of a directory. returns files, dirs."""
818 nino.borges 453 print "debug: listing dir"
819 nino.borges 203 path = os.path.join(self.initialPath,path)
820 nino.borges 453 args = [self.exeLocation,"-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
821 nino.borges 203 fnull = open(os.devnull, 'w')
822     process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
823     rawFileList,errCode =process.communicate()
824     rawFileList = rawFileList.split("\n")
825     fileList = []
826     dirList = []
827     if rawFileList:
828     for i in rawFileList:
829     if i:
830     i = i.split(" ")[-1]
831     if i[-1] == "/":
832     dirList.append(i)
833     else:
834     fileList.append(i)
835     fnull.close()
836 nino.borges 453 print "debug: dir listed."
837 nino.borges 203 return fileList, dirList
838    
839     def GatherFullDirListMatrix(self,vendorFolder):
840     """Returns a matrix of a list path, with all the files and dirs in a vendor folder"""
841     fileList,dirList = self.ListDir(vendorFolder)
842     folderMatrix = []
843     currentPath = vendorFolder
844     for indFile in fileList:
845     folderMatrix.append(indFile)
846     #while dirList:
847     for dir in dirList:
848 nino.borges 232 #print dir
849 nino.borges 206 newPath = os.path.join(currentPath, dir)
850 nino.borges 203 print currentPath
851 nino.borges 206 subFileList,subDirList = self.ListDir(newPath)
852 nino.borges 203 newList = []
853     for indFile in subFileList:
854     newList.append(indFile)
855 nino.borges 232 #print indFile
856 nino.borges 203 folderMatrix.append([dir,newList])
857 nino.borges 232 #print folderMatrix
858 nino.borges 203 #while dirList:
859     return folderMatrix
860    
861 nino.borges 232 def GatherSize(self,path):
862     """Returns the size of a given path or archive"""
863     extension = os.path.splitext(path)[1]
864     path = os.path.join(self.initialPath,path)
865     #path = self.initialPath + "/" + path
866     if extension.upper() == '.ZIP':
867 nino.borges 453 args = [self.exeLocation,"-D","-K","%s:%s%s:%s=zipsize"%(self.userName,self.userPassword,self.hostName,path)]
868 nino.borges 232 fnull = open(os.devnull, 'w')
869     process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
870     rawFileSize,errCode =process.communicate()
871     elif extension == "":
872 nino.borges 453 args = [self.exeLocation,"-K","%s:%s%s:%s=*lr"%(self.userName,self.userPassword,self.hostName,path)]
873 nino.borges 232 #print args
874     fnull = open(os.devnull, 'w')
875     process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
876     rawDirList,errCode =process.communicate()
877     rawDirList = rawDirList.split("\n")
878     rawFileSize = 0
879     for line in rawDirList[1:]:
880 nino.borges 453 #print "Debug:" + line
881 nino.borges 232 if line:
882     size = line.split("\t")[1]
883     itemType = line.split("\t")[3]
884     if itemType == "F":
885     rawFileSize = rawFileSize + int(size,16)
886     else:
887 nino.borges 453 args = [self.exeLocation,"-K","%s:%s%s:%s=*ls"%(self.userName,self.userPassword,self.hostName,path)]
888 nino.borges 232 #print args
889     fnull = open(os.devnull, 'w')
890     process = subprocess.Popen(args,stdout = subprocess.PIPE, stderr = fnull)
891     rawDirList,errCode =process.communicate()
892 nino.borges 453 #print rawDirList
893     #outputFile = open(r"c:\test.txt",'w')
894     #outputFile.writelines(rawDirList)
895     #outputFile.close()
896    
897     rawDirList = rawDirList.split("\n")[1]
898     #print rawDirList
899 nino.borges 232 rawFileSize = 0
900     if rawDirList:
901 nino.borges 453 print "Debug:" + rawDirList
902 nino.borges 232 size = rawDirList.split("\t")[1]
903     rawFileSize = int(size,16)
904     fnull.close()
905     if rawFileSize:
906     print "size is %s"%rawFileSize
907     else:
908     rawFileSize = False
909 nino.borges 239 return rawFileSize
910 nino.borges 232
911 ninoborges 8 def TestPath(self,path):
912     """Tests to see if path already exists"""
913 nino.borges 453 #print "debug: Testing path"
914 ninoborges 8 path = os.path.join(self.initialPath,path)
915 nino.borges 453 args = [self.exeLocation,"-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
916 nino.borges 232 #print args
917 ninoborges 8 fnull = open(os.devnull, 'w')
918     errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
919     fnull.close()
920     if errCode == 0:
921     return True
922     if errCode == 25:
923     return False
924     else:
925     print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
926 nino.borges 453 #print "debug: Testing path done."
927 ninoborges 8
928     def CreateNewPath(self,path):
929     """Creates a new path on the LN system"""
930     path = os.path.join(self.initialPath,path)
931 nino.borges 453 #print "debug: creating new path %s"% path
932     args = [self.exeLocation,"-n","-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,path)]
933 ninoborges 8 fnull = open(os.devnull, 'w')
934     errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
935     fnull.close()
936     #return errCode
937     if errCode == 0:
938     return True
939     if errCode == 34:
940     ## Path already exists
941     return False
942     else:
943     print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
944 nino.borges 453 #print "debug: new path created."
945 nino.borges 203
946     def MoveOnLN(self,absSourcePathAndFile,targetDirAndFile):
947     """Performs a move from LN to LN"""
948     targetDirAndFile = os.path.join(self.initialPath,targetDirAndFile)
949 nino.borges 453 print targetDirAndFile
950 nino.borges 203 absSourcePathAndFile = os.path.join(self.initialPath,absSourcePathAndFile)
951 nino.borges 453 print absSourcePathAndFile
952 nino.borges 203 #targetDir = targetDir + "\\"
953 nino.borges 453 args = [self.exeLocation,"-m","-K","%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,absSourcePathAndFile),"%s"%targetDirAndFile]
954 nino.borges 203 fnull = open(os.devnull, 'w')
955     errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
956     fnull.close()
957     #return errCode
958     if errCode == 0:
959     return True
960     if errCode == 34:
961     ## Path already exists
962     return False
963     else:
964     print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
965 ninoborges 8
966     def CopyToLN(self,absSourcePathAndFile,targetDir):
967     """copies absPath to LN. targetDir should be a dir not a file."""
968     ## Expedat requires that if it's a target dir, you end it in a trailing slash
969     targetDir = os.path.join(self.initialPath,targetDir)
970     targetDir = targetDir + "\\"
971 nino.borges 453 args = [self.exeLocation,"-K",absSourcePathAndFile,"%s:%s%s:%s"%(self.userName,self.userPassword,self.hostName,targetDir)]
972 ninoborges 8 fnull = open(os.devnull, 'w')
973     errCode = subprocess.call(args,stdout = fnull, stderr = fnull)
974     fnull.close()
975     #return errCode
976     if errCode == 0:
977     return True
978     if errCode == 25:
979     """The target path does not exist"""
980     return False
981     elif errCode == 29:
982     """The source file or path does not exist"""
983     return False
984     else:
985     print "OTHER ERROR CODE %s. CALL MANNY!"%str(errCode)
986    
987     class MweFtpConnection:
988     def __init__(self):
989     self.userName = "eborges"
990     self.hostName = "disftp.mwe.com"
991     self.userPassword = "rever78"
992     self.connection = ftplib.FTP_TLS(self.hostName)
993     self.connection.login(self.userName,self.userPassword)
994     self.connection.prot_p()
995    
996     def TestPath(self,path):
997     startDir = self.connection.pwd()
998     try:
999     self.connection.cwd(path)
1000     sucess = True
1001     except:
1002     sucess = False
1003     self.connection.cwd(startDir)
1004     return sucess
1005    
1006     def CreateNewPath(self,path):
1007     self.connection.mkd(path)
1008    
1009     def CopyToDis(self,absSourcePathAndFile,targetDir):
1010     startDir = self.connection.pwd()
1011     fileName = os.path.split(absSourcePathAndFile)[1]
1012     self.connection.cwd(targetDir)
1013     activePackage = open(absSourcePathAndFile,'rb')
1014     self.connection.storbinary("STOR %s"%fileName,activePackage)
1015     activePackage.close()
1016     self.connection.cwd(startDir)
1017    
1018     def CloseConnection(self):
1019     self.connection.close()