42 lines
983 B
Python
42 lines
983 B
Python
from models import File
|
|
import os
|
|
|
|
def clean_nulls():
|
|
x = []
|
|
for f in File.objects.all():
|
|
try:
|
|
fil = f.file.url
|
|
if not fil.startswith("/static"):
|
|
print fil
|
|
except ValueError:
|
|
f.delete()
|
|
|
|
def clean_relative_links():
|
|
for f in File.objects.all():
|
|
if f.file.url.startswith("/srv"):
|
|
new_url = f.file.url.replace("/srv/edgware/edgware/static/", "")
|
|
print "%s CHANGED TO %s" % (f.file.url, new_url,)
|
|
f.file = new_url
|
|
f.save()
|
|
print "woohoo!"
|
|
|
|
def file_exists():
|
|
exists = 0
|
|
not_found = 0
|
|
for f in File.objects.all():
|
|
if os.path.exists(f.file.path):
|
|
exists += 1
|
|
else:
|
|
not_found +=1
|
|
print "exist: %d \n" % exists
|
|
print "do not exist: %d" % not_found
|
|
|
|
|
|
def manage_types():
|
|
videos = 0
|
|
audios = 0
|
|
images = 0
|
|
|
|
for f in File.objects.all():
|
|
typ = f.type
|
|
|