ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidoxEclipseLiveReports.py
Revision: 666
Committed: Thu Dec 12 21:18:56 2019 UTC (6 years, 3 months ago) by nino.borges
Content type: text/x-python
File size: 4393 byte(s)
Log Message:
small changes

File Contents

# User Rev Content
1 nino.borges 633 """
2    
3     EvidoxEclipseLiveReports
4    
5     Created by
6     Emanuel Borges
7     02.20.2018
8    
9     A program that will create a live report in eclipse by copying a report that someone updates, clearing the metadata
10     and then copying to the live reports folder of that case. This would be a link that is already set up in the admin.
11     From here, it will be run by a cron that runs every hour.
12    
13     Eventually this should use com to take the spreadsheet report and lock the workbook.
14    
15     """
16    
17     import shutil, os
18 nino.borges 666 import cPickle as pickle
19 nino.borges 633 from win32com.client import Dispatch
20    
21    
22     if __name__ == '__main__':
23 nino.borges 666
24     jsPickleFile = r"C:\Dev\Site\TRON-Conscripts\ReportMatrix.pkl"
25    
26     ## reportMatrix = {
27     ## #r"\\bluearc01\Jobs\Beck Reed Riden\SharkNinja-Keurig\20180220 - Use Custodian and Search Summary.xlsx": r"\\iadcifs01\iproshares01\BERR-SharkNinja-Keurig\Work Product\Live Reports\Use Custodian and Search Summary.xlsx",
28     ## r"L:\__People\Emanuel\MCP3_Temp\I Grace Productions-JS-LiveReport.xlsx": r"\\iadcifs01\iproshares01\LABA-I Grace Productions\Work Product\Live Reports\I Grace Productions-JS-LiveReport.xlsx",
29     ## r"L:\__People\Emanuel\MCP3_Temp\McLaughlin Northrup - McDonald Fracassa-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\MUKI-McLaughlin Northup-McDonald\Work Product\Live Reports\McLaughlin Northrup - McDonald Fracassa-JS-LiveReport.xlsx",
30     ## r"L:\__People\Emanuel\MCP3_Temp\Dairy Farmers-Litigation-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\NYBP-Dairy Farmers Litigation\Work Product\Live Reports\Dairy Farmers-Litigation-JS-LiveReport.xlsx",
31     ## r"L:\__People\Emanuel\MCP3_Temp\Emilfarb-DOJ Subpoena-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\LHPC-Emilfarb-DOJ Subpoena\Work Product\Live Reports\Emilfarb-DOJ Subpoena-JS-LiveReport.xlsx",
32     ## r"L:\__People\Emanuel\MCP3_Temp\Glassman-Metropolitan-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\PSDU-Glassman-Metropolitan\Work Product\Live Reports\Glassman-Metropolitan-JS-LiveReport.xlsx",
33     ## r"L:\__People\Emanuel\MCP3_Temp\Bulger Capital Partners-Jenzabar Subpoena-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\PSDU-Bulger Capital Partners-Jenzabar Subpoena\Work Product\Live Reports\Bulger Capital Partners-Jenzabar Subpoena-JS-LiveReport.xlsx",
34     ## r"L:\__People\Emanuel\MCP3_Temp\Bielins-Bennardo-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\LABA-Gary Bielins-Bennardo\WorkProduct\Live Reports\Bielins-Bennardo-JS-LiveReport.xlsx",
35     ## r"L:\__People\Emanuel\MCP3_Temp\Schneider Electric-Perkins Will-JS-LiveReport.xlsx":r"\\iadcifs01\iproshares01\DFSW-Schneider Electric-Perkins Will\Work Product\Live Reports\Schneider Electric-Perkins Will-JS-LiveReport.xlsx"}
36    
37    
38     with open(jsPickleFile, 'rb') as input:
39     reportMatrix = pickle.load(input)
40    
41 nino.borges 633 excelFileExts = ['.xls','.xlsx']
42     print "Now updating live reports..."
43     for sourceABS in reportMatrix:
44 nino.borges 645 ## First test to see if the source has been modified
45     sourceModifiedDTT = os.stat(sourceABS)[8]
46 nino.borges 646 if os.path.exists(reportMatrix[sourceABS]):
47     targetModifiedDTT = os.stat(reportMatrix[sourceABS])[8]
48     else:
49     targetModifiedDTT = 0
50 nino.borges 666 # First see if the target dir, not just the file, exists
51     if os.path.exists(os.path.split(reportMatrix[sourceABS])[0]):
52     if sourceModifiedDTT > targetModifiedDTT:
53     shutil.copyfile(sourceABS,reportMatrix[sourceABS])
54     fileExt = os.path.splitext(reportMatrix[sourceABS])[1]
55     if fileExt in excelFileExts:
56     print "This is a spreadsheet. Locking..."
57     xlApp = Dispatch('Excel.Application')
58     xlBook = xlApp.Workbooks.Open(reportMatrix[sourceABS])
59     sheetCount = xlBook.Sheets.Count
60     for i in range(sheetCount):
61     sht = xlBook.Worksheets(i + 1)
62     sht.Protect("Evidox2013")
63     xlBook.Protect("Evidox2013")
64     xlBook.Save()
65     xlBook.Close()
66     print "Spreadsheet locked sucessfully."
67     else:
68     print "Identical files. Skipping."
69 nino.borges 645 else:
70 nino.borges 666 print "ERROR: The target folder doenst exist at all!!!"
71 nino.borges 633
72     print "All live reports updated."