diff --git a/.gitignore b/.gitignore
index 9c5e480..ad96969 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-/etc/execNotify/cfg.ini
+/etc/exec-notify/cfg.ini
/mail/
/.idea/workspace.xml
diff --git a/.idea/execNotify.iml b/.idea/execNotify.iml
index bc85af0..31737c9 100644
--- a/.idea/execNotify.iml
+++ b/.idea/execNotify.iml
@@ -1,6 +1,7 @@
-
+
+
@@ -8,8 +9,9 @@
+
-
+
\ No newline at end of file
diff --git a/.idea/runConfigurations/execNotify.xml b/.idea/runConfigurations/execNotify.xml
index d204577..1722157 100644
--- a/.idea/runConfigurations/execNotify.xml
+++ b/.idea/runConfigurations/execNotify.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/.idea/runConfigurations/notify.xml b/.idea/runConfigurations/notify.xml
index 070b15b..f0d9141 100644
--- a/.idea/runConfigurations/notify.xml
+++ b/.idea/runConfigurations/notify.xml
@@ -13,7 +13,7 @@
-
+
diff --git a/README.md b/README.md
index f9d72d2..cf0cf87 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,12 @@
-# execNotify
+# exec-notify
-* Send email notification if command fails with [de-p1st-execNotify](src/de/p1st/exec_notify/execNotify.py).
-* Send unconditional notifications with [de-p1st-notify](src/de/p1st/exec_notify/notify.py).
+* Send email notification if command fails with [exec-notify](src/de/p1st/exec_notify/exec_notify.py).
+* Send unconditional notifications with [do-notify](src/de/p1st/exec_notify/do_notify.py).
## TODOs
~~* Send notification about unread local mail only once!~~
+* add PKGBUILD
* Rename python module (and git repository?) to `exec-notify`
* Use subprocess_util > execute_print_capture
* This way, the user can see the stdout/stderr while it is executed
@@ -47,7 +48,7 @@ pip --version
Then install with one of the following options:
```shell
-sudo python3 -m pip install --upgrade --force-reinstall git+https://codeberg.org/privacy1st/execNotify
+sudo python3 -m pip install --upgrade --force-reinstall git+https://codeberg.org/privacy1st/exec-notify
sudo python3 -m pip install --upgrade --force-reinstall .
sudo python3 -m pip install --upgrade --index-url https://test.pypi.org/simple/ --no-deps de.p1st.exec-notify
```
@@ -59,13 +60,13 @@ More detailed instructions about _venv_ can be found at [https://docs.python.org
Create a _venv_:
```shell
-python3 -m venv ~/execNotify/venv
+python3 -m venv ~/exec-notify/venv
```
Activate the venv:
```shell
-source ~/execNotify/venv/bin/activate
+source ~/exec-notify/venv/bin/activate
# echo "VIRTUAL_ENV=${VIRTUAL_ENV}"
```
@@ -73,10 +74,10 @@ And choose one source of installation:
```shell
# Install from git URL
-python3 -m pip install git+https://codeberg.org/privacy1st/execNotify
+python3 -m pip install git+https://codeberg.org/privacy1st/exec-notify
# Install from local directory
-python3 -m pip install ~/Downloads/git/execNotify/
+python3 -m pip install ~/Downloads/git/exec-notify/
# Install the module from TestPyPI
python3 -m pip install --index-url https://test.pypi.org/simple/ --no-deps --upgrade de.p1st.exec-notify
@@ -97,10 +98,10 @@ pip list
## Configuration
-Create configuration file `/etc/execNotify/cfg.ini`:
+Create configuration file `/etc/exec-notify/cfg.ini`:
```shell
-install -Dm0600 /etc/execNotify/cfg.ini << 'EOF'
+install -Dm0600 /etc/exec-notify/cfg.ini << 'EOF'
[DEFAULT]
[mail]
@@ -116,42 +117,42 @@ maildir = /home/exampleUser/mail/
EOF
```
-See also: [./etc/execNotify/cfg.ini.example](etc/execNotify/cfg.ini.example)
+See also: [./etc/exec-notify/cfg.ini.example](etc/exec-notify/cfg.ini.example)
## Usage
-### Usage of execNotify
+### Usage of exec-notify
-Add `de-p1st-execNotify` in front of your command to execute.
+Add `exec-notify` in front of your command to execute.
**Example:**
-`de-p1st-execNotify ls /non/existent/file` will mail you the exit code, stdout and stderr of `ls /non/existent/file`
+`exec-notify ls /non/existent/file` will mail you the exit code, stdout and stderr of `ls /non/existent/file`
### Usage of notify
Send stdout via mail:
-`echo "Hello world!" | de-p1st-notify`
+`echo "Hello world!" | do-notify`
Send stdout and stderr via mail:
-`echo "Hello world!" 2>&1 | de-p1st-notify`
+`echo "Hello world!" 2>&1 | do-notify`
Send stdout and specify an optional email subject:
-`echo "Hello world!" | de-p1st-notify "someSubject"`
+`echo "Hello world!" | do-notify "someSubject"`
Send message without using a pipe:
-`de-p1st-notify "someSubject" "Hello World! What's up?"`
+`do-notify "someSubject" "Hello World! What's up?"`
## Development
When started with environment variable `DE_P1ST_EXEC_NOTIFY` set,
-then the configuration file is read from [./etc/execNotify/cfg.ini](etc/execNotify/cfg.ini).
+then the configuration file is read from [./etc/exec-notify/cfg.ini](etc/exec-notify/cfg.ini).
### Testing
@@ -179,4 +180,4 @@ python3 -m twine upload --repository testpypi dist/*
6) Congratulations! You can view the uploaded module under:
-* [https://test.pypi.org/project/de.p1st.exec_notify/](https://test.pypi.org/project/de.p1st.exec_notify/)
+* [https://test.pypi.org/project/exec_notify/](https://test.pypi.org/project/exec_notify/)
diff --git a/etc/execNotify/cfg.ini.example b/etc/exec-notify/cfg.ini.example
similarity index 100%
rename from etc/execNotify/cfg.ini.example
rename to etc/exec-notify/cfg.ini.example
diff --git a/setup.cfg b/setup.cfg
index 8d11f3b..6ca25c2 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -2,16 +2,16 @@
; https://packaging.python.org/tutorials/packaging-projects/#configuring-metadata
[metadata]
-name = de.p1st.exec_notify
+name = exec_notify
version = 0.1.10
author = Daniel Langbein
author_email = daniel@systemli.org
-description = mail notification if command fails
+description = email notification if command fails
long_description = file: README.md
long_description_content_type = text/markdown
-url = https://codeberg.org/privacy1st/execNotify
+url = https://codeberg.org/privacy1st/exec-notify
project_urls =
- Bug Tracker = https://codeberg.org/privacy1st/execNotify/issues
+ Bug Tracker = https://codeberg.org/privacy1st/exec-notify/issues
; https://pypi.org/classifiers/
classifiers =
@@ -32,5 +32,5 @@ where = src
[options.entry_points]
; https://setuptools.readthedocs.io/en/latest/userguide/entry_point.html
console_scripts=
- de-p1st-execNotify = de.p1st.exec_notify.execNotify:main
- de-p1st-notify = de.p1st.exec_notify.notify:main
+ exec-notify = de.p1st.exec_notify.exec_notify:main
+ do-notify = de.p1st.exec_notify.do_notify:main
diff --git a/src/de/p1st/exec_notify/notify.py b/src/de/p1st/exec_notify/do_notify.py
similarity index 76%
rename from src/de/p1st/exec_notify/notify.py
rename to src/de/p1st/exec_notify/do_notify.py
index bdcbeac..a795f7d 100755
--- a/src/de/p1st/exec_notify/notify.py
+++ b/src/de/p1st/exec_notify/do_notify.py
@@ -11,13 +11,13 @@ def main():
Send an email with some content and optionally specify an email subject.
Usage:
- echo
| de-p1st-notify
+ echo | do-notify
- echo | de-p1st-notify
+ echo | do-notify
- de-p1st-notify
+ do-notify
- de-p1st-notify
+ do-notify
"""
BODY = None
@@ -25,7 +25,7 @@ def main():
hostname = socket.gethostname()
if len(sys.argv) > 3:
- print('execNotify>> Expected at most two arguments!', file=sys.stderr)
+ print('exec-notify>> Expected at most two arguments!', file=sys.stderr)
exit(1)
if len(sys.argv) == 2 or len(sys.argv) == 3:
subj = sys.argv[1]
diff --git a/src/de/p1st/exec_notify/execNotify.py b/src/de/p1st/exec_notify/exec_notify.py
similarity index 97%
rename from src/de/p1st/exec_notify/execNotify.py
rename to src/de/p1st/exec_notify/exec_notify.py
index ea62cb5..6d733b9 100755
--- a/src/de/p1st/exec_notify/execNotify.py
+++ b/src/de/p1st/exec_notify/exec_notify.py
@@ -11,7 +11,7 @@ from de.p1st.exec_notify.lib import exec, mail, util
def main():
"""
Usage:
- de-p1st-execNotify
+ exec-notify
with command = [ ...]
diff --git a/src/de/p1st/exec_notify/lib/config.py b/src/de/p1st/exec_notify/lib/config.py
index a68dbd6..e3a3b0b 100644
--- a/src/de/p1st/exec_notify/lib/config.py
+++ b/src/de/p1st/exec_notify/lib/config.py
@@ -23,7 +23,7 @@ def getHostAndPort() -> Tuple[str, int]:
try:
return LazyConfig.get('mail', 'host'), int(LazyConfig.get('mail', 'port'))
except Exception:
- print(f'execNotify>> Could not read value [mail][host] from {_getCfgFile()}', file=stderr)
+ print(f'exec-notify>> Could not read value [mail][host] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@@ -32,7 +32,7 @@ def getPassword() -> str:
try:
return LazyConfig.get('mail', 'password')
except Exception:
- print(f'execNotify>> Could not read value [mail][password] from {_getCfgFile()}', file=stderr)
+ print(f'exec-notify>> Could not read value [mail][password] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@@ -41,7 +41,7 @@ def getFrom() -> str:
try:
return LazyConfig.get('mail', 'from') # used for mail login as well
except Exception:
- print(f'execNotify>> Could not read value [mail][from] from {_getCfgFile()}', file=stderr)
+ print(f'exec-notify>> Could not read value [mail][from] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@@ -50,7 +50,7 @@ def getTo() -> str:
try:
return LazyConfig.get('mail', 'to')
except Exception:
- print(f'execNotify>> Could not read value [mail][to] from {_getCfgFile()}', file=stderr)
+ print(f'exec-notify>> Could not read value [mail][to] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@@ -59,7 +59,7 @@ def getMailDir() -> Path:
try:
return Path(LazyConfig.get('file', 'maildir'))
except Exception:
- print(f'execNotify>> Could not read value [file][maildir] from {_getCfgFile()}', file=stderr)
+ print(f'exec-notify>> Could not read value [file][maildir] from {_getCfgFile()}', file=stderr)
traceback.print_exc()
exit(1)
@@ -75,6 +75,6 @@ def _getCfgFile() -> Path:
def _getCfgDir() -> Path:
if util.isInDevelopment():
- return util.getProjectBase().joinpath('etc', 'execNotify')
+ return util.getProjectBase().joinpath('etc', 'exec-notify')
else:
- return PosixPath('/etc/execNotify/')
+ return PosixPath('/etc/exec-notify/')
diff --git a/src/de/p1st/exec_notify/lib/exec.py b/src/de/p1st/exec_notify/lib/exec.py
index a7af4d1..05dd281 100644
--- a/src/de/p1st/exec_notify/lib/exec.py
+++ b/src/de/p1st/exec_notify/lib/exec.py
@@ -11,7 +11,8 @@ def execute(command: List[str]):
:param command: A command to executed as list of words, e.g. `['echo', 'Hello world!']`
:return: (exit_code, stdout, stderr)
- :raises Exception: Might throw an exception.E.g. FileNotFoundError if the executable (first element of `command`) does not exist.
+ :raises Exception: Might throw an exception.E.g. FileNotFoundError
+ if the executable (first element of `command`) does not exist.
"""
if sys.version_info.major == 3 and sys.version_info.minor < 7:
diff --git a/src/de/p1st/exec_notify/lib/mail.py b/src/de/p1st/exec_notify/lib/mail.py
index 560cf05..7ad4d83 100644
--- a/src/de/p1st/exec_notify/lib/mail.py
+++ b/src/de/p1st/exec_notify/lib/mail.py
@@ -22,8 +22,8 @@ def sendMailOrWriteToFile(SUBJECT: str, BODY: str, informAboutLocalMail: bool =
try:
sendMail(SUBJECT=SUBJECT, BODY=BODY)
except Exception as e:
- print(f'execNotify>> Could not send mail: {e}', file=sys.stderr)
- print(f'execNotify>> Writing to file instead ...', file=sys.stderr)
+ print(f'exec-notify>> Could not send mail: {e}', file=sys.stderr)
+ print(f'exec-notify>> Writing to file instead ...', file=sys.stderr)
# Instead, try to save the mail so that the user can read
# it later when connected to this computer
@@ -85,7 +85,7 @@ def saveMail(SUBJECT: str, BODY: str):
with open(mailFile, "a") as f:
f.write(mailStr)
except Exception as e:
- print(f'execNotify>> Could not write to file: {e}', file=sys.stderr)
+ print(f'exec-notify>> Could not write to file: {e}', file=sys.stderr)
def _localMailExists():