mirror of
https://codeberg.org/privacy1st/exec-notify
synced 2024-12-22 23:16:04 +01:00
add "make install" and other fixes
This commit is contained in:
parent
8894805f80
commit
52822c99ba
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
config/cfg.ini
|
execNotifyDir/config/cfg.ini
|
||||||
__pycache__/
|
__pycache__/
|
66
.idea/workspace.xml
generated
66
.idea/workspace.xml
generated
@ -1,22 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="066dfbfd-85ed-456f-9525-253ec03fa96b" name="Default Changelist" comment="">
|
<list default="true" id="066dfbfd-85ed-456f-9525-253ec03fa96b" name="Default Changelist" comment="fix">
|
||||||
<change afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/Makefile" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/.gitignore" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/execNotifyDir/__init__.py" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/execNotify.iml" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/execNotifyDir/exec.py" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config.py" beforeDir="false" afterPath="$PROJECT_DIR$/execNotifyDir/config.py" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/config/cfg.ini.example" beforeDir="false" afterPath="$PROJECT_DIR$/execNotifyDir/config/cfg.ini.example" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/config.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/exec.py" beforeDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/config/cfg.ini.example" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/execNotify.py" beforeDir="false" afterPath="$PROJECT_DIR$/execNotify" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/exec.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/mail.py" beforeDir="false" afterPath="$PROJECT_DIR$/execNotifyDir/mail.py" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/execNotify.py" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/util.py" beforeDir="false" afterPath="$PROJECT_DIR$/execNotifyDir/util.py" afterDir="false" />
|
||||||
<change afterPath="$PROJECT_DIR$/mail.py" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/password.txt" afterDir="false" />
|
|
||||||
<change afterPath="$PROJECT_DIR$/util.py" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -43,7 +40,7 @@
|
|||||||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
|
||||||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
|
||||||
<property name="WebServerToolWindowFactoryState" value="false" />
|
<property name="WebServerToolWindowFactoryState" value="false" />
|
||||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/config" />
|
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
|
||||||
<property name="node.js.detected.package.eslint" value="true" />
|
<property name="node.js.detected.package.eslint" value="true" />
|
||||||
<property name="node.js.detected.package.tslint" value="true" />
|
<property name="node.js.detected.package.tslint" value="true" />
|
||||||
<property name="node.js.path.for.package.eslint" value="project" />
|
<property name="node.js.path.for.package.eslint" value="project" />
|
||||||
@ -53,8 +50,12 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="$PROJECT_DIR$/config" />
|
|
||||||
<recent name="$PROJECT_DIR$" />
|
<recent name="$PROJECT_DIR$" />
|
||||||
|
<recent name="$PROJECT_DIR$/config" />
|
||||||
|
</key>
|
||||||
|
<key name="MoveFile.RECENT_KEYS">
|
||||||
|
<recent name="$PROJECT_DIR$" />
|
||||||
|
<recent name="$PROJECT_DIR$/execNotify" />
|
||||||
</key>
|
</key>
|
||||||
</component>
|
</component>
|
||||||
<component name="RunManager">
|
<component name="RunManager">
|
||||||
@ -71,7 +72,7 @@
|
|||||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/execNotify.py" />
|
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/execNotify" />
|
||||||
<option name="PARAMETERS" value="ls foobar" />
|
<option name="PARAMETERS" value="ls foobar" />
|
||||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||||
<option name="EMULATE_TERMINAL" value="false" />
|
<option name="EMULATE_TERMINAL" value="false" />
|
||||||
@ -99,12 +100,31 @@
|
|||||||
<workItem from="1607251381674" duration="2626000" />
|
<workItem from="1607251381674" duration="2626000" />
|
||||||
<workItem from="1607254060327" duration="231000" />
|
<workItem from="1607254060327" duration="231000" />
|
||||||
<workItem from="1607254312912" duration="2639000" />
|
<workItem from="1607254312912" duration="2639000" />
|
||||||
|
<workItem from="1607256975586" duration="5652000" />
|
||||||
</task>
|
</task>
|
||||||
|
<task id="LOCAL-00001" summary="first commit">
|
||||||
|
<created>1607257112486</created>
|
||||||
|
<option name="number" value="00001" />
|
||||||
|
<option name="presentableId" value="LOCAL-00001" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1607257112486</updated>
|
||||||
|
</task>
|
||||||
|
<task id="LOCAL-00002" summary="fix">
|
||||||
|
<created>1607257255152</created>
|
||||||
|
<option name="number" value="00002" />
|
||||||
|
<option name="presentableId" value="LOCAL-00002" />
|
||||||
|
<option name="project" value="LOCAL" />
|
||||||
|
<updated>1607257255152</updated>
|
||||||
|
</task>
|
||||||
|
<option name="localTasksCounter" value="3" />
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
<option name="version" value="3" />
|
<option name="version" value="3" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="UnknownFeatures">
|
||||||
|
<option featureType="com.intellij.fileTypeFactory" implementationName="Makefile" />
|
||||||
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
<option name="TAB_STATES">
|
<option name="TAB_STATES">
|
||||||
<map>
|
<map>
|
||||||
@ -115,8 +135,14 @@
|
|||||||
</entry>
|
</entry>
|
||||||
</map>
|
</map>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="oldMeFiltersMigrated" value="true" />
|
||||||
|
</component>
|
||||||
|
<component name="VcsManagerConfiguration">
|
||||||
|
<MESSAGE value="first commit" />
|
||||||
|
<MESSAGE value="fix" />
|
||||||
|
<option name="LAST_COMMIT_MESSAGE" value="fix" />
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/execNotify$execNotify.coverage" NAME="execNotify Coverage Results" MODIFIED="1607256518765" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
<SUITE FILE_PATH="coverage/execNotify$execNotify.coverage" NAME="execNotify Coverage Results" MODIFIED="1607264748140" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
21
Makefile
Normal file
21
Makefile
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
.PHONY: all install clean copy remove
|
||||||
|
|
||||||
|
all: install
|
||||||
|
|
||||||
|
clean: remove
|
||||||
|
|
||||||
|
install: permissions
|
||||||
|
|
||||||
|
permissions: copy
|
||||||
|
chmod 755 /usr/local/bin/execNotify
|
||||||
|
find /usr/local/bin/execNotifyDir \( -type d -exec chmod 755 {} + \) -o \( -type f -exec chmod 644 {} + \)
|
||||||
|
chown root:root /usr/local/bin/execNotify
|
||||||
|
chown -R root:root /usr/local/bin/execNotifyDir
|
||||||
|
|
||||||
|
copy:
|
||||||
|
cp execNotify /usr/local/bin/execNotify
|
||||||
|
cp -r execNotifyDir/ /usr/local/bin/
|
||||||
|
|
||||||
|
remove:
|
||||||
|
rm /usr/local/bin/execNotify
|
||||||
|
rm -r /usr/local/bin/execNotifyDir
|
@ -1,29 +1,32 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from sys import argv
|
from sys import argv
|
||||||
import socket
|
import socket
|
||||||
|
from typing import List
|
||||||
|
|
||||||
import exec, mail, config
|
from execNotifyDir import exec, config, mail
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
prevMailError = checkPrevError()
|
prevMailError = checkPrevError()
|
||||||
success = executeCommand()
|
|
||||||
|
if len(argv) >= 2:
|
||||||
|
success = executeCommand(argv[1:])
|
||||||
|
else:
|
||||||
|
success = True
|
||||||
|
|
||||||
if prevMailError:
|
if prevMailError:
|
||||||
tryToInform()
|
tryToInform()
|
||||||
|
|
||||||
if not prevMailError or not success:
|
if not success:
|
||||||
exit(1)
|
exit(1)
|
||||||
else:
|
else:
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
|
|
||||||
def executeCommand() -> bool:
|
def executeCommand(command: List) -> bool:
|
||||||
if len(argv) < 2:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
keys = ['command', 'status', 'stderr', 'stdout']
|
keys = ['command', 'status', 'stderr', 'stdout']
|
||||||
code, stdout, stderr = exec.execute(argv[1:])
|
code, stdout, stderr = exec.execute(command)
|
||||||
values = [str(argv[1:]), str(code), stderr, stdout]
|
values = [str(command), str(code), stderr, stdout]
|
||||||
|
|
||||||
BODY = ''
|
BODY = ''
|
||||||
for key, value in zip(keys, values):
|
for key, value in zip(keys, values):
|
||||||
@ -33,9 +36,12 @@ def executeCommand() -> bool:
|
|||||||
if code != 0:
|
if code != 0:
|
||||||
hostname = socket.gethostname()
|
hostname = socket.gethostname()
|
||||||
|
|
||||||
SUBJECT = '{} | {}'.format(hostname, str(argv[1:]))
|
SUBJECT = '{} | {}'.format(hostname, str(command))
|
||||||
mail.sendMailOrWriteToFile(SUBJECT=SUBJECT, BODY=BODY)
|
mail.sendMailOrWriteToFile(SUBJECT=SUBJECT, BODY=BODY)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
else:
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def checkPrevError():
|
def checkPrevError():
|
0
execNotifyDir/__init__.py
Normal file
0
execNotifyDir/__init__.py
Normal file
@ -1,6 +1,7 @@
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import configparser
|
import configparser
|
||||||
|
|
||||||
|
from execNotifyDir import util
|
||||||
|
|
||||||
def getHostAndPort():
|
def getHostAndPort():
|
||||||
return config['mail']['host'], config['mail']['port']
|
return config['mail']['host'], config['mail']['port']
|
||||||
@ -27,8 +28,10 @@ def _getCfgFile() -> Path:
|
|||||||
|
|
||||||
|
|
||||||
def _getCfgDir() -> Path:
|
def _getCfgDir() -> Path:
|
||||||
return Path('config')
|
return util.getProjectBase().joinpath('execNotifyDir').joinpath('config')
|
||||||
|
|
||||||
|
# DEBUG todo
|
||||||
|
print(_getCfgFile())
|
||||||
|
|
||||||
config: configparser.ConfigParser = configparser.ConfigParser()
|
config: configparser.ConfigParser = configparser.ConfigParser()
|
||||||
config.read(_getCfgFile())
|
config.read(_getCfgFile())
|
@ -4,9 +4,8 @@ import smtplib, ssl
|
|||||||
|
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.mime.multipart import MIMEMultipart
|
from email.mime.multipart import MIMEMultipart
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
import util, config
|
from execNotifyDir import config
|
||||||
|
|
||||||
|
|
||||||
def sendMailOrWriteToFile(SUBJECT: str, BODY: str):
|
def sendMailOrWriteToFile(SUBJECT: str, BODY: str):
|
@ -1,6 +1,11 @@
|
|||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
|
||||||
|
def getProjectBase() -> Path:
|
||||||
|
return Path(os.path.realpath(__file__)).parent.parent
|
||||||
|
|
||||||
|
|
||||||
def readFirstLine(file: Path) -> str:
|
def readFirstLine(file: Path) -> str:
|
||||||
"""
|
"""
|
||||||
:param file: Path to file
|
:param file: Path to file
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
# so far there are no requirements except python3
|
Loading…
Reference in New Issue
Block a user