def generate_symlinks(self):
     for (path, subdirs, files) in os.walk(self.indir):
         subdirs.sort()
         files.sort()
         for fname in files:
             dt = dateutil.parser.parse(fname.split('.')[0])
             sidtime = get_sidereal_time(dt)
             self.symlink(
                 os.path.abspath(os.path.realpath(os.path.join(path,fname))),
                 join(self.outdir,
                     str(sidtime.seconds/3600).zfill(2),
                     str((sidtime.seconds/60)%60).zfill(2),
                     fname))
Esempio n. 2
0
import clouds.settings
setup_environ(clouds.settings)

from clouds.models import Image, SidTime 
import datetime, os
import dateutil.parser
from utils import sidday, timedelta_as_time, get_sidereal_time

try:
    os.mkdir('tmp')
except OSError: pass

delta = datetime.timedelta(minutes=1)
s = datetime.timedelta(0)
while s < sidday:
    sidtime = SidTime(time=timedelta_as_time(s))
    sidtime.save()
    s += delta

for (path, subdirs, files) in os.walk('sym'):
    subdirs.sort()
    files.sort()

    for fname in files:
        dt = dateutil.parser.parse(fname.split('.')[0])
        sidtime = SidTime.objects.filter(time__lt=get_sidereal_time(dt)).order_by('-time')[0]
        image = Image(datetime=dt, sidtime=sidtime)
        image.save()