File: conf.py

package info (click to toggle)
python-caldav 1.3.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 636 kB
  • sloc: python: 6,824; makefile: 91; sh: 7
file content (169 lines) | stat: -rw-r--r-- 4,911 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
## YOU SHOULD MOST LIKELY NOT EDIT THIS FILE!
## Make a conf_private.py for personal configuration.
## Check conf_private.py.EXAMPLE
import logging

from caldav.davclient import DAVClient

# from .compatibility_issues import bedework, xandikos

####################################
# Import personal test server config
####################################

## TODO: there are probably more elegant ways of doing this?

try:
    from .conf_private import only_private  ## legacy compatibility

    test_public_test_servers = not only_private
except ImportError:
    try:
        from .conf_private import test_public_test_servers
    except ImportError:
        test_public_test_servers = False

try:
    from .conf_private import caldav_servers
except ImportError:
    caldav_servers = []
try:
    from .conf_private import test_private_test_servers

    if not test_private_test_servers:
        caldav_servers = []
except ImportError:
    pass

try:
    from .conf_private import xandikos_host, xandikos_port
except ImportError:
    xandikos_host = "localhost"
    xandikos_port = 8993  ## random port above 8000
try:
    from .conf_private import test_xandikos
except ImportError:
    try:
        import xandikos

        test_xandikos = True
    except:
        test_xandikos = False

try:
    from .conf_private import radicale_host, radicale_port
except ImportError:
    radicale_host = "localhost"
    radicale_port = 5232  ## default radicale host

try:
    from .conf_private import test_radicale
except ImportError:
    try:
        import radicale

        test_radicale = True
    except:
        test_radicale = False

try:
    from .conf_private import rfc6638_users
except ImportError:
    rfc6638_users = []

proxy = "127.0.0.1:8080"
proxy_noport = "127.0.0.1"

#####################
# Public test servers
#####################
## As of 2019-09, all of those are down.  Will try to fix Real Soon ... possibly before 2029 even.
if False:
    # if test_public_test_servers:

    ## TODO: this one is set up on emphemeral storage on OpenShift and
    ## then configured manually through the webui installer, it will
    ## most likely only work for some few days until it's down again.
    ## It's needed to hard-code the configuration into
    ## https://github.com/python-caldav/baikal

    caldav_servers.append(
        {
            "url": "http://baikal-caldav-servers.cloudapps.bitbit.net/html/cal.php/",
            "username": "baikaluser",
            "password": "asdf",
        }
    )

    # bedework:
    # * todos and journals are not properly supported -
    #   ref https://github.com/Bedework/bedework/issues/5
    # * propfind fails to return resourcetype,
    #   ref https://github.com/Bedework/bedework/issues/110
    # * date search on recurrences of recurring events doesn't work
    #   (not reported yet - TODO)
    caldav_servers.append(
        {
            "url": "http://bedework-caldav-servers.cloudapps.bitbit.net/ucaldav/",
            "username": "vbede",
            "password": "bedework",
            "incompatibilities": compatibility_issues.bedework,
        }
    )

    caldav_servers.append(
        {
            "url": "http://xandikos-caldav-servers.cloudapps.bitbit.net/",
            "username": "user1",
            "password": "password1",
            "incompatibilities": compatibility_issues.xandikos,
        }
    )

    # radicale
    caldav_servers.append(
        {
            "url": "http://radicale-caldav-servers.cloudapps.bitbit.net/",
            "username": "testuser",
            "password": "123",
            "nofreebusy": True,
            "nodefaultcalendar": True,
            "noproxy": True,
        }
    )

caldav_servers = [x for x in caldav_servers if x.get("enable", True)]

###################################################################
# Convenience - get a DAVClient object from the caldav_servers list
###################################################################
CONNKEYS = set(
    ("url", "proxy", "username", "password", "ssl_verify_cert", "ssl_cert", "auth")
)


def client(idx=None, **kwargs):
    if idx is None and not kwargs:
        return client(0)
    elif idx is not None and not kwargs and caldav_servers:
        return client(**caldav_servers[idx])
    elif not kwargs:
        return None
    for bad_param in (
        "incompatibilities",
        "backwards_compatibility_url",
        "principal_url",
        "enable",
    ):
        if bad_param in kwargs:
            kwargs.pop(bad_param)
    for kw in kwargs:
        if not kw in CONNKEYS:
            logging.critical(
                "unknown keyword %s in connection parameters.  All compatibility flags should now be sent as a separate list, see conf_private.py.EXAMPLE.  Ignoring."
                % kw
            )
            kwargs.pop(kw)
    return DAVClient(**kwargs)