Esempio n. 1
0
def analyze(request, id, name):
    storage = get_object_or_404(filter_by_access(request.user, Storage.objects.filter(id=id), manage=True))
    broken, extra = analyze_media(storage)
    return render_to_response('storage_analyze.html',
                          {'storage': storage,
                           'broken': broken,
                           'extra': extra,
                           },
                          context_instance=RequestContext(request))
Esempio n. 2
0
def analyze(request, id, name):
    storage = get_object_or_404(filter_by_access(request.user, Storage.objects.filter(id=id), manage=True))
    broken, extra = analyze_media(storage)
    return render_to_response('storage_analyze.html',
                          {'storage': storage,
                           'broken': broken,
                           'extra': extra,
                           },
                          context_instance=RequestContext(request))
Esempio n. 3
0
def analyze(request, id, name, allow_multiple_use=True):
    storage = get_object_or_404(filter_by_access(request.user, Storage.objects.filter(id=id), manage=True))
    broken, extra = analyze_media(storage, allow_multiple_use)
    broken = [m.url for m in broken]
    return render_to_response('storage_analyze.html',
                          {'storage': storage,
                           'broken': sorted(broken),
                           'extra': sorted(extra),
                           },
                          context_instance=RequestContext(request))
Esempio n. 4
0
    def testAnalyzeMedia(self):

        broken, extra = analyze_media(self.storage)

        self.assertEqual(1, len(broken))
        self.assertEqual('id_missing.txt', broken[0].url)

        self.assertEqual(2, len(extra))
        extra = sorted(extra)
        self.assertEqual('id_2.txt', extra[0])
        self.assertEqual(os.path.join('sub', 'id_99.txt'), extra[1])
Esempio n. 5
0
    def testAnalyzeMedia(self):
        no_signals()
        broken, extra = analyze_media(self.storage)

        self.assertEqual(1, len(broken))
        self.assertEqual('id_missing.txt', broken[0].url)

        self.assertEqual(2, len(extra))
        extra = sorted(extra)
        self.assertEqual('id_2.txt', extra[0])
        self.assertEqual(os.path.join('sub', 'id_99.txt'), extra[1])
Esempio n. 6
0
def analyze(request, id, name, allow_multiple_use=True):
    storage = get_object_or_404(
        filter_by_access(request.user,
                         Storage.objects.filter(id=id),
                         manage=True))
    broken, extra = analyze_media(storage, allow_multiple_use)
    broken = [m.url for m in broken]
    return render_to_response('storage_analyze.html', {
        'storage': storage,
        'broken': sorted(broken),
        'extra': sorted(extra),
    },
                              context_instance=RequestContext(request))
Esempio n. 7
0
def analyze_media_task(self, owner, storage_id):
    storage = filter_by_access(User.objects.get(id=owner),
                               Storage.objects.filter(id=storage_id),
                               manage=True)[0]
    broken, extra = analyze_media(storage, True)
    broken = [m.url for m in broken]
    attachment = get_attachment(self)
    with open(attachment, 'w') as report:
        report.write('Analyze Report for Storage %s (%d)\n\n' %
                     (storage.name, storage.id))
        report.write('Created on %s\n\n' % datetime.now())
        report.write('%d MISSING FILES:\n' % len(broken))
        report.write('\n'.join(sorted(broken)))
        report.write('\n\n%d EXTRA FILES:\n' % len(extra))
        report.write('\n'.join(sorted(extra)))
    return {
        'attachment': attachment,
    }