forked from skochaver-USGS/PubsWarehouse_UI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
56 lines (41 loc) · 1.31 KB
/
manage.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
"""
Created on Oct 17, 2014
@author: ayan
"""
# pylint: disable=C0111
from flask_script import Manager, Command
from flask_collect import Collect
import arrow
from pubs_ui import app as application
class CollectStaticFiles(Command):
"""
collects static files
so Apache can serve them
"""
def run(self):
collect = Collect()
collect.init_app(application)
collect.init_script(manager)
collect.collect(verbose=True)
class ReportDeployDate(Command):
"""
Create a file with the
deploy date
"""
@staticmethod
def report_current_utc_time():
utc_time = arrow.utcnow()
utc_time_str = utc_time.format('MMMM DD, YYYY HH:mm:ss ZZ')
return utc_time_str
def write_py_file(self, outfile='deploy_date.py'):
utc_time = self.report_current_utc_time()
with open(outfile, 'w') as py_file:
deploy_time_var = "DEPLOYED = '{utc_time}'".format(utc_time=utc_time)
py_file.write(deploy_time_var)
def run(self):
self.write_py_file()
manager = Manager(application) # pylint: disable=C0103
manager.add_command('collect', CollectStaticFiles())
manager.add_command('date_report', ReportDeployDate())
if __name__ == '__main__':
manager.run()