[WIP] new GUI for debug console

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

Moderators: winston, another_commander

Post Reply
cag
Deadly
Deadly
Posts: 200
Joined: Fri Mar 17, 2017 1:49 am

[WIP] new GUI for debug console

Post by cag »

Built using OoDebugConsole1.5 as a starting point, this version is functionally the same, just with less typing.

The one exception is the 'alias' function in Options menu. Basic-debug.oxp provides a few, eg. 'PS' for player.ship, but I wanted more (and in lower case!).

As with Basic-debug.oxp, these are just properties of the console script. I've added polling, so if you set one to something dynamic (eg. 'pt' for player.ship.target), it will be up to date. I've also had success adding functions, as long as I remember to type '()' after the alias :)

At present there is no documentation. What started as just my own hacked version has grown over time so I thought others may find it useful. I copied the Debug menu from the Mac OS version and tossed in anything else I could find in oolite-debug-console.js.

features:
  • menus for debug, options, font and once connected, a menu for options in debugConfig.plist
  • pop-up menus for frames (includes a search function) & scroll bars
  • command history search via the Tab key (Shift-Tab to search the other way)
    You can also remove a command from the history using the pop-up menu or Ctrl-Delete.
    (I load new functions a lot, even entire scripts, and my history file grew quite large!
    FYI: I also added a limit of 200 commands/2MB)

Python source: https://www.dropbox.com/s/junf73vkqibdn ... 2.zip?dl=0
- if not already present, will need to install the 'twisted' package

Windows exe: https://www.dropbox.com/s/x62r5gvp65yhe ... 2.exe?dl=0

Edited Jan. 7/20 @ 7:15 pm EST
- new versions uploaded to fix dialog window bug

requires:
Last edited by cag on Wed Jan 08, 2020 12:18 am, edited 1 time in total.
"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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6588
Joined: Wed Feb 28, 2007 7:54 am

Re: [WIP] new GUI for debug console

Post by another_commander »

Good job, thanks.

As a very minor observation, after building the application, I get the Tk icon on the console window rather than the "correct" one. Any idea why this would be?
cag
Deadly
Deadly
Posts: 200
Joined: Fri Mar 17, 2017 1:49 am

Re: [WIP] new GUI for debug console

Post by cag »

after building the application, I get the Tk icon on the console window rather than the "correct" one
I'm unable to reproduce on my rig (Windows 10 Pro - 1809) either by running the .exe or the script via pythonw.exe. I see the provided icon on the console, taskbar and dialog windows (Tk's "feather" icon is just ugly imho)

What's your OS? What do you mean by "building the application"? It should be sufficient, assuming you have Python installed, to run the script as is, as Python will check the script's folder for the icon.

Speed is not a factor. I always just run the script and it can handle a dozen or more log messages/frame easily. The .exe was provided for those who don't have Python installed.

If you are building an executable for another OS, getting it to cooperate with Tk can require some fiddling. I built the .exe using pyinstaller, which has a handy --icon= arg.
"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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6588
Joined: Wed Feb 28, 2007 7:54 am

Re: [WIP] new GUI for debug console

Post by another_commander »

I was using pyinstaller on Windows as well. When I talked about building the application I meant generating a stand-alone executable.

It turns out I had omitted adding the icon in the list of files that pyinstaller packs. Without the icon, it was defaulting to the Tk one. I have now managed to build a stand-alone console exe that runs correctly using this command line in the folder where the console source was copied to:

C:\OoDebugConsole2> pyinstaller --onefile --add-data="OoJSC.ico;." --windowed DebugConsole.py -i OoJSC.ico

Thanks again for the help.
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Re: [WIP] new GUI for debug console

Post by Svengali »

Nice work, a_c!!!! Thanks a lot. :D
User avatar
MrFlibble
---- E L I T E ----
---- E L I T E ----
Posts: 279
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

This looks really good, however I'm struggling to make it run on LinuxMint 21.3 here four years on.

Using the same pyenv as works for the 1.5 console, which is a python 2.7 venv with twisted etc, I get a connect followed by disconnect straight away.

Code: Select all

Listening on port 8563.

