Exemple #1
0
    def handle(self, *args, **options):

        if not len(args) == 1:
            raise CommandError('add_gedcom takes only one argument - the path to a gedcom file.')

        file_name = args[0]
        if not path.exists(file_name):
            raise CommandError('Gedcom file "%s" not found.' % file_name)
        if (not len(file_name) > 4) or (not file_name[-4:] == '.ged'):
            raise CommandError('File "%s" does not appear to be a .ged file.' % file_name)

        update_from_file(None, file_name)
Exemple #2
0
    def handle(self, *args, **options):

        if not len(args) == 1:
            raise CommandError(
                'add_gedcom takes only one argument - the path to a gedcom file.'
            )

        file_name = args[0]
        if not path.exists(file_name):
            raise CommandError('Gedcom file "%s" not found.' % file_name)
        if (not len(file_name) > 4) or (not file_name[-4:] == '.ged'):
            raise CommandError('File "%s" does not appear to be a .ged file.' %
                               file_name)

        update_from_file(None, file_name)
Exemple #3
0
    def handle(self, *args, **options):
        # arg init
        gid = args[0]
        try:
            g = Gedcom.objects.get(pk=gid)
        except:
            raise CommandError('Gedcom "%s" does not exist.' % gid)

        file_name = args[1]
        if not path.exists(file_name):
            raise CommandError('Gedcom file "%s" not found.' % file_name)
        if (not len(file_name) > 4) or (not file_name[-4:] == '.ged'):
            raise CommandError('File "%s" does not appear to be a .ged file.' %
                               file_name)

        # Check file time against gedcom last_update time.
        file_time = datetime.fromtimestamp(path.getmtime(file_name))
        last_update_time = g.last_updated.replace(tzinfo=None)
        if (options['force'] or (file_time > last_update_time)):
            start = datetime.now()

            errstr = ''
            try:
                update_from_file(g, file_name)
            except:
                e = exc_info()[0]
                errstr = 'There was an error: %s\n%s' % (
                    e, traceback.format_exc())

            end = datetime.now()

            send_mail(
                'Gedcom file updated (' +
                (g.title if g.title else 'id = ' + str(g.id)) + ')',
                'Started:  ' + start.strftime('%B %d, %Y at %I:%M %p') + '\n' +
                'Finished: ' + end.strftime('%B %d, %Y at %I:%M %p') + '\n\n' +
                errstr,
                '*****@*****.**',
                settings.SERVER_EMAIL,
            )
Exemple #4
0
    def handle(self, *args, **options):
        # arg init
        gid = args[0]
        try:
            g = Gedcom.objects.get(pk=gid)
        except:
            raise CommandError('Gedcom "%s" does not exist.' % gid)

        file_name = args[1]
        if not path.exists(file_name):
            raise CommandError('Gedcom file "%s" not found.' % file_name)
        if (not len(file_name) > 4) or (not file_name[-4:] == '.ged'):
            raise CommandError('File "%s" does not appear to be a .ged file.' % file_name)

        # Check file time against gedcom last_update time.
        file_time = datetime.fromtimestamp(path.getmtime(file_name))
        last_update_time = g.last_updated.replace(tzinfo=None)
        if (options['force'] or (file_time > last_update_time)):
            start = datetime.now()

            errstr = ''
            try:
                update_from_file(g, file_name)
            except:
                e = exc_info()[0]
                errstr = 'There was an error: %s\n%s' % (e, traceback.format_exc())

            end = datetime.now()

            send_mail(
                'Gedcom file updated (' + (g.title if g.title else 'id = ' + str(g.id)) + ')',
                'Started:  ' + start.strftime('%B %d, %Y at %I:%M %p') + '\n' +
                'Finished: ' + end.strftime('%B %d, %Y at %I:%M %p') + '\n\n' +
                errstr,
                '*****@*****.**',
                settings.SERVER_EMAIL,
            )
Exemple #5
0
 def setUp(self):
     self.file_ = 'gedgo/static/test/test.ged'
     update_from_file(None, self.file_, verbose=False)
Exemple #6
0
 def test_update_from_gedcom(self):
 	g = Gedcom.objects.get()
     update_from_file(g, self.file_, verbose=False)
     self.assertEqual(Person.objects.count(), 6)
     self.assertEqual(Family.objects.count(), 2)
Exemple #7
0
 def setUp(self):
     self.file_ = 'gedgo/static/test/test.ged'
     update_from_file(None, self.file_, verbose=False)
Exemple #8
0
 def test_update_from_gedcom(self):
     g = Gedcom.objects.get()
     update_from_file(g, self.file_, verbose=False)
     self.assertEqual(Person.objects.count(), 6)
     self.assertEqual(Family.objects.count(), 2)