Commit 6dd212eb authored by Mario Chirinos's avatar Mario Chirinos

update

parent 72672389
......@@ -10,6 +10,10 @@ import dateutil.parser
import itertools
from datetime import date
updateRadioStations = False
recordingsDir = "/home/geoint/M3_NFS/recordings/"
class Command(BaseCommand):
help = 'Update database'
......@@ -18,14 +22,11 @@ class Command(BaseCommand):
parser.add_argument('basedir', nargs=1, type=str)
def handle(self, *args, **options):
if False:
#update radio stations recotding time
if updateRadioStations:
print("Recording Time:")
# recordingsDir = "/home/mario/virtualHDD/m3/recordings/"
recordingsDir = "/home/geoint/M3_NFS/recordings/"
audioTime.objects.all().delete()
audioTime.objects.all().delete() #reset
publishers = Publisher.objects.all().filter(type="audio")
for p in publishers:
files = [files for r, d, files in os.walk(recordingsDir+p.shortName) if files]
......@@ -50,7 +51,7 @@ class Command(BaseCommand):
print("endDate: ", endDate)
audioTime.objects.update_or_create(publisher=p, defaults={'minutes': minutes, "startDate": since, "endDate":endDate},)
#load news
#Load news
os.chdir(options['basedir'][0])
publisherList = [ i for i in os.listdir(options['basedir'][0]) if os.path.isdir(i) ]
for p in publisherList:
......@@ -72,6 +73,7 @@ class Command(BaseCommand):
newPublisher.type="texto"
newPublisher.save()
publisher = Publisher.objects.all().filter(shortName=p)
publisher=publisher[0]
......
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