[WIP] new GUI for debug console

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: another_commander, winston

cag
Deadly
Deadly
Posts: 197
Joined: Fri Mar 17, 2017 1:49 am

Re: [WIP] new GUI for debug console

Post by cag »

MrFlibble wrote: Sat Apr 20, 2024 4:34 am
Barking up a similar tree I'll wager!
Yeah but I can't reproduce (so ze bug never happened)
MrFlibble wrote: Sat Apr 20, 2024 4:34 am
Which is where?
Sorry, got distracted by your post in Telescope 2 - I never got an email notification but I get'em for each post here???
The function initClientSettings starts around line 2808 with the for loop around 2826 - place line just before for loop.

Code: Select all

print('\n'.join(['{}: {}'.format(key, value) for key, value in pairs.items() if key != 'default-macros']))
I just want to verify your plist is getting thru, narrow down the possibilities.
MrFlibble wrote: Sat Apr 20, 2024 4:34 am
Python comfort... a bit prickly, way less comfy than bash, much more cozy than javascript..
Git. I know the acronym, and can fuddle my way around.
The reason I asked was, well, I kept my sanity during lockdown in part by doing a complete rewrite but it's not quite finished and I've kind of ran out of steam. Once we get this figured out, would you be interested in helping out? I'm sure we could get hiran or phkb to help set up the git part.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

cag wrote: Sat Apr 20, 2024 6:45 am
The function initClientSettings starts around line 2808 with the for loop around 2826 - place line just before for loop.

Code: Select all

print('\n'.join(['{}: {}'.format(key, value) for key, value in pairs.items() if key != 'default-macros']))
I just want to verify your plist is getting thru, narrow down the possibilities.
Ah! Got it. Thanks. Easier to see with mid-afternoon coffee than it was with last night's grog.

Here's the output from the pyenv python 2.7 venv. Font face is evidently not coming from ~/GNUstep/Applications/Oolite/AddOns/Basic-debug.oxp/Config/debugConfig.plist. It's set to Courier_New there, I also tried Courierz_New in case only the first alphanumeric portion of the string was being used.

Code: Select all

$ python DebugConsole.py 
font-face: Courier
font-size: 12
dump-stack-for-errors: true
dump-stack-for-warnings: true
show-console-on-error: True
show-console-on-log: False
show-console-on-warning: True
show-error-locations: true
show-error-locations-during-console-eval: false
general-background-color: [1.0, 1.0, 1.0, 1.0]
general-foreground-color: [0.0, 0.0, 0.0, 1.0]
command-background-color: [0.88, 0.88, 1.0, 1.0]
error-background-color: [1.0, 0.75, 0.75, 1.0]
exception-background-color: [1.0, 0.75, 0.9166666, 1.0]
warning-background-color: [1.0, 1.0, 0.75, 1.0]
command-error-background-color: [1.0, 0.88, 0.88, 1.0]
command-exception-background-color: [1.0, 0.75, 0.9166666, 1.0]
command-result-background-color: [0.8, 1.0, 0.8, 1.0]
macro-error-background-color: [1.0, 0.88, 0.88, 1.0]
macro-expansion-background-color: [0.94, 0.94, 1.0, 1.0]
macro-expansion-foreground-color: [0.3333333, 0.3333333, 0.3333333, 1.0]
macro-info-background-color: [0.8, 1.0, 0.8, 1.0]
macro-warning-background-color: [1.0, 1.0, 0.88, 1.0]
unknown-macro-background-color: [1.0, 1.0, 0.88, 1.0]
Unhandled Error
Traceback (most recent call last):
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/python/log.py", line 103, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/python/log.py", line 86, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/python/context.py", line 122, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/python/context.py", line 85, in callWithContext
    return func(*args,**kw)
