Ejemplo n.º 1
0
    def handle(self, *args, **options):
        for item in args:
            if options['delete']:
                try:
                    Satellite.objects.get(norad_cat_id=item).delete()
                    self.stdout.write('Satellite {}: deleted'.format(item))
                    continue
                except:
                    raise CommandError(
                        'Satellite with Identifier {} does not exist'.format(
                            item))

            try:
                sat = satellite(item)
            except:
                raise CommandError(
                    'Satellite with Identifier {} does not exist'.format(item))

            try:
                obj = Satellite.objects.get(norad_cat_id=item)
            except:
                obj = Satellite(norad_cat_id=item)

            obj.name = sat.name()
            obj.save()

            self.stdout.write('fetched data for {}: {}'.format(
                obj.norad_cat_id, obj.name))
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        for item in args:
            if options['delete']:
                try:
                    Satellite.objects.get(norad_cat_id=item).delete()
                    self.stdout.write('Satellite {}: deleted'.format(item))
                    continue
                except:
                    raise CommandError('Satellite with Identifier {} does not exist'.format(item))

            try:
                sat = satellite(item)
            except:
                raise CommandError('Satellite with Identifier {} does not exist'.format(item))

            try:
                obj = Satellite.objects.get(norad_cat_id=item)
            except:
                obj = Satellite(norad_cat_id=item)

            obj.name = sat.name()
            tle = sat.tle()
            obj.tle0 = tle[0]
            obj.tle1 = tle[1]
            obj.tle2 = tle[2]
            obj.save()

            self.stdout.write('fetched data for {}: {}'.format(obj.norad_cat_id, obj.name))
Ejemplo n.º 3
0
    def handle(self, *args, **options):

        satellites = Satellite.objects.all()

        self.stdout.write("==Fetching TLEs==")

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('Satellite {} with Identifier {} does '
                                  'not exist').format(obj.name, obj.norad_cat_id))
                continue

            obj.name = sat.name()
            obj.save()

            # Get latest satellite TLE and check if it changed
            tle = sat.tle()
            try:
                latest_tle = obj.latest_tle.tle1
                if latest_tle == tle[1]:
                    self.stdout.write(('Satellite {} with Identifier {} '
                                      'found [defer]').format(obj.name, obj.norad_cat_id))
                    continue
            except:
                pass

            Tle.objects.create(tle0=tle[0], tle1=tle[1], tle2=tle[2], satellite=obj)

            self.stdout.write(('Satellite {} with Identifier {} '
                              'found [updated]').format(obj.name, obj.norad_cat_id))
Ejemplo n.º 4
0
def update_all_tle():
    satellites = Satellite.objects.all()

    for obj in satellites:
        try:
            sat = satellite(obj.norad_cat_id)
        except:
            continue

        tle = sat.tle()
        obj.tle1 = tle[1]
        obj.tle2 = tle[2]
        obj.save()
Ejemplo n.º 5
0
def update_all_tle():
    """Task to update all satellite TLEs"""
    satellites = Satellite.objects.all()

    for obj in satellites:
        try:
            sat = satellite(obj.norad_cat_id)
        except:
            continue

        tle = sat.tle()
        obj.tle1 = tle[1]
        obj.tle2 = tle[2]
        obj.save()
Ejemplo n.º 6
0
    def handle(self, *args, **options):

        satellites = Satellite.objects.all()

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('Satellite {} with Identifier {} does '
                                  'not exist').format(obj.name, obj.norad_cat_id))
                continue

            obj.name = sat.name()
            obj.save()
            self.stdout.write(('Satellite {} with Identifier {} '
                              'found [updated]').format(obj.norad_cat_id, obj.name))
Ejemplo n.º 7
0
    def handle(self, *args, **options):

        satellites = Satellite.objects.all()

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('Satellite {} with Identifier {} does '
                                  'not exist').format(obj.name, obj.norad_cat_id))
                continue

            tle = sat.tle()
            obj.tle1 = tle[1]
            obj.tle2 = tle[2]
            obj.save()
            self.stdout.write(('Satellite {} with Identifier {} '
                              'found [updated]').format(obj.name, obj.norad_cat_id))
