This repository was archived by the owner on Oct 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmanage.py
More file actions
90 lines (71 loc) · 2.85 KB
/
manage.py
File metadata and controls
90 lines (71 loc) · 2.85 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
# -*- coding: utf-8 -*-
"""
manage
~~~~~~
Manager module
"""
import os
from flask.ext.script import Manager, Shell
from flask.ext.migrate import Migrate, MigrateCommand
from longboxed.core import db
from longboxed.frontend import create_app
from longboxed.models import (User, Issue, Title, Publisher, Bundle, Role,
DiamondList)
from longboxed.manage import *
app = create_app(os.getenv('APP_ENV') or 'default')
manager = Manager(app)
migrate = Migrate(app, db)
def _make_shell_context():
return dict(app=app, db=db, User=User, Issue=Issue,
Title=Title, Publisher=Publisher, Bundle=Bundle,
Role=Role, DiamondList=DiamondList)
manager.add_command("shell", Shell(make_context=_make_shell_context))
manager.add_command('db', MigrateCommand)
manager.add_command('test', TestCommand())
# Application management commands
manager.add_command('clear_cache', ClearCacheCommand())
# User Commands
manager.add_command('create_role', CreateNewRoleCommand())
manager.add_command('create_roles', CreateDefaultRolesCommand())
manager.add_command('create_user', CreateUserCommand())
manager.add_command('add_super_role', AddSuperUserRoleCommand())
manager.add_command('list_users', ListUsersCommand())
manager.add_command('list_roles', ListRolesCommand())
# Comic Book Management Commands
manager.add_command('import_database', ImportDatabase())
manager.add_command('download_diamond_list', DownloadDiamondListCommand())
manager.add_command('schedule_releases', ScheduleReleasesCommand())
manager.add_command('bundle_issues', BundleIssuesCommand())
manager.add_command('download_schedule_bundle', DownloadScheduleBundleCommand())
manager.add_command('reprocess_diamond_lists', ReprocessDiamondListsCommand())
manager.add_command('delete_all_issues', DeleteAllIssues())
manager.add_command('set_cover_image', SetCoverImageCommand())
manager.add_command('clean_cover_images', CleanCoverImages())
manager.add_command('remove_publisher_title_from_pull_lists',
RemovePublisherTitleFromPullLists())
manager.add_command('tweet_featured_issue', TweetFeaturedIssueCommand())
@manager.command
def deploy():
"""Run deployment tasks."""
from flask.ext.migrate import upgrade
print 'Running deployment tasks...'
# Migrate database to latest revision
print 'Migrating database to latest revison...',
upgrade()
print 'done'
print 'Checking for user roles...',
Role.insert_roles()
print 'done'
print 'Checking for Publisher images...'
Publisher.set_images()
print 'done'
if app.config.get('APP_ENV') in ('prod', 'stag'):
print 'Uploading Static assets to S3...'
import flask_s3
flask_s3.create_all(app)
print 'done'
else:
print 'NOT uploading assets to S3, on dev...'
if __name__ == '__main__':
# Run the manager
manager.run()