--- <exception caught here> ---
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/internet/posixbase.py", line 614, in _doReadOrWrite
    why = selectable.doRead()
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/internet/tcp.py", line 243, in doRead
    return self._dataReceived(data)
  File "/home/user/.pyenv/versions/2.7.18/envs/Oolite-Debug/lib/python2.7/site-packages/twisted/internet/tcp.py", line 249, in _dataReceived
    rval = self.protocol.dataReceived(data)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/PropertyListPacketProtocol.py", line 111, in dataReceived
    self.__dispatchPacket()
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/PropertyListPacketProtocol.py", line 154, in __dispatchPacket
    self.plistPacketReceived(plist)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 127, in plistPacketReceived
    self.__noteConfigurationPacket(packet)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 222, in __noteConfigurationPacket
    self.delegate.loadConfig(self.__configuration)
  File "DebugConsole.py", line 270, in loadConfig
    app.initClientSettings(config)
  File "DebugConsole.py", line 2830, in initClientSettings
    self.setFontFace(value, plist=True, skipUpdate='font-size' in settingsKeys)
  File "DebugConsole.py", line 2770, in setFontFace
    self.updateFontBox(self.fontList.index(face))
exceptions.ValueError: 'Courier' is not in list
Note: I'm using Oolite 1.91.
cag wrote: Sat Apr 20, 2024 6:45 am
Once we get this figured out, would you be interested in helping out? I'm sure we could get hiran or phkb to help set up the git part.
I'd be honoured to... if my brain can grok it.
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

Just drilled in a little. Got it surrounded.

Code: Select all

			if key == 'font-face':
				if 'Family' not in self.loadedConfig or override:
					print('\nbazinga! 1')
					self.setFontFace(value, plist=True, skipUpdate='font-size' in settingsKeys)
					print('\nbazinga! 2')
				self.settings[ key ] = value
			elif key == 'font-size':

Code: Select all

...
macro-warning-background-color: [1.0, 1.0, 0.88, 1.0]
unknown-macro-background-color: [1.0, 1.0, 0.88, 1.0]

bazinga! 1
Unhandled Error
Traceback (most recent call last):
...
HTH.
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

It works (for python 2.7) if I set a font in DebugConsole, uncheck "Use Oolite plist for local font/colors", and save settings.

The only errors I see now are:-

Code: Select all

DebugConsole: ERROR    Uunsupported var show-console-on-error: True, type: <type 'bool'>
DebugConsole: ERROR    Uunsupported var show-console-on-log: False, type: <type 'bool'>
DebugConsole: ERROR    Uunsupported var show-console-on-warning: True, type: <type 'bool'>
Doing the same for Python 3.10 it still fails to connect at all.
User avatar
hiran
Theorethicist
Posts: 2055
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: [WIP] new GUI for debug console

Post by hiran »

cag wrote: Sat Apr 20, 2024 6:45 am
The reason I asked was, well, I kept my sanity during lockdown in part by doing a complete rewrite but it's not quite finished and I've kind of ran out of steam. Once we get this figured out, would you be interested in helping out? I'm sure we could get hiran or phkb to help set up the git part.
I am willing to help out. Python is not my bag but tell me what is on your mind. We can get Github to run checks and package the code together with required resources.
Sunshine - Moonlight - Good Times - Oolite
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

So, we can make the existing version function adequately in python 2.7 on linux, without changing any of it, and doing userland config tweaks. In fact, if the default were to not use the debug config plist, then it'd work directly.

Wanting to have it run on 3.10, I've just 2to3'd a version, and preened it a bit, ripping out most of the python 2 stuff and making the tkinter things all start with tk. rather than importing tkinter as * into main namespace.

Seems to work in 3.10. I get exactly the same stderr output as the 2.7.

I'll pick over it one more time and put a copy up if anyone would care to test it on other OS.
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

My minimum change to get it working on 3.10.

In ooliteConsoleServer/PropertyListPacketProtocol.py

Code: Select all

#				self.transport.write(hdr)
				self.temp=bytes(hdr)
				self.transport.write(self.temp)
To also optionally get rid of two warns. Edit DebugConsole.py line 295 and change both "is not" to !=

