Log
This commit is contained in:
parent
2f7523fb87
commit
b3adba2780
4 changed files with 177 additions and 16 deletions
124
example.log
Normal file
124
example.log
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 14:36:00.203782+02:00 (in 599.998630 seconds)
|
||||||
|
INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:13:02.994723+02:00 (in 599.998307 seconds)
|
||||||
|
INFO:werkzeug: * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:13:03.500331+02:00 (in 599.998620 seconds)
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 279-108-830
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:03:10] "GET / HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:03:10] "GET /favicon.ico HTTP/1.1" 404 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:03:17] "GET /account/add HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:03:18] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:03:56] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:04:42] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:05:22] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:05:30] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:05:37] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:05:40] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:05:42] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:06:13] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug: * Detected change in '/home/soeren/dev/funk-simcard-manager/api/server.py', reloading
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:17:07.730877+02:00 (in 599.998289 seconds)
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 279-108-830
|
||||||
|
INFO:werkzeug: * Detected change in '/home/soeren/dev/funk-simcard-manager/api/server.py', reloading
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:17:11.466639+02:00 (in 599.998504 seconds)
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 279-108-830
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:13] "GET /log HTTP/1.1" 404 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:15] "GET /log HTTP/1.1" 404 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:16] "GET /log HTTP/1.1" 404 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:20] "GET /log HTTP/1.1" 404 -
|
||||||
|
INFO:werkzeug: * Detected change in '/home/soeren/dev/funk-simcard-manager/api/server.py', reloading
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:17:21.231891+02:00 (in 599.998729 seconds)
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 279-108-830
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:21] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug: * Detected change in '/home/soeren/dev/funk-simcard-manager/api/server.py', reloading
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:17:53.348377+02:00 (in 599.998540 seconds)
|
||||||
|
WARNING:werkzeug: * Debugger is active!
|
||||||
|
INFO:werkzeug: * Debugger PIN: 279-108-830
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:07:55] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:08:02] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:08:55] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:08:56] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:09:33] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:09:40] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:09:41] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:09:49] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:09:51] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:10:02] "GET /accounts HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:10:03] "GET /account/add HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug:127.0.0.1 - - [11/Jul/2019 15:10:05] "GET /log HTTP/1.1" 200 -
|
||||||
|
INFO:werkzeug: * Detected change in '/home/soeren/dev/funk-simcard-manager/api/server.py', reloading
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:werkzeug: * Restarting with stat
|
||||||
|
DEBUG:root:Start
|
||||||
|
INFO:apscheduler.scheduler:Adding job tentatively -- it will be properly scheduled when the scheduler starts
|
||||||
|
INFO:apscheduler.scheduler:Added job "function_cron" to job store "default"
|
||||||
|
INFO:apscheduler.scheduler:Scheduler started
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:Next wakeup is due at 2019-07-11 15:20:19.644345+02:00 (in 599.998534 seconds)
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
||||||
|
INFO:apscheduler.scheduler:Scheduler has been shut down
|
||||||
|
DEBUG:apscheduler.scheduler:Looking for jobs to run
|
||||||
|
DEBUG:apscheduler.scheduler:No jobs; waiting until a job is added
|
48
server.py
48
server.py
|
@ -13,6 +13,10 @@ from dateutil.relativedelta import relativedelta
|
||||||
from apscheduler.schedulers.background import BackgroundScheduler
|
from apscheduler.schedulers.background import BackgroundScheduler
|
||||||
import os
|
import os
|
||||||
import atexit
|
import atexit
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logging.basicConfig(filename='example.log',level=logging.DEBUG)
|
||||||
|
logging.debug("Start")
|
||||||
|
|
||||||
DATABASE = os.getenv("FUNK_DATABASE", 'database.db')
|
DATABASE = os.getenv("FUNK_DATABASE", 'database.db')
|
||||||
USERNAME = os.getenv("FUNK_USER", 'admin')
|
USERNAME = os.getenv("FUNK_USER", 'admin')
|
||||||
|
@ -174,33 +178,43 @@ def function_getPlanForDay(number, year, month, day):
|
||||||
return defaultPlan[0]
|
return defaultPlan[0]
|
||||||
|
|
||||||
def function_updateAccountsAtFunk():
|
def function_updateAccountsAtFunk():
|
||||||
print("Send Updates to Funk")
|
logging.debug("Send Updates to Func")
|
||||||
accounts = function_getAccounts(True)
|
accounts = function_getAccounts(True)
|
||||||
tomorrow = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
|
tomorrow = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
|
||||||
today = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
|
today = datetime.datetime.now(datetime.timezone.utc) + datetime.timedelta(days=1)
|
||||||
for account in accounts:
|
for account in accounts:
|
||||||
|
logging.debug("Update for Account: "+str(account["number"]))
|
||||||
api = FunkAPI(account["mail"], account["password"])
|
api = FunkAPI(account["mail"], account["password"])
|
||||||
function_updateAccount(account["number"], api) # We already have the API with the Data, so we can write them in the update table
|
function_updateAccount(account["number"], api) # We already have the API with the Data, so we can write them in the update table
|
||||||
planedPlan = function_getPlanForDay(account["number"], tomorrow.year, tomorrow.month, tomorrow.day)
|
planedPlan = function_getPlanForDay(account["number"], tomorrow.year, tomorrow.month, tomorrow.day)
|
||||||
plan = getCurrentPlan(api, tomorrow)
|
plan = getCurrentPlan(api, tomorrow)
|
||||||
currentPlan = getCurrentPlan(api)
|
currentPlan = getCurrentPlan(api)
|
||||||
if currentPlan == 42: # Wenn aktuell eine pause ist darf das update erst am selben tag erfolgen wie der neue Plan gültug ist
|
if currentPlan == 42: # Wenn aktuell eine pause ist darf das update erst am selben tag erfolgen wie der neue Plan gültug ist
|
||||||
|
logging.debug("Account is in a Break, updates will be called at the day the new Plan should work")
|
||||||
planedPlan = function_getPlanForDay(account["number"], today.year, today.month, today.day)
|
planedPlan = function_getPlanForDay(account["number"], today.year, today.month, today.day)
|
||||||
if planedPlan == "8": #Change to unlimit
|
|
||||||
api.orderUnlimitedPlan()
|
|
||||||
print("Switch to Unlimit")
|
|
||||||
elif planedPlan == "9": #Change to 1GB
|
|
||||||
api.order1GBPlan()
|
|
||||||
print("Switch to 1GB")
|
|
||||||
elif planedPlan == "42": #Change to break
|
|
||||||
api.startPause()
|
|
||||||
print("Switch to break")
|
|
||||||
else:
|
|
||||||
print("Cant update plan!!! ERROR")
|
|
||||||
else:
|
|
||||||
if(plan["productServiceId"] == planedPlan):
|
if(plan["productServiceId"] == planedPlan):
|
||||||
|
logging.debug("Next Day is already at the currect plan: "+str(planedPlan))
|
||||||
print("Nothing to Change, plan already set")
|
print("Nothing to Change, plan already set")
|
||||||
else:
|
else:
|
||||||
|
logging.debug("Next day should be updatedt")
|
||||||
|
if planedPlan == "8": #Change to unlimit
|
||||||
|
api.orderUnlimitedPlan()
|
||||||
|
print("Switch to Unlimit")
|
||||||
|
elif planedPlan == "9": #Change to 1GB
|
||||||
|
api.order1GBPlan()
|
||||||
|
print("Switch to 1GB")
|
||||||
|
elif planedPlan == "42": #Change to break
|
||||||
|
api.startPause()
|
||||||
|
print("Switch to break")
|
||||||
|
else:
|
||||||
|
print("Cant update plan!!! ERROR")
|
||||||
|
else:
|
||||||
|
logging.debug("Account it not on break, next Day can be set")
|
||||||
|
if(plan["productServiceId"] == planedPlan):
|
||||||
|
logging.debug("Next Day is already at the currect plan: "+str(planedPlan))
|
||||||
|
print("Nothing to Change, plan already set")
|
||||||
|
else:
|
||||||
|
logging.debug("Next day should be updatedt")
|
||||||
print("Update")
|
print("Update")
|
||||||
if planedPlan == "8": #Change to unlimit
|
if planedPlan == "8": #Change to unlimit
|
||||||
api.orderUnlimitedPlan()
|
api.orderUnlimitedPlan()
|
||||||
|
@ -223,6 +237,7 @@ def hello():
|
||||||
plans["1 GB"] = 0;
|
plans["1 GB"] = 0;
|
||||||
plans["Unlimit"] = 0;
|
plans["Unlimit"] = 0;
|
||||||
plans["Unlimit - First Day"] = 0;
|
plans["Unlimit - First Day"] = 0;
|
||||||
|
plans["Unlimit - Immidiately"] = 0;
|
||||||
plans["Break"] = 0
|
plans["Break"] = 0
|
||||||
for account in resData:
|
for account in resData:
|
||||||
plans[account["currentPlan"]["name"]] = plans[account["currentPlan"]["name"]] + 1;
|
plans[account["currentPlan"]["name"]] = plans[account["currentPlan"]["name"]] + 1;
|
||||||
|
@ -335,6 +350,13 @@ def add_account_gui_save():
|
||||||
r = addAccount()
|
r = addAccount()
|
||||||
return redirect("/accounts", code=302)
|
return redirect("/accounts", code=302)
|
||||||
|
|
||||||
|
@app.route("/log", methods=['GET'])
|
||||||
|
@requires_auth
|
||||||
|
def log_show_gui():
|
||||||
|
f = open("example.log")
|
||||||
|
content = f.readlines()
|
||||||
|
f.close()
|
||||||
|
return render_template("log.html", content=content, debug=app.debug)
|
||||||
|
|
||||||
# API
|
# API
|
||||||
@app.route('/api/accounts', methods=['GET'])
|
@app.route('/api/accounts', methods=['GET'])
|
||||||
|
|
|
@ -23,9 +23,17 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="/account/add">New Account</a>
|
<a class="nav-link" href="/account/add">New Account</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
</ul>
|
||||||
<a class="nav-link" href="/sendToFunk">Send Update to Funk (manual)</a>
|
<ul class="navbar-nav">
|
||||||
</li>
|
<li class="nav-item dropdown">
|
||||||
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
System
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||||
|
<a class="dropdown-item" href="/sendToFunk">Send Changes to Funk</a>
|
||||||
|
<a class="dropdown-item" href="/log">Log</a>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
7
templates/log.html
Normal file
7
templates/log.html
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{% extends "base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h3>Log</h3>
|
||||||
|
<pre>
|
||||||
|
{% for line in content %}{{ line }}{% endfor %}
|
||||||
|
</pre>
|
||||||
|
{% endblock %}
|
Loading…
Reference in a new issue