forked from inkcut/inkcut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-app.py
66 lines (53 loc) · 1.89 KB
/
setup-app.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
#!/usr/bin/env python
"""Setup the inkcut application"""
import sys
import os
import logging
dirname = os.path.dirname
sys.path.append(os.path.join(os.path.abspath(dirname(dirname(__file__))),'app'))
from inkcut import Inkcut
from lib.meta import Session, Base
from lib.job import Job
from lib.device import Device
from lib.material import Material
log = logging.getLogger(__name__)
def setup_app():
"""Setup the Inkcut database and other application settings"""
app = Inkcut()
try:
# Create the tables if they don't already exist
Base.metadata.drop_all(checkfirst=True, bind=app.session.bind)
Base.metadata.create_all(bind=app.session.bind)
# Add some stuff the the db
log.info('Create Materials')
material = Material(name=u'3M 180C White',
cost=.47,width=38.1,length=100,
velocity=16,force=80,color=u'#FFF'
)
app.session.add(material)
material = Material(name=u"3M 180C Black",
cost=.47,width=38.1,length=100,
velocity=16,force=80,color=u'#000'
)
app.session.add(material)
material = Material(name=u"Avery 900 Ultimate Cast Metallic Red",
cost=1.23,width=38.1,length=100,
velocity=4,force=100,color=u'#BE3934'
)
app.session.add(material)
material = Material(name=u"Generic 12\" Vinyl Roll",
cost=0.23,width=38.1,length=None,color=u'#FFFFFF'
)
app.session.add(material)
material = Material(name=u"Generic 24\" Vinyl Roll",
cost=1.23,width=76.2,length=None,margin=(20,20,20,20),
color=u'#626FF1'
)
app.session.add(material)
app.session.commit()
log.info("Successfully set up.")
except Exception, e:
log.info("Error: Setting up the databases failed: %s"%e)
raise
if __name__ == "__main__":
setup_app()