| 1 |
"""
|
| 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 |
from win32com.client import Dispatch
|
| 19 |
|
| 20 |
|
| 21 |
if __name__ == '__main__':
|
| 22 |
reportMatrix = {
|
| 23 |
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",
|
| 24 |
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",
|
| 25 |
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",
|
| 26 |
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"
|
| 27 |
}
|
| 28 |
excelFileExts = ['.xls','.xlsx']
|
| 29 |
print "Now updating live reports..."
|
| 30 |
for sourceABS in reportMatrix:
|
| 31 |
## First test to see if the source has been modified
|
| 32 |
sourceModifiedDTT = os.stat(sourceABS)[8]
|
| 33 |
if os.path.exists(reportMatrix[sourceABS]):
|
| 34 |
targetModifiedDTT = os.stat(reportMatrix[sourceABS])[8]
|
| 35 |
else:
|
| 36 |
targetModifiedDTT = 0
|
| 37 |
if sourceModifiedDTT > targetModifiedDTT:
|
| 38 |
shutil.copyfile(sourceABS,reportMatrix[sourceABS])
|
| 39 |
fileExt = os.path.splitext(reportMatrix[sourceABS])[1]
|
| 40 |
if fileExt in excelFileExts:
|
| 41 |
print "This is a spreadsheet. Locking..."
|
| 42 |
xlApp = Dispatch('Excel.Application')
|
| 43 |
xlBook = xlApp.Workbooks.Open(reportMatrix[sourceABS])
|
| 44 |
sheetCount = xlBook.Sheets.Count
|
| 45 |
for i in range(sheetCount):
|
| 46 |
sht = xlBook.Worksheets(i + 1)
|
| 47 |
sht.Protect("Evidox2013")
|
| 48 |
xlBook.Protect("Evidox2013")
|
| 49 |
xlBook.Save()
|
| 50 |
xlBook.Close()
|
| 51 |
print "Spreadsheet locked sucessfully."
|
| 52 |
else:
|
| 53 |
print "Identical files. Skipping."
|
| 54 |
|
| 55 |
print "All live reports updated." |