forked from stackimpact/stackimpact-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_loader.py
More file actions
33 lines (23 loc) · 874 Bytes
/
Copy pathconfig_loader.py
File metadata and controls
33 lines (23 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from .api_request import APIRequest
class ConfigLoader:
def __init__(self, agent):
self.agent = agent
self.load_timer = None
def start(self):
self.load_timer = self.agent.schedule(2, 120, self.load)
def destroy(self):
if self.load_timer:
self.load_timer.cancel()
self.load_timer = None
def load(self):
try:
api_request = APIRequest(self.agent)
config = api_request.post('config', {})
# profiling_enabled yes|no
if 'profiling_disabled' in config:
self.agent.config.set_profiling_disabled(config['profiling_disabled'] == 'yes')
else:
self.agent.config.set_profiling_disabled(False)
except Exception:
self.agent.log('Error loading config')
self.agent.exception()