Code: Select all

if app.top.state() != 'zoomed' and app.top.state() != 'normal':
These simple fixes seems to work with the 2.7 too.

I'll keep my python 3 only version to myself for now, as there's a high chance I missed an edit somewhere.

The above is a simpler fix.
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

I've uploaded the simple fixed version. OoDebugConsole2-01.zip.

By the time the upload site expires it, I'd hope it to have been superseded. The patches above will do the trick anyway.
User avatar
hiran
Theorethicist
Posts: 2055
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: [WIP] new GUI for debug console

Post by hiran »

Does Python 2.x matter at all? AFAIK it is no longer supported and you'd have to apply increasing amounts of magick to have it installed.
Sunshine - Moonlight - Good Times - Oolite
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

hiran wrote: Sat Apr 20, 2024 7:00 pm
Does Python 2.x matter at all? AFAIK it is no longer supported and you'd have to apply increasing amounts of magick to have it installed.
I'd agree that going forward there's no point in writing new 2.7 code.

Might as well leave Python 2 compatibility intact where it exists in older projects.

Those who have systems where Python2 is still default are in the minority, and can use pyenv or similar to have a current version handy.
User avatar
hiran
Theorethicist
Posts: 2055
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: [WIP] new GUI for debug console

Post by hiran »

MrFlibble wrote: Sat Apr 20, 2024 7:17 pm
Those who have systems where Python2 is still default are in the minority, and can use pyenv or similar to have a current version handy.
I'd stop bothering completely. Here an excerpt from Wikipedia:

Since 27 June 2023, Python 3.8 is the oldest supported version of Python (albeit in the 'security support' phase), due to Python 3.7 reaching end-of-life.

But what exactly did you mean by setting up git? What is your goal? (I guess setting up a git repository on Github is just a buttonclick any of us can do)
Sunshine - Moonlight - Good Times - Oolite
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

hiran wrote: Sat Apr 20, 2024 9:07 pm
I'd stop bothering completely. Here an excerpt from Wikipedia:

Since 27 June 2023, Python 3.8 is the oldest supported version of Python (albeit in the 'security support' phase), due to Python 3.7 reaching end-of-life.
Alas quite a few folk don't care to have 'latest' python, especially not system-wide. In the Telescope thread it became apparent that Cholly is still on a system where 2.7 is standard.

Obviously, for developer tools like the DebugConsole, requiring a reasonably current python is not an issue. The intended audience will already know, or rapidly learn, how to set up a Python environment. It's almost funny that the 'normal' Debug Console needs python2, though it was written c. 18 years ago.
hiran wrote: Sat Apr 20, 2024 9:07 pm
But what exactly did you mean by setting up git? What is your goal? (I guess setting up a git repository on Github is just a buttonclick any of us can do)
I think cag was intending to put DebugConsole v3 on github so we could collaboratively fix/improve it. I'm of the opinion that the most stable/current debug console should be kept alongside the debug OXP in the github for Oolite itself, and maybe even bundled with the dev version to simplify entry to Oolite development.
User avatar
hiran
Theorethicist
Posts: 2055
Joined: Fri Mar 26, 2021 1:39 pm
Location: a parallel world I created for myself. Some call it a singularity...

Re: [WIP] new GUI for debug console

Post by hiran »

MrFlibble wrote: Sat Apr 20, 2024 9:27 pm
hiran wrote: Sat Apr 20, 2024 9:07 pm
But what exactly did you mean by setting up git? What is your goal? (I guess setting up a git repository on Github is just a buttonclick any of us can do)
I think cag was intending to put DebugConsole v3 on github so we could collaboratively fix/improve it. I'm of the opinion that the most stable/current debug console should be kept alongside the debug OXP in the github for Oolite itself, and maybe even bundled with the dev version to simplify entry to Oolite development.
Sounds reasonable - there is some dependency on Oolite. Somehow the debug oxp is inside the core but the debug console is not.
However the choice of a network link between the two makes them weakly coupled via the network communication protocol. There could be many different implementations of the debug console. Indeed I implemented the debug console protocol in Nexus.

