Browse Source

update apply_template scripts

- check for existence of file
- use OVERWRITE boolean
- throw an exception sometimes
master
Charles Reid 4 months ago
parent
commit
6e414d0d1c
2 changed files with 12 additions and 4 deletions
  1. +6
    -2
      apache/apply_templates.py
  2. +6
    -2
      mediawiki/apply_templates.py

+ 6
- 2
apache/apply_templates.py View File

@@ -28,6 +28,7 @@ OVERWRITE = True
env = Environment(loader=FileSystemLoader('.'))

tfile = 'charlesreid1.wiki.conf.j2'
rfile = 'charlesreid1.wiki.conf'

content = env.get_template(tfile).render({
"server_name_default" : "charlesreid1.com",
@@ -35,6 +36,9 @@ content = env.get_template(tfile).render({
})

# Write to file
with open('charlesreid1.wiki.conf','w') as f:
f.write(content)
if os.path.exists(rfile) and not OVERWRITE:
raise Exception("Error: file %s already exists!"%(rfile))
else:
with open(rfile,'w') as f:
f.write(content)


+ 6
- 2
mediawiki/apply_templates.py View File

@@ -28,12 +28,16 @@ OVERWRITE = True
env = Environment(loader=FileSystemLoader('.'))

tfile = 'LocalSettings.php.j2'
rfile = 'LocalSettings.php'

content = env.get_template(tfile).render({
"server_name_default" : "charlesreid1.com"
})

# Write to file
with open('LocalSettings.php','w') as f:
f.write(content)
if os.path.exists(rfile) and not OVERWRITE:
raise Exception("Error: file %s already exists!"%(rfile))
else:
with open(rfile,'w') as f:
f.write(content)


Loading…
Cancel
Save