added to public repo https://pypi.org, available as "pip --install matrix-commander"

- changes necessary to publish it on PyPi
- convenient installation via `pip` or `pip3` possible now
- see Enhancement Request, Issue #43 (Upload to PyPi)
pull/74/head
8go 3 months ago
parent d25842bc3d
commit 08e5859107
  1. 13
      .gitignore
  2. 12
      PyPi-Instructions.md
  3. 185
      README.md
  4. 1
      matrix_commander/__init__.py
  5. 8
      matrix_commander/matrix-commander
  6. 1175
      matrix_commander/matrix_commander.py
  7. 3
      pyproject.toml
  8. 20
      scripts/create-pypi-package.sh
  9. 8
      scripts/lintmc.sh
  10. 104
      scripts/update-1-version.sh
  11. 8
      scripts/update-2-help.py
  12. 6
      scripts/update-3-readme.py
  13. 52
      setup.cfg
  14. 6
      tests/test-event.sh

13
.gitignore vendored

@ -11,12 +11,25 @@ credentials.json.*
# ignore backups
README.md.*
matrix-commander.py.*
/matrix_commander/matrix-commander.py.*
/matrix_commander/matrix_commander.py.*
setup.cfg.*
# ignore help file
help.txt
help.txt.*
# ignore soft link
mc
# ignore certain scripts
/scripts/prepare-commit.sh
/scripts/create-help.sh
# ignore cache
/matrix_commander/__pycache__/
# PyPi build files
versionnumber.txt
/dist/
/matrix_commander.egg-info/

