sequence
stringlengths
546
16.2k
code
stringlengths
108
19.3k
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, 11; 8, 16; 8, 20; 8, 26; 8, 45; 8, 71; 8, 80; 8, 81; 8, 105; 8, 116; 8, 122; 8, 176; 9, expression_...
def join(self, ignore_errors=False): """Waits until last executed command completed.""" 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...
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: """Experimental version of run propagates error messages to client. This...
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: """Uploads file to remote instance. If location not specified, dumps it into default directory. If remote location has files or directories with the same name, behavior is undefined.""" # support w...
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, 10; 7, 61; 7, 62; 7, 68; 7, 94; 7, 100; 7, 101; 7, 117; 7, 118; 8, expression_statement; 8, 9; 9, comment; 10, func...
def get_child_fn(attrs, names, bases): """Returns a function from the child class that matches one of the names. Searches the child class's set of methods (i.e., the attrs dict) for all the functions matching the given list of names. If more than one is found, an exception is raised, if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 20; 1, 21; 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_...
def authenticate(self, username=None, password=None, actions=None, response=None, authorization=None): # pylint: disable=too-many-arguments,too-many-locals """ Authenticate to the registry using a username and password, an au...
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, 14; 11, 25; 11, 36; 11...
def parse(self, ddl=None, source_database=None): """ Parse DDL script. :param ddl: DDL script :return: DdlParseTable, Parsed table define info. """ if ddl is not None: self._ddl = ddl if source_database is not None: self.source_database ...
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, 9; 6, 19; 6, 20; 6, 29; 6, 36; 6, 37; 6, 38; 6, 64; 6, 82; 6, 83; 6, 84; 6, 93; 6, 102; 6, 111; 6, 124; 6, 125; 7, expression...
def get_next_valid_time_from_t(self, timestamp): """Get next valid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid time (LOCAL TIME) :rtype: int | None """ if self.is_time_valid(timestamp): ...
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, 9; 6, 20; 6, 21; 6, 30; 6, 31; 6, 32; 6, 58; 6, 59; 6, 60; 6, 61; 6, 62; 6, 77; 6, 78; 6, 79; 6, 90; 6, 91; 6, 92; 6, 101; ...
def get_next_invalid_time_from_t(self, timestamp): """Get next invalid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid time (LOCAL TIME) :rtype: int """ if not self.is_time_valid(timestamp): ...
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, 11; 8, 20; 8, 35; 8, 53; 8, 66; 8, 81; 8, 99; 8, 112; 8, 121; 8, 284; 9, expression_statemen...
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthWeekDayDaterange :param ref: time in seconds :type ref: int | None :return: tuple with start and end time :rtype: tuple """ now = time.localtime(ref) ...
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, 11; 8, 20; 8, 35; 8, 50; 8, 63; 8, 78; 8, 93; 8, 106; 8, 115; 8, 266; 9, expression_statemen...
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDateDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
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, 11; 8, 20; 8, 21; 8, 36; 8, 42; 8, 58; 8, 69; 8, 70; 8, 85; 8, 91; 8, 107; 8, 118; 8, 119; 8...
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
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, 11; 8, 26; 8, 37; 8, 100; 8, 267; 9, expression_statement; 9, 10; 10, comment; 11, if_statement; 11, 12; 11,...
def flush(self, log=False): """Send inner stored metrics to the defined Graphite Returns False if the sending failed with a warning log if log parameter is set :return: bool """ if not self.my_metrics: logger.debug("Flushing - no metrics to send") return...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 2, function_name:counter; 3, parameters; 3, 4; 3, 5; 3, 6; 3, 7; 4, identifier:self; 5, identifier:key; 6, identifier:value; 7, default_parameter; 7, 8; 7, 9; 8, identifier:timestamp; 9, None; 10, block; 10, 11; 10, 13; 10, 33; 10, 37; 10, 41; 10, 54; 10, 67; ...
def counter(self, key, value, timestamp=None): """Set a counter value If the inner key does not exist is is created :param key: counter to update :type key: str :param value: counter value :type value: float :return: An alignak_stat brok if broks are enabled els...
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, 11; 8, 19; 8, 20; 8, 24; 8, 28; 8, 104; 8, 105; 8, 106; 8, 112; 8, 139; 8...
def create_and_launch_worker(self, module_name='fork'): """Create and launch a new worker, and put it into self.workers It can be mortal or not :param module_name: the module name related to the worker default is "fork" for no module Inde...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 1, 7; 2, function_name:check_and_del_zombie_workers; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, comment; 7, block; 7, 8; 7, 10; 7, 11; 7, 12; 7, 26; 7, 30; 7, 120; 7, 121; 7, 122; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, co...
def check_and_del_zombie_workers(self): # pragma: no cover, not with unit tests... # pylint: disable= not-callable """Check if worker are fine and kill them if not. Dispatch the actions in the worker to another one TODO: see if unit tests would allow to check this code? :retur...
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, 10; 7, 11; 7, 15; 7, 64; 7, 80; 7, 88; 8, expression_statement; 8, 9; 9, comment; 10, comment;...
def add_actions(self, actions_list, scheduler_instance_id): """Add a list of actions to the satellite queues :param actions_list: Actions list to add :type actions_list: list :param scheduler_instance_id: sheduler link to assign the actions to :type scheduler_instance_id: Schedu...
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, 12; 8, 21; 8, 28; 8, 29; 8, 42; 8, 43; 8, 44; 8, 48; 8, 138; 9, expression_statement; 9...
def split_semicolon(line, maxsplit=None): r"""Split a line on semicolons characters but not on the escaped semicolons :param line: line to split :type line: str :param maxsplit: maximal number of split (if None, no limit) :type maxsplit: None | int :return: split line :rtype: list >>> ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:sort_by_number_values; 3, parameters; 3, 4; 3, 5; 4, identifier:x00; 5, identifier:y00; 6, comment; 7, block; 7, 8; 7, 10; 7, 23; 7, 37; 7, 38; 8, expression_statement; 8, 9; 9, comment; 10, if_statement; 10, 11; 10, 20; 11, comparison_op...
def sort_by_number_values(x00, y00): # pragma: no cover, looks like not used! """Compare x00, y00 base on number of values :param x00: first elem to compare :type x00: list :param y00: second elem to compare :type y00: list :return: x00 > y00 (-1) if len(x00) > len(y00), x00 == y00 (0) if id e...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 10; 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, comment; 10, block; 10, 11; 10, 13; 10, 24; 10, 25; 10, 29; 10, 304; 10, 379; 11, expre...
def add_item(self, item, index=True): # pylint: disable=too-many-branches, too-many-locals, too-many-nested-blocks """ Add an item into our containers, and index it depending on the `index` flag. :param item: object to add :type item: alignak.objects.item.Item :param ind...
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, 9; 6, 18; 6, 19; 6, 23; 6, 56; 6, 63; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 16;...
def explode_contact_groups_into_contacts(item, contactgroups): """ Get all contacts of contact_groups and put them in contacts container :param item: item where have contact_groups property :type item: object :param contactgroups: all contactgroups object :type contactgr...
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, 9; 6, 10; 6, 20; 6, 21; 6, 132; 6, 133; 6, 134; 6, 135; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, ...
def dfs_loop_search(self, root): """Main algorithm to look for loop. It tags nodes and find ones stuck in loop. * Init all nodes with DFS_UNCHECKED value * DFS_TEMPORARY_CHECKED means we found it once * DFS_OK : this node (and all sons) are fine * DFS_NEAR_LOOP : One pro...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 13; 1, 14; 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, defau...
def eval_complex_cor_pattern(self, pattern, hosts, services, hostgroups, servicegroups, running=False): # pylint: disable=too-many-branches """Parse and build recursively a tree of DependencyNode from a complex pattern :param pattern: pattern to parse :t...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:get_next_valid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, comment; 7, block; 7, 8; 7, 10; 7, 17; 7, 21; 7, 30; 7, 37; 7, 41; 7, 42; 7, 234; 7, 235; 7, 243; 8, expression_statement; 8, 9; 9, com...
def get_next_valid_time_from_t(self, timestamp): # pylint: disable=too-many-branches """ Get next valid time. If it's in cache, get it, otherwise define it. The limit to find it is 1 year. :param timestamp: number of seconds :type timestamp: int or float :return:...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:get_next_invalid_time_from_t; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:timestamp; 6, comment; 7, block; 7, 8; 7, 10; 7, 17; 7, 21; 7, 25; 7, 100; 7, 107; 7, 108; 7, 112; 7, 193; 7, 210; 7, 265; 8, expression_statement;...
def get_next_invalid_time_from_t(self, timestamp): # pylint: disable=too-many-branches """ Get the next invalid time :param timestamp: timestamp in seconds (of course) :type timestamp: int or float :return: timestamp of next invalid time :rtype: int or float ...
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, 8; 5, 12; 5, 13; 5, 14; 5, 33; 5, 75; 5, 76; 5, 153; 5, 154; 5, 168; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; ...
def is_correct(self): """ check if each properties of timeperiods are valid :return: True if is correct, otherwise False :rtype: bool """ valid = True # We do not want a same hg to be explode again and again # so we tag it for timeperiod in list(s...
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, 9; 6, 10; 6, 14; 6, 31; 6, 32; 6, 36; 6, 40; 6, 44; 6, 90; 6, 94; 6, 101; 6, 108; 6, 115; 6, 121; 6, 122; 7, expression_statement...
def get_scheduler_ordered_list(self, realm): """Get sorted scheduler list for a specific realm List is ordered as: alive first, then spare (if any), then dead scheduler links :param realm: realm we want scheduler from :type realm: alignak.objects.realm.Realm :return: sorted sch...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 9; 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, comment; 9, block; 9, 10; 9, 12; 9, 25; 9, 37; 9, 50; 9, 57; 9, 63; 9, 64; 9, 182; 9, 274; 9, 375; 10, expression_...
def dispatch(self, test=False): # pylint: disable=too-many-branches """ Send configuration to satellites :return: None """ if not self.new_to_dispatch: raise DispatcherError("Dispatcher cannot dispatch, " "because no configuration i...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 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, comment; 8, block; 8, 9; 8, 11; 8, 15; 8, 16; 8, 29; 8, 38; 8, 45; 9, expression_statement; 9, 10; 10, comment; 11, ex...
def _get_value_from_element(self, elt, prop): # pylint: disable=too-many-return-statements """Get value from an element's property. the property may be a function to call. If the property is not resolved (because not implemented), this function will return 'n/a' :param elt: el...
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, comment; 9, for_statement; 9, 10; 9, 11; 9, 12; 9, 13; 10, identifier:macro; 11, identifier:macros;...
def _get_type_of_macro(macros, objs): r"""Set macros types Example:: ARG\d -> ARGN, HOSTBLABLA -> class one and set Host in class) _HOSTTOTO -> HOST CUSTOM MACRO TOTO SERVICESTATEID:srv-1:Load$ -> MACRO SERVICESTATEID of the service Load of host srv-1 :param ma...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 2, function_name:_resolve_ondemand; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:macro; 6, identifier:data; 7, comment; 8, block; 8, 9; 8, 11; 8, 20; 8, 27; 8, 33; 8, 34; 8, 229; 8, 230; 9, expression_statement; 9, 10; 10, comment; 1...
def _resolve_ondemand(self, macro, data): # pylint: disable=too-many-locals """Get on demand macro value If the macro cannot be resolved, this function will return 'n/a' rather than an empty string, this to alert the caller of a potential problem. :param macro: macro to parse ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:parse; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 14; 6, 27; 6, 39; 6, 48; 6, 105; 6, 114; 6, 115; 6, 125; 6, 348; 6, 358; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_sta...
def parse(self): # pylint: disable=too-many-branches """ Check if some extra configuration files are existing in an `alignak.d` sub directory near the found configuration file. Parse the Alignak configuration file(s) Exit the script if some errors are encountered. ...
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): """ Get the modules configuration parameters If name is provided, get the configuration for this module, else, If daemon_name is provided, get the configuration for all the modules of this daemon, else get the ...
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, 12; 9, 25; 9, 26; 9, 47; 9, 48; 9, 54; 9, 55; 9,...
def daemon_connection_init(self, s_link, set_wait_new_conf=False): """Initialize a connection with the daemon for the provided satellite link Initialize the connection (HTTP client) to the daemon and get its running identifier. Returns True if it succeeds else if any error occur or the daemon i...
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, 11; 8, 23; 8, 24; 8, 30; 8, 31; 8, 37; 8, 38; 8, 44; 8, 45; 8, 81; 8, 82; 8, 83...
def do_daemon_init_and_start(self, set_proc_title=True): """Main daemon function. Clean, allocates, initializes and starts all necessary resources to go in daemon mode. The set_proc_title parameter is mainly useful for the Alignak unit tests. This to avoid changing the test process name...
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, 1...
def make_a_pause(self, timeout=0.0001, check_time_change=True): """ Wait up to timeout and check for system time change. This function checks if the system time changed since the last call. If so, the difference is returned to the caller. The duration of this call is removed from the ti...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 2, function_name:explode_hostgroup; 3, parameters; 3, 4; 3, 5; 3, 6; 4, identifier:self; 5, identifier:svc_dep; 6, identifier:hostgroups; 7, comment; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 8, 32; 8, 33; 8, 52; 8, 53; 8, 72; 9, expression_statement; 9, 10; 1...
def explode_hostgroup(self, svc_dep, hostgroups): # pylint: disable=too-many-locals """Explode a service dependency for each member of hostgroup :param svc_dep: service dependency to explode :type svc_dep: alignak.objects.servicedependency.Servicedependency :param hostgroups: us...
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, 10; 7, 14; 7, 20; 7, 26; 7, 238; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; ...
def linkify_sd_by_s(self, hosts, services): """Replace dependent_service_description and service_description in service dependency by the real object :param hosts: host list, used to look for a specific one :type hosts: alignak.objects.host.Hosts :param services: service list to...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:init; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 24; 6, 52; 6, 302; 7, expression_statement; 7, 8; 8, comment; 9, if_statement; 9, 10; 9, 14; 10, not_operator; 10, 11; 11, attribute; 11, 12; 11, 13; 12, ...
def init(self): # pylint: disable=too-many-branches """Called by the daemon broker to initialize the module""" if not self.enabled: logger.info(" the module is disabled.") return True try: connections = self.test_connection() except Exception as exp:...
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, 10; 7, 14; 7, 21; 7, 193; 7, 202; 8, expression_statement; 8, 9; 9, comment; 10, expression_state...
def get_metrics_from_perfdata(self, service, perf_data): """Decode the performance data to build a metrics list""" result = [] metrics = PerfDatas(perf_data) for metric in metrics: logger.debug("service: %s, metric: %s (%s)", service, metric, metric.__dict__) if...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:manage_service_check_result_brok; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:b; 6, comment; 7, block; 7, 8; 7, 10; 7, 22; 7, 34; 7, 42; 7, 50; 7, 58; 7, 59; 7, 80; 7, 101; 7, 102; 7, 116; 7, 128; 7, 129; 7, 174; 7, 175; ...
def manage_service_check_result_brok(self, b): # pylint: disable=too-many-branches """A service check result brok has just arrived ...""" host_name = b.data.get('host_name', None) service_description = b.data.get('service_description', None) if not host_name or not service_description: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:manage_host_check_result_brok; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:b; 6, comment; 7, block; 7, 8; 7, 10; 7, 22; 7, 27; 7, 35; 7, 36; 7, 57; 7, 58; 7, 72; 7, 84; 7, 85; 7, 130; 7, 131; 7, 138; 7, 211; 7, 212; 7, 26...
def manage_host_check_result_brok(self, b): # pylint: disable=too-many-branches """An host check result brok has just arrived...""" host_name = b.data.get('host_name', None) if not host_name: return logger.debug("host check result: %s", host_name) # If host initial ...
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, 8; 5, 9; 5, 31; 5, 32; 5, 46; 5, 61; 5, 62; 5, 63; 5, 75; 5, 81; 5, 82; 5, 86; 5, 146; 5, 147; 5, 168; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, if_st...
def resolve_elements(self): """Get element of this node recursively Compute rules with OR or AND rule then NOT rules. :return: set of element :rtype: set """ # If it's a leaf, we just need to dump a set with the content of the node if self.leaf: if no...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:eval_cor_pattern; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:pattern; 6, comment; 7, block; 7, 8; 7, 10; 7, 18; 7, 22; 7, 23; 7, 24; 7, 37; 7, 43; 7, 44; 7, 45; 7, 46; 7, 123; 7, 127; 7, 131; 7, 135; 7, 384; 7, 385; 7, 3...
def eval_cor_pattern(self, pattern): # pylint:disable=too-many-branches """Parse and build recursively a tree of ComplexExpressionNode from pattern :param pattern: pattern to parse :type pattern: str :return: root node of parsed tree :type: alignak.complexexpression.ComplexExpr...
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, 9; 6, 13; 6, 17; 6, 25; 6, 71; 6, 72; 6, 184; 6, 195; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignmen...
def find_object(self, pattern): """Get a list of host corresponding to the pattern regarding the context :param pattern: pattern to find :type pattern: str :return: Host list matching pattern (hostgroup name, template, all) :rtype: list[alignak.objects.host.Host] """ ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:clean_queues; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 30; 6, 49; 6, 68; 6, 94; 6, 95; 6, 96; 6, 97; 6, 98; 6, 104; 6, 258; 6, 259; 6, 260; 6, 266; 6, 340; 6, 346; 7, expression_statement; 7, 8;...
def clean_queues(self): # pylint: disable=too-many-locals """Reduces internal list size to max allowed * checks and broks : 5 * length of hosts + services * actions : 5 * length of hosts + services + contacts :return: None """ # If we set the interval at 0, we b...
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, 8; 5, 16; 5, 17; 5, 55; 5, 69; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, 10; 9, 11; 10, identifier:now; ...
def scatter_master_notifications(self): """Generate children notifications from a master notification Also update notification number Master notification are raised when a notification must be sent out. They are not launched by reactionners (only children are) but they are used to build...
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, 8; 5, 9; 5, 21; 5, 22; 6, expression_statement; 6, 7; 7, comment; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 14; 10, identifier:elt; 11, attribute; 11, 12; 11, ...
def log_initial_states(self): """Raise hosts and services initial status logs First, raise hosts status and then services. This to allow the events log to be a little sorted. :return: None """ # Raise hosts initial status broks for elt in self.hosts: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 1, 7; 2, function_name:get_retention_data; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, comment; 7, block; 7, 8; 7, 10; 7, 20; 7, 112; 7, 125; 7, 126; 7, 222; 7, 235; 8, expression_statement; 8, 9; 9, comment; 10, expression_statement; 10, 11; ...
def get_retention_data(self): # pylint: disable=too-many-branches,too-many-statements # pylint: disable=too-many-locals """Get all hosts and services data to be sent to the retention storage. This function only prepares the data because a module is in charge of making the data survive ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 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, comment; 8, block; 8, 9; 8, 11; 8, 12; 8, 20; 8, 31; 8, 91; 8, 92; 8, 140; 8, 141; 8, 147; 8, 148; 8, 149; 8, 238...
def restore_retention_data_item(self, data, item): # pylint: disable=too-many-branches, too-many-locals """ Restore data in item :param data: retention data of the item :type data: dict :param item: host or service item :type item: alignak.objects.host.Host | ali...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:fill_initial_broks; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:broker_name; 6, comment; 7, block; 7, 8; 7, 10; 7, 14; 7, 26; 7, 100; 7, 121; 7, 136; 7, 137; 7, 145; 7, 153; 7, 154; 7, 155; 7, 183; 7, 198; 7, 213; 7, 320;...
def fill_initial_broks(self, broker_name): # pylint: disable=too-many-branches """Create initial broks for a specific broker :param broker_name: broker name :type broker_name: str :return: number of created broks """ broker_uuid = None logger.debug("My br...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:consume_results; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 11; 6, 21; 6, 41; 6, 42; 6, 173; 6, 174; 6, 178; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, comment; 11, expression_stat...
def consume_results(self): # pylint: disable=too-many-branches """Handle results waiting in waiting_results list. Check ref will call consume result and update their status :return: None """ # All results are in self.waiting_results # We need to get them first q...
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, 8; 5, 16; 5, 20; 5, 24; 5, 67; 5, 72; 5, 83; 5, 145; 5, 146; 5, 188; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, assignment; 9, ...
def send_broks_to_modules(self): """Put broks into module queues Only broks without sent_to_externals to True are sent Only modules that ask for broks will get some :return: None """ t00 = time.time() nb_sent = 0 broks = [] for broker_link in list...
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, 8; 5, 15; 5, 16; 5, 22; 5, 28; 5, 36; 5, 37; 5, 48; 5, 101; 5, 102; 5, 106; 5, 110; 5, 281; 5, 289; 6, expression_statement; 6, 7; 7, comment; 8, ...
def push_external_commands_to_schedulers(self): """Push received external commands to the schedulers :return: None """ if not self.unprocessed_external_commands: return # Those are the global external commands commands_to_process = self.unprocessed_external_...
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, 9; 6, 13; 6, 36; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identifi...
def get_groupnames(self, hostgroups): """Get names of the host's hostgroups :return: comma separated names of hostgroups alphabetically sorted :rtype: str """ group_names = [] for hostgroup_id in self.hostgroups: hostgroup = hostgroups[hostgroup_id] ...
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, 9; 6, 13; 6, 34; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, 12; 11, identi...
def get_groupaliases(self, hostgroups): """Get aliases of the host's hostgroups :return: comma separated aliases of hostgroups alphabetically sorted :rtype: str """ group_aliases = [] for hostgroup_id in self.hostgroups: hostgroup = hostgroups[hostgroup_id] ...
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, 9; 6, 13; 6, 70; 6, 71; 6, 111; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11; 10, ...
def get_overall_state(self, services): """Get the host overall state including the host self status and the status of its services Compute the host overall state identifier, including: - the acknowledged state - the downtime state The host overall state is (prioritized)...
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, 8; 5, 161; 5, 162; 5, 163; 6, expression_statement; 6, 7; 7, comment; 8, if_statement; 8, 9; 8, 13; 8, 14; 9, not_operator; 9, 10; 10, attribute; 10, 11; 10, 12; 11, iden...
def do_loop_turn(self): """Scheduler loop turn Simply run the Alignak scheduler loop This is called when a configuration got received by the scheduler daemon. As of it, check if the first scheduling has been done... and manage this. :return: None """ if not sel...
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, 11; 8, 17; 8, 27; 8, 44; 8, 45; 8, 46; 8, 92; 8, 93; 9, expression_statement; 9, 1...
def add_failed_check_attempt(self, reason=''): """Set the daemon as unreachable and add a failed attempt if we reach the maximum attempts, set the daemon as dead :param reason: the reason of adding an attempts (stack trace sometimes) :type reason: str :return: None """ ...
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): """Get a configuration dictionary with pollers, reactionners and receivers links for a broker :param pollers: pollers :type pollers: :param reactio...
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, 11; 8, 12; 8, 25; 8, 26; 8, 169; 9, expression_statement; 9, 10; ...
def get_links_for_a_scheduler(self, pollers, reactionners, brokers): """Get a configuration dictionary with pollers, reactionners and brokers links for a scheduler :return: dict containing pollers, reactionners and brokers links (key is satellite id) :rtype: dict """ # ...
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, 11; 8, 15; 8, 45; 8, 122; 8, 128; 8, 208; 8, 214; 9, expression_statement; 9, 10; 10, comment; 11, e...
def get_default(self, check=False): """Get the default realm :param check: check correctness if True :type check: bool :return: Default realm of Alignak configuration :rtype: alignak.objects.realm.Realm | None """ found = [] for realm in sorted(self, key=...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 26; 1, 27; 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,...
def command(self, command=None, timestamp=None, element=None, host=None, service=None, user=None, parameters=None): # pylint: disable=too-many-branches """ Request to execute an external command Allowed parameters are: `command`: mandatory parameter containing the whole ...
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; 8, 11; 9, expression_statement; 9, 10; 10, comment; 11, with_statement; 11, 12; 11, 19; 1...
def satellites_list(self, daemon_type=''): """Get the arbiter satellite names sorted by type Returns a list of the satellites as in: { reactionner: [ "reactionner-master" ], broker: [ "broker-master" ], ...
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, 8; 5, 15; 5, 23; 5, 89; 5, 90; 5, 124; 5, 132; 5, 199; 5, 200; 5, 208; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9,...
def fill_default_configuration(self): """Fill objects properties with default value if necessary :return: None """ logger.debug("Filling the unset properties with their default value:") types_creations = self.__class__.types_creations for o_type in types_creations: ...
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, 9; 6, 77; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 14; 9, 15; 10, identifier:arbi...
def got_arbiter_module_type_defined(self, module_type): """Check if a module type is defined in one of the arbiters Also check the module name :param module_type: module type to search for :type module_type: str :return: True if mod_type is found else False :rtype: bool ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 1, 8; 2, function_name:load_modules_configuration_objects; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:raw_objects; 6, comment; 7, comment; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 9, expression_statement; 9, 10; 10, comment; 11, comment; 12,...
def load_modules_configuration_objects(self, raw_objects): # pragma: no cover, # not yet with unit tests. """Load configuration objects from arbiter modules If module implements get_objects arbiter will call it and add create objects :param raw_objects: raw objects we got from ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:load_modules_alignak_configuration; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 13; 6, 14; 6, 117; 6, 121; 7, expression_statement; 7, 8; 8, comment; 9, expression_statement; 9, 10; 10, assignment; 10, 11...
def load_modules_alignak_configuration(self): # pragma: no cover, not yet with unit tests. """Load Alignak configuration from the arbiter modules If module implements get_alignak_configuration, call this function :param raw_objects: raw objects we got from reading config files :type ra...
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, 11; 8, 15; 8, 34; 8, 35; 8, 209; 9, expression_statement; 9, 10; 10, comment; 11, expression_...
def daemons_start(self, run_daemons=True): """Manage the list of the daemons in the configuration Check if the daemon needs to be started by the Arbiter. If so, starts the daemon if `run_daemons` is True :param run_daemons: run the daemons or make a simple check :type run_daem...
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, 14; 11...
def daemons_stop(self, timeout=30, kill_children=False): """Stop the Alignak daemons Iterate over the self-launched daemons and their children list to send a TERM Wait for daemons to terminate and then send a KILL for those that are not yet stopped As a default behavior, only the la...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 5; 1, 6; 2, function_name:setup_new_conf; 3, parameters; 3, 4; 4, identifier:self; 5, comment; 6, block; 6, 7; 6, 9; 6, 10; 6, 20; 6, 456; 6, 457; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, expression_statement; 10, 11; 11, call; 11, 12; 11, 19; 12...
def setup_new_conf(self): # pylint: disable=too-many-locals """ Setup a new configuration received from a Master arbiter. TODO: perharps we should not accept the configuration or raise an error if we do not find our own configuration data in the data. Thus this should never happen... ...
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, 8; 5, 15; 5, 19; 5, 29; 5, 33; 5, 58; 5, 66; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement; 8, 9; 9, call; 9, 10; 9, 13; 10, attribute; 10, ...
def wait_for_master_death(self): """Wait for a master timeout and take the lead if necessary :return: None """ logger.info("Waiting for master death") timeout = 1.0 self.last_master_ping = time.time() master_timeout = 300 for arbiter_link in self.conf.ar...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 2, function_name:configuration_dispatch; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, default_parameter; 5, 6; 5, 7; 6, identifier:not_configured; 7, None; 8, block; 8, 9; 8, 11; 8, 263; 8, 264; 8, 265; 8, 269; 8, 276; 9, expression_statement; 9, 10; 10, c...
def configuration_dispatch(self, not_configured=None): """Monitored configuration preparation and dispatch :return: None """ if not not_configured: self.dispatcher = Dispatcher(self.conf, self.link_to_myself) # I set my own dispatched configuration as the provide...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:duplicate; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:host; 6, comment; 7, block; 7, 8; 7, 10; 7, 14; 7, 15; 7, 29; 7, 39; 7, 40; 7, 48; 7, 49; 7, 50; 7, 75; 7, 82; 7, 91; 7, 92; 7, 93; 7, 165; 7, 357; 8, expression_stat...
def duplicate(self, host): # pylint: disable=too-many-locals """For a given host, look for all copy we must create for for_each property :param host: alignak host object :type host: alignak.objects.host.Host :return: list :rtype: list """ duplicates = []...
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, 11; 8, 15; 8, 16; 8, 20; 8, 21; 8, 64; 8, 65; 8, 75; 8, 76; 8, 77; 8, 9...
def explode_services_from_hosts(self, hosts, service, hnames): """ Explodes a service based on a list of hosts. :param hosts: The hosts container :type hosts: :param service: The base service to explode :type service: :param hnames: The host_name list to explode...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 1, 11; 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, comment; 11,...
def explode(self, hosts, hostgroups, contactgroups, servicegroups, servicedependencies): # pylint: disable=too-many-locals """ Explodes services, from host, hostgroups, contactgroups, servicegroups and dependencies. :param hosts: The hosts container :type hosts: [alignak.object....
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, 1...
def get_next_notif_time(self, t_wished, status, creation_time, interval, escal_period): """Get the next notification time for the escalation Only legit for time based escalation :param t_wished: time we would like to send a new notification (usually now) :type t_wished: :param s...
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; 6, 9; 7, expression_statement; 7, 8; 8, comment; 9, for_statement; 9, 10; 9, 11; 9, 12; 9, 13; 10, identifier:escalation; 11, identifier:sel...
def linkify_es_by_s(self, services): """Add each escalation object into service.escalation attribute :param services: service list, used to look for a specific service :type services: alignak.objects.service.Services :return: None """ for escalation in self: ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 6; 1, 7; 2, function_name:get_contacts_by_explosion; 3, parameters; 3, 4; 3, 5; 4, identifier:self; 5, identifier:contactgroups; 6, comment; 7, block; 7, 8; 7, 10; 7, 11; 7, 12; 7, 18; 7, 19; 7, 20; 7, 21; 7, 22; 7, 52; 7, 53; 7, 59; 7, 67; 7, 110; 7, 121; 8, expr...
def get_contacts_by_explosion(self, contactgroups): # pylint: disable=access-member-before-definition """ Get contacts of this group :param contactgroups: Contactgroups object, use to look for a specific one :type contactgroups: alignak.objects.contactgroup.Contactgroups ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 12; 1, 13; 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:checkmodulati...
def do_check_freshness(self, hosts, services, timeperiods, macromodulations, checkmodulations, checks, when): # pylint: disable=too-many-nested-blocks, too-many-branches """Check freshness and schedule a check now if necessary. This function is called by the scheduler...
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, 12; 9, 13; 9, 29; 9, 30; 9,...
def update_business_impact_value(self, hosts, services, timeperiods, bi_modulations): """We update our 'business_impact' value with the max of the impacts business_impact if we got impacts. And save our 'configuration' business_impact if we do not have do it before If we do not have impa...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 10; 1, 11; 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, comment; 11, block;...
def register_a_problem(self, prob, hosts, services, timeperiods, bi_modulations): # pylint: disable=too-many-locals """Call recursively by potentials impacts so they update their source_problems list. But do not go below if the problem is not a real one for me like If I've got mu...
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, 10; 7, 11; 7, 15; 7, 90; 8, expression_statement; 8, 9; 9, comment; 10, comment; 11, expression_sta...
def is_enable_action_dependent(self, hosts, services): """ Check if dependencies states match dependencies statuses This basically means that a dependency is in a bad state and it can explain this object state. :param hosts: hosts objects, used to get object in act_depend_of ...
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, 8; 5, 16; 5, 17; 5, 18; 5, 37; 5, 38; 5, 39; 5, 40; 5, 110; 5, 111; 5, 112; 5, 113; 6, expression_statement; 6, 7; 7, comment; 8, expression_statement;...
def update_hard_unknown_phase_state(self): """Update in_hard_unknown_reach_phase attribute and was_in_hard_unknown_reach_phase UNKNOWN during a HARD state are not so important, and they should not raise notif about it :return: None """ self.was_in_hard_unknown_r...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 8; 1, 9; 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, comment; 9, block; 9, 10; 9, 12; 9, 16; 9, 24; 9, 30; 9, 31; 9, 37; 9, 38...
def get_next_notification_time(self, notif, escalations, timeperiods): # pylint: disable=too-many-locals """Get the next notification time for a notification Take the standard notification_interval or ask for our escalation if one of them need a smaller value to escalade :param ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 9; 1, 10; 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, comment; 10, block; 10, 11; 10, 13; 10,...
def get_business_rule_output(self, hosts, services, macromodulations, timeperiods): # pylint: disable=too-many-locals, too-many-branches """ Returns a status string for business rules based items formatted using business_rule_output_template attribute as template. The template m...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 7; 1, 8; 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, comment; 8, block; 8, 9; 8, 11; 8, 12; 8, 13; 8, 17; 8, 105; 9, expression_statement; 9, 10; 10, c...
def business_rule_notification_is_blocked(self, hosts, services): # pylint: disable=too-many-locals """Process business rule notifications behaviour. If all problems have been acknowledged, no notifications should be sent if state is not OK. By default, downtimes are ignored, unless expl...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 15; 1, 16; 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;...
def acknowledge_problem(self, notification_period, hosts, services, sticky, notify, author, comment, end_time=0): # pylint: disable=too-many-arguments """ Add an acknowledge :param sticky: acknowledge will be always present is host return in UP state ...
0, module; 0, 1; 1, function_definition; 1, 2; 1, 3; 1, 14; 1, 15; 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:'...
def setup_logger(logger_configuration_file, log_dir=None, process_name='', log_file=''): # pylint: disable=too-many-branches """ Configure the provided logger - get and update the content of the Json configuration file - configure the logger with this file If a log_dir and process_name are prov...
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): """Check if notification options match the state of the service :param timestamp: time we want to notify the contact (usually now) :type timestamp:...
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, 10; 7, 11; 7, 18; 7, 19; 7, 20; 7, 39; 7, 40; 7, 80; 7, 81; 7, 82; 8, expression_statement; 8, 9; 9, c...
def explode(self, contactgroups, notificationways): """Explode all contact for each contactsgroup :param contactgroups: contactgroups to explode :type contactgroups: alignak.objects.contactgroup.Contactgroups :param notificationways: notificationways to explode :type notificatio...
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, 11; 8, 12; 8, 13; 8, 18; 8, 22; 8, 26; 8, 30; 8, 166; 8, 167; 8, 186; 8, 187; 8, 230; 8, 231; 8, 24...
def receive(self,arg_formats=None): """ Recieve commands coming off the serial port. arg_formats is an optimal keyword that specifies the formats to use to parse incoming arguments. If specified here, arg_formats supercedes the formats specified on initialization. ""...
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, 11; 8, 21; 8, 31; 8, 41; 8, 60; 8, 74; 8, 84; 8, 88; 8, 97; 8, 112; 8, 138; 8...
def update_share(self, share_id, **kwargs): """Updates a given share :param share_id: (int) Share ID :param perms: (int) update permissions (see share_file_with_user() below) :param password: (string) updated password for public link Share :param public_upload: (boolean) enable/...
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, 13; 10, 26; 10, 30; 10, 155; 1...
def get_shares(self, path='', **kwargs): """Returns array of shares :param path: path to the share to be checked :param reshares: (optional, boolean) returns not only the shares from the current user but all shares from the given file (default: False) :param subfiles: (optio...
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, 12; 9, 22; 9, 34; 9, 70; 9, 88; 9, 97; 9, 125;...
def share_file_with_user(self, path, user, **kwargs): """Shares a remote file with specified user :param path: path to the remote file to share :param user: name of the user whom we want to share a file/folder :param perms (optional): permissions of the shared object default...
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, 14; 11, 18; 11, 57; 11, 70...
def get_attribute(self, app=None, key=None): """Returns an application attribute :param app: application id :param key: attribute key or None to retrieve all values for the given application :returns: attribute value if key was specified, or an array of tuples (k...
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, 12; 9, 45; 9, 54; 9, 82; 9, 96; 9, 112; 9, 123;...
def _make_dav_request(self, method, path, **kwargs): """Makes a WebDAV request :param method: HTTP method :param path: remote path of the targetted file :param \*\*kwargs: optional arguments that ``requests.Request.request`` accepts :returns array of :class:`FileInfo` if the res...
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, 13; 9, 20; 9, 35; 9, 36; 9, 45; 9, 46; 9,...
def load_delimited(filename, converters, delimiter=r'\s+'): r"""Utility function for loading in data from an annotation file where columns are delimited. The number of columns is inferred from the length of the provided converters list. Examples -------- >>> # Load in a one-column list of even...
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, 9; 6, 10; 6, 25; 6, 40; 7, expression_statement; 7, 8; 8, comment; 9, comment; 10, if_statement; 10, 11; 10, 17; 11, com...
def validate(reference_patterns, estimated_patterns): """Checks that the input annotations to a metric look like valid pattern lists, and throws helpful errors if not. Parameters ---------- reference_patterns : list The reference patterns using the format returned by :func:`mir_eval...
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, 9; 6, 15; 6, 64; 6, 120; 6, 237; 6, 238; 6, 259; 6, 260; 6, 271; 6, 272; 6, 289; 6, 306; 6, 316; 7, expression_st...
def three_layer_FPR(reference_patterns, estimated_patterns): """Three Layer F1 Score, Precision and Recall. As described by Meridith. Examples -------- >>> ref_patterns = mir_eval.io.load_patterns("ref_pattern.txt") >>> est_patterns = mir_eval.io.load_patterns("est_pattern.txt") >>> F, P, R = m...
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): """Match notes, taking note velocity into considera...