mirror of https://git.48k.eu/ogclient
Delete ogConfig.py
This file is only used for its OG_PATH variable, this variable is now in ogClient.more_events
parent
3205e0f1e8
commit
d7b7b0b175
3
main.py
3
main.py
|
@ -11,12 +11,11 @@
|
|||
import json
|
||||
import subprocess
|
||||
from src.ogClient import *
|
||||
from src.ogConfig import *
|
||||
from signal import signal, SIGPIPE, SIG_DFL
|
||||
|
||||
def main():
|
||||
signal(SIGPIPE, SIG_DFL)
|
||||
config_path = f'{ogConfig.OG_PATH}ogclient/cfg/ogclient.json'
|
||||
config_path = f'{ogClient.OG_PATH}ogclient/cfg/ogclient.json'
|
||||
try:
|
||||
with open(config_path, 'r') as f:
|
||||
CONFIG = json.load(f)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import os
|
||||
import json
|
||||
import subprocess
|
||||
from src.ogConfig import *
|
||||
from src.ogClient import ogClient
|
||||
|
||||
OG_SHELL = '/bin/bash'
|
||||
|
||||
|
@ -52,16 +52,16 @@ class OgLinuxOperations:
|
|||
|
||||
def poweroff(self):
|
||||
if os.path.exists('/scripts/oginit'):
|
||||
cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||
f'{ogConfig.OG_PATH}scripts/poweroff'
|
||||
cmd = f'source {ogClient.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||
f'{ogClient.OG_PATH}scripts/poweroff'
|
||||
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
||||
else:
|
||||
subprocess.call(['/sbin/poweroff'])
|
||||
|
||||
def reboot(self):
|
||||
if os.path.exists('/scripts/oginit'):
|
||||
cmd = f'source {ogConfig.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||
f'{ogConfig.OG_PATH}scripts/reboot'
|
||||
cmd = f'source {ogClient.OG_PATH}etc/preinit/loadenviron.sh; ' \
|
||||
f'{ogClient.OG_PATH}scripts/reboot'
|
||||
subprocess.call([cmd], shell=True, executable=OG_SHELL)
|
||||
else:
|
||||
subprocess.call(['/sbin/reboot'])
|
||||
|
@ -81,7 +81,7 @@ class OgLinuxOperations:
|
|||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
|
||||
cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
|
||||
result = subprocess.check_output([cmd_get_conf], shell=True)
|
||||
self._restartBrowser(self._url)
|
||||
|
||||
|
@ -90,7 +90,7 @@ class OgLinuxOperations:
|
|||
def session(self, request, ogRest):
|
||||
disk = request.getDisk()
|
||||
partition = request.getPartition()
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/IniciarSesion {disk} {partition}'
|
||||
|
||||
try:
|
||||
ogRest.proc = subprocess.Popen([cmd],
|
||||
|
@ -110,7 +110,7 @@ class OgLinuxOperations:
|
|||
self._restartBrowser(self._url_log)
|
||||
|
||||
try:
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||
f'{partition} {path}'
|
||||
|
||||
ogRest.proc = subprocess.Popen([cmd],
|
||||
|
@ -132,7 +132,7 @@ class OgLinuxOperations:
|
|||
self._restartBrowser(self._url_log)
|
||||
|
||||
try:
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/InventarioHardware {path}'
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/InventarioHardware {path}'
|
||||
ogRest.proc = subprocess.Popen([cmd],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
|
@ -160,7 +160,7 @@ class OgLinuxOperations:
|
|||
if ogRest.terminated:
|
||||
break
|
||||
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/Configurar {disk} {cfg}'
|
||||
try:
|
||||
ogRest.proc = subprocess.Popen([cmd],
|
||||
stdout=subprocess.PIPE,
|
||||
|
@ -170,7 +170,7 @@ class OgLinuxOperations:
|
|||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
|
||||
cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
|
||||
result = subprocess.check_output([cmd_get_conf], shell=True)
|
||||
self._restartBrowser(self._url)
|
||||
|
||||
|
@ -184,7 +184,7 @@ class OgLinuxOperations:
|
|||
ctype = request.getType()
|
||||
profile = request.getProfile()
|
||||
cid = request.getId()
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/RestaurarImagen {disk} {partition} ' \
|
||||
f'{name} {repo} {ctype}'
|
||||
|
||||
self._restartBrowser(self._url_log)
|
||||
|
@ -198,7 +198,7 @@ class OgLinuxOperations:
|
|||
except:
|
||||
raise ValueError('Error: Incorrect command value')
|
||||
|
||||
cmd_get_conf = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
|
||||
cmd_get_conf = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
|
||||
result = subprocess.check_output([cmd_get_conf], shell=True)
|
||||
self._restartBrowser(self._url)
|
||||
|
||||
|
@ -209,9 +209,9 @@ class OgLinuxOperations:
|
|||
partition = request.getPartition()
|
||||
name = request.getName()
|
||||
repo = request.getRepo()
|
||||
cmd_software = f'{ogConfig.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||
cmd_software = f'{ogClient.OG_PATH}interfaceAdm/InventarioSoftware {disk} ' \
|
||||
f'{partition} {path}'
|
||||
cmd_create_image = f'{ogConfig.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
|
||||
cmd_create_image = f'{ogClient.OG_PATH}interfaceAdm/CrearImagen {disk} ' \
|
||||
f'{partition} {name} {repo}'
|
||||
|
||||
self._restartBrowser(self._url_log)
|
||||
|
@ -245,7 +245,7 @@ class OgLinuxOperations:
|
|||
self._restartBrowser(self._url_log)
|
||||
|
||||
try:
|
||||
cmd = f'{ogConfig.OG_PATH}interfaceAdm/getConfiguration'
|
||||
cmd = f'{ogClient.OG_PATH}interfaceAdm/getConfiguration'
|
||||
ogRest.proc = subprocess.Popen([cmd],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
|
|
|
@ -24,6 +24,8 @@ class State(Enum):
|
|||
FORCE_DISCONNECTED = 2
|
||||
|
||||
class ogClient:
|
||||
OG_PATH = '/opt/opengnsys/'
|
||||
|
||||
def __init__(self, config):
|
||||
self.CONFIG = config
|
||||
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# Copyright (C) 2020 Soleta Networks <info@soleta.eu>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under
|
||||
# the terms of the GNU Affero General Public License as published by the
|
||||
# Free Software Foundation, version 3.
|
||||
#
|
||||
|
||||
import configparser
|
||||
|
||||
class ogConfig:
|
||||
OG_PATH = '/opt/opengnsys/'
|
||||
|
||||
def __init__(self):
|
||||
self.parser = configparser.ConfigParser()
|
||||
|
||||
def parser_file(self, path):
|
||||
self.parser.read(path)
|
||||
if len(self.parser.sections()) == 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def get_sections(self):
|
||||
return self.parser.sections()
|
||||
|
||||
def get_contains_section(self, section):
|
||||
return section in self.parser
|
||||
|
||||
def get_value_section(self, section, key):
|
||||
if (not self.get_contains_section(section)):
|
||||
return ''
|
||||
|
||||
return self.parser[section][key]
|
Loading…
Reference in New Issue