mirror of
https://gitlab.com/JKANetwork/powerfulcomputermanager.git
synced 2026-02-23 21:43:43 +01:00
Changes to doc and to API, a bit more stable
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
# Build 8
|
||||
# Build 9
|
||||
param([Int32]$startup=0)
|
||||
Write-Host $startup
|
||||
$root = $PSCommandPath | Split-Path -Parent
|
||||
$server = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).server
|
||||
$resources = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).resources
|
||||
|
||||
$64bit = [Environment]::Is64BitOperatingSystem
|
||||
|
||||
$computerName = [System.Net.Dns]::GetHostName()
|
||||
$UUID=(get-wmiobject Win32_ComputerSystemProduct).UUID
|
||||
@@ -51,6 +51,14 @@ foreach ($CookName in $cooks){
|
||||
Write-Host "Se salta ya que no esta arrancando/apagandose el equipo..."
|
||||
continue # Go for next
|
||||
}
|
||||
if ($cook.only64bit -eq 1 -and $64bit -eq $false) { # If script is only for 64 bit and system is 32 bit..
|
||||
Write-Host "Se salta ya que es esta receta es solo para 64 bits..."
|
||||
continue # Go for next
|
||||
}
|
||||
if ($cook.only32bit -eq 1 -and $64bit -eq $true) { # If script is only for 32 bit and system is 64 bit..
|
||||
Write-Host "Se salta ya que es esta receta es solo para 32 bits..."
|
||||
continue # Go for next
|
||||
}
|
||||
$err = 0
|
||||
$exit = 0
|
||||
$inif = $false
|
||||
@@ -182,6 +190,12 @@ foreach ($CookName in $cooks){
|
||||
Invoke-Expression $param #Executes powershell command
|
||||
$if=$? # True -> Exists ; False -> Not exists
|
||||
}
|
||||
"IF64BIT" { # If 64 bit computer
|
||||
$if = $64bit # Its true if 64 bit computer
|
||||
}
|
||||
"IF32BIT" { # If 32 bit computer
|
||||
$if = !$64bit # Its true if 32 bit computer, flipped boolean
|
||||
}
|
||||
"ELSE" { # Turn bool $if
|
||||
$if = !$if
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
#!/usr/bin/python3
|
||||
# Version 0.72
|
||||
# Version 0.8
|
||||
import easygui
|
||||
import configparser
|
||||
import json
|
||||
import requests
|
||||
import subprocess, platform
|
||||
import hashlib #SHA256
|
||||
import os
|
||||
from translation import T
|
||||
|
||||
|
||||
@@ -30,9 +31,11 @@ def sendmenudot(text,title,choices):
|
||||
else:
|
||||
return menu
|
||||
## showchoicesapi, suburl has to have params (NOT inlcuding server part)
|
||||
def showchoicesapi(text,title,suburl,field='Name'):
|
||||
def showchoicesapi(text,title,suburl,field=['Name']):
|
||||
global c_server
|
||||
global passha256
|
||||
if isinstance(field,str):
|
||||
field=[field] # Convert to list
|
||||
if 'Password=' in suburl:
|
||||
twopart = ""
|
||||
elif '?' in suburl:
|
||||
@@ -42,8 +45,12 @@ def showchoicesapi(text,title,suburl,field='Name'):
|
||||
try:
|
||||
jsonobj = json.loads(requests.get(c_server+suburl+twopart).text)
|
||||
listitems = []
|
||||
for ite in jsonobj:
|
||||
listitems.append(ite[field])
|
||||
for ite in jsonobj: # Run in array from json
|
||||
to = ""
|
||||
for i in field: # Converting list of fields to large string for return. Not change API
|
||||
to = str(to) + str(ite[i]) + "|"
|
||||
to = to.rstrip('|')
|
||||
listitems.append(to)
|
||||
return easygui.choicebox(text,title,listitems)
|
||||
except:
|
||||
easygui.msgbox(msg=T('Error talking with API'), title=title, ok_button='OK')
|
||||
@@ -127,7 +134,7 @@ def mcomputers():
|
||||
elif menu == '3':
|
||||
m_addcomputergroup()
|
||||
elif menu == '4':
|
||||
showchoicesapi(T('Computers list'),T('Computers list'),"/get/computers")
|
||||
showchoicesapi(T('Computers list'),T('Computers list'),"/get/computers",['Name','RAM','CPUName','SOVersion'])
|
||||
elif menu == '5':
|
||||
computer = showchoicesapi(T('Select a computer'),T('Computer status'),"/get/computers")
|
||||
showchoicesapi(T('Cooks of computer')+' '+computer,T('Computer status'),"/get/cookpend?ComputerName="+computer+"&SeeAll=1",'CookName')
|
||||
@@ -165,7 +172,7 @@ def mgroups():
|
||||
def mcooks():
|
||||
global c_server
|
||||
global c_resources
|
||||
menu = sendmenudot(T('Cooks menu'),T('Select option'),['1.Detalles de una receta','2.'+T('Rename cook'),'3.Añadir receta a un grupo','4.Eliminar receta de un grupo','5.Grupos de una receta','6.'+T('Clean cook status')])
|
||||
menu = sendmenudot(T('Cooks menu'),T('Select option'),['1.'+T('Cook details'),'2.'+T('Rename cook'),'3.Añadir receta a un grupo','4.Eliminar receta de un grupo','5.'+T('Cook groups'),'6.'+T('Clean cook status')])
|
||||
if menu == '1':
|
||||
cook = showchoicesapi("Lista de recetas implementadas en algún grupo. Selecciona una para ver sus datos","Detalles de una receta","/get/cookall",'CookName')
|
||||
if cook is not None:
|
||||
@@ -192,15 +199,20 @@ def mcooks():
|
||||
if newname is not None and easygui.ynbox("Cambiar nombre de la receta '"+cook+"' por '"+newname+"'. ¿Seguro?",T('Rename cook')):
|
||||
sendsettoapi("/upd/cookname?CookName="+cook+"&CookNewName="+newname,"Receta cambiada de nombre")
|
||||
elif menu == '3':
|
||||
cook = easygui.enterbox(T('Name of the cook'),"Añadir receta a un grupo")
|
||||
group = showchoicesapi("Lista de grupos existentes","Listado de grupos","/get/groups")
|
||||
if easygui.ynbox("Añadir la receta "+cook+" al grupo '"+group+"'. ¿Seguro?","Añadir receta a un grupo"):
|
||||
sendsettoapi("/add/cookgrp?CookName="+cook+"&GroupName="+group,"Receta añadida al grupo")
|
||||
files = os.listdir(os.path.dirname(os.path.realpath(__file__))+'/../cooks')
|
||||
files_txt = [i for i in files if i.endswith('.yaml')]
|
||||
cook = easygui.choicebox(T('Name of the cook'),T('Add cook to a group'),sorted(files_txt))
|
||||
if cook is not None:
|
||||
cook = cook.replace('.yaml','')
|
||||
group = showchoicesapi("Lista de grupos existentes",T('Groups list'),"/get/groups")
|
||||
if group is not None:
|
||||
if easygui.ynbox("Añadir la receta "+cook+" al grupo '"+group+"'. ¿Seguro?",T('Add cook to a group')):
|
||||
sendsettoapi("/add/cookgrp?CookName="+cook+"&GroupName="+group,"Receta añadida al grupo")
|
||||
elif menu == '4':
|
||||
cook = showchoicesapi("Lista de recetas implementadas en algún grupo. Selecciona una para elegir un grupo de esa receta para borrar. Si la receta no está en ningún grupo, no saldrá.","Eliminar receta de un grupo","/get/cookall",'CookName')
|
||||
if cook is not None:
|
||||
group = showchoicesapi("Lista de grupos que tienen esa receta ("+cook+"). Selecciona el grupo a quitar","Eliminar receta de un grupo","/get/grpcook?CookName="+cook,'Name')
|
||||
if group is not None and easygui.ynbox("Se va a quitar la receta "+cook+" del grupo "+group+". ¿Seguro?","Eliminar receta de un grupo"):
|
||||
group = showchoicesapi("Lista de grupos que tienen esa receta ("+cook+"). Selecciona el grupo a quitar",T('Remove cook from a group'),"/get/grpcook?CookName="+cook,'Name')
|
||||
if group is not None and easygui.ynbox("Se va a quitar la receta "+cook+" del grupo "+group+". ¿Seguro?",T('Remove cook from a group')):
|
||||
sendsettoapi("/del/cookgrp?CookName="+cook+"&GroupName="+group,"Receta quitada del grupo")
|
||||
elif menu == '5':
|
||||
cook = showchoicesapi("Lista de recetas implementadas en algún grupo. Selecciona una para ver los grupos de la receta. Si la receta no está en ningún grupo, no saldrá.","Grupos de una receta","/get/cookall",'CookName')
|
||||
|
||||
@@ -38,7 +38,9 @@ def T_es(textid):
|
||||
'Select a computer': 'Selecciona un equipo',
|
||||
'Computer status': 'Estado de un equipo',
|
||||
'Add computer to group':'Añadir equipo a un grupo',
|
||||
'Add cook to a group':'Añadir receta a un grupo',
|
||||
'Remove computer of a group':'Quitar equipo de un grupo',
|
||||
'Remove cook from a group':'Quitar receta de un grupo',
|
||||
'Name of the cook':'Nombre de la receta',
|
||||
'Select a group': 'Seleccione un grupo',
|
||||
'Cooks of computer': 'Recetas del equipo',
|
||||
@@ -63,7 +65,9 @@ def T_es(textid):
|
||||
'Enter password to start': 'Introduzca la contraseña para empezar',
|
||||
'Clean cook status': 'Borrar estado de una receta',
|
||||
'With errors': 'Con errores',
|
||||
'Error talking with API': 'Error en la comunicación con la API'
|
||||
'Error talking with API': 'Error en la comunicación con la API',
|
||||
'Cook details':'Detalles de una receta',
|
||||
'Cook groups':'Grupos de una receta'
|
||||
}
|
||||
|
||||
return dict[textid]
|
||||
|
||||
Reference in New Issue
Block a user