Ejemplo n.º 8
0
    def handle(self, *args, **options):
        for arg in args:
            try:
                start, end = arg.split(':')
            except ValueError:
                raise CommandError(
                    'You need to spacify the range in the form: xxxx:xxxx')

        r = range(int(start), int(end))
        for item in r:
            if options['delete']:
                try:
                    Satellite.objects.get(norad_cat_id=item).delete()
                    self.stdout.write('Satellite {}: deleted'.format(item))
                    continue
                except:
                    self.stdout.write(
                        'Satellite with Identifier {} does not exist'.format(
                            item))
                    continue

            try:
                sat = satellite(item)
            except:
                self.stdout.write(
                    'Satellite with Identifier {} does not exist'.format(item))
                continue

            try:
                obj = Satellite.objects.get(norad_cat_id=item)
            except:
                obj = Satellite(norad_cat_id=item)

            obj.name = sat.name()
            obj.tle = str(sat.tle())
            obj.save()

            self.stdout.write('fetched data for {}: {}'.format(
                obj.norad_cat_id, obj.name))
    def handle(self, *args, **options):

        satellites = Satellite.objects.exclude(manual_tle=True)

        self.stdout.write("==Fetching TLEs==")

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('Satellite {} with Identifier {} does '
                                   'not exist').format(obj.name,
                                                       obj.norad_cat_id))
                continue

            obj.name = sat.name()
            obj.save()

            # Get latest satellite TLE and check if it changed
            tle = sat.tle()
            try:
                latest_tle = obj.latest_tle.tle1
                if latest_tle == tle[1]:
                    self.stdout.write(
                        ('Satellite {} with Identifier {} '
                         'found [defer]').format(obj.name, obj.norad_cat_id))
                    continue
            except:
                pass

            Tle.objects.create(tle0=tle[0],
                               tle1=tle[1],
                               tle2=tle[2],
                               satellite=obj)

            self.stdout.write(
                ('Satellite {} with Identifier {} '
                 'found [updated]').format(obj.name, obj.norad_cat_id))
Ejemplo n.º 10
0
    def handle(self, *args, **options):
        ObservationFactory.create_batch(20)
        StationFactory.create_batch(20)

        satellites = Satellite.objects.all()

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('Satellite {} with Identifier {} does '
                                  'not exist [deleted]').format(obj.name, obj.norad_cat_id))
                obj.delete()
                continue

            obj.name = sat.name()
            tle = sat.tle()
            obj.tle0 = tle[0]
            obj.tle1 = tle[1]
            obj.tle2 = tle[2]
            obj.save()
            self.stdout.write(('Satellite {} with Identifier {} '
                              'found [updated]').format(obj.norad_cat_id, obj.name))
Ejemplo n.º 11
0
def update_all_tle():
    """Task to update all satellite TLEs"""
    satellites = Satellite.objects.exclude(manual_tle=True)

    for obj in satellites:
        try:
            sat = satellite(obj.norad_cat_id)
        except:
            continue

        # Get latest satellite TLE and check if it changed
        tle = sat.tle()
        try:
            latest_tle = obj.latest_tle.tle1
        except:
            pass
        if latest_tle == tle[1]:
            continue

        Tle.objects.create(tle0=tle[0],
                           tle1=tle[1],
                           tle2=tle[2],
                           satellite=obj)
Ejemplo n.º 12
0
    def handle(self, *args, **options):
        for arg in args:
            try:
                start, end = arg.split(':')
            except ValueError:
                raise CommandError('You need to spacify the range in the form: xxxx:xxxx')

        r = range(int(start), int(end))
        for item in r:
            if options['delete']:
                try:
                    Satellite.objects.get(norad_cat_id=item).delete()
                    self.stdout.write('Satellite {}: deleted'.format(item))
                    continue
                except:
                    self.stdout.write('Satellite with Identifier {} does not exist'.format(item))
                    continue

            try:
                sat = satellite(item)
            except:
                self.stdout.write('Satellite with Identifier {} does not exist'.format(item))
                continue

            try:
                obj = Satellite.objects.get(norad_cat_id=item)
            except:
                obj = Satellite(norad_cat_id=item)

            obj.name = sat.name()
            tle = sat.tle()
            obj.tle0 = tle[0]
            obj.tle1 = tle[1]
            obj.tle2 = tle[2]
            obj.save()

            self.stdout.write('fetched data for {}: {}'.format(obj.norad_cat_id, obj.name))
    def handle(self, *args, **options):

        satellites = Satellite.objects.exclude(manual_tle=True)

        self.stdout.write("==Fetching TLEs==")

        for obj in satellites:
            try:
                sat = satellite(obj.norad_cat_id)
            except:
                self.stdout.write(('{0} - {1}: TLE not found [error]').format(
                    obj.name, obj.norad_cat_id))
                continue

            obj.name = sat.name()
            obj.save()

            # Get latest satellite TLE and check if it changed
            tle = sat.tle()
            latest_tle = None
            try:
                latest_tle = obj.latest_tle.tle1
            except:
                pass
            if latest_tle == tle[1]:
                self.stdout.write(
                    ('{0} - {1}: TLE already exists [defer]').format(
                        obj.name, obj.norad_cat_id))
                continue

            Tle.objects.create(tle0=tle[0],
                               tle1=tle[1],
                               tle2=tle[2],
                               satellite=obj)
            self.stdout.write(('{0} - {1}: new TLE found [updated]').format(
                obj.name, obj.norad_cat_id))