@ -0,0 +1,12 @@
# PRE-INSTALLATION
Before you install `matrix-commander` with `pip3 --install matrix-commander`
you *must* have `libolm` installed. `pip3` installation will fail otherwise!
For e2ee
support, python-olm is needed which requires the
[libolm](https://gitlab.matrix.org/matrix-org/olm) C library (version 3.x).
On Debian and Ubuntu one can use `apt-get` to install package `libolm-dev`.
On Fedora one can use `dnf` to install package `libolm-devel`.
On MacOS one can use [brew](https://brew.sh/) to install package `libolm`.
Make sure version 3 is installed.

@ -25,6 +25,7 @@ creating rooms, inviting, verifying, and so much more.
OS notification)
- It uses the [matrix-nio](https://github.com/poljar/matrix-nio/) SDK
- Both `matrix-nio` and `matrix-commander` are written in Python 3
- Convenient to install via `pip` or `pip3`.
# Summary
@ -158,7 +159,17 @@ is enabled by default and cannot be turned off.
# Dependencies
- Python 3.8 or higher (3.7 will NOT work) installed
- If you install via `pip`, then `pip` will take care of most of the
dependencies.
- See https://pypi.org/project/matrix-commander
- Usually `pip install matrix-commander`
- Note that even if you install via `pip` you must have a) Python 3.8+
and b) `libolm` installed. See `PyPi-Instructions.md`.
If you install vit `git` or via file download then these are the
dependencies that you must take care of:
- Python 3.8 or higher installed (3.7 will NOT work)
- libolm-dev must be installed as it is required by matrix-nio
- libolm-dev on Debian/Ubuntu, libolm-devel on Fedora, libolm on MacOS
- matrix-nio must be installed, see https://github.com/poljar/matrix-nio
@ -173,9 +184,12 @@ is enabled by default and cannot be turned off.
- pip3 install --user --upgrade notify2 # optional
- python3 package urllib must be installed to support media download
- pip3 install --user --upgrade urllib
- the matrix-commander.py file must be installed, and should have
execution permissions
- chmod 755 matrix-commander.py
- `matrix_commander/matrix_commander.py` file must be installed, and should
have execution permissions
- chmod 755 matrix_commander.py
- `matrix_commander/matrix-commander` file is recommended for the install,
and should have execution permissions
- chmod 755 matrix-commander
- for a full list or requirements look at the `requirements.txt` file
- run `pip install -r requirements.txt` to automatically install
all required Python packages
@ -186,8 +200,8 @@ is enabled by default and cannot be turned off.
# Examples of calling `matrix-commander`
```
$ matrix-commander.py # first run; this will configure everything
$ matrix-commander.py --no-sso # alternative first run without Single Sign-On;
$ matrix-commander # first run; this will configure everything
$ matrix-commander --no-sso # alternative first run without Single Sign-On;
$ # this will configure everything on a headless server w/o a browser
$ # this created a credentials.json file, and a store directory.
$ # optionally, if you want you can move credentials to app config directory
@ -199,134 +213,134 @@ $ mv -i store $HOME/.local/share/matrix-commander/
$ # Now you are ready to run program for a second time
$ # Let us verify the device/room to where we want to send messages
$ # The other device will issue a "verify by emoji" request
$ matrix-commander.py --verify
$ matrix-commander --verify
$ # Now program is both configured and verified, let us send the first message
$ matrix-commander.py -m "First message!"
$ matrix-commander.py --debug # turn debugging on
$ matrix-commander.py --help # print help
$ matrix-commander.py # this will ask user for message to send
$ matrix-commander.py --message "Hello World!" # sends provided message
$ echo "Hello World" | matrix-commander.py # pipe input msg into program
$ matrix-commander.py -m msg1 -m msg2 # sends 2 messages
$ matrix-commander.py -m msg1 msg2 msg3 # sends 3 messages
$ df -h | matrix-commander.py --code # formatting for code/tables
$ matrix-commander.py -m "<b>BOLD</b> and <i>ITALIC</i>" --html
$ matrix-commander.py -m "- bullet1" --markdown
$ matrix-commander -m "First message!"
$ matrix-commander --debug # turn debugging on
$ matrix-commander --help # print help
$ matrix-commander # this will ask user for message to send
$ matrix-commander --message "Hello World!" # sends provided message
$ echo "Hello World" | matrix-commander # pipe input msg into program
$ matrix-commander -m msg1 -m msg2 # sends 2 messages
$ matrix-commander -m msg1 msg2 msg3 # sends 3 messages
$ df -h | matrix-commander --code # formatting for code/tables
$ matrix-commander -m "<b>BOLD</b> and <i>ITALIC</i>" --html
$ matrix-commander -m "- bullet1" --markdown
$ # take input from an RSS feed and split large RSS entries into multiple
$ # Matrix messages wherever the pattern "\n\n\n" is found
$ rssfeed | matrix-commander.py --split "\n\n\n"
$ matrix-commander.py --credentials usr1room2.json # select credentials file
$ matrix-commander.py --store /var/storage/ # select store directory
$ rssfeed | matrix-commander --split "\n\n\n"
$ matrix-commander --credentials usr1room2.json # select credentials file
$ matrix-commander --store /var/storage/ # select store directory
$ # Send to a specific room
$ matrix-commander.py -m "hi" --room '!YourRoomId:example.org'
$ matrix-commander -m "hi" --room '!YourRoomId:example.org'
$ # some shells require the ! of the room id to be escaped with \
$ matrix-commander.py -m "hi" --room "\!YourRoomId:example.org"
$ matrix-commander -m "hi" --room "\!YourRoomId:example.org"
$ # Send to multiple rooms
$ matrix-commander.py -m "hi" -r '!r1:example.org' '!r2:example.org'
$ matrix-commander -m "hi" -r '!r1:example.org' '!r2:example.org'
$ # Send to multiple rooms, another way
$ matrix-commander.py -m "hi" -r '!r1:example.org' -r '!r2:example.org'
$ matrix-commander -m "hi" -r '!r1:example.org' -r '!r2:example.org'
$ # send 2 images and 1 text, text will be sent last
$ matrix-commander.py -i photo1.jpg photo2.img -m "Do you like my 2 photos?"
$ matrix-commander -i photo1.jpg photo2.img -m "Do you like my 2 photos?"
$ # send 1 image and no text
$ matrix-commander.py -i photo1.jpg -m ""
$ matrix-commander -i photo1.jpg -m ""
$ # pipe 1 image and no text
$ cat image1.jpg | matrix-commander.py -i -
$ cat image1.jpg | matrix-commander -i -
$ # send 1 audio and 1 text to 2 rooms
$ matrix-commander.py -a song.mp3 -m "Do you like this song?" \
$ matrix-commander -a song.mp3 -m "Do you like this song?" \
-r '!someroom1:example.com' '!someroom2:example.com'
$ # send 2 audios, 1 via stdin pipe
$ audio-generator | matrix-commander.py -a intro.mp3 -
$ audio-generator | matrix-commander -a intro.mp3 -
$ # send a .pdf file and a video with a text
$ matrix-commander.py -f example.pdf video.mp4 -m "Here are the promised files"
$ matrix-commander -f example.pdf video.mp4 -m "Here are the promised files"
$ # send a .pdf file via stdin pipe
$ pdf-generator | matrix-commander.py -f -
$ pdf-generator | matrix-commander -f -
$ # listen forever, get msgs in real-time and notify me via OS
$ matrix-commander.py --listen forever --os-notify
$ matrix-commander --listen forever --os-notify
$ # listen forever, and show me also my own messages
$ matrix-commander.py --listen forever --listen-self
$ matrix-commander --listen forever --listen-self
$ # listen once, get any new messages and quit
$ matrix-commander.py --listen once --listen-self
$ matrix-commander.py --listen once --listen-self | process-in-other-app
$ matrix-commander --listen once --listen-self
$ matrix-commander --listen once --listen-self | process-in-other-app
$ # listen to tail, get the last N messages and quit
$ matrix-commander.py --listen tail --tail 10 --listen-self
$ matrix-commander --listen tail --tail 10 --listen-self
$ # listen to tail, another way of specifying it
$ matrix-commander.py --tail 10 --listen-self | process-in-other-app
$ matrix-commander --tail 10 --listen-self | process-in-other-app
$ # get the very last message
$ matrix-commander.py --tail 1 --listen-self
$ matrix-commander --tail 1 --listen-self
$ # listen to (get) all messages, old and new, and process them in another app
$ matrix-commander.py --listen all | process-in-other-app
$ matrix-commander --listen all | process-in-other-app
$ # listen to (get) all messages, including own
$ matrix-commander.py --listen all --listen-self
$ matrix-commander --listen all --listen-self
$ # rename device-name, sometimes also called device display-name
$ matrix-commander.py --rename-device "my new name"
$ matrix-commander --rename-device "my new name"
$ # set display-name for authenticated user
$ matrix-commander.py --display-name "Alex"
$ matrix-commander --display-name "Alex"
$ # skip SSL certificate verification for a homeserver without SSL
$ matrix-commander.py --no-ssl -m "also working without Let's Encrypt SSL"
$ matrix-commander --no-ssl -m "also working without Let's Encrypt SSL"
$ # use your own SSL certificate for a homeserver with SSL and local certs
$ matrix-commander.py --ssl-certificate mycert.crt -m "using my own cert"
$ matrix-commander --ssl-certificate mycert.crt -m "using my own cert"
$ # download and decrypt media files like images, audio, PDF, etc.
$ # and store downloaded files in directory "mymedia"
$ matrix-commander.py --listen forever --listen-self --download-media mymedia
$ matrix-commander --listen forever --listen-self --download-media mymedia
$ # create rooms without name and topic, just with alias, use a simple alias
$ matrix-commander.py --room-create roomAlias1
$ matrix-commander --room-create roomAlias1
$ # don't use a well formed alias like '#roomAlias1:example.com' as it will
$ # confuse the server!
$ # BAD: matrix-commander.py --room-create roomAlias1 '#roomAlias1:example.com'
$ matrix-commander.py --room-create roomAlias2
$ # BAD: matrix-commander --room-create roomAlias1 '#roomAlias1:example.com'
$ matrix-commander --room-create roomAlias2
$ # create rooms with name and topic
$ matrix-commander.py --room-create roomAlias3 --name 'Fancy Room' \
$ matrix-commander --room-create roomAlias3 --name 'Fancy Room' \
--topic 'All about Matrix'
$ matrix-commander.py --room-create roomAlias4 roomAlias5 \
$ matrix-commander --room-create roomAlias4 roomAlias5 \
--name 'Fancy Room 4' -name 'Cute Room 5' \
--topic 'All about Matrix 4' 'All about Nio 5'
$ # join rooms
$ matrix-commander.py --room-join '!someroomId1:example.com' \
$ matrix-commander --room-join '!someroomId1:example.com' \
'!someroomId2:example.com' '#roomAlias1:example.com'
$ # leave rooms
$ matrix-commander.py --room-leave '#roomAlias1:example.com' \
$ matrix-commander --room-leave '#roomAlias1:example.com' \
'!someroomId2:example.com'
$ # forget rooms, you have to first leave a room before you forget it
$ matrix-commander.py --room-forget '#roomAlias1:example.com'
$ matrix-commander --room-forget '#roomAlias1:example.com'
$ # invite users to rooms
$ matrix-commander.py --room-invite '#roomAlias1:example.com' \
$ matrix-commander --room-invite '#roomAlias1:example.com' \
--user '@user1:example.com' '@user2:example.com'
$ # ban users from rooms
$ matrix-commander.py --room-ban '!someroom1:example.com' \
$ matrix-commander --room-ban '!someroom1:example.com' \
'!someroom2:example.com' \
--user '@user1:example.com' '@user2:example.com'
$ # unban users from rooms, remember after unbanning you have to invite again
$ matrix-commander.py --room-unban '!someroom1:example.com' \
$ matrix-commander --room-unban '!someroom1:example.com' \
'!someroom2:example.com' \
--user '@user1:example.com' '@user2:example.com'
$ # kick users from rooms
$ matrix-commander.py --room-kick '!someroom1:example.com' \
$ matrix-commander --room-kick '!someroom1:example.com' \
'#roomAlias2:example.com' \
--user '@user1:example.com' '@user2:example.com'
$ # set log levels, INFO for matrix-commander and ERROR for modules below
$ matrix-commander.py -m "test" --log-level INFO ERROR
$ matrix-commander -m "test" --log-level INFO ERROR
$ # example of how to quote text correctly, e.g. JSON text
$ matrix-commander.py -m '{title: "hello", message: "here it is"}'
$ matrix-commander.py -m "{title: \"hello\", message: \"here it is\"}"
$ matrix-commander.py -m "{title: \"${TITLE}\", message: \"${MSG}\"}"
$ matrix-commander.py -m "Don't do this"
$ matrix-commander.py -m 'He said "No" to me.'
$ matrix-commander -m '{title: "hello", message: "here it is"}'
$ matrix-commander -m "{title: \"hello\", message: \"here it is\"}"
$ matrix-commander -m "{title: \"${TITLE}\", message: \"${MSG}\"}"
$ matrix-commander -m "Don't do this"
$ matrix-commander -m 'He said "No" to me.'
$ # example of how to use stdin, how to pipe data into the program
$ echo "Some text" | matrix-commander.py # send a text msg via pipe
$ echo "Some text" | matrix-commander.py -m - # long form to send text via pipe
$ matrix-commander.py -m "\-" # send the literal minus sign as a text msg
$ cat image1.png | matrix-commander.py -i - # send an image via pipe
$ matrix-commander.py -i - < image1.png # send an image via pipe
$ cat image1.png | matrix-commander.py -i - -m "text" # send image and text
$ echo "Some text" | matrix-commander # send a text msg via pipe
$ echo "Some text" | matrix-commander -m - # long form to send text via pipe
$ matrix-commander -m "\-" # send the literal minus sign as a text msg
$ cat image1.png | matrix-commander -i - # send an image via pipe
$ matrix-commander -i - < image1.png # send an image via pipe
$ cat image1.png | matrix-commander -i - -m "text" # send image and text
$ # send 3 images out of which the second will be read from stdin via pipe
$ cat im2.png | matrix-commander.py -i im1.jpg - im3.jpg # send 3 images
$ echo "text" | matrix-commander.py -i im1.png # first image, then piped text
$ echo "text" | matrix-commander.py -i im1.png -m - # same, long version
$ pdf-generator | matrix-commander.py -f - -m "Here is my PDF file."
$ audio-generator | matrix-commander.py -a - -m "Like this song?"
$ echo "junk" | matrix-commander.py -i - -m - # this will fail, not allowed
$ cat im2.png | matrix-commander -i im1.jpg - im3.jpg # send 3 images
$ echo "text" | matrix-commander -i im1.png # first image, then piped text
$ echo "text" | matrix-commander -i im1.png -m - # same, long version
$ pdf-generator | matrix-commander -f - -m "Here is my PDF file."
$ audio-generator | matrix-commander -a - -m "Like this song?"
$ echo "junk" | matrix-commander -i - -m - # this will fail, not allowed
$ # remember, pipe or stdin, i.e. the "-" can be used at most once
$ cat im.png | matrix-commander.py -i im1.png - im3.png - im5.png # will fail
$ cat im.png | matrix-commander -i im1.png - im3.png - im5.png # will fail
$ # sending an event: e.g. reacting with an emoji
$ JSON_REACT_MSC2677='{ "type": "m.reaction",
"content": { "m.relates_to": { "rel_type": "m.annotation",
@ -334,13 +348,13 @@ $ JSON_REACT_MSC2677='{ "type": "m.reaction",
$ TARGET_EVENT="\$...a.valid.event.id" # event to which to react
$ REACT_EMOJI="😀" # how to react
$ printf "$JSON_REACT_MSC2677" "$TARGET_EVENT" "$REACT_EMOJI" |
matrix-commander.py --event -
$ # for more examples of "matrix-commander.py --event" see tests/test-event.sh
matrix-commander --event -
$ # for more examples of "matrix-commander --event" see tests/test-event.sh
```
# Usage
```
usage: matrix-commander.py [-h] [-d] [--log-level LOG_LEVEL [LOG_LEVEL ...]]
usage: matrix_commander.py [-h] [-d] [--log-level LOG_LEVEL [LOG_LEVEL ...]]
[-c CREDENTIALS] [-r ROOM [ROOM ...]]
[--room-create ROOM_CREATE [ROOM_CREATE ...]]
[--room-join ROOM_JOIN [ROOM_JOIN ...]]
@ -713,8 +727,8 @@ optional arguments:
information program will continue to run. This is
useful for having version number in the log files.
You are running version 2022-05-25. Enjoy, star on Github and contribute by
submitting a Pull Request.
You are running version 2.15.0 2022-05-26. Enjoy, star on Github and
contribute by submitting a Pull Request.
```
# Features
@ -767,6 +781,7 @@ submitting a Pull Request.
- Can be run as a service
- Smart tab completion for shells like bash (thanks to PR from @mizlan :clap:)
- More than 200 stars :stars: on Github
- Available through `pip`, i.e. available in PyPi store
# Autocompletion
@ -798,9 +813,9 @@ Here is a sample snapshot of tab completion in action:
- then `flake8` linter/formater
- then `black` linter/formater
- linelength: 79
- isort matrix-commander.py
- flake8 matrix-commander.py
- python3 -m black --line-length 79 matrix-commander.py
- isort matrix_commander.py
- flake8 matrix_commander.py
- python3 -m black --line-length 79 matrix_commander.py
- There is a script called `lintmc.sh` in `scripts` directory for that.
# License

