mirror of
https://github.com/Sneed-Group/Poodletooth-iLand
synced 2024-12-26 05:02:31 -06:00
35b646c4e6
This reverts commit 1e4bad8c6b
.
39 lines
No EOL
1.3 KiB
Python
Executable file
39 lines
No EOL
1.3 KiB
Python
Executable file
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 |