#!/usr/bin/python2.7 # -*- coding: utf-8 -*- # -*- mode: Python -*- ''' LJ UI IP updater v0.8.1 ''' #wwwIP = "192.168.2.78" #wwwIP = "aurora.teamlaser.fr" wwwIP = "192.168.2.43" import os, sys ljpath = r'%s' % os.getcwd().replace('\\','/') def Updatewww(file_name): print("updating", file_name) f=open(file_name,"r+") a=f.readlines() #print a for line in a: #print line if (2, 6) <= sys.version_info < (3, 0) == True: # python2 if "var LJ = " in line > -1: p=a.index(line) #so now we have the position of the line which to be modified a[p]=" var LJ = 'ws://"+wwwIP+":9001/'\n" #print p, line, a[p] else: # python3 if "var LJ = " in line == True: p=a.index(line) #so now we have the position of the line which to be modified a[p]=" var LJ = 'ws://"+wwwIP+":9001/'\n" #print p, line, a[p] f.seek(0) f.truncate() #ersing all data from the file f.close() #so now we have an empty file and we will write the modified content now in the file o=open(file_name,"w") for i in a: o.write(i) o.close() #now the modification is done in the file print("Updating www files...") Updatewww(ljpath+"/www/LJ.js") Updatewww(ljpath+"/www/trckr/trckrcam1.html") Updatewww(ljpath+"/www/simu.html") Updatewww(ljpath+"/www/align.html") Updatewww(ljpath+"/www/gen0.html") Updatewww(ljpath+"/www/aur0.html") Updatewww(ljpath+"/www/aur0s.html") Updatewww(ljpath+"/www/aur1.html") Updatewww(ljpath+"/www/auralls.html") Updatewww(ljpath+"/www/index.html")