Commit d67a47b1 authored by Jonathan Schaeffer's avatar Jonathan Schaeffer
Browse files

Using subprocess stdout on the fly

parent e85a86e4
......@@ -3,6 +3,7 @@
import logging
import os
import sys
import io
import subprocess
from time import gmtime, strftime
from datetime import datetime, date, timedelta
......@@ -28,11 +29,10 @@ def scan_volume(path):
logger.debug("Volume %s", volume)
# TODO mettre le niveau de profondeur (2) en option
starttime =
lines = subprocess.check_output(
["du", "--exclude", ".snapshot", "-b", "-d4", volume]).decode("utf-8").splitlines()
logger.debug("Volume scanned in %s", - starttime)
for l in lines:
logger.debug("Scanning %s",l)
proc = subprocess.Popen(["du", "--exclude", ".snapshot", "-b", "-d4", volume], stdout=subprocess.PIPE)
for l in io.TextIOWrapper(proc.stdout, encoding='utf-8'):
l = l.strip()
logger.debug("Scanned %s",l)
(size, path) = l.split('\t')
# On ne garde que le chemin qui nous intéresse
path = path.replace(volume, '').split('/')
......@@ -43,6 +43,7 @@ def scan_volume(path):
data.append({'year': path[1], 'network': path[0], 'station': path[2],
'channel': channel, 'quality': quality, 'size': size})
logger.debug("Volume scanned in %s", - starttime)
return data
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