Commit 717196d5 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Code sanity check

parent c58510b2
......@@ -7,7 +7,7 @@ import subprocess
from time import gmtime,strftime
import yaml
from influxdb import InfluxDBClient
from pprint import pprint, pformat
from pprint import pformat
import datetime
import psycopg2
from psycopg2.extras import execute_values
......@@ -40,16 +40,16 @@ def scan_volume(path):
"""
data = []
volume = os.path.realpath(path)+'/'
logger.debug("Volume %s"%(volume))
logger.debug("Volume %s",volume)
# TODO mettre le niveau de profondeur (2) en option
starttime = datetime.datetime.now()
lines = subprocess.check_output(["du", "--exclude", ".snapshot", "-d4", volume]).decode("utf-8").splitlines()
logger.debug("Volume scanned in %s"%(datetime.datetime.now() - starttime))
logger.debug("Volume scanned in %s",datetime.datetime.now() - starttime)
for l in lines:
logger.debug(l)
(size, path) = l.split('\t')
# On ne garde que le chemin qui nous intéresse
path = path.replace(volume,'').split('/')
path = path.replace(volume, '').split('/')
# Ne pas considérer le seul chemin de niveau 1
if len(path) == 4:
logger.debug(f"path : {path}")
......@@ -146,7 +146,6 @@ def cli(configfile):
stat['date'] = today
logger.debug(stat)
# Open dump file and write the stats.
if use_cache == False:
try:
......@@ -157,8 +156,7 @@ def cli(configfile):
},
outfile, default_flow_style=False)
except:
logger.error("Error writing data to cache : "+sys.exc_info()[0])
logger.error("Error writing data to cache")
# Write to postgres database
if 'postgres' in cfg:
......@@ -219,8 +217,3 @@ def cli(configfile):
except Exception as e:
logger.error("Unexpected error writing data to influxdb")
logger.error(e)
if __name__ == "__main__":
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment