-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstaller.py
78 lines (57 loc) · 3 KB
/
installer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# -*- coding: utf-8 -*-
""" This script is to setup the local development environment
Assumption: settings is configured to use sqlite database
for the digas database!
Do not run this thingy in production.
"""
import os
import sys
import subprocess
import django
# Forteller hvor django finner settingsene for podkastprosjektet.
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "podkast.settings")
django.setup()
# Most work done here to the default database.
subprocess.call("python manage.py migrate", shell=True)
# Secondly, we create tables for the local fake dev digas sqlite db.
#
# Will produce an error "missing django_content_types" or something
# -- ignore it, those are already installed in the default db.
subprocess.call("python manage.py migrate --database digas podcastserver 0001", shell=True)
print( "\n" * 4)
print("""
Ignore the error above if it says:
django.db.utils.OperationalError: no such table: django_content_type
Lets create a superuser now.
""")
#createsuperuser (googled how to automate creating superuser django)
from django.contrib.auth.models import User
User.objects.create_superuser('admin', '[email protected]', '1234')
print("""
-------------------------------------------------------------------
ALMOST DONE
-------------------------------------------------------------------
Superuser Admin created:
username: admin
password: 1234
OK :). Take note.
And now you should load test data into the local databases.
""")
def load_tulledata():
print("Laster mockdata inn i db. For å ha noe der. Podcasts og sann.")
subprocess.call('python manage.py loaddata --database digas digastull', shell=True)
subprocess.call('python manage.py loaddata --database default podcasttull', shell=True)
# Hack to make py2 and py3 input work.
if sys.version[0] =='2':
input = raw_input
load_it = input("Vill du laste inn testdata til bruk for utvikling? (ja/nei): ")
if 'j' in load_it.lower():
load_tulledata()
def the_end():
return """
FINISHED SETTING UP LOCAL DEVELOPMENT ENVIRONMENT :)!
Hint: you might want to do this now:
1. run: python manage.py runserver
2. go to http://127.0.0.1:8000 in your browser.
"""
print(the_end())