sequence
stringlengths
1.19k
35k
code
stringlengths
75
8.58k
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'join'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'},...
def join(self, ignore_errors=False): assert self._status_fn, "Asked to join a task which hasn't had any commands executed on it" check_interval = 0.2 status_fn = self._status_fn if not self.wait_for_file(status_fn, max_wait_sec=30): self.log(f"Retrying waiting for {status_fn}") while not self....
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '22', '24']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run_with_output_on_failure'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '19']}; {'id': '4', 'ty...
def _run_with_output_on_failure(self, cmd, non_blocking=False, ignore_errors=False, max_wait_sec=365 * 24 * 3600, check_interval=0.2) -> str: if not self._can_run: assert False, "Using .run before initializat...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '19', '21']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upload'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '14']}; {'id': '4', 'type': 'identifier', 'children': [...
def upload(self, local_fn: str, remote_fn: str = '', dont_overwrite: bool = False) -> None: if '*' in local_fn: for local_subfn in glob.glob(local_fn): self.upload(local_subfn) return if ' self.log("skipping backup file {local_fn}") return if not self.sftp: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_child_fn'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def get_child_fn(attrs, names, bases): def call_method(obj, method): if isinstance(obj, type): instance = None owner = obj else: instance = obj owner = obj.__class__ method.__get__(instance, owner)() defa...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '20']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'authenticate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17']}; {'id': '4', 'type': 'identifier', '...
def authenticate(self, username=None, password=None, actions=None, response=None, authorization=None): if response is None: with warnings.catch_warnings(): _ignore_warnings(self) response = self._sessions[...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def parse(self, ddl=None, source_database=None): if ddl is not None: self._ddl = ddl if source_database is not None: self.source_database = source_database if self._ddl is None: raise ValueError("DDL is not specified") ret = self._DDL_PARSE_EXPR.parseS...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_valid_time_from_t'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
def get_next_valid_time_from_t(self, timestamp): if self.is_time_valid(timestamp): return timestamp t_day = self.get_next_valid_day(timestamp) if t_day is None: return t_day if timestamp < t_day: sec_from_morning = self.get_next_future_timerange_valid(...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_invalid_time_from_t'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children...
def get_next_invalid_time_from_t(self, timestamp): if not self.is_time_valid(timestamp): return timestamp t_day = self.get_next_invalid_day(timestamp) if timestamp < t_day: sec_from_morning = self.get_next_future_timerange_invalid(t_day) else: sec_from...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_start_and_end_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year day_start = find_day_by_weekday_offset(self.syear, self.smon, self.swday, self.swday_offset) start_time = get_start_of_day(self.syear, self.smon, day_start) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_start_and_end_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year day_start = find_day_by_offset(self.syear, self.smon, self.smday) start_time = get_start_of_day(self.syear, self.smon, day_start) if self.eyear == 0: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_start_and_end_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [],...
def get_start_and_end_time(self, ref=None): now = time.localtime(ref) if self.syear == 0: self.syear = now.tm_year month_start_id = now.tm_mon day_start = find_day_by_weekday_offset(self.syear, month_start_id, self.swday, self.sw...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'flush'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
def flush(self, log=False): if not self.my_metrics: logger.debug("Flushing - no metrics to send") return True now = int(time.time()) if self.last_failure and self.last_failure + self.metrics_flush_pause > now: if not self.log_metrics_flush_pause: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '252', '317']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '11']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'counter'}; {'id': '4', 'type': 'parameters', 'children': ['5', '6', '7...
def counter(self, key, value, timestamp=None): _min, _max, count, _sum = self.stats.get(key, (None, None, 0, 0)) count += 1 _sum += value if _min is None or value < _min: _min = value if _max is None or value > _max: _max = value self.stats[key] = ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_and_launch_worker'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def create_and_launch_worker(self, module_name='fork'): logger.info("Allocating new '%s' worker...", module_name) target = None __warned = [] if module_name == 'fork': target = None else: for module in self.modules_manager.instances: if mod...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_and_del_zombie_workers'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
def check_and_del_zombie_workers(self): for p in active_children(): logger.debug("got child: %s", p) w_to_del = [] for worker in list(self.workers.values()): logger.debug("checking if worker %s (pid=%d) is alive", worker.get_id(), worker.get_pid()...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_actions'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def add_actions(self, actions_list, scheduler_instance_id): scheduler_link = None for scheduler_id in self.schedulers: logger.debug("Trying to add an action, scheduler: %s", self.schedulers[scheduler_id]) if scheduler_instance_id == self.schedulers[scheduler_id].instance_id: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'split_semicolon'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def split_semicolon(line, maxsplit=None): r split_line = line.split(';') split_line_size = len(split_line) if maxsplit is None or maxsplit < 0: maxsplit = split_line_size i = 0 while i < split_line_size - 1: ends = split_line[i].endswith('\\') if ends: split_l...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_by_number_values'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def sort_by_number_values(x00, y00): if len(x00) < len(y00): return 1 if len(x00) > len(y00): return -1 return 0
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_item'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def add_item(self, item, index=True): name_property = getattr(self.__class__, "name_property", None) generated_hosts = [] if name_property: name = getattr(item, name_property, None) if name and '[' in name and ']' in name: pattern = name[name.find("[")+1:n...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode_contact_groups_into_contacts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', '...
def explode_contact_groups_into_contacts(item, contactgroups): if not hasattr(item, 'contact_groups'): return cgnames = '' if item.contact_groups: if isinstance(item.contact_groups, list): cgnames = item.contact_groups else: cgn...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dfs_loop_search'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def dfs_loop_search(self, root): self.nodes[root]['dfs_loop_status'] = 'DFS_TEMPORARY_CHECKED' for child in self.nodes[root]["sons"]: child_status = self.nodes[child]['dfs_loop_status'] if child_status == 'DFS_UNCHECKED': self.dfs_loop_search(child) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'eval_complex_cor_pattern'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': ...
def eval_complex_cor_pattern(self, pattern, hosts, services, hostgroups, servicegroups, running=False): node = DependencyNode() pattern = self.eval_xof_pattern(node, pattern) in_par = False tmp = '' son_is_not = False stacked_parenthesis =...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_valid_time_from_t'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
def get_next_valid_time_from_t(self, timestamp): timestamp = int(timestamp) original_t = timestamp res_from_cache = self.find_next_valid_time_from_cache(timestamp) if res_from_cache is not None: return res_from_cache still_loop = True while still_loop: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_invalid_time_from_t'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children...
def get_next_invalid_time_from_t(self, timestamp): timestamp = int(timestamp) original_t = timestamp dr_mins = [] for daterange in self.dateranges: timestamp = original_t cont = True while cont: start = daterange.get_next_valid_time_fro...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_correct'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}...
def is_correct(self): valid = True for timeperiod in list(self.items.values()): timeperiod.rec_tag = False for timeperiod in list(self.items.values()): for tmp_tp in list(self.items.values()): tmp_tp.rec_tag = False valid = timeperiod.check_exc...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_scheduler_ordered_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children':...
def get_scheduler_ordered_list(self, realm): scheduler_links = [] for scheduler_link_uuid in realm.schedulers: scheduler_links.append(self.schedulers[scheduler_link_uuid]) alive = [] spare = [] deads = [] for sdata in scheduler_links: if sdata.aliv...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dispatch'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'sel...
def dispatch(self, test=False): if not self.new_to_dispatch: raise DispatcherError("Dispatcher cannot dispatch, " "because no configuration is prepared!") if self.first_dispatch_done: raise DispatcherError("Dispatcher cannot dispatch, " ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_value_from_element'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children...
def _get_value_from_element(self, elt, prop): args = None if isinstance(prop, tuple): prop, args = prop value = getattr(elt, prop, None) if value is None: return 'n/a' try: if isinstance(value, list): return "[%s]" % ','.join(va...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_type_of_macro'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def _get_type_of_macro(macros, objs): r for macro in macros: if re.match(r'ARG\d', macro): macros[macro]['type'] = 'ARGN' continue elif re.match(r'_HOST\w', macro): macros[macro]['type'] = 'CUSTOM' macros[macro]['cla...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_resolve_ondemand'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def _resolve_ondemand(self, macro, data): elts = macro.split(':') nb_parts = len(elts) macro_name = elts[0] if nb_parts == 3: val = '' (host_name, service_description) = (elts[1], elts[2]) if host_name == '': for elt in data: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'i...
def parse(self): sub_directory = 'alignak.d' dir_name = os.path.dirname(self.configuration_file) dir_name = os.path.join(dir_name, sub_directory) self.cfg_files = [self.configuration_file] if os.path.exists(dir_name): for root, _, walk_files in os.walk(dir_name, follo...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_modules'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': []...
def get_modules(self, name=None, daemon_name=None, names_only=True): if name is not None: sections = self._search_sections('module.' + name) if 'module.' + name in sections: return sections['module.' + name] return {} if daemon_name is not None: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'daemon_connection_init'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children'...
def daemon_connection_init(self, s_link, set_wait_new_conf=False): logger.debug("Daemon connection initialization: %s %s", s_link.type, s_link.name) if not s_link.active: logger.warning("%s '%s' is not active, do not initialize its connection!", s_link.type, s_link...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_daemon_init_and_start'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def do_daemon_init_and_start(self, set_proc_title=True): if set_proc_title: self.set_proctitle(self.name) self.change_to_user_group() self.change_to_workdir() self.check_parallel_run() if self.is_daemon: if not self.daemonize(): logger.erro...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'make_a_pause'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def make_a_pause(self, timeout=0.0001, check_time_change=True): if timeout == 0: timeout = 0.0001 if not check_time_change: time.sleep(timeout) self.sleep_time += timeout return 0, 0 before = time.time() time_changed = self.check_for_system...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode_hostgroup'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [],...
def explode_hostgroup(self, svc_dep, hostgroups): snames = [d.strip() for d in svc_dep.service_description.split(',')] dep_snames = [d.strip() for d in svc_dep.dependent_service_description.split(',')] hg_names = [n.strip() for n in svc_dep.hostgroup_name.split(',')] for hg_name in hg_na...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'linkify_sd_by_s'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], '...
def linkify_sd_by_s(self, hosts, services): to_del = [] errors = self.configuration_errors warns = self.configuration_warnings for servicedep in self: try: s_name = servicedep.dependent_service_description hst_name = servicedep.dependent_host_n...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'init'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}, {'id...
def init(self): if not self.enabled: logger.info(" the module is disabled.") return True try: connections = self.test_connection() except Exception as exp: logger.error("initialization, test connection failed. Error: %s", str(exp)) if self....
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_metrics_from_perfdata'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'childr...
def get_metrics_from_perfdata(self, service, perf_data): result = [] metrics = PerfDatas(perf_data) for metric in metrics: logger.debug("service: %s, metric: %s (%s)", service, metric, metric.__dict__) if metric.name in ['time']: metric.name = "duration" ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'manage_service_check_result_brok'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'chil...
def manage_service_check_result_brok(self, b): host_name = b.data.get('host_name', None) service_description = b.data.get('service_description', None) if not host_name or not service_description: return service_id = host_name+"/"+service_description logger.debug("serv...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'manage_host_check_result_brok'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'childre...
def manage_host_check_result_brok(self, b): host_name = b.data.get('host_name', None) if not host_name: return logger.debug("host check result: %s", host_name) if host_name not in self.hosts_cache and not self.ignore_unknown: logger.warning("received host check re...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resolve_elements'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def resolve_elements(self): if self.leaf: if not self.content: return set() return set(self.content) not_nodes = [s for s in self.sons if s.not_value] positiv_nodes = [s for s in self.sons if not s.not_value] if not self.operand: self.o...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'eval_cor_pattern'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def eval_cor_pattern(self, pattern): pattern = pattern.strip() complex_node = False for char in '()+&|,': if char in pattern: complex_node = True node = ComplexExpressionNode() if not complex_node: if pattern.startswith('!'): ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_object'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def find_object(self, pattern): obj = None error = None pattern = pattern.strip() if pattern == '*': obj = [h.host_name for h in list(self.all_elements.items.values()) if getattr(h, 'host_name', '') != '' and not h.is_tpl()] return obj, error ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clean_queues'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def clean_queues(self): if getattr(self.pushed_conf, 'tick_clean_queues', 0) == 0: logger.debug("No queues cleaning...") return max_checks = MULTIPLIER_MAX_CHECKS * (len(self.hosts) + len(self.services)) max_broks = MULTIPLIER_MAX_BROKS * (len(self.hosts) + len(self.servi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'scatter_master_notifications'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': []...
def scatter_master_notifications(self): now = time.time() notifications = [a for a in self.actions.values() if a.is_a == u'notification' and a.status == ACT_STATUS_SCHEDULED and not a.contact and a.is_launchable(now)] if notifications: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'log_initial_states'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def log_initial_states(self): for elt in self.hosts: elt.raise_initial_state() for elt in self.services: elt.raise_initial_state()
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_retention_data'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def get_retention_data(self): retention_data = { 'hosts': {}, 'services': {} } for host in self.hosts: h_dict = {} properties = host.__class__.properties properties.update(host.__class__.running_properties) for prop, entry in list(prope...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'restore_retention_data_item'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'chil...
def restore_retention_data_item(self, data, item): properties = item.__class__.properties properties.update(item.__class__.running_properties) for prop, entry in list(properties.items()): if not entry.retention: continue if prop not in data: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fill_initial_broks'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def fill_initial_broks(self, broker_name): broker_uuid = None logger.debug("My brokers: %s", self.my_daemon.brokers) for broker_link in list(self.my_daemon.brokers.values()): logger.debug("Searching broker: %s", broker_link) if broker_name == broker_link.name: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'consume_results'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 's...
def consume_results(self): queue_size = self.waiting_results.qsize() for _ in range(queue_size): self.manage_results(self.waiting_results.get()) for chk in list(self.checks.values()): if chk.status == ACT_STATUS_WAIT_CONSUME: logger.debug("Consuming: %s", ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_broks_to_modules'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def send_broks_to_modules(self): t00 = time.time() nb_sent = 0 broks = [] for broker_link in list(self.my_daemon.brokers.values()): for brok in broker_link.broks: if not getattr(brok, 'sent_to_externals', False): brok.to_send = True ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'push_external_commands_to_schedulers'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'child...
def push_external_commands_to_schedulers(self): if not self.unprocessed_external_commands: return commands_to_process = self.unprocessed_external_commands self.unprocessed_external_commands = [] logger.debug("Commands: %s", commands_to_process) logger.debug("Commands ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_groupnames'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value'...
def get_groupnames(self, hostgroups): group_names = [] for hostgroup_id in self.hostgroups: hostgroup = hostgroups[hostgroup_id] group_names.append(hostgroup.get_name()) return ','.join(sorted(group_names))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_groupaliases'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def get_groupaliases(self, hostgroups): group_aliases = [] for hostgroup_id in self.hostgroups: hostgroup = hostgroups[hostgroup_id] group_aliases.append(hostgroup.alias) return ','.join(sorted(group_aliases))
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_overall_state'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def get_overall_state(self, services): overall_state = 0 if not self.monitored: overall_state = 5 elif self.acknowledged: overall_state = 1 elif self.downtimed: overall_state = 2 elif self.state_type == 'HARD': if self.state == 'UNR...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_loop_turn'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def do_loop_turn(self): if not self.first_scheduling: logger.info("First scheduling launched") _t0 = time.time() self.sched.initial_program_status() self.sched.schedule() statsmgr.timer('first_scheduling', time.time() - _t0) logger.info("Fi...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_failed_check_attempt'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [...
def add_failed_check_attempt(self, reason=''): self.reachable = False self.attempt = self.attempt + 1 logger.debug("Failed attempt for %s (%d/%d), reason: %s", self.name, self.attempt, self.max_check_attempts, reason) if self.alive: if not self.stopping: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_links_for_a_broker'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identif...
def get_links_for_a_broker(self, pollers, reactionners, receivers, realms, manage_sub_realms=False): cfg = { 'pollers': {}, 'reactionners': {}, 'receivers': {}, } for poller_id in self.pollers: poller = pollers[poller...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_links_for_a_scheduler'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'c...
def get_links_for_a_scheduler(self, pollers, reactionners, brokers): cfg = { 'pollers': {}, 'reactionners': {}, 'brokers': {}, } try: for poller in self.pollers + self.get_potential_satellites_by_type(pollers, "poller"): if poller i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_default'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': '...
def get_default(self, check=False): found = [] for realm in sorted(self, key=lambda r: r.level): if getattr(realm, 'default', False): found.append(realm) if not found: found_names = sorted([r.get_name() for r in self]) if not found_names: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'command'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'identif...
def command(self, command=None, timestamp=None, element=None, host=None, service=None, user=None, parameters=None): if cherrypy.request.method in ["POST"]: if not cherrypy.request.json: return {'_status': u'ERR', '_message': u'You must POST par...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'satellites_list'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def satellites_list(self, daemon_type=''): with self.app.conf_lock: res = {} for s_type in ['arbiter', 'scheduler', 'poller', 'reactionner', 'receiver', 'broker']: if daemon_type and daemon_type != s_type: continue satellite_list = [] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fill_default_configuration'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], ...
def fill_default_configuration(self): logger.debug("Filling the unset properties with their default value:") types_creations = self.__class__.types_creations for o_type in types_creations: (_, _, inner_property, _, _) = types_creations[o_type] if inner_property in ['realm...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'got_arbiter_module_type_defined'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'child...
def got_arbiter_module_type_defined(self, module_type): for arbiter in self.arbiters: for module in getattr(arbiter, 'modules', []): module_name = module.get_name() for mod in self.modules: if getattr(mod, 'python_name', '').strip() == module_type....
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_modules_configuration_objects'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'ch...
def load_modules_configuration_objects(self, raw_objects): for instance in self.modules_manager.instances: logger.debug("Getting objects from the module: %s", instance.name) if not hasattr(instance, 'get_objects'): logger.debug("The module '%s' do not provide any objects....
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_modules_alignak_configuration'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'childre...
def load_modules_alignak_configuration(self): alignak_cfg = {} for instance in self.modules_manager.instances: if not hasattr(instance, 'get_alignak_configuration'): return try: logger.info("Getting Alignak global configuration from module '%s'", i...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'daemons_start'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value':...
def daemons_start(self, run_daemons=True): result = True if run_daemons: logger.info("Alignak configured daemons start:") else: logger.info("Alignak configured daemons check:") for satellites_list in [self.conf.arbiters, self.conf.receivers, self.conf.reactionners...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'daemons_stop'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'va...
def daemons_stop(self, timeout=30, kill_children=False): def on_terminate(proc): logger.debug("process %s terminated with exit code %s", proc.pid, proc.returncode) result = True if self.my_daemons: logger.info("Alignak self-launched daemons stop:") start = tim...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_new_conf'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def setup_new_conf(self): super(Arbiter, self).setup_new_conf() with self.conf_lock: logger.info("I received a new configuration from my master") self.cur_conf = self.new_conf self_conf = self.cur_conf.get('self_conf', None) if not self_conf: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wait_for_master_death'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def wait_for_master_death(self): logger.info("Waiting for master death") timeout = 1.0 self.last_master_ping = time.time() master_timeout = 300 for arbiter_link in self.conf.arbiters: if not arbiter_link.spare: master_timeout = \ ar...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'ERROR', 'children': ['2', '257', '261', '268', '408']}; {'id': '2', 'type': 'function_definition', 'children': ['3', '4', '9']}, {'id': '3', 'type': 'function_name', 'children': [], 'value': 'configuration_dispatch'}; {'id': '4', 'type': 'parameters...
def configuration_dispatch(self, not_configured=None): if not not_configured: self.dispatcher = Dispatcher(self.conf, self.link_to_myself) self.cur_conf = self.conf first_connection_try_count = 0 logger.info("Connecting to my satellites...") while True...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'duplicate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'se...
def duplicate(self, host): duplicates = [] prop = self.duplicate_foreach.strip().upper() if prop not in host.customs: return duplicates entry = host.customs[prop] not_entry = host.customs.get('_' + '!' + prop[1:], '').split(',') not_keys = strip_and_uniq(not_e...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode_services_from_hosts'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', ...
def explode_services_from_hosts(self, hosts, service, hnames): duplicate_for_hosts = [] not_hosts = [] for hname in hnames: hname = hname.strip() if hname.startswith('!'): not_hosts.append(hname[1:]) else: duplicate_for_hosts.ap...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children...
def explode(self, hosts, hostgroups, contactgroups, servicegroups, servicedependencies): itemkeys = list(self.items.keys()) for s_id in itemkeys: serv = self.items[s_id] self.explode_host_groups_into_hosts(serv, hosts, hostgroups) self.explode_contact_groups_into_cont...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_notif_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier...
def get_next_notif_time(self, t_wished, status, creation_time, interval, escal_period): short_states = {u'WARNING': 'w', u'UNKNOWN': 'u', u'CRITICAL': 'c', u'RECOVERY': 'r', u'FLAPPING': 'f', u'DOWNTIME': 's', u'DOWN': 'd', u'UNREACHABLE': 'u', u'OK': 'o', u'UP': ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'linkify_es_by_s'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def linkify_es_by_s(self, services): for escalation in self: if not hasattr(escalation, 'host_name'): continue es_hname, sdesc = escalation.host_name, escalation.service_description if not es_hname.strip() or not sdesc.strip(): continue ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_contacts_by_explosion'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': ...
def get_contacts_by_explosion(self, contactgroups): self.already_exploded = True if self.rec_tag: logger.error("[contactgroup::%s] got a loop in contactgroup definition", self.get_name()) if hasattr(self, 'members'): return self.members ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'do_check_freshness'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': ...
def do_check_freshness(self, hosts, services, timeperiods, macromodulations, checkmodulations, checks, when): now = when cls = self.__class__ if not self.in_checking and self.freshness_threshold and not self.freshness_expired: if os.getenv('ALIGNAK_LOG_CHEC...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_business_impact_value'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identif...
def update_business_impact_value(self, hosts, services, timeperiods, bi_modulations): if self.my_own_business_impact == -1: self.my_own_business_impact = self.business_impact in_modulation = False for bi_modulation_id in self.business_impact_modulations: bi_modulation = b...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_a_problem'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier'...
def register_a_problem(self, prob, hosts, services, timeperiods, bi_modulations): if prob.uuid in self.source_problems: return [] now = time.time() was_an_impact = self.is_impact self.is_impact = True impacts = [] if self.is_impact: logger.debug("I...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'is_enable_action_dependent'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'child...
def is_enable_action_dependent(self, hosts, services): enable_action = False for (dep_id, status, _, _) in self.act_depend_of: if 'n' in status: enable_action = True else: if dep_id in hosts: dep = hosts[dep_id] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_hard_unknown_phase_state'}, {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children':...
def update_hard_unknown_phase_state(self): self.was_in_hard_unknown_reach_phase = self.in_hard_unknown_reach_phase if self.state_type != 'HARD' or self.last_state_type != 'HARD': self.in_hard_unknown_reach_phase = False if not self.in_hard_unknown_reach_phase: if self.sta...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_next_notification_time'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', '...
def get_next_notification_time(self, notif, escalations, timeperiods): res = None now = time.time() cls = self.__class__ notification_interval = self.notification_interval in_notif_time = time.time() - notif.creation_time for escalation_id in self.escalations: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_business_rule_output'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier'...
def get_business_rule_output(self, hosts, services, macromodulations, timeperiods): got_business_rule = getattr(self, 'got_business_rule', False) if got_business_rule is False or self.business_rule is None: return "" output_template = self.business_rule_output_template if not...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'business_rule_notification_is_blocked'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifi...
def business_rule_notification_is_blocked(self, hosts, services): acknowledged = 0 for src_prob_id in self.source_problems: if src_prob_id in hosts: src_prob = hosts[src_prob_id] else: src_prob = services[src_prob_id] if src_prob.last_h...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'acknowledge_problem'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11', '12']}; {'id': '4', '...
def acknowledge_problem(self, notification_period, hosts, services, sticky, notify, author, comment, end_time=0): comm = None logger.debug("Acknowledge requested for %s %s.", self.my_type, self.get_name()) if self.state != self.ok_up: if self.problem_has_b...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setup_logger'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [...
def setup_logger(logger_configuration_file, log_dir=None, process_name='', log_file=''): logger_ = logging.getLogger(ALIGNAK_LOGGER_NAME) for handler in logger_.handlers: if not process_name: break if getattr(handler, '_name', None) == 'daemons': for hdlr in logger_.handl...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'want_service_notification'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', '...
def want_service_notification(self, notifways, timeperiods, timestamp, state, n_type, business_impact, cmd=None): if not self.service_notifications_enabled: return False for downtime_id in self.downtimes: downtime = self.downtimes[downtime_id] ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'explode'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': ...
def explode(self, contactgroups, notificationways): self.apply_partial_inheritance('contactgroups') for prop in Contact.special_properties: if prop == 'contact_name': continue self.apply_partial_inheritance(prop) for contact in self: if not (ha...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'receive'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self...
def receive(self,arg_formats=None): msg = [[]] raw_msg = [] escaped = False command_sep_found = False while True: tmp = self.board.read() raw_msg.append(tmp) if escaped: if tmp in self._escaped_characters: ms...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_share'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'val...
def update_share(self, share_id, **kwargs): perms = kwargs.get('perms', None) password = kwargs.get('password', None) public_upload = kwargs.get('public_upload', None) if (isinstance(perms, int)) and (perms > self.OCS_PERMISSION_ALL): perms = None if not (perms or pas...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_shares'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'valu...
def get_shares(self, path='', **kwargs): if not (isinstance(path, six.string_types)): return None data = 'shares' if path != '': data += '?' path = self._encode_string(self._normalize_path(path)) args = {'path': path} reshares = kwargs....
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'share_file_with_user'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'childr...
def share_file_with_user(self, path, user, **kwargs): remote_user = kwargs.get('remote_user', False) perms = kwargs.get('perms', self.OCS_PERMISSION_READ) if (((not isinstance(perms, int)) or (perms > self.OCS_PERMISSION_ALL)) or ((not isinstance(user, six.string_types)) or (user...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get_attribute'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def get_attribute(self, app=None, key=None): path = 'getattribute' if app is not None: path += '/' + parse.quote(app, '') if key is not None: path += '/' + parse.quote(self._encode_string(key), '') res = self._make_ocs_request( 'GET', ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_make_dav_request'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children'...
def _make_dav_request(self, method, path, **kwargs): if self._debug: print('DAV request: %s %s' % (method, path)) if kwargs.get('headers'): print('Headers: ', kwargs.get('headers')) path = self._normalize_path(path) res = self._session.request( ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_delimited'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'v...
def load_delimited(filename, converters, delimiter=r'\s+'): r n_columns = len(converters) columns = tuple(list() for _ in range(n_columns)) splitter = re.compile(delimiter) with _open(filename, mode='r') as input_file: for row, line in enumerate(input_file, 1): data = splitter.sp...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'validate'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'ref...
def validate(reference_patterns, estimated_patterns): if _n_onset_midi(reference_patterns) == 0: warnings.warn('Reference patterns are empty.') if _n_onset_midi(estimated_patterns) == 0: warnings.warn('Estimated patterns are empty.') for patterns in [reference_patterns, estimated_patterns]: ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'three_layer_FPR'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value...
def three_layer_FPR(reference_patterns, estimated_patterns): validate(reference_patterns, estimated_patterns) def compute_first_layer_PR(ref_occs, est_occs): s = len(_occurrence_intersection(ref_occs, est_occs)) precision = s / float(len(ref_occs)) recall = s / float(len(est_occs)) ...
{'id': '0', 'type': 'module', 'children': ['1']}, {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'match_notes'}, {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '13', '16', '19', '22', '25']}; {'i...
def match_notes( ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches, est_velocities, onset_tolerance=0.05, pitch_tolerance=50.0, offset_ratio=0.2, offset_min_tolerance=0.05, strict=False, velocity_tolerance=0.1): matching = transcription.match_notes( ref_i...