From 2221f80dcece2c0382b44628ed8905b1896734a7 Mon Sep 17 00:00:00 2001 From: alban Date: Tue, 22 Sep 2020 21:58:14 +0200 Subject: [PATCH] [enh] adds configuration script --- configure.py | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 configure.py diff --git a/configure.py b/configure.py new file mode 100644 index 0000000..106b2aa --- /dev/null +++ b/configure.py @@ -0,0 +1,55 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- +# -*- mode: Python -*- +''' +LJay/LJ +v0.1.0 + +A console friendly interface to change important parameters + + +LICENCE : CC +''' + +import configparser +from libs3 import gstt +import ast +import numpy as np + + +config = configparser.ConfigParser() +config.read(gstt.ConfigName) + +qList = [ + {"q":"The server IP address","c":"General","k":"ljayserverip"}, + {"q":"How many lasers to use","c":"General","k":"lasernumber"}, + {"q":"Laser 0 IP address","c":"laser0","k":"ip"}, + {"q":"Laser 1 IP address","c":"laser1","k":"ip"}, + {"q":"Laser 2 IP address","c":"laser2","k":"ip"}, + {"q":"Laser 3 IP address","c":"laser3","k":"ip"} + ] +stop = False +while stop == False : + print( "------------------------------------------------------") + print( "Which part of the configuration do you wish to change?") + print( "------------------------------------------------------") + print( "Enter a numeric key or 'x' to stop") + for i in range(len(qList)): + item = qList[i] + question = item["q"] + category = item["c"] + key = item["k"] + val = config.get(category,key ) + print( "-") + print( "Choice #"+str(i), "\t"+question+ "\tCurrent value:",val ) + print( "......................................................") + name = input("Enter your choice: ") + if name == "x": + stop = True + break + print( "......................................................") + choice = qList[int(name)] + new_value = input("Please enter the new value:") + config.set(choice["c"],choice["k"],new_value) + config.write(open(gstt.ConfigName,'w')) +