Jython/Java Unable to Open File From Within Python Module

Joined
Mar 14, 2015
Messages
19
Reaction score
0
Hello again, folks. It has been a while since I last posted on the Mac Help forum. As I may have possibly mentioned previously, for the fourth time since 1993, I recently resurrected my Hermes II BBS from several decades ago. Currently, I am in the process of writing a new game for my BBS, which is written in Python. While as a non-programmer I have made considerable progress with my Python module, at the moment, I am having one basic problem which neither I, nor ChatGPT, have figured out how to rectify, despite many hours working on it.

Basically, the Hermes II software that I use has its own Jython 2-based runtime environment. Within the file and folder structure of Hermes II, there is in fact a Jython folder, which among other things contains various packages, including a Hermes API package, a Jython package, a QT Java package, an MRJClasses package, as well as a few other things.

The python module I am creating is heavily based on the code of another BBS game which was quite popular within the BBS world quite a few years ago. That game is called Leech. Some of you older folks will no doubt be familiar with one flavor or another of this game.

At any rate, back around 2015 — or a little earlier — the last developer of my BBS software -- Michael Alyn Miller -- made a huge departure from the Pascal-based framework which was used to make games -- meaning externals -- for Hermes II, when he created a development system for externals -- called External Development System -- which is based on Jython, and not on Pascal. He then released a new version of Hermes II, which utilizes this then-new Jython framework.

The primary reason why he did this was to simplify the process of creating externals, so that SysOps who use his BBS software, can more easily create externals themselves for their own Hermes II BBSes, without all of the heavy coding and compilation work involved when using Pascal.

To show and teach SysOps how to create their own BBS externals with Python/Jython, he created an open source version of the Leech game, so that SysOps could learn from his code, which uses a lot of different functions and methods from the Jython development environment.

His Jython version of Leech in fact includes a number of class files, which after some online research, I figured out how to open with an app I found on the web. Upon opening these class files, I can see all of the imports he has made from python.org, all of the strings he has made, function names he has created, etc.

For those of you here who may have experience with this stuff, you will probably find all of this very easy to understand. However, I am not a programmer of Pascal, Python, Jython, C or anything else. Thus, I have struggled since my journey began about a week ago, and a lot of it is still Greek to me.

But, trying my best to understand Michael's coding examples, and more recently getting some help from ChatGPT — which is blowing my mind — I have made considerable progress for a 70-year-old n00b such as myself.

I now have the entry point for my game module set up in the main.py file, which consists of six ANSI screens which serve as the welcome and backstory for my game.

I also have the framework for the main menu, which currently has 5 or 6 working menu commands. I haven’t even begun working on the real meat of the game yet.

This leads us to my current problem. In the storyline for my game, I am including an option on the main menu where the game’s users can go to a spiritual retreat to relax from work. It is a place for spiritual inspiration.

If the game user types in the key command for the retreat, they will be able to randomly display, as many times as they want, quotes taken from the Bible, which are all stored in a text file in the “strings” folder, which is inside of the “resources” folder. This text file contains over 3,000 verses and verse sets from the KJV Bible, which I have personally compiled since 2002.

The coding structure for all of this has already been added to the main.py module, thanks to the Leech coding example, and to a lot of help from ChatGPT.

Now here is the problem — and I have seen through online research, that others have encountered this same problem too.

With all of this code in place, my game module is unable to load within my BBS environment, because the Java/Jython components are unable to open and read the text file which contains the aforementioned 3,000+ strings,.

The error output is stating the following. I have obfuscated the actual path for reasons of security:

Traceback (innermost last):
File "/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame/main.py", line 305, in ?
File "/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame//main.py", line 264, in main
File "/Macintosh HD/Applications/BBS Soft/BBS Files/Doors/MyGame//main.py", line 96, in read_quotes

java.lang.SecurityException: java.lang.SecurityException: not allowed to read resources/strings/QuotesFile.txt

A runtimeException occurred.

So the problem is that I have absolutely no idea how to give — I assume main.py — the permissions it needs to read the “QuotesFile.txt” file. It knows exactly where to find the file, and sees it, but it doesn't have permission to open it, or Java doesn't have permission, or Jython. I am really not sure which is trying to open the file. If someone can explain to me exactly how to do this -- that is, provide the needed permissions -- then hopefully, my game module will load again, and I will be able to continue working on it.

Please note that this is all happening in a Mac OS 9.2.2 environment, which is made possible by running the Qemu PPC emulator, which runs inside of macOS Sonoma 14.4.1, on my 2019 5K iMac.

So, if anyone knows the solution to this problem, and can explain it to me in layman’s terms, I would be most appreciative.

So there you have it.
Kind regards,

Bill Kochman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top