def get_canonical_path(self): owner_dir = self.deployment.owner.code deployment_dir = "%s-%s" % (self.deployment.site.code, self.deployment.start.\ astimezone(pytz.timezone(self.deployment.start_timezone)).\ strftime('%Y-%m-%d')) name = "%s-%s-%s.wav" % ( self.deployment.owner.code, self.deployment.site.code, isotime(self.datetime), ) return os.path.join(settings.RECORDINGS_ROOT, owner_dir, deployment_dir, name)
def handle(self, *args, **options): # First, fix the deployment times logging.info("fix deployment times") # for d in Deployment.objects.all(): # logging.info(d) # d.start = pytz.timezone(d.start_timezone).localize(d.start.replace(tzinfo=None)).astimezone(utc) # d.end = pytz.timezone(d.start_timezone).localize(d.end.replace(tzinfo=None)).astimezone(utc) # d.save() # print d.start, d.end already = 0 moved = 0 for r in Recording.objects.all(): if 'Z' in r.path: already += 1 logging.info('%s. Already moved %s' % (already, r)) continue # Second, check that the files are where they are expected to be if not r.verify_hash(): msg = "Something wrong wth file %s" % r.path logging.error(msg) else: moved += 1 logging.info('%s. Moving %s' % (moved, r)) # Third, update the datetime in the database r.datetime = pytz.timezone(r.deployment.start_timezone).localize(r.datetime.replace(tzinfo=None)).astimezone(utc) r.save() # Fourth, move the file directory, name = os.path.split(r.path) new_name = "%s-%s-%s.wav" % (r.deployment.owner.code, r.deployment.site.code, isotime(r.datetime)) new_path = os.path.join(directory, new_name) os.rename(r.path, new_path) #Fively, update the path to match r.path = new_path r.save() if not r.verify_hash(): msg = "Oops. Something wrong wth file %s" % r.path logging.error(msg) raise ValueError, msg
def get_canonical_path(self): owner_dir = self.deployment.owner.code deployment_dir = "%s-%s" % ( self.deployment.site.code, self.deployment.start.astimezone(pytz.timezone(self.deployment.start_timezone)).strftime("%Y-%m-%d"), ) name = "%s-%s-%s.wav" % (self.deployment.owner.code, self.deployment.site.code, isotime(self.datetime)) return os.path.join(settings.RECORDINGS_ROOT, owner_dir, deployment_dir, name)
def __unicode__(self): return "%s-%s-%s" % (self.deployment.owner.code, self.deployment.site.code, isotime(self.datetime))
def __unicode__(self): return "%s-%s-%s" % (self.owner.code, self.site, isotime(self.start))
def __unicode__(self): return '%s-%s-%s' % (self.deployment.owner.code, self.deployment.site.code, isotime(self.datetime))
def __unicode__(self): return '%s-%s-%s' % ( self.owner.code, self.site, isotime(self.start), )