Commit 7fd82566 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

pep8

parent fba773b1
#!/bin/env python2
# -*- coding: utf-8 -*-
#!/bin/env python
import logging.config
import os
......@@ -7,7 +6,6 @@ import subprocess
from time import gmtime, strftime
import yaml
from influxdb import InfluxDBClient
from pprint import pformat
import datetime
import psycopg2
from psycopg2.extras import execute_values
......@@ -55,8 +53,8 @@ def scan_volume(path):
path = path.replace(volume, '').split('/')
# Ne pas considérer le seul chemin de niveau 1
if len(path) == 4:
logger.debug(f"path : {path}")
logger.debug(f"size : {size}")
logger.debug("path : %s",{path})
logger.debug("size : %s",{size})
(channel, quality) = path[3].split('.')
data.append({'year': path[0], 'network': path[1], 'station': path[2],
'channel': channel, 'quality': quality, 'size': size})
......@@ -84,7 +82,7 @@ def scan_volumes(volumes):
else:
raise ValueError("Volume has no path key : %s" % (volume))
# on applati la liste de listes :
logger.debug("All volumes scanned in %s" %
logger.debug("All volumes scanned in %s",
(datetime.datetime.now() - starttime))
return [x for vol in volume_stats for x in vol]
......@@ -92,10 +90,12 @@ def scan_volumes(volumes):
@click.command()
@click.option('--config-file', 'configfile', type=click.File(), help='Configuration file path', envvar='CONFIG_FILE', show_default=True, default=f"{os.path.dirname(os.path.realpath(__file__))}/config.yml")
def cli(configfile):
"""
Command line interface. Stands as main
"""
try:
cfg = yaml.load(configfile, Loader=yaml.SafeLoader)
except Error as e:
except:
print(f"Error reading file {configfile}")
validate_config(cfg)
......@@ -188,31 +188,31 @@ def cli(configfile):
influxdb_json_data.append(
{"measurement": cfg['influxdb']['measurement'],
"tags": {
"year": int(stat['year']),
"network": stat['network'],
"station": stat['station'],
"channel": stat['channel'],
"quality": stat['quality'],
"permanent": bool(stat['is_permanent']),
"type": stat['type'],
"date": stat['date']
},
"time": record_time,
"fields": {
"size": int(stat['size'])
}
"year": int(stat['year']),
"network": stat['network'],
"station": stat['station'],
"channel": stat['channel'],
"quality": stat['quality'],
"permanent": bool(stat['is_permanent']),
"type": stat['type'],
"date": stat['date']
},
"time": record_time,
"fields": {
"size": int(stat['size'])
}
}
)
logger.info(pformat(influxdb_json_data))
logger.info(influxdb_json_data)
# Now, send this data to influxdb
try:
logger.info("Sending data to influxdb")
logger.debug("host = "+cfg['influxdb']['server'])
logger.debug("port = "+str(cfg['influxdb']['port']))
logger.debug("database = "+cfg['influxdb']['database'])
logger.debug("username = "+cfg['influxdb']['user'])
logger.debug("host = %s", cfg['influxdb']['server'])
logger.debug("port = %s", str(cfg['influxdb']['port']))
logger.debug("database = %s", cfg['influxdb']['database'])
logger.debug("username = %s", cfg['influxdb']['user'])
client = InfluxDBClient(host=cfg['influxdb']['server'],
port=cfg['influxdb']['port'],
......
Markdown is supported
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