]>
jfr.im git - irc/rizon/acid.git/blob - pyva/src/main/python/pseudoclient/sys_base.py
4 class Subsystem(object):
5 #--------------------------------------------------------------#
6 # i'm not entirely sure if this functionality is still
7 # required, but it seems it was removed from this module
8 # but not from cmd_admin, so I can only assume the removal
14 def set_db_up(cls
, up
):
21 #--------------------------------------------------------------#
23 def __init__(self
, module
, options
, name
):
25 self
.__options
= options
26 self
.__lock
= threading
.Lock()
34 self
.conn
= db
.connect(
35 host
=self
.module
.config
.get('database', 'host'),
36 user
=self
.module
.config
.get('database', 'user'),
37 passwd
=self
.module
.config
.get('database', 'passwd'),
38 db
=self
.module
.config
.get('database', 'db'),
39 unix_socket
=self
.module
.config
.get('database','sock')
42 self
.conn
.autocommit(True)
43 self
.cursor
= self
.conn
.cursor()
46 if self
.cursor
!= None:
55 self
.__delay
= self
.get_option('update_period', int, 120)
57 if self
.__timer
!= None:
67 def get_option(self
, name
, type, default
):
68 return self
.__options
.get('%s_%s' % (self
.name
, name
), type, default
)
70 def set_option(self
, name
, value
):
71 return self
.__options
.set('%s_%s' % (self
.name
, name
), value
)
74 self
.__timer
= threading
.Timer(self
.__delay
, self
.worker
)
75 self
.__timer
.daemon
= True
82 if self
.__timer
!= None:
104 if self
.conn
!= None:
109 if self
.__class
__.db_up
:
112 self
.__timer
= threading
.Timer(self
.__delay
, self
.worker
)
113 self
.__timer
.daemon
= True