-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgiles.py
More file actions
executable file
·58 lines (45 loc) · 1.7 KB
/
giles.py
File metadata and controls
executable file
·58 lines (45 loc) · 1.7 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
#!/usr/bin/env python2
# Giles: giles.py, the main loop.
# Copyright 2012 Phil Bordelon
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import ConfigParser
import giles.server
import sys
cp = ConfigParser.SafeConfigParser()
if len(sys.argv) == 2:
config_filename = sys.argv[1]
else:
config_filename = "giles.conf"
cp.read(config_filename)
if not cp.has_option("server", "source_url"):
print("You absolutely must provide a giles.conf with a valid source_url.")
print("See giles.conf.sample for more information.")
sys.exit(1)
source_url = cp.get("server", "source_url")
if not cp.has_option("server", "name"):
name = "Giles"
else:
name = cp.get("server", "name")
if not cp.has_option("server", "admin_password"):
admin_password = None
else:
admin_password = cp.get("server", "admin_password")
if not cp.has_option("server", "port"):
port = 9435
else:
port = cp.getint("server", "port")
# No need to keep the config parser around now that we're done with it.
del cp
server = giles.server.Server(name, source_url, admin_password, config_filename)
server.instantiate(port)
server.loop()