mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-26 05:02:31 -06:00
d7279b7778
This reverts commit d3a352f395
.
39 lines
No EOL
1.3 KiB
Python
39 lines
No EOL
1.3 KiB
Python
from direct.distributed.DistributedObject import DistributedObject
|
|
from direct.directnotify.DirectNotifyGlobal import directNotify
|
|
from datetime import datetime
|
|
|
|
class AccountDate(DistributedObject):
|
|
neverDisable = 1
|
|
notify = directNotify.newCategory('AccountDate')
|
|
|
|
def __init__(self, cr):
|
|
DistributedObject.__init__(self, cr)
|
|
self.accountDays = 0
|
|
|
|
def announceGenerate(self):
|
|
DistributedObject.announceGenerate(self)
|
|
base.cr.accountDateMgr = self
|
|
taskMgr.doMethodLater(10, self.requestDate, 'request-task')
|
|
|
|
def delete(self):
|
|
if hasattr(base.cr, 'accountDateMgr'):
|
|
if base.cr.accountDateMgr is self:
|
|
del base.cr.accountDateMgr
|
|
DistributedObject.delete(self)
|
|
|
|
def getAccountDays(self):
|
|
return self.accountDays
|
|
|
|
def requestDate(self, task=None):
|
|
self.sendUpdate('requestDate')
|
|
|
|
if task is not None:
|
|
return task.done
|
|
|
|
def requestDateResult(self, result):
|
|
if result is None:
|
|
notify.warning('Invalid response from server.')
|
|
self.accountDays = 0
|
|
else:
|
|
date = datetime.strptime(result, "%a %b %d %H:%M:%S %Y")
|
|
self.accountDays = (datetime.now() - date).days |