ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidoxEclipseLiveReports.py
Revision: 645
Committed: Tue Apr 3 15:15:57 2018 UTC (7 years, 11 months ago) by nino.borges
Content type: text/x-python
File size: 2461 byte(s)
Log Message:
Updated so that it checks the last mod date. will now skip if the mod date of the source is not newer.

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