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

update

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