CPU usage problem might be solved
[systematiki.git] / systematikid.py
blobfd14db9c8b0954b5247ec3297e7bf7d0ea1e32ce
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 """
4 Systematiki server.
6 The client is called 'systematiki.py'.
7 """
9 # Copyright (C) 2007 Felix Rabe <public@felixrabe.textdriven.com>
11 # This library is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU Lesser General Public
13 # License as published by the Free Software Foundation; either
14 # version 2.1 of the License, or (at your option) any later version.
16 # This library is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 # Lesser General Public License for more details.
21 # You should have received a copy of the GNU Lesser General Public License
22 # along with this library; if not, write to the Free Software Foundation,
23 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 # Recommended line length or text width: 75 characters.
27 from Systematiki.Database.Dummy import Database
28 from Systematiki.Networking.BlockingStringProtocol import StringProtocol
31 class ServerConfig(object):
32 """
33 Server configuration class.
35 TODO: Proper configuration using either command-line arguments,
36 configuration files, or a GUI.
37 """
39 def __init__(self, argv):
40 self.host = "localhost"
41 self.port = 6420
42 self.database_class = Database
43 self.ui = "cli"
46 def cli_ui(config):
47 database = config.database_class(config)
48 server_proto = StringProtocol()
49 server_proto.listen((config.host, config.port))
50 server_proto.accept(cli_ui_cb_1)
53 def cli_ui_cb_1(client_proto):
54 print client_proto
57 def main(argv):
58 config = ServerConfig(argv) # Might run and quit a gobject.MainLoop
59 if config.ui == "cli":
60 cli_ui(config)
61 # TODO: GTK interface, web interface, brain interface, ...
62 return 0
65 if __name__ == "__main__":
66 import sys
67 sys.exit(main(sys.argv))