-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenvapplist.py
65 lines (62 loc) · 2.34 KB
/
envapplist.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import os
baseDir = '//carver/infosys/'
dirFile = '//carver/infosys/envapps.html'
htmlheader = """<HTML>
<body>
<h1>Environment System List</h1>
<h2>"setup.bat" links will only work using Internet Explorer.</h2>
For Firefox or Chrome:<br>
1. Copy the link<br>
2. Press "Windows Key" + "R"<br>
3. Paste link and click "OK"<br>
<br>
<table border="1" cellpadding="10">
"""
htmlfooter = """
</table>
<script type="text\javascript">
function ClipBoard()
{
Copied = linktext.createTextRange();
Copied.execCommand("Copy");
}
</script>
</body>
</HTML>"""
appList = [['Title', 'Link (IE only)', 'Contact', 'Document Dir']]
for envApp in filter(lambda x: os.path.isdir(os.path.join(baseDir, x)), os.listdir(baseDir)):
infoFile = baseDir + envApp + '/appinfo.txt'
if os.path.isfile(infoFile):
print infoFile
with open(infoFile) as f:
lines = f.read().splitlines()
title, link, contact = lines
# Check for Doc Directory
print title
if 'http' in link:
fullLink = '<a href="{0}">{0}</a>'.format(link)
else:
winPath = '{0}{1}/{2}'.format(baseDir, envApp, link).replace('/', '\\')
fullLink = '<a href="file:///{0}{1}/{2}">'.format(baseDir, envApp, link.replace('\\', '/'))
fullLink += winPath
fullLink += '</a>'
print link
print contact
if 'gov.yk.ca' not in contact:
contactLink = '<a href="mailto:service.desk@gov.yk.ca?Subject=Environment Application: {1}" target="_top">{0}</a>'.format(contact, title)
else:
contactLink = '<a href="mailto:{0}?Subject={1}" target="_top">{0}</a>'.format(contact, title)
docDir = baseDir + envApp + '/Doc'
if os.path.isdir(docDir):
print docDir
docLink = '<a href="file:///{}">{}</a>'.format(docDir, docDir.replace('/','\\'))
appList.append([title, fullLink, contactLink, docLink if os.path.isdir(docDir) else ''])
tr = "<tr>{0}</tr>"
td = "<td>{0}</td>"
apps = [tr.format('\n'.join([td.format(a) for a in app])) for app in appList]
output = htmlheader;
output += ''.join(apps);
output += htmlfooter;
print output
with open(dirFile, 'w') as w:
w.write(output)