simple-bpq-telnet-application
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
simple-bpq-telnet-application [2024/11/28 17:18] – created kc2ihx | simple-bpq-telnet-application [2024/11/29 14:57] (current) – kc2ihx | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Creating a simple BPQ Application ====== | ====== Creating a simple BPQ Application ====== | ||
This tutorial shows you how to set up a simple python script [[https:// | This tutorial shows you how to set up a simple python script [[https:// | ||
+ | |||
+ | In order to do this we'll do the following: | ||
+ | - Create a location for the script, data, and a python '' | ||
+ | - Write the script | ||
+ | - Add the application to '' | ||
+ | - Setup a '' | ||
+ | |||
+ | ===== Setup ===== | ||
+ | To organize this project, I created a python virtual environment called '' | ||
+ | |||
+ | I'm using the python virtual environment framework to help manage the various dependencies I might want to use for these scripts. | ||
+ | |||
+ | < | ||
+ | $ cd ~/.local | ||
+ | $ python -m venv bpq-apps | ||
+ | $ cd ./bpq-apps | ||
+ | $ mkdir scripts data | ||
+ | $ source ./ | ||
+ | (bpq-apps)$ pip install telnetlib3 | ||
+ | </ | ||
===== Writing the program ===== | ===== Writing the program ===== | ||
I chose to write this in Python to be a //little// more clear than the Perl application provided in the link above. | I chose to write this in Python to be a //little// more clear than the Perl application provided in the link above. | ||
- | This program, called '' | + | The BPQ Application, called '' |
- | + | ||
- | I saved both of these to '' | + | |
==== Program Code ==== | ==== Program Code ==== | ||
Line 29: | Line 47: | ||
writer.write(" | writer.write(" | ||
textblocks = messages[" | textblocks = messages[" | ||
- | | + | leave = False #inp[0].upper() in [" |
- | | + | rolled = False |
+ | inp = await reader.read(1) | ||
while inp and not leave and len(textblocks) > 0: | while inp and not leave and len(textblocks) > 0: | ||
print(" | print(" | ||
- | writer.write(textblocks.pop()) | + | writer.write(textblocks.pop(0)) |
await writer.drain() | await writer.drain() | ||
inp = await reader.readline() | inp = await reader.readline() | ||
- | leave = inp[0].upper() in [" | + | |
+ | rolled = True | ||
+ | | ||
writer.close() | writer.close() | ||
Line 75: | Line 96: | ||
===== Configuring this as a service ===== | ===== Configuring this as a service ===== | ||
- | //todo write block describing adding | + | Next we'll configure |
+ | I created this file as a " | ||
+ | < | ||
+ | # service for RRoAX25 server | ||
+ | # replace USER with the username under which you created the bpq-apps venv | ||
+ | [Unit] | ||
+ | Description=" | ||
+ | After=network.target | ||
+ | [Service] | ||
+ | Type=simple | ||
+ | WorkingDirectory=/ | ||
+ | ExecStart=/ | ||
+ | Restart=always | ||
+ | |||
+ | [Install] | ||
+ | WantedBy=default.target | ||
+ | </ | ||
+ | |||
+ | Activate it by running: | ||
+ | < | ||
+ | systemctl --user enable rick.service | ||
+ | systemctl --user start rick.service | ||
+ | </ | ||
+ | |||
+ | Then check the status to confirm it is working: | ||
+ | |||
+ | < | ||
+ | systemctl --user status rick.service | ||
+ | </ | ||
+ | |||
+ | If you need to edit the service file, reload it with: | ||
+ | < | ||
+ | systemctl --user daemon-reload | ||
+ | </ |
simple-bpq-telnet-application.1732814305.txt.gz · Last modified: 2024/11/28 17:18 by kc2ihx