Ok, I'll write a brief Python introduction :-)
You will need two things to write or modify Python programs yourself:
1. A simple text editor. Notepad is ok but bare-bones. There are many free others that help you better, such as Notepad++. I personally use Vim... yes... I am old. On Windows you probably want gvim.
https://notepad-plus-plus.org/https://www.vim.org/Do not get scared by the plethora of features of modern text editors. You need 1% of them, if at all. Again, Notepad will do the job.
2. Python. Just the standard (also free) install is fine. Allow the thing to add itself to the "path" so that you can open a cmd prompt anywhere (in any folder) and the system can still find the "python" command.
https://www.python.org/To check whether your Python has been correctly installed, open a cmd window and type:
C:\Users\Hoppie>python --version
Python 3.8.1
You need 3.8 at least.
I assume you know what I mean with "cmd" and "type X" with some things your computer generates and some things you type yourself mixed up. If not, we'll cover that, just ask.
Now write your first Python program. Create a flat text file called "mytest.py" and put this in it:
# mytest.py is my first Python program.
print("Congratulations!")
The first line is just a comment. I like comments. They help me remembering what the heck I was doing again.
The second line, well, prints a word onto the screen.
Save the file and see whether it works:
C:\Users\Hoppie>python mytest.py
Congratulations!
If so, congratulations, as the rest should now work, too.
The program file we'll work on is psx-print-pushover.py, as posted above in this Forum thread. Copy it somewhere and make sure you have a backup copy at hand, just in case.
Open the file in your text editor. It is possible that double-clicking does not open it in the editor, but executes it. Personally I want .py files to open in the editor so I kicked Windows to take this default action. Near the bottom of it, you find the "Main" section. This is where things happen. Everything before is just setup for use later on.
I used a pre-written routine that comes with Python out of the box, to read and process the command line parameters such as --userkey. This means that you should modify only this block of text to get what you want: default user and app keys, so you don't need to type them in again and again. The ArgumentParser building block can do this. If you want to read up on it, go to the wonderful Python documentation:
https://docs.python.org/3/library/argparse.htmlExploring this web site is what will keep you busy for as many hours as PSX! :-)
Here's the unchanged code we're talking about:
p = argparse.ArgumentParser(description="""
Connects to a PSX Main Server and picks up all virtual printout;
then sends this printout to a Pushover account so you can get it
on any device you like (and paid for).""")
p.add_argument("--userkey", help="your Pushover User Key", required=True)
p.add_argument("--appkey", help="your Pushover App Key", required=True)
p.add_argument("--host", help="the PSX Main Server host, "
"default 127.0.0.1",
default="127.0.0.1")
p.add_argument("--port", help="the PSX Main Server port, default 10747",
default=10747)
You already see several lines that have default values. They may look like duplications, but look closer. The line stating:
"default 127.0.0.1"
is text meant for the user, displayed when (s)he types --help. And the other line,
default="127.0.0.1"
is text meant for the Python program interpreter, to instruct it to set up "127.0.0.1" as the default "host" to find the PSX Main Server on. Both lines convey the same thing, but to different audiences. Try it:
C:\Users\Hoppie>python psx-print-pushover.py --help
PSX Python Connector v0.0-beta-1*, (C) Hoppie 2020
usage: psx-print-pushover.py [-h] --userkey USERKEY --appkey APPKEY
[--host HOST] [--port PORT]
Connects to a PSX Main Server and picks up all virtual printout; then sends
this printout to a Pushover account so you can get it on any device you like
(and paid for).
optional arguments:
-h, --help show this help message and exit
--userkey USERKEY your Pushover User Key
--appkey APPKEY your Pushover App Key
--host HOST the PSX Main Server host, default 127.0.0.1
--port PORT the PSX Main Server port, default 10747
Note that the --userkey and --appkey lines do not have a default! Hey, this is what we're going to add.
Change the code to look like:
p.add_argument("--userkey", help="your Pushover User Key, default is mine",
default="YOUR_USER_KEY_HERE")
p.add_argument("--appkey", help="your Pushover App Key, default is mine",
default="YOUR_APP_KEY_HERE")
Save the file, and test the help function again:
C:\Users\Hoppie>python psx-print-pushover.py --help
... stuff ...
optional arguments:
-h, --help show this help message and exit
--userkey USERKEY your Pushover User Key, default is mine
--appkey APPKEY your Pushover App Key, default is mine
--host HOST the PSX Main Server host, default 127.0.0.1
--port PORT the PSX Main Server port, default 10747
And then run the thing plain, which shall use your own user key and app key without further assistance.
If everything is OK, update the line saying VERSION (at the top) to say whatever you like, update other things, and have fun!
Let me know whether you need any more help. I'll gladly provide it.
Hoppie