mirror of
https://github.com/vale981/dirkules
synced 2025-03-05 09:21:38 -05:00
db updates
This commit is contained in:
parent
e9ec305a29
commit
413bdfe644
4 changed files with 53 additions and 29 deletions
|
@ -3,6 +3,7 @@ import psutil
|
|||
import subprocess
|
||||
import os
|
||||
from dirkules.models import Drive
|
||||
from dirkules import db
|
||||
|
||||
|
||||
def getAllDrives():
|
||||
|
@ -34,9 +35,13 @@ 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
|
||||
sortedDriveDict = sorted(driveDict, key=lambda drive: drive['device'])
|
||||
|
||||
#add to db
|
||||
#db.session.add(Drive(values[0], values[1], values[2], values[3]))
|
||||
#db.session.commit()
|
||||
|
||||
return sortedDriveDict
|
||||
|
||||
|
||||
def smartPassed(device):
|
||||
|
|
|
@ -13,6 +13,12 @@ class Drive(db.Model):
|
|||
smart = db.Column(db.Boolean)
|
||||
partitions = db.relationship("Partitions")
|
||||
|
||||
def __init__(self, device, name, smart, size):
|
||||
self.device = device
|
||||
self.name = name
|
||||
self.smart = smart
|
||||
self.size = size
|
||||
|
||||
|
||||
class Partitions(db.Model):
|
||||
__tablename__ = 'partitions'
|
||||
|
@ -23,3 +29,14 @@ class Partitions(db.Model):
|
|||
uuid = db.Column(db.String)
|
||||
mountpoint = db.Column(db.String)
|
||||
label = db.Column(db.String)
|
||||
|
||||
|
||||
class Times(db.Model):
|
||||
__tablename__ = 'times'
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
desc = db.Column(db.String)
|
||||
time = db.Column(db.Integer, default=0, onupdate=1)
|
||||
|
||||
def __init__(self, desc, time):
|
||||
self.desc = desc
|
||||
self.time = time
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
{% extends "base.html" %}
|
||||
{% block title %}Dashboard{% endblock %}
|
||||
{% block head %}
|
||||
{{ super() }}
|
||||
{{ super() }}
|
||||
{% endblock %}
|
||||
{% block body %}
|
||||
<div class="title">
|
||||
<t1>Festplatten</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>
|
||||
<div class="title">
|
||||
<t1>Festplatten</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>
|
||||
<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 %}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from flask import Flask, render_template
|
||||
from dirkules import app
|
||||
import dirkules.driveManagement.driveController as drico
|
||||
from dirkules.models import Drive
|
||||
|
||||
|
||||
@app.route('/', methods=['GET'])
|
||||
|
@ -11,6 +12,7 @@ def index():
|
|||
@app.route('/drives', methods=['GET'])
|
||||
def drives():
|
||||
drives = drico.getAllDrives()
|
||||
print(Drive.query.filter_by(device='/dev/sda').all())
|
||||
return render_template('drives.html', drives=drives)
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue