Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sympa-pymanage] Basic tool to interact with Sympa server using mail commands #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ it You can also update this README by giving a brief description of your contrib

### Utils

Tools for sysadmins.
Tools for sysadmins :

* [datasources_utils](utils/datasources_utils/README.md): view and test list datasources and custom attributes datasources
* [sympatoldap](utils/sympatoldap/README.md): creates LDAP entries for every list (and its aliases) whose status is open on the LDAP server
* [splitting_daemons_logs](utils/splitting_daemons_logs/README.md): split Sympa processus logs into separated files
* [sqlite2mysql](utils/sqlite2mysql/README.md): attempt to convert sqlite to mysql

Tools for mailing list owners :

* [sympa-pymanage](utils/sympa-user-cli-pymanage/README.md): a basic python tool which sends [email commands](https://lists.sympa.community/help/commands.html) to the sympa server (eg: in order to update mailing lists from a program pipeline).
178 changes: 178 additions & 0 deletions utils/sympa-pymanage/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
outputs/*.log
config/*.conf
poetry.lock

# from https://github.com/github/gitignore/blob/main/Python.gitignore

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# UV
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
#uv.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
.pdm.toml
.pdm-python
.pdm-build/

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
*venv*/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

# PyPI configuration file
.pypirc
65 changes: 65 additions & 0 deletions utils/sympa-pymanage/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Sympa Manage

This is a basic python client program to send emails as a mailing list admin to the sympa server.

You can see a list of commands available [here](https://lists.sympa.community/help/commands.html).

It is not using [sympa SOAP API](https://www.sympa.community/manual/customize/soap-api.html), which, unfortunately, does not seem to be very actively used nowadays.

Use it to ADD, DEL user or send STATS or REVIEW commands.

## Requirements

[`Typer`](https://typer.tiangolo.com/) python library.


## Configuration

You need either a working MTA (eg. [_basic SMTP configuration working with Postfix_](http://www.postfix.org/BASIC_CONFIGURATION_README.html)), or a user/password configuration from an email provider.

Whatever the solution you use, the email sender must have admin permissions on the admin list. You can check logs in the sympa server to see what mail address is used.


Every configuration must be set in `config/sympa.conf`.

## Installation

Clone that directory, and install the requirements in a virtualenv :

```bash
python3 -m venv sympa_venv
source sympa_venv/bin/activate
python3 -m pip install typer
```


## Basic usage

Help :

```bash
#source sympa_venv/bin/activate
python3 sympa_manage.py --help
```

Review :

```bash
python3 sympa_manage.py -m [email protected]
# same as the following (REVIEW is the default):
python3 sympa_manage.py REVIEW -m [email protected]
```

Add :

```bash
python3 sympa_manage.py "QUIET ADD" -m [email protected] -u "[email protected] John Doe"
# you repeat -u option as much as you want
python3 sympa_manage.py "QUIET ADD" -m [email protected] -u "[email protected] John Doe" -u [email protected]
```

Delete :

```bash
python3 sympa_manage.py DEL -m [email protected] -u [email protected]
```
2 changes: 2 additions & 0 deletions utils/sympa-pymanage/TODO
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- key message to use (for commands CONFIRM, REJECT, DISTRIBUTE)
- set of sub-actions
20 changes: 20 additions & 0 deletions utils/sympa-pymanage/config/sympa.conf.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[general]
# sympa email server address
[email protected]
# either to receive or not an aknowledgement
confirmation=yes
[email protected]

[send_method]
# either "local" or "custom"
# if local, use the local machine SMTP method
# if "custom", you must fullfill the next values.
email_send_method=local

# following is needed only if you do not have a local working MTA...
smtp_remote_server="<smtp server to use>"
smtp_remote_port=465
smtp_sender="<sender email>"
smtp_receiver="<sender recipient 1>, <sender recipient 2>"
smtp_password="<my email password>"

Empty file.
18 changes: 18 additions & 0 deletions utils/sympa-pymanage/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[project]
name = "sympa-pymanage"
version = "0.1.0"
description = "A project to manage python list from terminal as a mailing list owner"
authors = [
{name = "Rémy Dernat",email = "[email protected]"}
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
"typer (>=0.15.1,<0.16.0)"
]


[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
Loading