日志记录逻辑

This commit is contained in:
Jerry Yan 2019-04-10 07:04:12 +08:00 committed by JerryYan
parent e066048e9f
commit e77fa5d6ad
6 changed files with 14 additions and 9 deletions

View File

@ -47,9 +47,10 @@ def getCurrentStatus():
os.system("rm -f `find . -ctime 1 -name '*.flv'`") os.system("rm -f `find . -ctime 1 -name '*.flv'`")
_mem = psutil.virtual_memory() _mem = psutil.virtual_memory()
_net = psutil.net_io_counters() _net = psutil.net_io_counters()
if 60 > getTimeDelta(datetime.now(),network["currentTime"]) > 0: _delta= getTimeDelta(datetime.now(),network["currentTime"])
_outSpeed = (_net.bytes_sent - network["out"]["currentByte"])/getTimeDelta(datetime.now(),network["currentTime"]) if 60 > _delta > 0:
_inSpeed = (_net.bytes_recv - network["in"]["currentByte"])/getTimeDelta(datetime.now(),network["currentTime"]) _inSpeed = (_net.bytes_recv - network["in"]["currentByte"])/_delta
_outSpeed = (_net.bytes_sent - network["out"]["currentByte"])/_delta
else: else:
_outSpeed = 0 _outSpeed = 0
_inSpeed = 0 _inSpeed = 0

View File

@ -32,6 +32,7 @@ def readConfig():
@app.route("/config", methods=["POST"]) @app.route("/config", methods=["POST"])
def writeConfig(): def writeConfig():
# TODO : 完善 # TODO : 完善
Common.appendOperation("更新配置")
Common.reloadConfig() Common.reloadConfig()
return jsonify({"message":"ok","code":200,"status":0,"data":request.form}) return jsonify({"message":"ok","code":200,"status":0,"data":request.form})

View File

@ -336,7 +336,7 @@ class Bilibili:
"order_id": 0, "order_id": 0,
"videos": self.videos} "videos": self.videos}
) )
Common.appendUploadStatus("[{}] Published | Result : {}".format(title, r.text)) Common.modifyLastUploadStatus("[{}] Published | Result : {}".format(title, r.text))
def reloadFromPrevious(self): def reloadFromPrevious(self):
if os.path.exists("uploaded.json"): if os.path.exists("uploaded.json"):

View File

@ -37,6 +37,7 @@ def download(url):
f.close() f.close()
isDownload = False isDownload = False
if os.path.getsize(path) < 1024 * 1024: if os.path.getsize(path) < 1024 * 1024:
Common.modifyLastDownloadStatus("Downloaded File >{}< is too small, will ignore it".format(path))
os.remove(path) os.remove(path)
return False return False
if Common.forceNotDownload: if Common.forceNotDownload:

View File

@ -18,6 +18,7 @@
{% endfor %} {% endfor %}
</table> </table>
<hr/> <hr/>
<h3><a href="/">录播信息页</a></h3>
{% include 'device.html' %} {% include 'device.html' %}
</div> </div>
</body> </body>

View File

@ -50,28 +50,29 @@
<table> <table>
<tr> <tr>
<td>下载日志</td> <td>下载日志</td>
<td><span id="download"></span></td> <td colspan="2"><span id="download"></span></td>
</tr> </tr>
<tr> <tr>
<td>转码日志</td> <td>转码日志</td>
<td>转码队列<br><span id="encodeQueueSize"></span></td>
<td><span id="encode"></span></td> <td><span id="encode"></span></td>
<td>转码队列<span id="encodeQueueSize"></span></td>
</tr> </tr>
<tr> <tr>
<td>上传日志</td> <td>上传日志</td>
<td>上传队列<br><span id="uploadQueueSize"></span></td>
<td><span id="upload"></span></td> <td><span id="upload"></span></td>
<td>上传队列<span id="uploadQueueSize"></span></td>
</tr> </tr>
<tr> <tr>
<td>错误日志</td> <td>错误日志</td>
<td><span id="error"></span></td> <td colspan="2"><span id="error"></span></td>
</tr> </tr>
<tr> <tr>
<td>操作日志</td> <td>操作日志</td>
<td><span id="operation"></span></td> <td colspan="2"><span id="operation"></span></td>
</tr> </tr>
</table> </table>
<hr/> <hr/>
<h3><a href="/files/">所有录播文件</a></h3>
{% include 'device.html' %} {% include 'device.html' %}
</div> </div>
<script src="../static/index.js"></script> <script src="../static/index.js"></script>