setup.py 951 Bytes
Newer Older
Skia's avatar
Skia committed
1
import os
Skia's avatar
Skia committed
2
3
from django.core.management.base import BaseCommand, CommandError
from django.core.management import call_command
4
from django.conf import settings
Skia's avatar
Skia committed
5
6


Skia's avatar
Skia committed
7
8
9
class Command(BaseCommand):
    help = "Set up a new instance of the Sith AE"

Skia's avatar
Skia committed
10
11
12
    def add_arguments(self, parser):
        parser.add_argument('--prod', action="store_true")

Skia's avatar
Skia committed
13
    def handle(self, *args, **options):
Skia's avatar
Skia committed
14
        root_path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
Skia's avatar
Skia committed
15
        try:
Skia's avatar
Skia committed
16
            os.mkdir(os.path.join(root_path)+'/data')
17
            print("Data dir created")
Skia's avatar
Skia committed
18
        except Exception as e:
19
20
21
22
23
24
            repr(e)
        try:
            os.remove(os.path.join(root_path, 'db.sqlite3'))
            print("db.sqlite3 deleted")
        except Exception as e:
            repr(e)
Skia's avatar
Skia committed
25
        call_command('migrate')
Skia's avatar
Skia committed
26
27
28
29
        if options['prod']:
            call_command('populate', '--prod')
        else:
            call_command('populate')