mirror of
https://gitlab.os-k.eu/neox/CNIRevelator.git
synced 2023-08-25 14:03:10 +02:00
More GUI improvements
This commit is contained in:
parent
9142994360
commit
f75b1db8ea
19
src/main.py
19
src/main.py
@ -55,11 +55,13 @@ class mainWindow(Tk):
|
||||
self.Tags = []
|
||||
self.compliance = True
|
||||
|
||||
# Get the screen size
|
||||
# Hide during construction
|
||||
self.withdraw()
|
||||
|
||||
# Get the screen size and center
|
||||
ws = self.winfo_screenwidth()
|
||||
hs = self.winfo_screenheight()
|
||||
logfile.printdbg('Launching main window with resolution' + str(ws) + 'x' + str(hs))
|
||||
self.grid()
|
||||
|
||||
# Configuring the size of each part of the window
|
||||
self.grid_columnconfigure(0, weight=1, minsize=(ws / 2 * 0.3333333333333333))
|
||||
@ -201,7 +203,6 @@ class mainWindow(Tk):
|
||||
self.terminal.grid(column=0, row=2, sticky='EWNS', columnspan=2, padx=5, pady=5)
|
||||
self.terminal2.grid(column=0, row=1, sticky='EWNS', columnspan=2, padx=5, pady=5)
|
||||
self.monitor.grid(column=2, row=1, sticky='EWNS', columnspan=1, rowspan=2, padx=5, pady=5)
|
||||
self.update()
|
||||
|
||||
# What is a window without a menu bar ?
|
||||
menubar = Menu(self)
|
||||
@ -229,19 +230,21 @@ class mainWindow(Tk):
|
||||
# Make this window resizable and set her size
|
||||
self.resizable(width=True, height=True)
|
||||
self.minsize(self.winfo_width(), self.winfo_height())
|
||||
w = int(self.winfo_width())
|
||||
h = int(self.winfo_height())
|
||||
self.update()
|
||||
w = int(self.winfo_reqwidth())
|
||||
h = int(self.winfo_reqheight())
|
||||
ws = self.winfo_screenwidth()
|
||||
hs = self.winfo_screenheight()
|
||||
x = ws / 2 - w / 2
|
||||
y = hs / 2 - h / 2
|
||||
x = (ws - w)/2
|
||||
y = (hs - h)/2
|
||||
self.geometry('%dx%d+%d+%d' % (w, h, x, y))
|
||||
self.update()
|
||||
self.deiconify()
|
||||
|
||||
# Some bindings
|
||||
self.termtext.bind('<Key>', self.entryValidation)
|
||||
self.termtext.bind('<<Paste>>', self.pasteValidation)
|
||||
self.speed731text.bind('<Control_R>', self.speedValidation)
|
||||
self.update()
|
||||
logfile.printdbg('Initialization successful')
|
||||
|
||||
def stringValidation(self, keysym):
|
||||
|
@ -79,6 +79,47 @@ def exitProcess(arg):
|
||||
process.terminate()
|
||||
sys.exit(arg)
|
||||
|
||||
def runPowershell(scriptblock, cwd=os.getcwd()):
|
||||
"""
|
||||
Executes a powershell command
|
||||
"""
|
||||
log.debug("Running PowerShell Block:\r\n%s", scriptblock)
|
||||
log.debug("Current Directory: %s\r\n" % cwd)
|
||||
psProc = subprocess.Popen([r'C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell.exe',
|
||||
'-ExecutionPolicy', 'Bypass',
|
||||
'-noprofile',
|
||||
'-c', '-',],
|
||||
cwd=cwd,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE)
|
||||
stdoutdata, stderrdata = psProc.communicate(scriptblock)
|
||||
|
||||
if stdoutdata:
|
||||
log.debug("Script Output:\r\n%s" % stdoutdata)
|
||||
elif not stderrdata:
|
||||
log.debug("Script completed succssfully (no stdout/stderr).")
|
||||
if stderrdata:
|
||||
log.error("Script Error:\r\n%s" % stderrdata)
|
||||
|
||||
return stdoutdata, stderrdata
|
||||
|
||||
|
||||
def getCertificates(server_list, location="LocalMachine", store="My"):
|
||||
"""
|
||||
Returns the json data of all installed certificates
|
||||
"""
|
||||
cmd = '''
|
||||
$sb = { ls Cert:\%s\%s | Select Subject,ThumbPrint }
|
||||
$Servers = '%s' | ConvertFrom-Json
|
||||
|
||||
Invoke-Command -ComputerName $Servers -ScriptBlock $sb -Authentication Negotiate | ConvertTo-Json -Depth 999
|
||||
''' % (location, store, json.dumps(server_list))
|
||||
stdoutdata, stderrdata = runPowershell(cmd)
|
||||
return json.loads(stdoutdata)
|
||||
|
||||
|
||||
|
||||
def getLatestVersion(credentials):
|
||||
"""
|
||||
Returns the latest version of the software
|
||||
|
Loading…
Reference in New Issue
Block a user