But put aside, so far I see all that you need is a repository. If that one shall be in the OoliteProject organization I am not privileged enough to set it up for you. On the other hand it already exists: https://github.com/OoliteProject/oolite-debug-console. All you'd need to do is create a branch and move on with development in there. Eventually we just swap the master branch into the version you create.

However we might want to add some automatic version and release management in there just the way it works on OoliteAddonScanner, OoliteStarter or Oolite itself.
Sunshine - Moonlight - Good Times - Oolite
User avatar
MrFlibble
Deadly
Deadly
Posts: 170
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

hiran wrote: Sat Apr 20, 2024 10:19 pm
But put aside, so far I see all that you need is a repository. If that one shall be in the OoliteProject organization I am not privileged enough to set it up for you. On the other hand it already exists: https://github.com/OoliteProject/oolite-debug-console. All you'd need to do is create a branch and move on with development in there. Eventually we just swap the master branch into the version you create.
Excellent. I'd not tripped over that in my fumblings. That version of course still requires python2.

Notes to self & cag:

The one on github has a new icon, has been modified to allow multiple instances, and some other tweaks/fixes. Anything useful needs patching into the v2 since that's largely based on 1.5, and should be reasonably easy... unless of course it's already been done in the v3.

plistlib appears to be standard in python from 2.7. I believe the assumption is made in DebugConsole2 that >=2.7 and >=3.6 have a working plistlib as standard.
cag
Deadly
Deadly
Posts: 197
Joined: Fri Mar 17, 2017 1:49 am

Re: [WIP] new GUI for debug console

Post by cag »

[wiki][/wiki]
MrFlibble wrote: Sat Apr 20, 2024 3:25 pm
The only errors I see now are:-

Code: Select all

DebugConsole: ERROR    Uunsupported var show-console-on-error: True, type: <type 'bool'>
DebugConsole: ERROR    Uunsupported var show-console-on-log: False, type: <type 'bool'>
DebugConsole: ERROR    Uunsupported var show-console-on-warning: True, type: <type 'bool'>
These 3 are being interpreted as Python booleans! On Windows, they are ints, 0 or 1 while other bools are 'true' or 'false'. I guess it's Linux version of Python's plistlib. Nothing to do but deal with it. Lines 2867-2868

Code: Select all

				if valueType == int or value in ['1', '0', 'true', 'false', 'yes', 'no',]:
					tkValue = 1 if value == 'true' or value == 'yes' or value == 1 else 0
should be changed to read

Code: Select all

				if valueType == bool or (valueType == int and value in [0, 1]) \
						or value in ['1', '0', 'true', 'false', 'yes', 'no']:
					if valueType == bool:
						tkValue = 1 if value else 0
					if valueType == int:
						tkValue = value
					else:
						tkValue = 1 if value in ['1', 'true', 'yes'] else 0
As for the 'Courier', that also comes straight from Oolite upon connection, ie. not our fault! As a work around, we could include a config file if we knew of a font that was common to all three OSs. I set it to 'Arial' but don't remember if I queried Linux & MacOS users about its ubiquity.

Click on 'Options' - 'Save configuraton Now!' without a connection to Oolite to get the defaults. Yes, 'PlistOverrides' defaults to 'Yes'. That and any other defaults you think need changing can be found starting at line 200. We should proceed with your copies as I notices that I had some CR-LF files which you corrected. (I saw all the updated timestamps and had to know why!)

When you're ready, I'll test both Pythons on my Windows PC. Then we can upload it to the wiki so it has a central & permanent home.
"Better to be thought a fool, boy, than to open your trap and remove all doubt." - Grandma [over time, just "Shut your trap... fool"]
"The only stupid questions are the ones you fail to ask." - Dad
How do I...? Nevermind.
Post Reply