Ejemplo n.º 1
0
 def __init__(self, request):
     self.batchpath = request.GET.get('batchpath') or request.POST.get('batchpath') or DEFAULT_BATCH_PATH
     self.batch = Batch(self.batchpath)
     self.ArtistFormSet = formset_factory(ArtistForm, formset=DataFormSet, extra=0)
     self.LabelFormSet = formset_factory(LabelForm, formset=DataFormSet, extra=0)
     self.ReleaseFormSet = formset_factory(ReleaseForm, formset=DataFormSet, extra=0)
     self.bad_deliveries = list(self.batch.bad_deliveries())
Ejemplo n.º 2
0
default_disc = Disc.objects.get(status='default')
albums_directory = os.path.join(default_disc.full_path(), main_localsettings.ALBUMS_DIRECTORY)
if os.path.exists(albums_directory):
    """
    Clean the directory
    """
    shutil.rmtree(albums_directory)
if not os.path.exists(albums_directory):
    os.makedirs(albums_directory)


"""
Clean the database of all previous ingestions
"""
from mp3.ingestion.models import Batch
batch = Batch(DEFAULT_BATCH_PATH)
from django.db import connection
for delivery in batch.good_deliveries():
    try:
        album = Album.objects.get(albumvendor__external_album_id=delivery.release.pk)
        artist = album.artist
        album.label.delete()
        artist.delete()
    except Album.DoesNotExist:
        try:
            Artist.objects.get(artistvendor__external_artist_id=delivery.artist.pk).delete()
        except (Artist.DoesNotExist, AttributeError):
            pass
        try:
            Label.objects.get(labelvendor__external_label_id=delivery.label.pk).delete()
        except (Label.DoesNotExist, AttributeError):