Mercurial > templog
comparison web/settings.py @ 586:87c20b8c5472 default master
port to python3
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 09 Sep 2019 22:24:10 +0800 |
parents | 03e540c3ec24 |
children |
comparison
equal
deleted
inserted
replaced
585:1c484dab4e83 | 586:87c20b8c5472 |
---|---|
1 import gevent | 1 import gevent.event |
2 import fcntl | 2 import fcntl |
3 import hashlib | |
4 | 3 |
5 import binascii | 4 import binascii |
6 import os | 5 import os |
7 | 6 |
8 class Settings(object): | 7 class Settings(object): |
36 | 35 |
37 def epoch_tag(self): | 36 def epoch_tag(self): |
38 return '%s-%s' % (self.epoch, self.tag) | 37 return '%s-%s' % (self.epoch, self.tag) |
39 | 38 |
40 def random(self): | 39 def random(self): |
41 return binascii.hexlify(os.urandom(self.RAND_SIZE)) | 40 return os.urandom(self.RAND_SIZE).hex() |
42 | 41 |
43 def update(self, contents, epoch = None): | 42 def update(self, contents, epoch = None): |
44 """ replaces settings contents and updates waiters if changed """ | 43 """ replaces settings contents and updates waiters if changed """ |
45 if epoch: | 44 if epoch: |
46 if self.epoch == epoch: | 45 if self.epoch == epoch: |