CronEDIT
This commit is contained in:
parent
0f55bc9cee
commit
5d2b45f8b8
2 changed files with 103 additions and 1 deletions
59
app.py
59
app.py
|
|
@ -243,7 +243,35 @@ def get_balance_color(balance):
|
|||
|
||||
return "green"
|
||||
|
||||
def get_cron_jobs():
|
||||
|
||||
jobs = {
|
||||
"balance": "nur unter Linux verfügbar",
|
||||
"transactions": "nur unter Linux verfügbar",
|
||||
"categorize": "nur unter Linux verfügbar"
|
||||
}
|
||||
|
||||
if platform.system() != "Linux":
|
||||
return jobs
|
||||
|
||||
result = subprocess.run(
|
||||
["crontab", "-l"],
|
||||
capture_output=True,
|
||||
text=True
|
||||
)
|
||||
|
||||
for line in result.stdout.splitlines():
|
||||
|
||||
if "balance.py" in line:
|
||||
jobs["balance"] = " ".join(line.split()[:5])
|
||||
|
||||
elif "transactions.py" in line:
|
||||
jobs["transactions"] = " ".join(line.split()[:5])
|
||||
|
||||
elif "categorize_transactions.py" in line:
|
||||
jobs["categorize"] = " ".join(line.split()[:5])
|
||||
|
||||
return jobs
|
||||
def get_balance_comparison():
|
||||
|
||||
if not all([
|
||||
|
|
@ -421,6 +449,34 @@ def download_log():
|
|||
as_attachment=True,
|
||||
download_name="ing.log"
|
||||
)
|
||||
@app.route("/maintenance/run/<script>")
|
||||
def run_script(script):
|
||||
if platform.system() != "Linux":
|
||||
return redirect(
|
||||
"/maintenance?message=Nur unter Linux verfügbar"
|
||||
)
|
||||
scripts = {
|
||||
"balance":
|
||||
"/home/banking/ING/balance.py",
|
||||
|
||||
"transactions":
|
||||
"/home/banking/ING/transactions.py",
|
||||
|
||||
"categorize":
|
||||
"/home/banking/ING/categorize_transactions.py"
|
||||
}
|
||||
|
||||
if script not in scripts:
|
||||
return redirect("/maintenance")
|
||||
|
||||
subprocess.Popen(
|
||||
["python3", scripts[script]]
|
||||
)
|
||||
|
||||
return redirect(
|
||||
"/maintenance?message=Script gestartet"
|
||||
)
|
||||
|
||||
@app.route("/log/delete")
|
||||
def delete_log():
|
||||
|
||||
|
|
@ -829,11 +885,12 @@ def maintenance():
|
|||
"message",
|
||||
""
|
||||
)
|
||||
|
||||
cron_jobs = get_cron_jobs()
|
||||
return render_template(
|
||||
"maintenance.html",
|
||||
year=year,
|
||||
week=week,
|
||||
cron_jobs=cron_jobs,
|
||||
message=message
|
||||
)
|
||||
@app.route("/log")
|
||||
|
|
|
|||
|
|
@ -208,6 +208,51 @@
|
|||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="card">
|
||||
|
||||
<h2>Automatisierung</h2>
|
||||
|
||||
<table class="category-table">
|
||||
|
||||
<tr>
|
||||
<th>Script</th>
|
||||
<th>Cron</th>
|
||||
<th>Aktion</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>balance.py</td>
|
||||
<td>{{ cron_jobs.balance }}</td>
|
||||
<td>
|
||||
<a href="/maintenance/run/balance">
|
||||
<button>Jetzt ausführen</button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>transactions.py</td>
|
||||
<td>{{ cron_jobs.transactions }}</td>
|
||||
<td>
|
||||
<a href="/maintenance/run/transactions">
|
||||
<button>Jetzt ausführen</button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>categorize_transactions.py</td>
|
||||
<td>{{ cron_jobs.categorize }}</td>
|
||||
<td>
|
||||
<a href="/maintenance/run/categorize">
|
||||
<button>Jetzt ausführen</button>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue