mirror of
https://github.com/vale981/dirkules
synced 2025-03-05 09:21:38 -05:00
new database format...
This commit is contained in:
parent
3c7876a007
commit
e9ec305a29
6 changed files with 69 additions and 26 deletions
|
@ -1,8 +1,6 @@
|
|||
import os
|
||||
|
||||
|
||||
baseDir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(
|
||||
baseDir, 'dirkules.db')
|
||||
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(baseDir, 'dirkules.db')
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import psutil
|
||||
import subprocess
|
||||
import os
|
||||
from dirkules.models import Drive
|
||||
|
||||
|
||||
def getAllDrives():
|
||||
|
@ -33,16 +34,17 @@ def getAllDrives():
|
|||
values.append(smartPassed(values[0]))
|
||||
values.append(getTotalSize(values[0]))
|
||||
driveDict.append(dict(zip(keys, values)))
|
||||
db.session.add(Drive(values[0], values[1], values[2], values[3]))
|
||||
db.session.commit()
|
||||
return driveDict
|
||||
|
||||
|
||||
def smartPassed(device):
|
||||
passed = False
|
||||
smartctl = subprocess.Popen(
|
||||
["smartctl -H " + device],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
universal_newlines=True)
|
||||
smartctl = subprocess.Popen(["smartctl -H " + device],
|
||||
stdout=subprocess.PIPE,
|
||||
shell=True,
|
||||
universal_newlines=True)
|
||||
while True:
|
||||
line = smartctl.stdout.readline()
|
||||
if "PASSED" in line:
|
||||
|
@ -54,6 +56,7 @@ def smartPassed(device):
|
|||
smartctl.stdout.close()
|
||||
return passed
|
||||
|
||||
|
||||
def getTotalSize(device):
|
||||
# Hier könnte man auch die Partitionen mit abfragen
|
||||
drives = []
|
||||
|
@ -76,6 +79,7 @@ def getTotalSize(device):
|
|||
size = firstLine[2] + " " + firstLine[3][:-1]
|
||||
return size
|
||||
|
||||
|
||||
#nicht verwenden
|
||||
def OLDgetAllDrives():
|
||||
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
import time
|
||||
from dirkules import db
|
||||
from sqlalchemy import Table, Column, Integer, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
class Drive(Base):
|
||||
__tablename__ = 'drives'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String)
|
||||
path = db.Column(db.String)
|
||||
storage = db.Column(db.Integer)
|
||||
observed = db.Column(db.Boolean)
|
||||
statuse = db.relationship("Drive_status")
|
||||
|
||||
class Drive_status(Base):
|
||||
__tablename__ = 'drive_status'
|
||||
class Drive(db.Model):
|
||||
__tablename__ = 'drives'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
drive_id = db.Column(db.Integer, db.ForeignKey('drive.id'))
|
||||
device = db.Column(db.String)
|
||||
name = db.Column(db.String)
|
||||
size = db.Column(db.Integer)
|
||||
smart = db.Column(db.Boolean)
|
||||
operating_hours = db.Column(db.Integer)
|
||||
startups = db.Column(db.Integer)
|
||||
startups = db.Column(db.Integer)
|
||||
time = db.Column(db.Integer)
|
||||
partitions = db.relationship("Partitions")
|
||||
|
||||
|
||||
class Partitions(db.Model):
|
||||
__tablename__ = 'partitions'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
drive_id = db.Column(db.Integer, db.ForeignKey('drives.id'))
|
||||
name = db.Column(db.String)
|
||||
fs = db.Column(db.String)
|
||||
uuid = db.Column(db.String)
|
||||
mountpoint = db.Column(db.String)
|
||||
label = db.Column(db.String)
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<li><a href="{{ url_for('index') }}">Startseite</a></li>
|
||||
<li><a href="/nzbget">NZBGet</a></li>
|
||||
<li><a href="{{ url_for('drives') }}">Festplatten</a></li>
|
||||
<li><a href="{{ url_for('partitions') }}">Partitionen</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
33
dirkules/templates/partitions.html
Normal file
33
dirkules/templates/partitions.html
Normal file
|
@ -0,0 +1,33 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}Dashboard{% endblock %}
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="title">
|
||||
<t1>Partitionen</t1>
|
||||
</div>
|
||||
<div class="tablebox">
|
||||
<table class="striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Laufwerk</th>
|
||||
<th>Name</th>
|
||||
<th>Speicherplatz</th>
|
||||
<th>SMART Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{% for drive in drives %}
|
||||
<tr>
|
||||
<td>{{drive.device}}</td>
|
||||
<td>{{drive.name}}</td>
|
||||
<td>{{drive.size}}</td>
|
||||
<td>{{drive.smart}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -2,16 +2,24 @@ from flask import Flask, render_template
|
|||
from dirkules import app
|
||||
import dirkules.driveManagement.driveController as drico
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@app.route('/drives', methods=['GET'])
|
||||
def drives():
|
||||
drives = drico.getAllDrives()
|
||||
return render_template('drives.html', drives=drives)
|
||||
|
||||
|
||||
@app.route('/about', methods=['GET'])
|
||||
def about():
|
||||
version = "1.0"
|
||||
return render_template('about.html', version=version)
|
||||
|
||||
|
||||
@app.route('/partitions', methods=['GET'])
|
||||
def partitions():
|
||||
return render_template('partitions.html')
|
||||
|
|
Loading…
Add table
Reference in a new issue