ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/MCP/MCP_Lib.py
Revision: 459
Committed: Fri Sep 20 20:32:02 2013 UTC (12 years, 6 months ago) by nino.borges
Content type: text/x-python
File size: 48743 byte(s)
Log Message:
Added support for transffering cases between TPMs in other offices and intra office. Updated the main View Edit to support this. Now just need a busy dialog and a dialog for transfering through the menu option.

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