|
Lines 1331-1336
class UNIX_TimeInterval( complex ):
Link Here
|
| 1331 |
subsyntaxes = ( ( '', integer ), ( '', TimeUnits ) ) |
1331 |
subsyntaxes = ( ( '', integer ), ( '', TimeUnits ) ) |
| 1332 |
size = ( 'Half', 'Half' ) |
1332 |
size = ( 'Half', 'Half' ) |
| 1333 |
|
1333 |
|
|
|
1334 |
@classmethod |
| 1335 |
def parse(cls, texts): |
| 1336 |
return super(UNIX_TimeInterval, cls).parse(texts) |
| 1337 |
|
| 1338 |
class UNIX_BoundedTimeInterval( UNIX_TimeInterval ): |
| 1339 |
lower_bound = -1 # in seconds, -1 unbounded |
| 1340 |
upper_bound = -1 # in seconds, -1 unbounded |
| 1341 |
error_message = _ ("Value out of bounds (%d - %d seconds)") |
| 1342 |
|
| 1343 |
@classmethod |
| 1344 |
def parse(cls, texts): |
| 1345 |
parsed = super(UNIX_BoundedTimeInterval, cls).parse(texts) |
| 1346 |
|
| 1347 |
in_seconds = int(parsed[0]) |
| 1348 |
if len(parsed) > 1: |
| 1349 |
in_seconds = { |
| 1350 |
'seconds': lambda x: x, |
| 1351 |
'minutes': lambda x: x * 60, |
| 1352 |
'hours': lambda x: x * 60 * 60, |
| 1353 |
'days': lambda x: x * 24 * 60 * 60, |
| 1354 |
}[parsed[1]](in_seconds) |
| 1355 |
|
| 1356 |
msg = cls.error_message % (cls.lower_bound, cls.upper_bound) |
| 1357 |
if cls.lower_bound != -1 and in_seconds < cls.lower_bound: |
| 1358 |
raise univention.admin.uexceptions.valueError(msg) |
| 1359 |
if cls.upper_bound != -1 and in_seconds > cls.upper_bound: |
| 1360 |
raise univention.admin.uexceptions.valueError(msg) |
| 1361 |
|
| 1362 |
return parsed |
| 1363 |
|
| 1364 |
class SambaMinPwdAge( UNIX_BoundedTimeInterval ): |
| 1365 |
lower_bound = 0 |
| 1366 |
upper_bound = 998 * 24 * 60 * 60 # 998 days in seconds |
| 1367 |
|
| 1368 |
class SambaMaxPwdAge( UNIX_BoundedTimeInterval ): |
| 1369 |
lower_bound = 0 |
| 1370 |
upper_bound = 999 * 24 * 60 * 60 # 999 days in seconds |
| 1371 |
|
| 1334 |
class NetworkType( select ): |
1372 |
class NetworkType( select ): |
| 1335 |
choices = ( ( 'ethernet', _( 'Ethernet' ) ), ( 'fddi', _( 'FDDI' ) ), ( 'token-ring', _( 'Token-Ring' ) ) ) |
1373 |
choices = ( ( 'ethernet', _( 'Ethernet' ) ), ( 'fddi', _( 'FDDI' ) ), ( 'token-ring', _( 'Token-Ring' ) ) ) |
| 1336 |
|
1374 |
|