/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos-ctl

  • Committer: Teddy Hogeborn
  • Date: 2013-10-24 20:21:45 UTC
  • Revision ID: teddy@recompile.se-20131024202145-456a9y6x910a2vhb
* debian/control (Build-Depends): Changed debhelper version to (>= 9)
                                  to match debian/compat.
* mandos-options.xml (priority): Changed back to normal priority.
  (priority_compat): New option; for the server which needs to a
                     priority string compatible with old keys.
* mandos-conf.xml (OPTIONS/priority): Include "priority_compat".
* mandos.xml (OPTIONS/priority): - '' -

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
server_path = "/"
67
67
server_interface = domain + ".Mandos"
68
68
client_interface = domain + ".Mandos.Client"
69
 
version = "1.6.0"
 
69
version = "1.6.1"
70
70
 
71
71
def timedelta_to_milliseconds(td):
72
72
    """Convert a datetime.timedelta object to milliseconds"""
85
85
 
86
86
 
87
87
def rfc3339_duration_to_delta(duration):
88
 
    """Parse a RFC 3339 "duration" and return a datetime.timedelta
 
88
    """Parse an RFC 3339 "duration" and return a datetime.timedelta
89
89
    
90
90
    >>> rfc3339_duration_to_delta("P7D")
91
91
    datetime.timedelta(7)
103
103
    datetime.timedelta(1, 200)
104
104
    """
105
105
    
106
 
    # Parsing a RFC 3339 duration with regular expressions is not
 
106
    # Parsing an RFC 3339 duration with regular expressions is not
107
107
    # possible - there would have to be multiple places for the same
108
 
    # values, like seconds.  This, while more esoteric, is cleaner
109
 
    # without depending on a parsing library.  If Python had a
 
108
    # values, like seconds.  The current code, while more esoteric, is
 
109
    # cleaner without depending on a parsing library.  If Python had a
110
110
    # built-in library for parsing we would use it, but we'd like to
111
111
    # avoid excessive use of external libraries.
112
112
    
199
199
    >>> string_to_delta("5m 30s")
200
200
    datetime.timedelta(0, 330)
201
201
    """
202
 
    value = datetime.timedelta(0)
203
 
    regexp = re.compile(r"(\d+)([dsmhw]?)")
204
202
    
205
203
    try:
206
204
        return rfc3339_duration_to_delta(interval)
207
205
    except ValueError:
208
206
        pass
209
207
    
 
208
    value = datetime.timedelta(0)
 
209
    regexp = re.compile(r"(\d+)([dsmhw]?)")
 
210
    
210
211
    for num, suffix in regexp.findall(interval):
211
212
        if suffix == "d":
212
213
            value += datetime.timedelta(int(num))