diff --git a/dirkules/config.py b/dirkules/config.py index e152400..bcd6bb9 100644 --- a/dirkules/config.py +++ b/dirkules/config.py @@ -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 diff --git a/dirkules/driveManagement/driveController.py b/dirkules/driveManagement/driveController.py index 3bf4a34..7885f29 100644 --- a/dirkules/driveManagement/driveController.py +++ b/dirkules/driveManagement/driveController.py @@ -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(): diff --git a/dirkules/models.py b/dirkules/models.py index 67ae0ec..81deb97 100644 --- a/dirkules/models.py +++ b/dirkules/models.py @@ -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) diff --git a/dirkules/templates/base.html b/dirkules/templates/base.html index 31d853a..f5143a1 100644 --- a/dirkules/templates/base.html +++ b/dirkules/templates/base.html @@ -22,6 +22,7 @@
Laufwerk | +Name | +Speicherplatz | +SMART Status | +
---|---|---|---|
{{drive.device}} | +{{drive.name}} | +{{drive.size}} | +{{drive.smart}} | +