This commit is contained in:
bkfox
2018-07-01 19:24:22 +02:00
parent 08f519451a
commit 34b72b4485
3 changed files with 60 additions and 86 deletions

View File

@ -258,42 +258,6 @@ class Command(BaseCommand):
logger.info('%s, %s: %s', str(program), str(component),
' '.join([str(c) for c in content]))
def add_arguments(self, parser):
parser.formatter_class=RawTextHelpFormatter
parser.add_argument(
'-q', '--quality_check', action='store_true',
help='Enable quality check using sound_quality_check on all ' \
'sounds marqued as not good'
)
parser.add_argument(
'-s', '--scan', action='store_true',
help='Scan programs directories for changes, plus check for a '
' matching diffusion on sounds that have not been yet assigned'
)
parser.add_argument(
'-m', '--monitor', action='store_true',
help='Run in monitor mode, watch for modification in the filesystem '
'and react in consequence'
)
def handle(self, *args, **options):
if options.get('scan'):
self.scan()
if options.get('quality_check'):
self.check_quality(check = (not options.get('scan')) )
if options.get('monitor'):
self.monitor()
@staticmethod
def check_sounds(qs):
"""
Only check for the sound existence or update
"""
# check files
for sound in qs:
if sound.check_on_file():
sound.save(check = False)
def scan(self):
"""
For all programs, scan dirs
@ -314,10 +278,6 @@ class Command(BaseCommand):
)
dirs.append(os.path.join(program.path))
# extra scan for files that are not in programs' dir anymore
# TODO
def scan_for_program(self, program, subdir, **sound_kwargs):
"""
Scan a given directory that is associated to the given program, and
@ -350,6 +310,16 @@ class Command(BaseCommand):
exclude(pk__in = sounds)
self.check_sounds(sounds)
@staticmethod
def check_sounds(qs):
"""
Only check for the sound existence or update
"""
# check files
for sound in qs:
if sound.check_on_file():
sound.save(check = False)
def check_quality(self, check = False):
"""
Check all files where quality has been set to bad
@ -419,4 +389,29 @@ class Command(BaseCommand):
while True:
time.sleep(1)
def add_arguments(self, parser):
parser.formatter_class=RawTextHelpFormatter
parser.add_argument(
'-q', '--quality_check', action='store_true',
help='Enable quality check using sound_quality_check on all ' \
'sounds marqued as not good'
)
parser.add_argument(
'-s', '--scan', action='store_true',
help='Scan programs directories for changes, plus check for a '
' matching diffusion on sounds that have not been yet assigned'
)
parser.add_argument(
'-m', '--monitor', action='store_true',
help='Run in monitor mode, watch for modification in the filesystem '
'and react in consequence'
)
def handle(self, *args, **options):
if options.get('scan'):
self.scan()
if options.get('quality_check'):
self.check_quality(check = (not options.get('scan')) )
if options.get('monitor'):
self.monitor()

View File

@ -94,8 +94,6 @@ class Monitor:
self.station = station
self.__dict__.update(kwargs)
now = tz.now()
def monitor(self):
"""
Run all monitoring functions.
@ -191,16 +189,18 @@ class Monitor:
comment = current_sound,
)
# tracks -- only for streams
if not log.diffusion:
self.trace_sound_tracks(log)
# trace tracks
self.trace_sound_tracks(log)
def trace_sound_tracks(self, log):
"""
Log tracks for the given sound log (for streamed programs).
Log tracks for the given sound log (for streamed programs only).
Called by self.trace
"""
if log.diffusion:
return
tracks = Track.objects.get_for(object = log.sound) \
.filter(in_seconds = True)
if not tracks.exists():