ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Evidox/EvidoxEclipseLiveReports.py
Revision: 699
Committed: Wed May 13 22:04:21 2020 UTC (5 years, 10 months ago) by nino.borges
Content type: text/x-python
File size: 4669 byte(s)
Log Message:
adding checking for the source too.

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 699 ## First make sure Source exists
45     if os.path.exists(sourceABS):
46     ## Second test to see if the source has been modified
47     sourceModifiedDTT = os.stat(sourceABS)[8]
48     if os.path.exists(reportMatrix[sourceABS]):
49     targetModifiedDTT = os.stat(reportMatrix[sourceABS])[8]
50 nino.borges 666 else:
51 nino.borges 699 targetModifiedDTT = 0
52     # First see if the target dir, not just the file, exists
53     if os.path.exists(os.path.split(reportMatrix[sourceABS])[0]):
54     if sourceModifiedDTT > targetModifiedDTT:
55     shutil.copyfile(sourceABS,reportMatrix[sourceABS])
56     fileExt = os.path.splitext(reportMatrix[sourceABS])[1]
57     if fileExt in excelFileExts:
58     print "This is a spreadsheet. Locking..."
59     xlApp = Dispatch('Excel.Application')
60     xlBook = xlApp.Workbooks.Open(reportMatrix[sourceABS])
61     sheetCount = xlBook.Sheets.Count
62     for i in range(sheetCount):
63     sht = xlBook.Worksheets(i + 1)
64     sht.Protect("Evidox2013")
65     xlBook.Protect("Evidox2013")
66     xlBook.Save()
67     xlBook.Close()
68     print "Spreadsheet locked sucessfully."
69     else:
70     print "Identical files. Skipping."
71     else:
72     print "ERROR: The target folder doenst exist at all!!!"
73 nino.borges 645 else:
74 nino.borges 699 print "ERROR: The source file %s doesnt exist"% sourceABS
75 nino.borges 633
76     print "All live reports updated."