@ -0,0 +1 @@
from .matrix_commander import main

@ -0,0 +1,8 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from matrix_commander import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())

File diff suppressed because it is too large Load Diff

@ -0,0 +1,3 @@
[build-system]
requires = ['setuptools>=42']
build-backend = 'setuptools.build_meta'

@ -0,0 +1,20 @@
#!/bin/bash
#
# # on PC where PyPi package is to be created
# python3 -m pip install --upgrade build # install necessary build packages
# rm dist/* # cleanup
# nano setup.cfg # increment version number
# python3 -m build # build PyPi package
# python3 -m twine upload dist/* # upload PyPi package, use __token__ as user
#
# # on PC where to install
# sudo apt install libolm-dev
# pip3 install matrix-commander
# export PATH=$PATH:/home/user/.local/bin
# matrix-commander --help # test it
#
# prepare-commit, including version increase in setup.cfg
rm dist/* # cleanup
python3 -m build && python3 -m twine upload dist/*

@ -1,14 +1,14 @@
#!/bin/bash
# tiny script to lint matrix-commander.py
# tiny script to lint matrix_commander.py
FN="matrix-commander.py"
FN="matrix_commander.py"
if ! [ -f "$FN" ]; then
FN="../$FN"
FN="matrix_commander/$FN"
if ! [ -f "$FN" ]; then
echo -n "ERROR: $(basename -- "$FN") not found. "
echo "Neither in local nor in parent directory."
echo "Neither in local nor in child directory."
exit 1
fi
fi

@ -1,6 +1,6 @@
#!/bin/bash
FN="matrix-commander.py"
FN="matrix_commander/matrix_commander.py"
if ! [ -f "$FN" ]; then
FN="../$FN"
@ -11,32 +11,96 @@ if ! [ -f "$FN" ]; then
fi
fi
if ! [ -f "$FN" ]; then
echo "ERROR: File \"$FN\" not found."
exit 1
fi
PREFIX="VERSION = "
REGEX="^${PREFIX}\"20[0-9][0-9]-[0-9][0-9]-[0-9][0-9].*\""
COUNT=$(grep --count -e "$REGEX" $FN)
if [ "$COUNT" == "1" ]; then
# NEWVERSION="$PREFIX\"$(date +%Y-%m-%d-%H%M%S)\""
NEWVERSION="$PREFIX\"$(date +%Y-%m-%d)\""
sed -i "s/$REGEX/$NEWVERSION/" $FN
RETURN=$?
if [ "$RETURN" == "0" ]; then
echo "SUCCESS: Modified file $FN by setting version to $NEWVERSION."
else
echo "ERROR: could not change version to $NEWVERSION in $FN."
exit 1
fi
else
echo "Error while searching for $REGEX"
grep -e "$PREFIX" $FN
if [ "$COUNT" == "1" ]; then
echo "ERROR: Version not found, expected 1 occurance."
else
echo "ERROR: Version found $COUNT times, expected 1 occurance."
fi
exit 1
fi
PREFIX="VERSIONNR = "
REGEX="^${PREFIX}\"[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\""
COUNT=$(grep --count -e "$REGEX" $FN)
if [ "$COUNT" == "1" ]; then
NR=$(grep -e "$REGEX" $FN | cut -d'"' -f2)
A=$(echo $NR | cut -d'.' -f1)
M=$(echo $NR | cut -d'.' -f2)
Z=$(echo $NR | cut -d'.' -f3)
M=$((M + 1))
NEWVERSIONNR="${A}.${M}.${Z}"
echo $NEWVERSIONNR >versionnumber.txt
NEWVERSION="$PREFIX\"${A}.${M}.${Z}\""
sed -i "s/$REGEX/$NEWVERSION/" $FN
RETURN=$?
if [ "$RETURN" == "0" ]; then
echo "SUCCESS: Modified file $FN by setting version to $NEWVERSION."
else
echo "ERROR: could not change version to $NEWVERSION in $FN."
exit 1
fi
else
echo "Error while searching for $REGEX"
grep -e "$PREFIX" $FN
if [ "$COUNT" == "1" ]; then
echo "ERROR: Version not found in $FN, expected 1 occurance."
else
echo "ERROR: Version found $COUNT times in $FN, expected 1 occurance."
fi
exit 1
fi
# update PyPi setup file
# version = 2.1.0
FN="setup.cfg"
if ! [ -f "$FN" ]; then
echo "ERROR: File \"$FN\" not found."
exit 1
fi
PREFIX="version = "
REGEX="^${PREFIX}[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*"
COUNT=$(grep --count -e "$REGEX" $FN)
if [ "$COUNT" == "1" ]; then
NEWVERSION="${PREFIX}${NEWVERSIONNR}"
sed -i "s/$REGEX/$NEWVERSION/" $FN
RETURN=$?
if [ "$RETURN" == "0" ]; then
echo "SUCCESS: Modified file $FN by setting version to $NEWVERSION."
else
echo "ERROR: could not change version to $NEWVERSION in $FN."
exit 1
fi
else
COUNT=$(grep --count -e "$REGEX" $FN)
echo "Error while searching for $REGEX"
grep -e "$PREFIX" $FN
if [ "$COUNT" == "1" ]; then
# NEWVERSION="$PREFIX\"$(date +%Y-%m-%d-%H%M%S)\""
NEWVERSION="$PREFIX\"$(date +%Y-%m-%d)\""
sed -i "s/$REGEX/$NEWVERSION/" $FN
RETURN=$?
if [ "$RETURN" == "0" ]; then
echo "SUCCESS: Modified file $FN by setting version to $NEWVERSION."
exit 0
else
echo "ERROR: could not change version to $NEWVERSION in $FN."
fi
echo "ERROR: Version not found in $FN, expected 1 occurance."
else
echo "Error while searching for $REGEX"
grep -e "$PREFIX" $FN
if [ "$COUNT" == "1" ]; then
echo "ERROR: Version not found, expected 1 occurance."
else
echo "ERROR: Version found $COUNT times, expected 1 occurance."
fi
echo "ERROR: Version found $COUNT times in $FN, expected 1 occurance."
fi
exit 1
fi
exit 1
exit 0

@ -11,15 +11,15 @@ from os.path import isfile
# ```
# usage: ...
# ```
# in the matrix-commander.py file with the output of
# matrix-commander.py --help
# in the matrix_commander.py file with the output of
# matrix_commander.py --help
# datetime object containing current date and time
now = datetime.now()
date_string = now.strftime("%d%m%Y-%H%M%S")
date_string = now.strftime("%Y%m%d-%H%M%S")
helpfile = "help.txt"
filename = "matrix-commander.py"
filename = "matrix_commander/matrix_commander.py"
if isfile(filename) and access(filename, R_OK):
# so that subprocess can execute it without PATH

@ -7,15 +7,15 @@ from datetime import datetime
from os import R_OK, access
from os.path import isfile
# extract the README portion within the matrix-commander.py file
# extract the README portion within the matrix_commander.py file
# into a separate stand-alone README.md file
# datetime object containing current date and time
now = datetime.now()
date_string = now.strftime("%d%m%Y-%H%M%S")
date_string = now.strftime("%Y%m%d-%H%M%S")
readmemd = "README.md"
filename = "matrix-commander.py"
filename = "matrix_commander/matrix_commander.py"
if isfile(filename) and access(filename, R_OK):
# so that subprocess can execute it without PATH

@ -0,0 +1,52 @@
[metadata]
# https://packaging.python.org/en/latest/tutorials/packaging-projects/
# https://setuptools.pypa.io/en/latest/userguide/
name = matrix-commander
version = 2.15.0
author = 8go
description = A simple command-line Matrix client
long_description = file: PyPi-Instructions.md, README.md
# long_description = file: README.md
long_description_content_type = text/markdown
keywords = Matrix, chat, messaging
url = https://github.com/8go/matrix-commander
project_urls =
Bug Tracker = https://github.com/8go/matrix-commander/issues
repository = https://github.com/8go/matrix-commander
classifiers =
Programming Language :: Python :: 3
License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
Operating System :: OS Independent
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Natural Language :: English
Topic :: Communications :: Chat
[options]
# use root, i.e. leave empty
package_dir =
packages = find:
python_requires = >=3.8
install_requires =
aiohttp
aiofiles>=0.6.0
argparse
asyncio
datetime
dbus-python
markdown
matrix-nio[e2e]>=0.14.1
notify2
Pillow
python_magic
uuid
[options.entry_points]
console_scripts =
# desired-command-name = module:function
matrix-commander = matrix_commander:main
[options.packages.find]
# where is root directory, i.e. empty
where =

@ -34,9 +34,9 @@ printf "$MSC2677_REACT" "$TARGET_EVENT" "❤" >event2.json
printf "$MSC3440_THREAD" "Thread reply $(date +%H:%M:%S)" \
"$TARGET_EVENT" >event3.json
matrix-commander.py --event event1.json event2.json -m "" $MC_OPTIONS
matrix-commander --event event1.json event2.json -m "" $MC_OPTIONS
# also test the stdin pipe logic
cat event3.json | matrix-commander.py --event - $MC_OPTIONS
cat event3.json | matrix-commander --event - $MC_OPTIONS
echo -e "\n\n\nThe next 4 test cases should ***FAIL*** due to " \
"***INCORRECT*** JSON objects.\n\n\n"
@ -57,5 +57,5 @@ printf "$BAD_MSC3440_THREAD" "Thread reply $(date +%H:%M:%S)" \
# this will fail due to not being valid JSON
printf "$BAD_MSC2677_REACT_2" "$TARGET_EVENT" "❤" >event4.json
# These 4 test cases should ***FAIL***
cat event2.json | matrix-commander.py --event event1.json - event3.json event4.json -m "" $MC_OPTIONS
cat event2.json | matrix-commander --event event1.json - event3.json event4.json -m "" $MC_OPTIONS
rm event1.json event2.json event3.json event4.json # clean up

Loading…
Cancel
Save