sequence
stringlengths
492
15.9k
code
stringlengths
75
8.58k
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:join; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ignore_errors; 7, False; 8, block; 8, 9; 8, 14; 8, 18; 8, 24; 8, 43; 8, 69; 8, 78; 8, 102; 8, 113; 8, 119; 8, 173; 9, assert_statement; 9, 10; ...
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....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 22; 1, 24; 2, function_name:_run_with_output_on_failure; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 9; 3, 12; 3, 19; 4, identifier:self; 5, identifier:cmd; 6, default_parameter; 6, 7; 6, 8; 7, identifier:non_blocking; 8, False; 9, default_parameter; 9, 10; 9, 11; 10, ide...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 19; 1, 21; 2, function_name:upload; 3, parameters; 3, 4; 3, 5; 3, 9; 3, 14; 4, identifier:self; 5, typed_parameter; 5, 6; 5, 7; 6, identifier:local_fn; 7, type; 7, 8; 8, identifier:str; 9, typed_default_parameter; 9, 10; 9, 11; 9, 13; 10, identifier:remote_fn; 11,...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_child_fn; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:attrs; 5, identifier:names; 6, identifier:bases; 7, block; 7, 8; 7, 51; 7, 57; 7, 83; 7, 89; 7, 105; 8, function_definition; 8, 9; 8, 10; 8, 13; 9, function_name:call_method; 10, para...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 2, function_name:authenticate; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:username; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:password; 10, None; 11, default_paramet...
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[...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:parse; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ddl; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:source_database; 10, None; 11, block; 11, 12; 11, 23; 11, 34; 11, 46; 11...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_valid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, block; 6, 7; 6, 17; 6, 26; 6, 33; 6, 58; 6, 76; 6, 85; 6, 94; 6, 103; 6, 116; 7, if_statement; 7, 8; 7, 14; 8, call; 8, 9; 8, 12; 9, attribut...
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(...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_invalid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, block; 6, 7; 6, 18; 6, 27; 6, 52; 6, 67; 6, 78; 6, 87; 6, 96; 6, 105; 6, 120; 6, 131; 7, if_statement; 7, 8; 7, 15; 8, not_operator; 8, 9; ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_start_and_end_time; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ref; 7, None; 8, block; 8, 9; 8, 18; 8, 33; 8, 51; 8, 64; 8, 79; 8, 97; 8, 110; 8, 119; 8, 278; 9, expression_statement; 9, 1...
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) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_start_and_end_time; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ref; 7, None; 8, block; 8, 9; 8, 18; 8, 33; 8, 48; 8, 61; 8, 76; 8, 91; 8, 104; 8, 113; 8, 260; 9, expression_statement; 9, 1...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_start_and_end_time; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:ref; 7, None; 8, block; 8, 9; 8, 18; 8, 33; 8, 39; 8, 55; 8, 66; 8, 81; 8, 87; 8, 103; 8, 114; 8, 165; 8, 174; 8, 271; 9, exp...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:flush; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:log; 7, False; 8, block; 8, 9; 8, 24; 8, 35; 8, 98; 8, 264; 9, if_statement; 9, 10; 9, 14; 10, not_operator; 10, 11; 11, attribute; 11, 12; 11...
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: ...
0, module; 0, 1; 1, ERROR; 1, 2; 1, 252; 1, 317; 2, function_definition; 2, 3; 2, 4; 2, 11; 3, function_name:counter; 4, parameters; 4, 5; 4, 6; 4, 7; 4, 8; 5, identifier:self; 6, identifier:key; 7, identifier:value; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timestamp; 10, None; 11, block; 11, 12; 11, 32; 11, 36...
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] = ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:create_and_launch_worker; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:module_name; 7, string:'fork'; 8, block; 8, 9; 8, 17; 8, 21; 8, 25; 8, 99; 8, 105; 8, 132; 8, 144; 8, 158; 8, 164; 9, expre...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:check_and_del_zombie_workers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 20; 5, 24; 5, 110; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:p; 8, call; 8, 9; 8, 10; 9, identifier:active_children; 10, argument_list; 11, block...
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()...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:add_actions; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:actions_list; 6, identifier:scheduler_instance_id; 7, block; 7, 8; 7, 12; 7, 61; 7, 77; 7, 85; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, ident...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:split_semicolon; 3, parameters; 3, 4; 3, 5; 4, identifier:line; 5, default_parameter; 5, 6; 5, 7; 6, identifier:maxsplit; 7, None; 8, block; 8, 9; 8, 11; 8, 20; 8, 27; 8, 40; 8, 44; 8, 127; 9, expression_statement; 9, 10; 10, identifier:r; 11, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:sort_by_number_values; 3, parameters; 3, 4; 3, 5; 4, identifier:x00; 5, identifier:y00; 6, block; 6, 7; 6, 20; 6, 34; 7, if_statement; 7, 8; 7, 17; 8, comparison_operator:<; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:len; 11, argument_l...
def sort_by_number_values(x00, y00): if len(x00) < len(y00): return 1 if len(x00) > len(y00): return -1 return 0
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:add_item; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:item; 6, default_parameter; 6, 7; 6, 8; 7, identifier:index; 8, True; 9, block; 9, 10; 9, 21; 9, 25; 9, 296; 9, 371; 10, expression_statement; 10, 11; 11, assignment; ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:explode_contact_groups_into_contacts; 3, parameters; 3, 4; 3, 5; 4, identifier:item; 5, identifier:contactgroups; 6, block; 6, 7; 6, 16; 6, 20; 6, 53; 6, 60; 7, if_statement; 7, 8; 7, 14; 8, not_operator; 8, 9; 9, call; 9, 10; 9, 11; 10, identi...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:dfs_loop_search; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:root; 6, block; 6, 7; 6, 17; 6, 122; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 16; 9, subscript; 9, 10; 9, 15; 10, subscript; 10, 11; 10, 14; 11, attribu...
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) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 2, function_name:eval_complex_cor_pattern; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 4, identifier:self; 5, identifier:pattern; 6, identifier:hosts; 7, identifier:services; 8, identifier:hostgroups; 9, identifier:servicegroups; 10, default_para...
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 =...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_valid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, block; 6, 7; 6, 14; 6, 18; 6, 27; 6, 34; 6, 38; 6, 225; 6, 233; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:time...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_next_invalid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, block; 6, 7; 6, 14; 6, 18; 6, 22; 6, 97; 6, 104; 6, 108; 6, 189; 6, 206; 6, 258; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10;...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:is_correct; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 29; 5, 71; 5, 147; 5, 161; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:valid; 9, True; 10, for_statement; 10, 11; 10, 12; 10, 22; 11, ide...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_scheduler_ordered_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:realm; 6, block; 6, 7; 6, 11; 6, 28; 6, 32; 6, 36; 6, 40; 6, 86; 6, 90; 6, 97; 6, 104; 6, 111; 6, 117; 7, expression_statement; 7, 8; 8, assignment; 8, 9; ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:dispatch; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:test; 7, False; 8, block; 8, 9; 8, 22; 8, 34; 8, 47; 8, 54; 8, 60; 8, 172; 8, 263; 8, 363; 9, if_statement; 9, 10; 9, 14; 10, not_operator;...
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, " ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_get_value_from_element; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:elt; 6, identifier:prop; 7, block; 7, 8; 7, 12; 7, 25; 7, 34; 7, 41; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:args; 11...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:_get_type_of_macro; 3, parameters; 3, 4; 3, 5; 4, identifier:macros; 5, identifier:objs; 6, block; 6, 7; 6, 9; 7, expression_statement; 7, 8; 8, identifier:r; 9, for_statement; 9, 10; 9, 11; 9, 12; 10, identifier:macro; 11, identifier:macros; 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:_resolve_ondemand; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:macro; 6, identifier:data; 7, block; 7, 8; 7, 17; 7, 24; 7, 30; 7, 216; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:elts; 11, c...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:parse; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 23; 5, 35; 5, 44; 5, 101; 5, 110; 5, 120; 5, 340; 5, 350; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:sub_directory; 9, string:'alignak.d'; 10...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:get_modules; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:name; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:daemon_name; 10, None; 11, default_parameter; 11, 12; 11, ...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:daemon_connection_init; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:s_link; 6, default_parameter; 6, 7; 6, 8; 7, identifier:set_wait_new_conf; 8, False; 9, block; 9, 10; 9, 23; 9, 44; 9, 50; 9, 63; 9, 69; 9, 75; 9, 79; 9,...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:do_daemon_init_and_start; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:set_proc_title; 7, True; 8, block; 8, 9; 8, 21; 8, 27; 8, 33; 8, 39; 8, 74; 8, 80; 8, 97; 8, 107; 8, 114; 8, 136; 8, 144; 8...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:make_a_pause; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeout; 7, float:0.0001; 8, default_parameter; 8, 9; 8, 10; 9, identifier:check_time_change; 10, True; 11, block; 11, 12; 11, 2...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:explode_hostgroup; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:svc_dep; 6, identifier:hostgroups; 7, block; 7, 8; 7, 27; 7, 46; 7, 65; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:snames; 11,...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:linkify_sd_by_s; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, block; 7, 8; 7, 12; 7, 18; 7, 24; 7, 234; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:to_del; 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:init; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 21; 5, 48; 5, 291; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:enabled; 11, block; 11, 12; 11, 19; 12, expr...
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....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:get_metrics_from_perfdata; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:service; 6, identifier:perf_data; 7, block; 7, 8; 7, 12; 7, 19; 7, 189; 7, 198; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identi...
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" ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:manage_service_check_result_brok; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:b; 6, block; 6, 7; 6, 19; 6, 31; 6, 39; 6, 47; 6, 55; 6, 76; 6, 97; 6, 111; 6, 123; 6, 168; 6, 175; 6, 248; 6, 255; 6, 296; 6, 328; 6, 365; 6, 369; 6...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:manage_host_check_result_brok; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:b; 6, block; 6, 7; 6, 19; 6, 24; 6, 32; 6, 53; 6, 67; 6, 79; 6, 124; 6, 131; 6, 204; 6, 258; 6, 295; 6, 299; 6, 320; 7, expression_statement; 7, 8; 8, a...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:resolve_elements; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 28; 5, 42; 5, 57; 5, 69; 5, 75; 5, 79; 5, 138; 5, 159; 6, if_statement; 6, 7; 6, 10; 7, attribute; 7, 8; 7, 9; 8, identifier:self; 9, identifier:leaf; 10, block; 10, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:eval_cor_pattern; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:pattern; 6, block; 6, 7; 6, 15; 6, 19; 6, 32; 6, 38; 6, 113; 6, 117; 6, 121; 6, 125; 6, 361; 6, 369; 6, 392; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 1...
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('!'): ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:find_object; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:pattern; 6, block; 6, 7; 6, 11; 6, 15; 6, 23; 6, 69; 6, 176; 6, 187; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:obj; 10, None; 11, expressio...
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 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:clean_queues; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 26; 5, 45; 5, 64; 5, 90; 5, 96; 5, 245; 5, 251; 5, 323; 5, 329; 6, if_statement; 6, 7; 6, 17; 7, comparison_operator:==; 7, 8; 7, 16; 8, call; 8, 9; 8, 10; 9, identifier:...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:scatter_master_notifications; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 52; 5, 66; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:now; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12; 11, i...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:log_initial_states; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 18; 6, for_statement; 6, 7; 6, 8; 6, 11; 7, identifier:elt; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:hosts; 11, block; 11, 12; 12, expression_s...
def log_initial_states(self): for elt in self.hosts: elt.raise_initial_state() for elt in self.services: elt.raise_initial_state()
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:get_retention_data; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 106; 5, 119; 5, 213; 5, 226; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:retention_data; 9, dictionary; 9, 10; 9, 13; 10, pair; 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:restore_retention_data_item; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:data; 6, identifier:item; 7, block; 7, 8; 7, 16; 7, 27; 7, 86; 7, 132; 7, 138; 7, 224; 7, 256; 7, 284; 7, 290; 7, 296; 7, 334; 7, 340; 8, expression...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:fill_initial_broks; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:broker_name; 6, block; 6, 7; 6, 11; 6, 23; 6, 96; 6, 117; 6, 132; 6, 140; 6, 148; 6, 176; 6, 191; 6, 206; 6, 309; 6, 327; 6, 335; 6, 350; 6, 362; 6, 368; 6, 374; 6...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:consume_results; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 36; 5, 162; 5, 166; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:queue_size; 9, call; 9, 10; 9, 15; 10, attribute; 10, 11; 10, 14; 11...
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", ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:send_broks_to_modules; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 18; 5, 22; 5, 65; 5, 70; 5, 81; 5, 143; 5, 185; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:t00; 9, call; 9, 10; 9, 13; 10, at...
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 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:push_external_commands_to_schedulers; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 19; 5, 25; 5, 33; 5, 44; 5, 96; 5, 100; 5, 104; 5, 271; 5, 279; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8,...
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 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_groupnames; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:hostgroups; 6, block; 6, 7; 6, 11; 6, 34; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:group_names; 10, list:[]; 11, for_statement; 11, 12;...
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))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_groupaliases; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:hostgroups; 6, block; 6, 7; 6, 11; 6, 32; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:group_aliases; 10, list:[]; 11, for_statement; 11,...
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))
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_overall_state; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:services; 6, block; 6, 7; 6, 11; 6, 68; 6, 107; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:overall_state; 10, integer:0; 11, if_statem...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:do_loop_turn; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 154; 6, if_statement; 6, 7; 6, 11; 7, not_operator; 7, 8; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:first_scheduling; 11, block; 11, 12; 11, 19; 11, 2...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:add_failed_check_attempt; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:reason; 7, string:''; 8, block; 8, 9; 8, 15; 8, 25; 8, 42; 8, 88; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:get_links_for_a_broker; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:pollers; 6, identifier:reactionners; 7, identifier:receivers; 8, identifier:realms; 9, default_parameter; 9, 10; 9, 11; 10, identifier...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_links_for_a_scheduler; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:pollers; 6, identifier:reactionners; 7, identifier:brokers; 8, block; 8, 9; 8, 22; 8, 155; 9, expression_statement; 9, 10; 10, assignment; 10, 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_default; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:check; 7, False; 8, block; 8, 9; 8, 13; 8, 43; 8, 119; 8, 125; 8, 203; 8, 209; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 1...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 2, function_name:command; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 3, 14; 3, 17; 3, 20; 3, 23; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:command; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:timestamp; 10, None; 11, defaul...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:satellites_list; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:daemon_type; 7, string:''; 8, block; 8, 9; 9, with_statement; 9, 10; 9, 17; 10, with_clause; 10, 11; 11, with_item; 11, 12; 12, attr...
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 = [] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:fill_default_configuration; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 21; 5, 86; 5, 119; 5, 127; 5, 193; 5, 201; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:got_arbiter_module_type_defined; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:module_type; 6, block; 6, 7; 6, 70; 7, for_statement; 7, 8; 7, 9; 7, 12; 8, identifier:arbiter; 9, attribute; 9, 10; 9, 11; 10, identifier:self; 11, i...
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....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:load_modules_configuration_objects; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:raw_objects; 6, block; 6, 7; 7, for_statement; 7, 8; 7, 9; 7, 14; 8, identifier:instance; 9, attribute; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12...
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....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:load_modules_alignak_configuration; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 10; 5, 112; 5, 116; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 9; 8, identifier:alignak_cfg; 9, dictionary; 10, for_statement; 10, 11; 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:daemons_start; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:run_daemons; 7, True; 8, block; 8, 9; 8, 13; 8, 32; 8, 204; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:daemons_stop; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:timeout; 7, integer:30; 8, default_parameter; 8, 9; 8, 10; 9, identifier:kill_children; 10, False; 11, block; 11, 12; 11, 30; 11...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:setup_new_conf; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 16; 5, 412; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 15; 8, attribute; 8, 9; 8, 14; 9, call; 9, 10; 9, 11; 10, identifier:super; 11, argument_list; 11, 12; 11, ...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:wait_for_master_death; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 13; 5, 17; 5, 27; 5, 31; 5, 56; 5, 64; 6, expression_statement; 6, 7; 7, call; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:logger; 10, identifier:info;...
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...
0, module; 0, 1; 1, ERROR; 1, 2; 1, 257; 1, 261; 1, 268; 1, 408; 2, function_definition; 2, 3; 2, 4; 2, 9; 3, function_name:configuration_dispatch; 4, parameters; 4, 5; 4, 6; 5, identifier:self; 6, default_parameter; 6, 7; 6, 8; 7, identifier:not_configured; 8, None; 9, block; 9, 10; 9, 179; 9, 187; 9, 199; 9, 213; 9, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:duplicate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:host; 6, block; 6, 7; 6, 11; 6, 25; 6, 34; 6, 42; 6, 67; 6, 74; 6, 83; 6, 155; 6, 339; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 10; 9, identifier:duplicates; ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:explode_services_from_hosts; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:hosts; 6, identifier:service; 7, identifier:hnames; 8, block; 8, 9; 8, 13; 8, 17; 8, 57; 8, 67; 8, 84; 9, expression_statement; 9, 10; 10, ass...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:explode; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:hosts; 6, identifier:hostgroups; 7, identifier:contactgroups; 8, identifier:servicegroups; 9, identifier:servicedependencies; 10, block; 10, 11; 10, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_next_notif_time; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:t_wished; 6, identifier:status; 7, identifier:creation_time; 8, identifier:interval; 9, identifier:escal_period; 10, block; 10, 11; 10, 4...
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': ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:linkify_es_by_s; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:services; 6, block; 6, 7; 7, for_statement; 7, 8; 7, 9; 7, 10; 8, identifier:escalation; 9, identifier:self; 10, block; 10, 11; 10, 20; 10, 32; 10, 48; 11, if_stateme...
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 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:get_contacts_by_explosion; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:contactgroups; 6, block; 6, 7; 6, 13; 6, 43; 6, 49; 6, 57; 6, 100; 6, 111; 7, expression_statement; 7, 8; 8, assignment; 8, 9; 8, 12; 9, attribute; 9, 10; 9...
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 ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 2, function_name:do_check_freshness; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, identifier:timeperiods; 8, identifier:macromodulations; 9, identifier:checkmodulations; 10...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:update_business_impact_value; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, identifier:timeperiods; 8, identifier:bi_modulations; 9, block; 9, 10; 9, 26; 9, 30; 9, 83; 9, 143; 1...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:register_a_problem; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 4, identifier:self; 5, identifier:prob; 6, identifier:hosts; 7, identifier:services; 8, identifier:timeperiods; 9, identifier:bi_modulations; 10, block; 10, 11; 10, 22; 10,...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:is_enable_action_dependent; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, block; 7, 8; 7, 12; 7, 86; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:enable_action...
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] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 2, function_name:update_hard_unknown_phase_state; 3, parameters; 3, 4; 4, identifier:self; 5, block; 5, 6; 5, 14; 5, 33; 5, 101; 6, expression_statement; 6, 7; 7, assignment; 7, 8; 7, 11; 8, attribute; 8, 9; 8, 10; 9, identifier:self; 10, identifier:was_in_hard...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:get_next_notification_time; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:notif; 6, identifier:escalations; 7, identifier:timeperiods; 8, block; 8, 9; 8, 13; 8, 21; 8, 27; 8, 33; 8, 45; 8, 107; 8, 119; 8, 134; 8, 138;...
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: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:get_business_rule_output; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, identifier:macromodulations; 8, identifier:timeperiods; 9, block; 9, 10; 9, 19; 9, 32; 9, 38; 9, 44; 9, 5...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:business_rule_notification_is_blocked; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:hosts; 6, identifier:services; 7, block; 7, 8; 7, 12; 7, 93; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:ac...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 2, function_name:acknowledge_problem; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 3, 12; 4, identifier:self; 5, identifier:notification_period; 6, identifier:hosts; 7, identifier:services; 8, identifier:sticky; 9, identifier:notify; 10, id...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:setup_logger; 3, parameters; 3, 4; 3, 5; 3, 8; 3, 11; 4, identifier:logger_configuration_file; 5, default_parameter; 5, 6; 5, 7; 6, identifier:log_dir; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:process_name; 10, string:''; 11, ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 2, function_name:want_service_notification; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 11; 4, identifier:self; 5, identifier:notifways; 6, identifier:timeperiods; 7, identifier:timestamp; 8, identifier:state; 9, identifier:n_type; 10, identif...
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] ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 2, function_name:explode; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:contactgroups; 6, identifier:notificationways; 7, block; 7, 8; 7, 15; 7, 34; 7, 74; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, 11; 10, 12;...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:receive; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:arg_formats; 7, None; 8, block; 8, 9; 8, 14; 8, 18; 8, 22; 8, 26; 8, 155; 8, 174; 8, 216; 8, 229; 8, 243; 8, 287; 8, 291; 8, 336; 8, 350; 8,...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:update_share; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:share_id; 6, dictionary_splat_pattern; 6, 7; 7, identifier:kwargs; 8, block; 8, 9; 8, 19; 8, 29; 8, 39; 8, 58; 8, 72; 8, 82; 8, 86; 8, 95; 8, 110; 8, 136; 8, 157; ...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:get_shares; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:path; 7, string:''; 8, dictionary_splat_pattern; 8, 9; 9, identifier:kwargs; 10, block; 10, 11; 10, 24; 10, 28; 10, 153; 10, 166; ...
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....
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:share_file_with_user; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:path; 6, identifier:user; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 20; 9, 32; 9, 68; 9, 86; 9, 95; 9, 123; 9, 139...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 11; 2, function_name:get_attribute; 3, parameters; 3, 4; 3, 5; 3, 8; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:app; 7, None; 8, default_parameter; 8, 9; 8, 10; 9, identifier:key; 10, None; 11, block; 11, 12; 11, 16; 11, 55; 11, 68; 11, 19...
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', ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:_make_dav_request; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:method; 6, identifier:path; 7, dictionary_splat_pattern; 7, 8; 8, identifier:kwargs; 9, block; 9, 10; 9, 43; 9, 52; 9, 80; 9, 94; 9, 110; 9, 121; 10, if...
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( ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 2, function_name:load_delimited; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:filename; 5, identifier:converters; 6, default_parameter; 6, 7; 6, 8; 7, identifier:delimiter; 8, string:r'\s+'; 9, block; 9, 10; 9, 12; 9, 19; 9, 34; 9, 43; 9, 158; 10, expression_...
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...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:validate; 3, parameters; 3, 4; 3, 5; 4, identifier:reference_patterns; 5, identifier:estimated_patterns; 6, block; 6, 7; 6, 22; 6, 37; 7, if_statement; 7, 8; 7, 14; 8, comparison_operator:==; 8, 9; 8, 13; 9, call; 9, 10; 9, 11; 10, identifier:_...
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]: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 2, function_name:three_layer_FPR; 3, parameters; 3, 4; 3, 5; 4, identifier:reference_patterns; 5, identifier:estimated_patterns; 6, block; 6, 7; 6, 13; 6, 58; 6, 110; 6, 221; 6, 242; 6, 253; 6, 270; 6, 287; 6, 297; 7, expression_statement; 7, 8; 8, call; 8, 9; ...
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)) ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 28; 2, function_name:match_notes; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 3, 8; 3, 9; 3, 10; 3, 13; 3, 16; 3, 19; 3, 22; 3, 25; 4, identifier:ref_intervals; 5, identifier:ref_pitches; 6, identifier:ref_velocities; 7, identifier:est_intervals; 8, identifier:est_pitc...
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...