1 # -*- coding: utf-8 -*-
2 """Setup the floof application"""
5 from floof
.config
.environment
import load_environment
7 log
= logging
.getLogger(__name__
)
9 from pylons
import config
11 from floof
import model
as model
15 def setup_app(command
, conf
, vars):
16 """Place any commands to setup floof here"""
17 load_environment(conf
.global_conf
, conf
.local_conf
)
19 # We try to recreate the db when it already exists, like, a lot. This
20 # fucks everything. Do a dumb check for it.
21 assert not model
.User
.table
.exists(), \
22 "Database is already initialized; please purge it first."
25 model
.metadata
.create_all()
29 identity_url
= model
.IdentityURL(url
=u
'http://eevee.livejournal.com/')
30 user
= model
.User(name
=u
'eevee', display_name
=u
'Eevee')
31 user
.identity_urls
.append(identity_url
)
33 model
.Session
.commit()
36 # Only necessary if we're using the filesystem for storage.
38 art_path
= os
.path
.join(config
['app_conf']['static_root'], 'art')
39 # Test that we can write to the art directory
40 if os
.access(art_path
, os
.W_OK | os
.X_OK
):
41 # Create directories for various image sizes
42 for subdir
in ['original', 'medium', 'thumbnail']:
43 path
= os
.path
.join(art_path
, subdir
)
44 # If it exists, it should be writeable. If not, create it.
45 if os
.path
.exists(path
):
46 if not os
.access(path
, os
.W_OK | os
.X_OK
):
47 print "*** WARNING: Can't write to the art/{0} " \
48 "directory!".format(subdir
)
52 print "*** WARNING: Can't write to the art directory!"