Use Up and Down arrows to scroll through the command history.
Type /quit to quit.
Waiting for connection...
Opened connection with Oolite version 1.91

Connection closed with no message at <built-in function asctime>.
This goes to standard error on the launching terminal:

Code: Select all

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 2829, 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
Using the more current system python (3.10) with python3-twisted installed via apt, things appear worse. The connection does not appear to happen at all. Stderr looks like this:

Code: Select all

/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py:295: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if app.top.state() is not 'zoomed' and app.top.state() is not 'normal':
/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py:295: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if app.top.state() is not 'zoomed' and app.top.state() is not 'normal':
--- Logging error ---
Traceback (most recent call last):
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 164, in __requestConnectionPacket
    self.sendPlistPacket(response)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/PropertyListPacketProtocol.py", line 139, in sendPlistPacket
    self.transport.write(hdr)
  File "/usr/lib/python3/dist-packages/twisted/internet/_newtls.py", line 179, in write
    FileDescriptor.write(self, bytes)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 356, in write
    _dataMustBeBytes(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 24, in _dataMustBeBytes
    raise TypeError("Data must be bytes")
TypeError: Data must be bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 678, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py", line 4318, in <module>
    main()
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py", line 4305, in main
    reactor.run()
  File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1315, in run
    self.mainLoop()
  File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1328, in mainLoop
    reactorBaseSelf.doIteration(t)
  File "/usr/lib/python3/dist-packages/twisted/internet/epollreactor.py", line 244, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 96, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 80, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/internet/posixbase.py", line 683, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 247, in doRead
    return self._dataReceived(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 252, 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 117, in plistPacketReceived
    self.__requestConnectionPacket(packet)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 169, in __requestConnectionPacket
    consoleLogger.exception("Exception in connection set-up: ", inst)
Message: 'Exception in connection set-up: '
Arguments: (TypeError('Data must be bytes'),)
--- Logging error ---
Traceback (most recent call last):
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 164, in __requestConnectionPacket
    self.sendPlistPacket(response)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/PropertyListPacketProtocol.py", line 139, in sendPlistPacket
    self.transport.write(hdr)
  File "/usr/lib/python3/dist-packages/twisted/internet/_newtls.py", line 179, in write
    FileDescriptor.write(self, bytes)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 356, in write
    _dataMustBeBytes(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 24, in _dataMustBeBytes
    raise TypeError("Data must be bytes")
TypeError: Data must be bytes

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.10/logging/__init__.py", line 1100, in emit
    msg = self.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 943, in format
    return fmt.format(record)
  File "/usr/lib/python3.10/logging/__init__.py", line 678, in format
    record.message = record.getMessage()
  File "/usr/lib/python3.10/logging/__init__.py", line 368, in getMessage
    msg = msg % self.args
TypeError: not all arguments converted during string formatting
Call stack:
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py", line 4318, in <module>
    main()
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/DebugConsole.py", line 4305, in main
    reactor.run()
  File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1315, in run
    self.mainLoop()
  File "/usr/lib/python3/dist-packages/twisted/internet/base.py", line 1328, in mainLoop
    reactorBaseSelf.doIteration(t)
  File "/usr/lib/python3/dist-packages/twisted/internet/epollreactor.py", line 244, in doPoll
    log.callWithLogger(selectable, _drdw, selectable, fd, event)
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 96, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 80, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/internet/posixbase.py", line 683, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 247, in doRead
    return self._dataReceived(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 252, 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 117, in plistPacketReceived
    self.__requestConnectionPacket(packet)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 169, in __requestConnectionPacket
    consoleLogger.exception("Exception in connection set-up: ", inst)
Message: 'Exception in connection set-up: '
Arguments: (TypeError('Data must be bytes'),)
DebugConsole.ODCProtocol: ERROR    Failed to open connection.
Unhandled Error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 96, in callWithLogger
    return callWithContext({"system": lp}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/log.py", line 80, in callWithContext
    return context.call({ILogContext: newCtx}, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 117, in callWithContext
    return self.currentContext().callWithContext(ctx, func, *args, **kw)
  File "/usr/lib/python3/dist-packages/twisted/python/context.py", line 82, in callWithContext
    return func(*args, **kw)
--- <exception caught here> ---
  File "/usr/lib/python3/dist-packages/twisted/internet/posixbase.py", line 683, in _doReadOrWrite
    why = selectable.doRead()
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 247, in doRead
    return self._dataReceived(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/tcp.py", line 252, 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 117, in plistPacketReceived
    self.__requestConnectionPacket(packet)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/OoliteDebugConsoleProtocol.py", line 177, in __requestConnectionPacket
    self.sendPlistPacket(response)
  File "/home/user/Oolite-scripts/OoliteDebugConsole2/ooliteConsoleServer/PropertyListPacketProtocol.py", line 139, in sendPlistPacket
    self.transport.write(hdr)
  File "/usr/lib/python3/dist-packages/twisted/internet/_newtls.py", line 179, in write
    FileDescriptor.write(self, bytes)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 356, in write
    _dataMustBeBytes(data)
  File "/usr/lib/python3/dist-packages/twisted/internet/abstract.py", line 24, in _dataMustBeBytes
    raise TypeError("Data must be bytes")
builtins.TypeError: Data must be bytes
If there's anything further I can do to help debug this, let me know.
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 671
Joined: Sat Aug 09, 2014 4:16 pm

Re: [WIP] new GUI for debug console

Post by Commander_X »

For the python 2, due to the
MrFlibble wrote: Fri Apr 19, 2024 6:31 pm
[...]
File "DebugConsole.py", line 2829, 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[/code]
[...]
setFondFace and 'Courier' references, I'd bet your Linux doesn't come with a Courier font installed. Either install one, or replace the Courier reference (on the line 2770?) with a name of monospaced font you know it is installed on your system.
User avatar
MrFlibble
---- E L I T E ----
---- E L I T E ----
Posts: 279
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

Commander_X wrote: Fri Apr 19, 2024 9:01 pm
For the python 2, due to the
MrFlibble wrote: Fri Apr 19, 2024 6:31 pm
[...]
File "DebugConsole.py", line 2829, 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[/code]
[...]
setFondFace and 'Courier' references, I'd bet your Linux doesn't come with a Courier font installed. Either install one, or replace the Courier reference (on the line 2770?) with a name of monospaced font you know it is installed on your system.
I have the mscorefonts, so have Courier_New in four flavours.

Code: Select all

$ find /usr/share/fonts | grep -i courier
/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf

Code: Select all

$ sed -n 2770p DebugConsole.py
    self.updateFontBox(self.fontList.index(face))
grep -ri courier * in the OoliteDebugConsole2 directory returns blank.
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 671
Joined: Sat Aug 09, 2014 4:16 pm

Re: [WIP] new GUI for debug console

Post by Commander_X »

MrFlibble wrote: Fri Apr 19, 2024 9:28 pm
[...]

Code: Select all

$ sed -n 2770p DebugConsole.py
    self.updateFontBox(self.fontList.index(face))
grep -ri courier * in the OoliteDebugConsole2 directory returns blank.
The absence of 'Courier' in the .py file seems to happen because it's being picked from a plist file in the Debug OXP. E.g. in my instance, in Config/debugConfig.plist at line 165 there is

Code: Select all

	font-face							= "Courier";
User avatar
MrFlibble
---- E L I T E ----
---- E L I T E ----
Posts: 279
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

Commander_X wrote: Fri Apr 19, 2024 10:52 pm
The absence of 'Courier' in the .py file seems to happen because it's being picked from a plist file in the Debug OXP. E.g. in my instance, in Config/debugConfig.plist at line 165 there is

Code: Select all

	font-face							= "Courier";
I chopped that over to Courier_New, and still get:

Code: Select all

exceptions.ValueError: 'Courier' is not in list
The font in the window actually changes to a monospace font at that point too. It still drops the connection.
cag
Deadly
Deadly
Posts: 200
Joined: Fri Mar 17, 2017 1:49 am

Re: [WIP] new GUI for debug console

Post by cag »

Been following you & Commander_X's post. I can't type that fast I keep having to start over.

I searched & the only occurance of "Courier" wrt debug console is in Oolite\AddOns\Basic-debug.oxp\Config\debugConfig.plist and it will be overwritten each time you install a new dev version of Oolite!
MrFlibble wrote: Fri Apr 19, 2024 11:48 pm
The font in the window actually changes to a monospace font at that point too. It still drops the connection.
What error are you getting now?
"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
---- E L I T E ----
---- E L I T E ----
Posts: 279
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

cag wrote: Sat Apr 20, 2024 12:07 am
Been following you & Commander_X's post. I can't type that fast I keep having to start over.

I searched & the only occurance of "Courier" wrt debug console is in Oolite\AddOns\Basic-debug.oxp\Config\debugConfig.plist and it will be overwritten each time you install a new dev version of Oolite!
MrFlibble wrote: Fri Apr 19, 2024 11:48 pm
The font in the window actually changes to a monospace font at that point too. It still drops the connection.
What error are you getting now?
I've changed the line in debugConfig.plist to

Code: Select all

<------>font-face<-----><------><------><------><------><------><------>= "Courier_New";
(that's pasted from mcedit, which shows all the tabs.)

And now, when I launch Oolite, I get (using the python 2.7 venv that works for the 1.5 Debug)
From the new debug console:

Code: Select all

Opened connection with Oolite version 1.91

Connection closed with no message at <built-in function asctime>.
At that point, the text in the debug console has become monospace.

And stderr is the same as before AFAICT:

Code: Select all

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 2829, 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
cag
Deadly
Deadly
Posts: 200
Joined: Fri Mar 17, 2017 1:49 am

Re: [WIP] new GUI for debug console

Post by cag »

I was getting 'Palatino' is not in list! I've never heard of it and it's not a font on Windows! The only thing grep turned up was a comment in debugConfig.plist, so I bit the bullet and started from scratch. Fresh install of Oolite & debugConsole on a different drive and ... it went away. And that reminded me of another place font-face may be recorded:

C:\Oolite\oolite.app\GNUstep\Defaults\.GNUstepDefaults

If that's not it, I'll need more information. Place the following line before the 'for' loop in initClientSettings:

Code: Select all

print('\n'.join(['{}: {}'.format(key, value) for key, value in pairs.items() if key != 'default-macros']))
In addition to stderr output, send along your debugConfig.plist file and the latest DebugConsole.cfg & DebugConsole.log files (if they exist).

BTW, how comfortable are you w/ Python? Do you get git?
"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
---- E L I T E ----
---- E L I T E ----
Posts: 279
Joined: Sun Feb 18, 2024 12:13 pm

Re: [WIP] new GUI for debug console

Post by MrFlibble »

cag wrote: Sat Apr 20, 2024 2:33 am
I was getting 'Palatino' is not in list
Barking up a similar tree I'll wager!
cag wrote: Sat Apr 20, 2024 2:33 am
If that's not it, I'll need more information. Place the following line before the 'for' loop in initClientSettings:
Which is where?
cag wrote: Sat Apr 20, 2024 2:33 am
In addition to stderr output, send along your debugConfig.plist file and the latest DebugConsole.cfg & DebugConsole.log files (if they exist).
BTW, how comfortable are you w/ Python? Do you get git?

Code: Select all

debugConfig.plist
[code]cat ./GNUstep/Applications/Oolite/AddOns/Basic-debug.oxp/Config/debugConfig.plist
/*	JavaScript console configuration.
	
	This plist is merged and overrideable in the usual fashion. Additionally,
	settings may be changed from within JavaScript using syntax such as:
	
		console.settings["font-face"] = "Palatino";
		console.settings["command-background-color"] = [0.9, 0.9, 1];
		console.settings["show-console-on-log"] = true;
	
	or using the predefined console macros fgColor and bgColor, like:
	
		:fgColor general "redColor"
		:bgColor general "0.8 0.8 0.9"
	
	Settings like this are saved in Oolite's preferences and always override
	settings in debugConfig.plist. An override can be removed in
	JavaScript like this:
	
		delete console.settings["font-face"];
*/

{
	/*	Settings for external TCP debug console support.
		
		Under Mac OS X, the integrated debug console will be used if
		console-host is not specified. Set console-host to "127.0.0.1" to use
		an external debug console running on the same machine.
		
		On other systems, not specifying console-host is equivalent to setting
		it to 127.0.0.1.
		
		If console-port is not specified, 8563 will be used.
		
		NOTE: console-host and console-port overrides set in JavaScript will
		be ignored. This is by design.
	*/
	// console-host = "127.0.0.1";
	// console-port = 8563;
	
	
	// Automatic showing of console for various types of message
	show-console-on-warning						= true;		// JavaScript warning
	show-console-on-error						= true;		// JavaScript error or exception
	show-console-on-log							= false;	// log() called
	
	// Show where an error or warning occurred.
	show-error-locations						= true;
	show-error-locations-during-console-eval	= false;
	
	// Log stack trace when reporting errors/warnings.
	dump-stack-for-errors						= true;
	dump-stack-for-warnings						= true;
	
	// Macro definitions for the console macro system (implemented in oolite-debug-console.js).
	// Note that these call simple functions in oolite-debug-console.js, not magic functions provided by Oolite.
	default-macros =
	{
		// Manipulating macros
		"setM"		= "setMacro(PARAM)";
		"delM"		= "deleteMacro(PARAM)";
		"showM"		= "showMacro(PARAM)";
		"listM"		= "listMacro()";
		
		// Reload macros from plist, removing any custom ones.
		"resetM"	= "macros = console.settings.macros = {}; undefined";
		
		// Examining (“dumping”) objects
		"d"			= "dumpObject(eval(PARAM))";
		"proto"		= "consoleMessage('dumpObject', protoChain(eval(PARAM)))";
		
		// Clearing the console
		"clr"		= "console.clearConsole()";
		"clear"		= "console.clearConsole()";
		
		/*	For creating/testing colour sets. Syntax is flexible, as in plists,
			for example:
			:fgColor general "redColor"
			:bgColor command { hue: 60, saturation: 0.1 }
			:bgColor general [0, 0, 1, 1]
			
			rmFgColor/rmBgColor remove the specified setting from config
			overrides, returning to whatever is set in the plist.
		*/
		"fgColor"	= "setColorFromString(PARAM, 'foreground')";
		"bgColor"	= "setColorFromString(PARAM, 'background')";
		"rmFgColor"	= "void delete console.settings[PARAM + '-foreground-color']";
		"rmBgColor"	= "void delete console.settings[PARAM + '-background-color']";
		
		// ":nearest role" -- find nearest ship with specified role.
		// ":tnearest role" -- target nearest ship with specified role.
		"nearest"	= "this.result = system.shipsWithRole(PARAM, player.ship)[0]";
		"tnearest"	= "player.ship.target = system.shipsWithRole(PARAM, player.ship)[0]";
		
		// ":find expr" -- find entities matching expr; for example, ":find entity.isShip" to find all ships.
		// ":findS expr" -- find ships matching expr; for example, ":find ship.scanClass == 'CLASS_BUOY'".
		// ":target expr" -- target closest ship matching expr.
		"find"		= "this.result = system.filteredEntities(player.ship, function(entity) { return eval(PARAM); })";
		"findS"		= "this.result = system.filteredEntities(player.ship, function(ship) { return ship.isShip && eval(PARAM); })";
		"target"	= "player.ship.target = system.filteredEntities(player.ship, function(ship) { return ship.isShip && eval(PARAM); }, player.ship)[0]";
		
		// ":logOn className" -- enable logging for log message class className.
		// ":logOff className" -- disable logging for log message class className.
		"logOn"		= "console.setDisplayMessagesInClass(PARAM, true)";
		"logOff"	= "console.setDisplayMessagesInClass(PARAM, false)";
		
		// ":spawn foo" -- create a ship with role "foo" near the player.
		"spawn"		= "this.T = system.addShips(PARAM, 1, player.ship.position, 10000); if (this.T) this.T = this.T[0]; else consoleMessage('command-error', 'Could not spawn \"' + PARAM + '\".');";
		
		// ":qotd" -- quote of the day. Or the moment, anyway.
		"qotd"		= "expandDescription('[thargoid_curses]')";
		
		// ":test" -- display a ship of the specified role, assuming you're docked.
		"test"		= "mission.runScreen({model:PARAM})";
		
		// ":time <expression>" -- time a JavaScript expression.
		"time"		= "console.profile(eval(\"(function codeToBeProfiled() { (\" + PARAM + \") })\"), this)";
		
		// ":trace <expression>" -- trace a JavaScript expression.
		"trace"		= "console.trace(eval(\"(function codeToBeTraced() { (\" + PARAM + \") })\"), this)";
	};
	
	
	/*	Colours for various types of console messages. These are standard
		Oolite colour specifiers.
		Each colour key comes in a pair, foo-foreground-color and
		foo-background-color. A class of messages can be hidden by giving its
		colour key a fully transparent colour (such as clearColor).
	*/
	general-foreground-color			= blackColor;
	general-background-color			= whiteColor;
	command-background-color			= { hue = 240; brightness = 1.0; saturation = 0.12; };	// Pale blue
	warning-background-color			= { hue = 60; brightness = 1.0; saturation = 0.25; };	// Pale yellow
	error-background-color				= { hue = 0; brightness = 1.0; saturation = 0.25; };	// Pale red
	exception-background-color			= { hue = 320; brightness = 1.0; saturation = 0.25; };	// Pale magentaish
	
	// These colours are used by oolite-debug-console.js
	command-result-background-color		= { hue = 120; brightness = 1.0; saturation = 0.2; };	// Pale green
	command-error-background-color		= { hue = 0; brightness = 1.0; saturation = 0.12; };	// Very pale red
	macro-expansion-background-color	= { hue = 240; brightness = 1.0; saturation = 0.06; };	// Very pale blue
	macro-expansion-foreground-color	= darkGrayColor;
	macro-warning-background-color		= { hue = 60; brightness = 1.0; saturation = 0.12; };	// Very pale yellow
	unknown-macro-background-color		= { hue = 60; brightness = 1.0; saturation = 0.12; };	// Very pale yellow
	macro-error-background-color		= { hue = 0; brightness = 1.0; saturation = 0.12; };	// Very pale red
	macro-info-background-color			= { hue = 120; brightness = 1.0; saturation = 0.2; };	// Pale green
	command-exception-background-color	= { hue = 320; brightness = 1.0; saturation = 0.25; };	// Pale magentaish
	
	// Alternative configuration for people who find black on white insufficiently l33t:
/*
	general-background-color			= blackColor;
	general-foreground-color			= "0.8 0.8 0.8";
	command-foreground-color			= cyanColor;
	warning-foreground-color			= yellowColor;
	error-foreground-color				= redColor;
	exception-foreground-color			= orangeColor;
	
	command-result-foreground-color		= greenColor;
	macro-expansion-foreground-color	= "0 0.8 0.8";
	macro-warning-foreground-color		= "1 0.5 1";
	unknown-macro-foreground-color		= "1 0.5 1";
	macro-error-foreground-color		= "1 0.5 0.5";
	macro-info-foreground-color			= greenColor;
	command-exception-foreground-color	= "1 0.75 0.5";
*/
	
	font-face							= "Courier_New";
	font-size							= "12";
}
The latter pair are sadly non-existant.

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.
Commander_X
---- E L I T E ----
---- E L I T E ----
Posts: 671
Joined: Sat Aug 09, 2014 4:16 pm

Re: [WIP] new GUI for debug console

Post by Commander_X »

Couple of things that might also help here:

Code: Select all

find . -name \*.pyc | xargs rm
(that is, get rid of any cache that might interfere).
MrFlibble wrote: Fri Apr 19, 2024 9:28 pm
[...]
I have the mscorefonts, so have Courier_New in four flavours.

Code: Select all

$ find /usr/share/fonts | grep -i courier
/usr/share/fonts/truetype/msttcorefonts/Courier_New.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Bold_Italic.ttf
/usr/share/fonts/truetype/msttcorefonts/Courier_New_Italic.ttf
[...]
I just remembered -- you might want to try

Code: Select all

fc-list | grep -i courier
and find the name you should use for "font-face" between the ":" characters coming after file name. (IIRC "Courier_New" should actually be used as "Courier New").
Regardless, replacing the string in the .plist file should've reported the new attempt ('Courier_New' in your case) so something's still amiss.
Post Reply