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
|
#!/usr/bin/env python3
import argparse
import os.path
import sys
import cherrypy
import guacamole
import lesana
import cherry_lesana as cl
from pkg_resources import resource_filename
class CherryLesana(guacamole.Command):
def register_arguments(self, parser):
parser.add_argument(
'--collection', '-c',
help='The collection to work on (default .)',
default='.',
)
parser.add_argument(
'--browser', '-b',
help='',
)
def invoked(self, ctx):
# TODO: read config from a file or something
config = {
'/': {
'tools.staticdir.root': resource_filename(
'cherry_lesana',
'data',
)
},
'/static': {
'tools.staticdir.on': True,
'tools.staticdir.dir': 'static',
}
}
if os.path.exists(os.path.join(ctx.args.collection, '.lesana')):
collection = lesana.Collection(ctx.args.collection)
else:
collection = None
app = cl.App(collection)
cherrypy.quickstart(app, '/', config)
if __name__ == '__main__':
CherryLesana().main()
|