File: __init__.py

package info (click to toggle)
sshproxy 0.6.0~beta2-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 956 kB
  • ctags: 1,296
  • sloc: python: 8,932; sh: 268; sql: 40; makefile: 38; xml: 21
file content (81 lines) | stat: -rw-r--r-- 2,803 bytes parent folder | download
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
#!/usr/bin/env python
# -*- coding: ISO-8859-15 -*-
#
# Copyright (C) 2005-2007 David Guerizec <david@guerizec.net>
#
# Last modified: 2007 Dec 08, 20:01:24 by david
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

__plugin_name__ = "File Backend"
__description__ = """
    The File backend can handle the client database,
    the ACL rules database, and the site database.
    You can optionnaly choose either both three of them,
    or one or two only.
"""
__backend__ = True

def __init_plugin__():
    from sshproxy.config import get_config
    cfg = get_config('sshproxy')
    if cfg['acl_db'] == 'ini_db':
        from acl import FileACLDB
        FileACLDB.register()
    if cfg['client_db'] == 'ini_db':
        from client import FileClientDB, FileClientInfo
        FileClientDB.register()
        FileClientInfo.register()
    if cfg['site_db'] == 'ini_db':
        from site import FileSiteInfo, FileSiteDB
        FileSiteInfo.register()
        FileSiteDB.register()

def __setup__():
    from sshproxy import menu
    from sshproxy.config import get_config

    cfg = get_config('sshproxy')
    items = []

    if cfg['acl_db'] == 'ini_db':
        import acl
        def update(value):
            get_config('acl_db.ini')['file'] = value
        items.append(menu.MenuInput('ACL database file',
                    "",
                    get_config('acl_db.ini').get('file', raw=True),
                    cb=update))

    if cfg['client_db'] == 'ini_db':
        import client
        def update(value):
            get_config('client_db.ini')['file'] = value
        items.append(menu.MenuInput('Client database file',
                    "",
                    get_config('client_db.ini').get('file', raw=True),
                    cb=update))

    if cfg['site_db'] == 'ini_db':
        import site
        def update(value):
            get_config('site_db.ini')['db_path'] = value
        items.append(menu.MenuInput('Site database directory',
                    "",
                    get_config('site_db.ini').get('db_path', raw=True),
                    cb=update))

    return menu.MenuSub("FileDB", "", *items)