LJ/updateUI.py

32 lines
832 B
Python

#!/usr/bin/python3
# -*- coding: utf-8 -*-
# -*- mode: Python -*-
'''
LJ UI IP updater v0.9.0
MUST be called from configure.py
'''
import os, sys
import fileinput
from shutil import copyfile
ljpath = r'%s' % os.getcwd().replace('\\','/')
def www(config):
global ljpath
wwwip = config.get('General','wwwip')
wstype = config.get('General','wstype')
wsport = config.get('General','wsport')
# copy template
src = ljpath + "/templates/config.js"
dst = ljpath + "/www/config.js"
copyfile(src, dst)
# Interpolate variables
with fileinput.FileInput(dst, inplace=True) as file:
for line in file:
line = line.replace("%wstype%", wstype)
line = line.replace("%wsport%", wsport)
line = line.replace("%wwwip%", wwwip)
print(line, end='')