mirror of
https://github.com/fergalmoran/dss.git
synced 2026-02-13 03:23:59 +00:00
27 lines
936 B
Python
27 lines
936 B
Python
import logging
|
|
import os
|
|
from django.core.management.base import NoArgsCommand
|
|
from spa.models.mix import Mix
|
|
from datetime import datetime
|
|
import time
|
|
|
|
|
|
class Command(NoArgsCommand):
|
|
help = "Change file modified date to mix upload date (easier sorting in airtime)"
|
|
logger = logging.getLogger(__name__)
|
|
|
|
def handle_noargs(self, **options):
|
|
self.logger.debug("Updating file times")
|
|
mixes = Mix.objects.all()
|
|
try:
|
|
for mix in mixes:
|
|
self.logger.debug("Setting file time: %s" % mix.title)
|
|
mix_file = mix.get_absolute_path()
|
|
if os.path.isfile(mix_file):
|
|
os.utime(mix_file,
|
|
(time.mktime(datetime.now().timetuple()), time.mktime(mix.upload_date.timetuple())))
|
|
except Exception:
|
|
self.logger.exception("Error changing create date: %s" % mix.uid)
|
|
|
|
print "Finished tagging"
|