repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
Alignak-monitoring/alignak | alignak/action.py | no_block_read | def no_block_read(output):
"""Try to read a file descriptor in a non blocking mode
If the fcntl is available (unix only) we try to read in a
asynchronous mode, so we won't block the PIPE at 64K buffer
(deadlock...)
:param output: file or socket to read from
:type output: file
:return: data... | python | def no_block_read(output):
"""Try to read a file descriptor in a non blocking mode
If the fcntl is available (unix only) we try to read in a
asynchronous mode, so we won't block the PIPE at 64K buffer
(deadlock...)
:param output: file or socket to read from
:type output: file
:return: data... | [
"def",
"no_block_read",
"(",
"output",
")",
":",
"_buffer",
"=",
"\"\"",
"if",
"not",
"fcntl",
":",
"return",
"_buffer",
"o_fd",
"=",
"output",
".",
"fileno",
"(",
")",
"o_fl",
"=",
"fcntl",
".",
"fcntl",
"(",
"o_fd",
",",
"fcntl",
".",
"F_GETFL",
")... | Try to read a file descriptor in a non blocking mode
If the fcntl is available (unix only) we try to read in a
asynchronous mode, so we won't block the PIPE at 64K buffer
(deadlock...)
:param output: file or socket to read from
:type output: file
:return: data read from fd
:rtype: str | [
"Try",
"to",
"read",
"a",
"file",
"descriptor",
"in",
"a",
"non",
"blocking",
"mode"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/action.py#L106-L130 | train |
Alignak-monitoring/alignak | alignak/action.py | ActionBase.get_local_environnement | def get_local_environnement(self):
"""
Mix the environment and the environment variables into a new local
environment dictionary
Note: We cannot just update the global os.environ because this
would effect all other checks.
:return: local environment variables
:r... | python | def get_local_environnement(self):
"""
Mix the environment and the environment variables into a new local
environment dictionary
Note: We cannot just update the global os.environ because this
would effect all other checks.
:return: local environment variables
:r... | [
"def",
"get_local_environnement",
"(",
"self",
")",
":",
"local_env",
"=",
"os",
".",
"environ",
".",
"copy",
"(",
")",
"for",
"local_var",
"in",
"self",
".",
"env",
":",
"local_env",
"[",
"local_var",
"]",
"=",
"self",
".",
"env",
"[",
"local_var",
"]... | Mix the environment and the environment variables into a new local
environment dictionary
Note: We cannot just update the global os.environ because this
would effect all other checks.
:return: local environment variables
:rtype: dict | [
"Mix",
"the",
"environment",
"and",
"the",
"environment",
"variables",
"into",
"a",
"new",
"local",
"environment",
"dictionary"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/action.py#L245-L262 | train |
Alignak-monitoring/alignak | alignak/action.py | ActionBase.execute | def execute(self):
"""Start this action command in a subprocess.
:raise: ActionError
'toomanyopenfiles' if too many opened files on the system
'no_process_launched' if arguments parsing failed
'process_launch_failed': if the process launch failed
:return: re... | python | def execute(self):
"""Start this action command in a subprocess.
:raise: ActionError
'toomanyopenfiles' if too many opened files on the system
'no_process_launched' if arguments parsing failed
'process_launch_failed': if the process launch failed
:return: re... | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"status",
"=",
"ACT_STATUS_LAUNCHED",
"self",
".",
"check_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"wait_time",
"=",
"0.0001",
"self",
".",
"last_poll",
"=",
"self",
".",
"check_time",
... | Start this action command in a subprocess.
:raise: ActionError
'toomanyopenfiles' if too many opened files on the system
'no_process_launched' if arguments parsing failed
'process_launch_failed': if the process launch failed
:return: reference to the started process... | [
"Start",
"this",
"action",
"command",
"in",
"a",
"subprocess",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/action.py#L264-L295 | train |
Alignak-monitoring/alignak | alignak/action.py | ActionBase.copy_shell__ | def copy_shell__(self, new_i):
"""Create all attributes listed in 'ONLY_COPY_PROP' and return `self` with these attributes.
:param new_i: object to
:type new_i: object
:return: object with new properties added
:rtype: object
"""
for prop in ONLY_COPY_PROP:
... | python | def copy_shell__(self, new_i):
"""Create all attributes listed in 'ONLY_COPY_PROP' and return `self` with these attributes.
:param new_i: object to
:type new_i: object
:return: object with new properties added
:rtype: object
"""
for prop in ONLY_COPY_PROP:
... | [
"def",
"copy_shell__",
"(",
"self",
",",
"new_i",
")",
":",
"for",
"prop",
"in",
"ONLY_COPY_PROP",
":",
"setattr",
"(",
"new_i",
",",
"prop",
",",
"getattr",
"(",
"self",
",",
"prop",
")",
")",
"return",
"new_i"
] | Create all attributes listed in 'ONLY_COPY_PROP' and return `self` with these attributes.
:param new_i: object to
:type new_i: object
:return: object with new properties added
:rtype: object | [
"Create",
"all",
"attributes",
"listed",
"in",
"ONLY_COPY_PROP",
"and",
"return",
"self",
"with",
"these",
"attributes",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/action.py#L507-L517 | train |
Alignak-monitoring/alignak | alignak/objects/contactgroup.py | Contactgroup.get_contacts_by_explosion | 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
... | python | 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
... | [
"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 contacts of this group
:param contactgroups: Contactgroups object, use to look for a specific one
:type contactgroups: alignak.objects.contactgroup.Contactgroups
:return: list of contact of this group
:rtype: list[alignak.objects.contact.Contact] | [
"Get",
"contacts",
"of",
"this",
"group"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contactgroup.py#L110-L148 | train |
Alignak-monitoring/alignak | alignak/objects/contactgroup.py | Contactgroups.add_member | def add_member(self, contact_name, contactgroup_name):
"""Add a contact string to a contact member
if the contact group do not exist, create it
:param contact_name: contact name
:type contact_name: str
:param contactgroup_name: contact group name
:type contactgroup_name:... | python | def add_member(self, contact_name, contactgroup_name):
"""Add a contact string to a contact member
if the contact group do not exist, create it
:param contact_name: contact name
:type contact_name: str
:param contactgroup_name: contact group name
:type contactgroup_name:... | [
"def",
"add_member",
"(",
"self",
",",
"contact_name",
",",
"contactgroup_name",
")",
":",
"contactgroup",
"=",
"self",
".",
"find_by_name",
"(",
"contactgroup_name",
")",
"if",
"not",
"contactgroup",
":",
"contactgroup",
"=",
"Contactgroup",
"(",
"{",
"'contact... | Add a contact string to a contact member
if the contact group do not exist, create it
:param contact_name: contact name
:type contact_name: str
:param contactgroup_name: contact group name
:type contactgroup_name: str
:return: None | [
"Add",
"a",
"contact",
"string",
"to",
"a",
"contact",
"member",
"if",
"the",
"contact",
"group",
"do",
"not",
"exist",
"create",
"it"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contactgroup.py#L159-L176 | train |
Alignak-monitoring/alignak | alignak/objects/contactgroup.py | Contactgroups.linkify_contactgroups_contacts | def linkify_contactgroups_contacts(self, contacts):
"""Link the contacts with contactgroups
:param contacts: realms object to link with
:type contacts: alignak.objects.contact.Contacts
:return: None
"""
for contactgroup in self:
mbrs = contactgroup.get_contac... | python | def linkify_contactgroups_contacts(self, contacts):
"""Link the contacts with contactgroups
:param contacts: realms object to link with
:type contacts: alignak.objects.contact.Contacts
:return: None
"""
for contactgroup in self:
mbrs = contactgroup.get_contac... | [
"def",
"linkify_contactgroups_contacts",
"(",
"self",
",",
"contacts",
")",
":",
"for",
"contactgroup",
"in",
"self",
":",
"mbrs",
"=",
"contactgroup",
".",
"get_contacts",
"(",
")",
"new_mbrs",
"=",
"[",
"]",
"for",
"mbr",
"in",
"mbrs",
":",
"mbr",
"=",
... | Link the contacts with contactgroups
:param contacts: realms object to link with
:type contacts: alignak.objects.contact.Contacts
:return: None | [
"Link",
"the",
"contacts",
"with",
"contactgroups"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contactgroup.py#L212-L239 | train |
Alignak-monitoring/alignak | alignak/objects/contactgroup.py | Contactgroups.explode | def explode(self):
"""
Fill members with contactgroup_members
:return:None
"""
# We do not want a same hg to be explode again and again
# so we tag it
for tmp_cg in list(self.items.values()):
tmp_cg.already_exploded = False
for contactgroup i... | python | def explode(self):
"""
Fill members with contactgroup_members
:return:None
"""
# We do not want a same hg to be explode again and again
# so we tag it
for tmp_cg in list(self.items.values()):
tmp_cg.already_exploded = False
for contactgroup i... | [
"def",
"explode",
"(",
"self",
")",
":",
"for",
"tmp_cg",
"in",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
":",
"tmp_cg",
".",
"already_exploded",
"=",
"False",
"for",
"contactgroup",
"in",
"list",
"(",
"self",
".",
"items",
"."... | Fill members with contactgroup_members
:return:None | [
"Fill",
"members",
"with",
"contactgroup_members"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contactgroup.py#L241-L266 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.add_flapping_change | def add_flapping_change(self, sample):
"""Add a flapping sample and keep cls.flap_history samples
:param sample: Sample to add
:type sample: bool
:return: None
"""
cls = self.__class__
# If this element is not in flapping check, or
# the flapping is glob... | python | def add_flapping_change(self, sample):
"""Add a flapping sample and keep cls.flap_history samples
:param sample: Sample to add
:type sample: bool
:return: None
"""
cls = self.__class__
# If this element is not in flapping check, or
# the flapping is glob... | [
"def",
"add_flapping_change",
"(",
"self",
",",
"sample",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"not",
"self",
".",
"flap_detection_enabled",
"or",
"not",
"cls",
".",
"enable_flap_detection",
":",
"return",
"self",
".",
"flapping_changes",
".",... | Add a flapping sample and keep cls.flap_history samples
:param sample: Sample to add
:type sample: bool
:return: None | [
"Add",
"a",
"flapping",
"sample",
"and",
"keep",
"cls",
".",
"flap_history",
"samples"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L550-L570 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.add_attempt | def add_attempt(self):
"""Add an attempt when a object is a non-ok state
:return: None
"""
self.attempt += 1
self.attempt = min(self.attempt, self.max_check_attempts) | python | def add_attempt(self):
"""Add an attempt when a object is a non-ok state
:return: None
"""
self.attempt += 1
self.attempt = min(self.attempt, self.max_check_attempts) | [
"def",
"add_attempt",
"(",
"self",
")",
":",
"self",
".",
"attempt",
"+=",
"1",
"self",
".",
"attempt",
"=",
"min",
"(",
"self",
".",
"attempt",
",",
"self",
".",
"max_check_attempts",
")"
] | Add an attempt when a object is a non-ok state
:return: None | [
"Add",
"an",
"attempt",
"when",
"a",
"object",
"is",
"a",
"non",
"-",
"ok",
"state"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L637-L643 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.do_check_freshness | 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... | python | 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... | [
"def",
"do_check_freshness",
"(",
"self",
",",
"hosts",
",",
"services",
",",
"timeperiods",
",",
"macromodulations",
",",
"checkmodulations",
",",
"checks",
",",
"when",
")",
":",
"now",
"=",
"when",
"cls",
"=",
"self",
".",
"__class__",
"if",
"not",
"sel... | Check freshness and schedule a check now if necessary.
This function is called by the scheduler if Alignak is configured to check the freshness.
It is called for hosts that have the freshness check enabled if they are only
passively checked.
It is called for services that have the fre... | [
"Check",
"freshness",
"and",
"schedule",
"a",
"check",
"now",
"if",
"necessary",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L653-L740 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.update_business_impact_value | 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... | python | 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... | [
"def",
"update_business_impact_value",
"(",
"self",
",",
"hosts",
",",
"services",
",",
"timeperiods",
",",
"bi_modulations",
")",
":",
"if",
"self",
".",
"my_own_business_impact",
"==",
"-",
"1",
":",
"self",
".",
"my_own_business_impact",
"=",
"self",
".",
"... | 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 impacts, we revert our value
:param hosts: hosts objects, used to get impacts
:type ... | [
"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",
"bef... | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L796-L844 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.no_more_a_problem | def no_more_a_problem(self, hosts, services, timeperiods, bi_modulations):
"""Remove this objects as an impact for other schedulingitem.
:param hosts: hosts objects, used to get impacts
:type hosts: alignak.objects.host.Hosts
:param services: services objects, used to get impacts
... | python | def no_more_a_problem(self, hosts, services, timeperiods, bi_modulations):
"""Remove this objects as an impact for other schedulingitem.
:param hosts: hosts objects, used to get impacts
:type hosts: alignak.objects.host.Hosts
:param services: services objects, used to get impacts
... | [
"def",
"no_more_a_problem",
"(",
"self",
",",
"hosts",
",",
"services",
",",
"timeperiods",
",",
"bi_modulations",
")",
":",
"was_pb",
"=",
"self",
".",
"is_problem",
"if",
"self",
".",
"is_problem",
":",
"self",
".",
"is_problem",
"=",
"False",
"for",
"im... | Remove this objects as an impact for other schedulingitem.
:param hosts: hosts objects, used to get impacts
:type hosts: alignak.objects.host.Hosts
:param services: services objects, used to get impacts
:type services: alignak.objects.service.Services
:param timeperiods: Timeper... | [
"Remove",
"this",
"objects",
"as",
"an",
"impact",
"for",
"other",
"schedulingitem",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L846-L884 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.register_a_problem | 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... | python | 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... | [
"def",
"register_a_problem",
"(",
"self",
",",
"prob",
",",
"hosts",
",",
"services",
",",
"timeperiods",
",",
"bi_modulations",
")",
":",
"if",
"prob",
".",
"uuid",
"in",
"self",
".",
"source_problems",
":",
"return",
"[",
"]",
"now",
"=",
"time",
".",
... | 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 multiple parents for examples
:param prob: problem to register
:type prob: alignak.objects.schedulingitem.SchedulingItem... | [
"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"... | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L886-L961 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.unregister_a_problem | def unregister_a_problem(self, prob):
"""Remove the problem from our problems list
and check if we are still 'impacted'
:param prob: problem to remove
:type prob: alignak.objects.schedulingitem.SchedulingItem
:return: None
"""
self.source_problems.remove(prob.uui... | python | def unregister_a_problem(self, prob):
"""Remove the problem from our problems list
and check if we are still 'impacted'
:param prob: problem to remove
:type prob: alignak.objects.schedulingitem.SchedulingItem
:return: None
"""
self.source_problems.remove(prob.uui... | [
"def",
"unregister_a_problem",
"(",
"self",
",",
"prob",
")",
":",
"self",
".",
"source_problems",
".",
"remove",
"(",
"prob",
".",
"uuid",
")",
"if",
"not",
"self",
".",
"source_problems",
":",
"self",
".",
"is_impact",
"=",
"False",
"self",
".",
"unset... | Remove the problem from our problems list
and check if we are still 'impacted'
:param prob: problem to remove
:type prob: alignak.objects.schedulingitem.SchedulingItem
:return: None | [
"Remove",
"the",
"problem",
"from",
"our",
"problems",
"list",
"and",
"check",
"if",
"we",
"are",
"still",
"impacted"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L963-L982 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.is_enable_action_dependent | 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
... | python | 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
... | [
"def",
"is_enable_action_dependent",
"(",
"self",
",",
"hosts",
",",
"services",
")",
":",
"enable_action",
"=",
"False",
"for",
"(",
"dep_id",
",",
"status",
",",
"_",
",",
"_",
")",
"in",
"self",
".",
"act_depend_of",
":",
"if",
"'n'",
"in",
"status",
... | 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
:type hosts: alignak.objects.host.Hosts
:param services: servi... | [
"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",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L984-L1014 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.check_and_set_unreachability | def check_and_set_unreachability(self, hosts, services):
"""
Check if all dependencies are down, if yes set this object
as unreachable.
todo: this function do not care about execution_failure_criteria!
:param hosts: hosts objects, used to get object in act_depend_of
:ty... | python | def check_and_set_unreachability(self, hosts, services):
"""
Check if all dependencies are down, if yes set this object
as unreachable.
todo: this function do not care about execution_failure_criteria!
:param hosts: hosts objects, used to get object in act_depend_of
:ty... | [
"def",
"check_and_set_unreachability",
"(",
"self",
",",
"hosts",
",",
"services",
")",
":",
"parent_is_down",
"=",
"[",
"]",
"for",
"(",
"dep_id",
",",
"_",
",",
"_",
",",
"_",
")",
"in",
"self",
".",
"act_depend_of",
":",
"if",
"dep_id",
"in",
"hosts... | Check if all dependencies are down, if yes set this object
as unreachable.
todo: this function do not care about execution_failure_criteria!
:param hosts: hosts objects, used to get object in act_depend_of
:type hosts: alignak.objects.host.Hosts
:param services: services object... | [
"Check",
"if",
"all",
"dependencies",
"are",
"down",
"if",
"yes",
"set",
"this",
"object",
"as",
"unreachable",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1016-L1042 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.compensate_system_time_change | def compensate_system_time_change(self, difference): # pragma: no cover,
# not with unit tests
"""If a system time change occurs we have to update
properties time related to reflect change
:param difference: difference between new time and old time
:type difference:
:re... | python | def compensate_system_time_change(self, difference): # pragma: no cover,
# not with unit tests
"""If a system time change occurs we have to update
properties time related to reflect change
:param difference: difference between new time and old time
:type difference:
:re... | [
"def",
"compensate_system_time_change",
"(",
"self",
",",
"difference",
")",
":",
"for",
"prop",
"in",
"(",
"'last_notification'",
",",
"'last_state_change'",
",",
"'last_hard_state_change'",
")",
":",
"val",
"=",
"getattr",
"(",
"self",
",",
"prop",
")",
"val",... | If a system time change occurs we have to update
properties time related to reflect change
:param difference: difference between new time and old time
:type difference:
:return: None | [
"If",
"a",
"system",
"time",
"change",
"occurs",
"we",
"have",
"to",
"update",
"properties",
"time",
"related",
"to",
"reflect",
"change"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1300-L1314 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.remove_in_progress_check | def remove_in_progress_check(self, check):
"""Remove check from check in progress
:param check: Check to remove
:type check: alignak.objects.check.Check
:return: None
"""
# The check is consumed, update the in_checking properties
if check in self.checks_in_progre... | python | def remove_in_progress_check(self, check):
"""Remove check from check in progress
:param check: Check to remove
:type check: alignak.objects.check.Check
:return: None
"""
# The check is consumed, update the in_checking properties
if check in self.checks_in_progre... | [
"def",
"remove_in_progress_check",
"(",
"self",
",",
"check",
")",
":",
"if",
"check",
"in",
"self",
".",
"checks_in_progress",
":",
"self",
".",
"checks_in_progress",
".",
"remove",
"(",
"check",
")",
"self",
".",
"update_in_checking",
"(",
")"
] | Remove check from check in progress
:param check: Check to remove
:type check: alignak.objects.check.Check
:return: None | [
"Remove",
"check",
"from",
"check",
"in",
"progress"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1334-L1344 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.remove_in_progress_notification | def remove_in_progress_notification(self, notification):
"""
Remove a notification and mark them as zombie
:param notification: the notification to remove
:type notification: alignak.notification.Notification
:return: None
"""
if notification.uuid in self.notific... | python | def remove_in_progress_notification(self, notification):
"""
Remove a notification and mark them as zombie
:param notification: the notification to remove
:type notification: alignak.notification.Notification
:return: None
"""
if notification.uuid in self.notific... | [
"def",
"remove_in_progress_notification",
"(",
"self",
",",
"notification",
")",
":",
"if",
"notification",
".",
"uuid",
"in",
"self",
".",
"notifications_in_progress",
":",
"notification",
".",
"status",
"=",
"ACT_STATUS_ZOMBIE",
"del",
"self",
".",
"notifications_... | Remove a notification and mark them as zombie
:param notification: the notification to remove
:type notification: alignak.notification.Notification
:return: None | [
"Remove",
"a",
"notification",
"and",
"mark",
"them",
"as",
"zombie"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1354-L1364 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.remove_in_progress_notifications | def remove_in_progress_notifications(self, master=True):
"""Remove all notifications from notifications_in_progress
Preserves some specific notifications (downtime, ...)
:param master: remove master notifications only if True (default value)
:type master: bool
:param force: for... | python | def remove_in_progress_notifications(self, master=True):
"""Remove all notifications from notifications_in_progress
Preserves some specific notifications (downtime, ...)
:param master: remove master notifications only if True (default value)
:type master: bool
:param force: for... | [
"def",
"remove_in_progress_notifications",
"(",
"self",
",",
"master",
"=",
"True",
")",
":",
"for",
"notification",
"in",
"list",
"(",
"self",
".",
"notifications_in_progress",
".",
"values",
"(",
")",
")",
":",
"if",
"master",
"and",
"notification",
".",
"... | Remove all notifications from notifications_in_progress
Preserves some specific notifications (downtime, ...)
:param master: remove master notifications only if True (default value)
:type master: bool
:param force: force remove all notifications except if False
:type force: boo... | [
"Remove",
"all",
"notifications",
"from",
"notifications_in_progress"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1366-L1384 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.check_for_flexible_downtime | def check_for_flexible_downtime(self, timeperiods, hosts, services):
"""Enter in a downtime if necessary and raise start notification
When a non Ok state occurs we try to raise a flexible downtime.
:param timeperiods: Timeperiods objects, used for downtime period
:type timeperiods: alig... | python | def check_for_flexible_downtime(self, timeperiods, hosts, services):
"""Enter in a downtime if necessary and raise start notification
When a non Ok state occurs we try to raise a flexible downtime.
:param timeperiods: Timeperiods objects, used for downtime period
:type timeperiods: alig... | [
"def",
"check_for_flexible_downtime",
"(",
"self",
",",
"timeperiods",
",",
"hosts",
",",
"services",
")",
":",
"status_updated",
"=",
"False",
"for",
"downtime_id",
"in",
"self",
".",
"downtimes",
":",
"downtime",
"=",
"self",
".",
"downtimes",
"[",
"downtime... | Enter in a downtime if necessary and raise start notification
When a non Ok state occurs we try to raise a flexible downtime.
:param timeperiods: Timeperiods objects, used for downtime period
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param hosts: hosts objects, used to ... | [
"Enter",
"in",
"a",
"downtime",
"if",
"necessary",
"and",
"raise",
"start",
"notification",
"When",
"a",
"non",
"Ok",
"state",
"occurs",
"we",
"try",
"to",
"raise",
"a",
"flexible",
"downtime",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1505-L1530 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.update_hard_unknown_phase_state | 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... | python | 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... | [
"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'",
"... | 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 | [
"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"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1532-L1567 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.update_notification_command | def update_notification_command(self, notif, contact, macromodulations, timeperiods,
host_ref=None):
"""Update the notification command by resolving Macros
And because we are just launching the notification, we can say
that this contact has been notified
... | python | def update_notification_command(self, notif, contact, macromodulations, timeperiods,
host_ref=None):
"""Update the notification command by resolving Macros
And because we are just launching the notification, we can say
that this contact has been notified
... | [
"def",
"update_notification_command",
"(",
"self",
",",
"notif",
",",
"contact",
",",
"macromodulations",
",",
"timeperiods",
",",
"host_ref",
"=",
"None",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"macrosolver",
"=",
"MacroResolver",
"(",
")",
"data",
... | Update the notification command by resolving Macros
And because we are just launching the notification, we can say
that this contact has been notified
:param notif: notification to send
:type notif: alignak.objects.notification.Notification
:param contact: contact for this host/... | [
"Update",
"the",
"notification",
"command",
"by",
"resolving",
"Macros",
"And",
"because",
"we",
"are",
"just",
"launching",
"the",
"notification",
"we",
"can",
"say",
"that",
"this",
"contact",
"has",
"been",
"notified"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L1997-L2021 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.is_escalable | def is_escalable(self, notification, escalations, timeperiods):
"""Check if a notification can be escalated.
Basically call is_eligible for each escalation
:param notification: notification we would like to escalate
:type notification: alignak.objects.notification.Notification
:... | python | def is_escalable(self, notification, escalations, timeperiods):
"""Check if a notification can be escalated.
Basically call is_eligible for each escalation
:param notification: notification we would like to escalate
:type notification: alignak.objects.notification.Notification
:... | [
"def",
"is_escalable",
"(",
"self",
",",
"notification",
",",
"escalations",
",",
"timeperiods",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"in_notif_time",
"=",
"time",
".",
"time",
"(",
")",
"-",
"notification",
".",
"creation_time",
"for",
"escalatio... | Check if a notification can be escalated.
Basically call is_eligible for each escalation
:param notification: notification we would like to escalate
:type notification: alignak.objects.notification.Notification
:param escalations: Esclations objects, used to get escalation objects (peri... | [
"Check",
"if",
"a",
"notification",
"can",
"be",
"escalated",
".",
"Basically",
"call",
"is_eligible",
"for",
"each",
"escalation"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2023-L2050 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.get_next_notification_time | 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 ... | python | 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 ... | [
"def",
"get_next_notification_time",
"(",
"self",
",",
"notif",
",",
"escalations",
",",
"timeperiods",
")",
":",
"res",
"=",
"None",
"now",
"=",
"time",
".",
"time",
"(",
")",
"cls",
"=",
"self",
".",
"__class__",
"notification_interval",
"=",
"self",
"."... | 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 notif: Notification we need time
:type notif: alignak.objects.notification.Notification
:param escalations: ... | [
"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"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2052-L2113 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.get_business_rule_output | 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... | python | 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... | [
"def",
"get_business_rule_output",
"(",
"self",
",",
"hosts",
",",
"services",
",",
"macromodulations",
",",
"timeperiods",
")",
":",
"got_business_rule",
"=",
"getattr",
"(",
"self",
",",
"'got_business_rule'",
",",
"False",
")",
"if",
"got_business_rule",
"is",
... | Returns a status string for business rules based items formatted
using business_rule_output_template attribute as template.
The template may embed output formatting for itself, and for its child
(dependent) items. Child format string is expanded into the $( and )$,
using the string betw... | [
"Returns",
"a",
"status",
"string",
"for",
"business",
"rules",
"based",
"items",
"formatted",
"using",
"business_rule_output_template",
"attribute",
"as",
"template",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2612-L2692 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.business_rule_notification_is_blocked | 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... | python | 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... | [
"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",
... | 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 explicitly told to be treated
as acknowledgements through with the business_rule_downtime_as_ack set.
:ret... | [
"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",
"un... | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2694-L2729 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.fill_data_brok_from | def fill_data_brok_from(self, data, brok_type):
"""Fill data brok dependent on the brok_type
:param data: data to fill
:type data: dict
:param brok_type: brok type
:type: str
:return: None
"""
super(SchedulingItem, self).fill_data_brok_from(data, brok_typ... | python | def fill_data_brok_from(self, data, brok_type):
"""Fill data brok dependent on the brok_type
:param data: data to fill
:type data: dict
:param brok_type: brok type
:type: str
:return: None
"""
super(SchedulingItem, self).fill_data_brok_from(data, brok_typ... | [
"def",
"fill_data_brok_from",
"(",
"self",
",",
"data",
",",
"brok_type",
")",
":",
"super",
"(",
"SchedulingItem",
",",
"self",
")",
".",
"fill_data_brok_from",
"(",
"data",
",",
"brok_type",
")",
"if",
"brok_type",
"==",
"'check_result'",
":",
"data",
"[",... | Fill data brok dependent on the brok_type
:param data: data to fill
:type data: dict
:param brok_type: brok type
:type: str
:return: None | [
"Fill",
"data",
"brok",
"dependent",
"on",
"the",
"brok_type"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2934-L2949 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.acknowledge_problem | 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
... | python | 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
... | [
"def",
"acknowledge_problem",
"(",
"self",
",",
"notification_period",
",",
"hosts",
",",
"services",
",",
"sticky",
",",
"notify",
",",
"author",
",",
"comment",
",",
"end_time",
"=",
"0",
")",
":",
"comm",
"=",
"None",
"logger",
".",
"debug",
"(",
"\"A... | Add an acknowledge
:param sticky: acknowledge will be always present is host return in UP state
:type sticky: integer
:param notify: if to 1, send a notification
:type notify: integer
:param author: name of the author or the acknowledge
:type author: str
:param c... | [
"Add",
"an",
"acknowledge"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L2951-L3017 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.check_for_expire_acknowledge | def check_for_expire_acknowledge(self):
"""
If have acknowledge and is expired, delete it
:return: None
"""
if (self.acknowledgement and
self.acknowledgement.end_time != 0 and
self.acknowledgement.end_time < time.time()):
self.unacknow... | python | def check_for_expire_acknowledge(self):
"""
If have acknowledge and is expired, delete it
:return: None
"""
if (self.acknowledgement and
self.acknowledgement.end_time != 0 and
self.acknowledgement.end_time < time.time()):
self.unacknow... | [
"def",
"check_for_expire_acknowledge",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"acknowledgement",
"and",
"self",
".",
"acknowledgement",
".",
"end_time",
"!=",
"0",
"and",
"self",
".",
"acknowledgement",
".",
"end_time",
"<",
"time",
".",
"time",
"(",... | If have acknowledge and is expired, delete it
:return: None | [
"If",
"have",
"acknowledge",
"and",
"is",
"expired",
"delete",
"it"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3019-L3028 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.unacknowledge_problem | def unacknowledge_problem(self):
"""
Remove the acknowledge, reset the flag. The comment is deleted
:return: None
"""
if self.problem_has_been_acknowledged:
logger.debug("[item::%s] deleting acknowledge of %s",
self.get_name(),
... | python | def unacknowledge_problem(self):
"""
Remove the acknowledge, reset the flag. The comment is deleted
:return: None
"""
if self.problem_has_been_acknowledged:
logger.debug("[item::%s] deleting acknowledge of %s",
self.get_name(),
... | [
"def",
"unacknowledge_problem",
"(",
"self",
")",
":",
"if",
"self",
".",
"problem_has_been_acknowledged",
":",
"logger",
".",
"debug",
"(",
"\"[item::%s] deleting acknowledge of %s\"",
",",
"self",
".",
"get_name",
"(",
")",
",",
"self",
".",
"get_full_name",
"("... | Remove the acknowledge, reset the flag. The comment is deleted
:return: None | [
"Remove",
"the",
"acknowledge",
"reset",
"the",
"flag",
".",
"The",
"comment",
"is",
"deleted"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3030-L3055 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.unacknowledge_problem_if_not_sticky | def unacknowledge_problem_if_not_sticky(self):
"""
Remove the acknowledge if it is not sticky
:return: None
"""
if hasattr(self, 'acknowledgement') and self.acknowledgement is not None:
if not self.acknowledgement.sticky:
self.unacknowledge_problem() | python | def unacknowledge_problem_if_not_sticky(self):
"""
Remove the acknowledge if it is not sticky
:return: None
"""
if hasattr(self, 'acknowledgement') and self.acknowledgement is not None:
if not self.acknowledgement.sticky:
self.unacknowledge_problem() | [
"def",
"unacknowledge_problem_if_not_sticky",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'acknowledgement'",
")",
"and",
"self",
".",
"acknowledgement",
"is",
"not",
"None",
":",
"if",
"not",
"self",
".",
"acknowledgement",
".",
"sticky",
":",
... | Remove the acknowledge if it is not sticky
:return: None | [
"Remove",
"the",
"acknowledge",
"if",
"it",
"is",
"not",
"sticky"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3057-L3065 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.set_impact_state | def set_impact_state(self):
"""We just go an impact, so we go unreachable
But only if we enable this state change in the conf
:return: None
"""
cls = self.__class__
if cls.enable_problem_impacts_states_change:
logger.debug("%s is impacted and goes UNREACHABLE... | python | def set_impact_state(self):
"""We just go an impact, so we go unreachable
But only if we enable this state change in the conf
:return: None
"""
cls = self.__class__
if cls.enable_problem_impacts_states_change:
logger.debug("%s is impacted and goes UNREACHABLE... | [
"def",
"set_impact_state",
"(",
"self",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"cls",
".",
"enable_problem_impacts_states_change",
":",
"logger",
".",
"debug",
"(",
"\"%s is impacted and goes UNREACHABLE\"",
",",
"self",
")",
"self",
".",
"state_bef... | We just go an impact, so we go unreachable
But only if we enable this state change in the conf
:return: None | [
"We",
"just",
"go",
"an",
"impact",
"so",
"we",
"go",
"unreachable",
"But",
"only",
"if",
"we",
"enable",
"this",
"state",
"change",
"in",
"the",
"conf"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3215-L3231 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItem.unset_impact_state | def unset_impact_state(self):
"""Unset impact, only if impact state change is set in configuration
:return: None
"""
cls = self.__class__
if cls.enable_problem_impacts_states_change and not self.state_changed_since_impact:
self.state = self.state_before_impact
... | python | def unset_impact_state(self):
"""Unset impact, only if impact state change is set in configuration
:return: None
"""
cls = self.__class__
if cls.enable_problem_impacts_states_change and not self.state_changed_since_impact:
self.state = self.state_before_impact
... | [
"def",
"unset_impact_state",
"(",
"self",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"cls",
".",
"enable_problem_impacts_states_change",
"and",
"not",
"self",
".",
"state_changed_since_impact",
":",
"self",
".",
"state",
"=",
"self",
".",
"state_befor... | Unset impact, only if impact state change is set in configuration
:return: None | [
"Unset",
"impact",
"only",
"if",
"impact",
"state",
"change",
"is",
"set",
"in",
"configuration"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3233-L3241 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItems.find_by_filter | def find_by_filter(self, filters, all_items):
"""
Find items by filters
:param filters: list of filters
:type filters: list
:param all_items: monitoring items
:type: dict
:return: list of items
:rtype: list
"""
items = []
for i in ... | python | def find_by_filter(self, filters, all_items):
"""
Find items by filters
:param filters: list of filters
:type filters: list
:param all_items: monitoring items
:type: dict
:return: list of items
:rtype: list
"""
items = []
for i in ... | [
"def",
"find_by_filter",
"(",
"self",
",",
"filters",
",",
"all_items",
")",
":",
"items",
"=",
"[",
"]",
"for",
"i",
"in",
"self",
":",
"failed",
"=",
"False",
"if",
"hasattr",
"(",
"i",
",",
"\"host\"",
")",
":",
"all_items",
"[",
"\"service\"",
"]... | Find items by filters
:param filters: list of filters
:type filters: list
:param all_items: monitoring items
:type: dict
:return: list of items
:rtype: list | [
"Find",
"items",
"by",
"filters"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3379-L3403 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItems.add_act_dependency | def add_act_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
"""
Add a logical dependency for actions between two hosts or services.
:param son_id: uuid of son host
:type son_id: str
:param parent_id: uuid of p... | python | def add_act_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
"""
Add a logical dependency for actions between two hosts or services.
:param son_id: uuid of son host
:type son_id: str
:param parent_id: uuid of p... | [
"def",
"add_act_dependency",
"(",
"self",
",",
"son_id",
",",
"parent_id",
",",
"notif_failure_criteria",
",",
"dep_period",
",",
"inherits_parents",
")",
":",
"if",
"son_id",
"in",
"self",
":",
"son",
"=",
"self",
"[",
"son_id",
"]",
"else",
":",
"msg",
"... | Add a logical dependency for actions between two hosts or services.
:param son_id: uuid of son host
:type son_id: str
:param parent_id: uuid of parent host
:type parent_id: str
:param notif_failure_criteria: notification failure criteria,
notification for a dependent hos... | [
"Add",
"a",
"logical",
"dependency",
"for",
"actions",
"between",
"two",
"hosts",
"or",
"services",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3405-L3435 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItems.del_act_dependency | def del_act_dependency(self, son_id, parent_id): # pragma: no cover, not yet tested
"""Remove act_dependency between two hosts or services.
TODO: do we really intend to remove dynamically ?
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uuid of par... | python | def del_act_dependency(self, son_id, parent_id): # pragma: no cover, not yet tested
"""Remove act_dependency between two hosts or services.
TODO: do we really intend to remove dynamically ?
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uuid of par... | [
"def",
"del_act_dependency",
"(",
"self",
",",
"son_id",
",",
"parent_id",
")",
":",
"son",
"=",
"self",
"[",
"son_id",
"]",
"parent",
"=",
"self",
"[",
"parent_id",
"]",
"to_del",
"=",
"[",
"]",
"for",
"(",
"host",
",",
"status",
",",
"timeperiod",
... | Remove act_dependency between two hosts or services.
TODO: do we really intend to remove dynamically ?
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uuid of parent host/service
:type parent_id: str
:return: None | [
"Remove",
"act_dependency",
"between",
"two",
"hosts",
"or",
"services",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3437-L3470 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItems.add_chk_dependency | def add_chk_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
"""
Add a logical dependency for checks between two hosts or services.
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uu... | python | def add_chk_dependency(self, son_id, parent_id, notif_failure_criteria, dep_period,
inherits_parents):
"""
Add a logical dependency for checks between two hosts or services.
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uu... | [
"def",
"add_chk_dependency",
"(",
"self",
",",
"son_id",
",",
"parent_id",
",",
"notif_failure_criteria",
",",
"dep_period",
",",
"inherits_parents",
")",
":",
"son",
"=",
"self",
"[",
"son_id",
"]",
"parent",
"=",
"self",
"[",
"parent_id",
"]",
"son",
".",
... | Add a logical dependency for checks between two hosts or services.
:param son_id: uuid of son host/service
:type son_id: str
:param parent_id: uuid of parent host/service
:type parent_id: str
:param notif_failure_criteria: notification failure criteria,
notification for ... | [
"Add",
"a",
"logical",
"dependency",
"for",
"checks",
"between",
"two",
"hosts",
"or",
"services",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3472-L3499 | train |
Alignak-monitoring/alignak | alignak/objects/schedulingitem.py | SchedulingItems.create_business_rules | def create_business_rules(self, hosts, services, hostgroups, servicegroups,
macromodulations, timeperiods):
"""
Loop on hosts or services and call SchedulingItem.create_business_rules
:param hosts: hosts to link to
:type hosts: alignak.objects.host.Hosts
... | python | def create_business_rules(self, hosts, services, hostgroups, servicegroups,
macromodulations, timeperiods):
"""
Loop on hosts or services and call SchedulingItem.create_business_rules
:param hosts: hosts to link to
:type hosts: alignak.objects.host.Hosts
... | [
"def",
"create_business_rules",
"(",
"self",
",",
"hosts",
",",
"services",
",",
"hostgroups",
",",
"servicegroups",
",",
"macromodulations",
",",
"timeperiods",
")",
":",
"for",
"item",
"in",
"self",
":",
"item",
".",
"create_business_rules",
"(",
"hosts",
",... | Loop on hosts or services and call SchedulingItem.create_business_rules
:param hosts: hosts to link to
:type hosts: alignak.objects.host.Hosts
:param services: services to link to
:type services: alignak.objects.service.Services
:param hostgroups: hostgroups to link to
:... | [
"Loop",
"on",
"hosts",
"or",
"services",
"and",
"call",
"SchedulingItem",
".",
"create_business_rules"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/schedulingitem.py#L3501-L3522 | train |
Alignak-monitoring/alignak | alignak/objects/servicegroup.py | Servicegroup.get_services_by_explosion | def get_services_by_explosion(self, servicegroups):
# pylint: disable=access-member-before-definition
"""
Get all services of this servicegroup and add it in members container
:param servicegroups: servicegroups object
:type servicegroups: alignak.objects.servicegroup.Servicegro... | python | def get_services_by_explosion(self, servicegroups):
# pylint: disable=access-member-before-definition
"""
Get all services of this servicegroup and add it in members container
:param servicegroups: servicegroups object
:type servicegroups: alignak.objects.servicegroup.Servicegro... | [
"def",
"get_services_by_explosion",
"(",
"self",
",",
"servicegroups",
")",
":",
"self",
".",
"already_exploded",
"=",
"True",
"if",
"self",
".",
"rec_tag",
":",
"logger",
".",
"error",
"(",
"\"[servicegroup::%s] got a loop in servicegroup definition\"",
",",
"self",
... | Get all services of this servicegroup and add it in members container
:param servicegroups: servicegroups object
:type servicegroups: alignak.objects.servicegroup.Servicegroups
:return: return empty string or list of members
:rtype: str or list | [
"Get",
"all",
"services",
"of",
"this",
"servicegroup",
"and",
"add",
"it",
"in",
"members",
"container"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicegroup.py#L115-L154 | train |
Alignak-monitoring/alignak | alignak/objects/servicegroup.py | Servicegroups.explode | def explode(self):
"""
Get services and put them in members container
:return: None
"""
# We do not want a same service group to be exploded again and again
# so we tag it
for tmp_sg in list(self.items.values()):
tmp_sg.already_exploded = False
... | python | def explode(self):
"""
Get services and put them in members container
:return: None
"""
# We do not want a same service group to be exploded again and again
# so we tag it
for tmp_sg in list(self.items.values()):
tmp_sg.already_exploded = False
... | [
"def",
"explode",
"(",
"self",
")",
":",
"for",
"tmp_sg",
"in",
"list",
"(",
"self",
".",
"items",
".",
"values",
"(",
")",
")",
":",
"tmp_sg",
".",
"already_exploded",
"=",
"False",
"for",
"servicegroup",
"in",
"list",
"(",
"self",
".",
"items",
"."... | Get services and put them in members container
:return: None | [
"Get",
"services",
"and",
"put",
"them",
"in",
"members",
"container"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/servicegroup.py#L260-L285 | train |
Alignak-monitoring/alignak | alignak/log.py | setup_logger | 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... | python | 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... | [
"def",
"setup_logger",
"(",
"logger_configuration_file",
",",
"log_dir",
"=",
"None",
",",
"process_name",
"=",
"''",
",",
"log_file",
"=",
"''",
")",
":",
"logger_",
"=",
"logging",
".",
"getLogger",
"(",
"ALIGNAK_LOGGER_NAME",
")",
"for",
"handler",
"in",
... | 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 provided, the format and filename in the configuration file
are updated with the provided values if they contain the patterns %(logdir)s and ... | [
"Configure",
"the",
"provided",
"logger",
"-",
"get",
"and",
"update",
"the",
"content",
"of",
"the",
"Json",
"configuration",
"file",
"-",
"configure",
"the",
"logger",
"with",
"this",
"file"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/log.py#L111-L198 | train |
Alignak-monitoring/alignak | alignak/log.py | set_log_console | def set_log_console(log_level=logging.INFO):
"""Set the Alignak daemons logger have a console log handler.
This is only used for the arbiter verify mode to add a console log handler.
:param log_level: log level
:return: n/a
"""
# Change the logger and all its handlers log level
logger_ = l... | python | def set_log_console(log_level=logging.INFO):
"""Set the Alignak daemons logger have a console log handler.
This is only used for the arbiter verify mode to add a console log handler.
:param log_level: log level
:return: n/a
"""
# Change the logger and all its handlers log level
logger_ = l... | [
"def",
"set_log_console",
"(",
"log_level",
"=",
"logging",
".",
"INFO",
")",
":",
"logger_",
"=",
"logging",
".",
"getLogger",
"(",
"ALIGNAK_LOGGER_NAME",
")",
"logger_",
".",
"setLevel",
"(",
"log_level",
")",
"csh",
"=",
"ColorStreamHandler",
"(",
"sys",
... | Set the Alignak daemons logger have a console log handler.
This is only used for the arbiter verify mode to add a console log handler.
:param log_level: log level
:return: n/a | [
"Set",
"the",
"Alignak",
"daemons",
"logger",
"have",
"a",
"console",
"log",
"handler",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/log.py#L201-L217 | train |
Alignak-monitoring/alignak | alignak/log.py | set_log_level | def set_log_level(log_level=logging.INFO, handlers=None):
"""Set the Alignak logger log level. This is mainly used for the arbiter verify code to
set the log level at INFO level whatever the configured log level is set.
This is also used when changing the daemon log level thanks to the WS interface
If... | python | def set_log_level(log_level=logging.INFO, handlers=None):
"""Set the Alignak logger log level. This is mainly used for the arbiter verify code to
set the log level at INFO level whatever the configured log level is set.
This is also used when changing the daemon log level thanks to the WS interface
If... | [
"def",
"set_log_level",
"(",
"log_level",
"=",
"logging",
".",
"INFO",
",",
"handlers",
"=",
"None",
")",
":",
"logger_",
"=",
"logging",
".",
"getLogger",
"(",
"ALIGNAK_LOGGER_NAME",
")",
"logger_",
".",
"setLevel",
"(",
"log_level",
")",
"if",
"handlers",
... | Set the Alignak logger log level. This is mainly used for the arbiter verify code to
set the log level at INFO level whatever the configured log level is set.
This is also used when changing the daemon log level thanks to the WS interface
If an handlers name list is provided, all the handlers which name i... | [
"Set",
"the",
"Alignak",
"logger",
"log",
"level",
".",
"This",
"is",
"mainly",
"used",
"for",
"the",
"arbiter",
"verify",
"code",
"to",
"set",
"the",
"log",
"level",
"at",
"INFO",
"level",
"whatever",
"the",
"configured",
"log",
"level",
"is",
"set",
".... | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/log.py#L220-L242 | train |
Alignak-monitoring/alignak | alignak/log.py | make_monitoring_log | def make_monitoring_log(level, message, timestamp=None, to_logger=False):
"""
Function used to build the monitoring log.
Emit a log message with the provided level to the monitoring log logger.
Build a Brok typed as monitoring_log with the provided message
When to_logger is True, the information i... | python | def make_monitoring_log(level, message, timestamp=None, to_logger=False):
"""
Function used to build the monitoring log.
Emit a log message with the provided level to the monitoring log logger.
Build a Brok typed as monitoring_log with the provided message
When to_logger is True, the information i... | [
"def",
"make_monitoring_log",
"(",
"level",
",",
"message",
",",
"timestamp",
"=",
"None",
",",
"to_logger",
"=",
"False",
")",
":",
"level",
"=",
"level",
".",
"lower",
"(",
")",
"if",
"level",
"not",
"in",
"[",
"'debug'",
",",
"'info'",
",",
"'warnin... | Function used to build the monitoring log.
Emit a log message with the provided level to the monitoring log logger.
Build a Brok typed as monitoring_log with the provided message
When to_logger is True, the information is sent to the python logger, else a monitoring_log
Brok is returned. The Brok is m... | [
"Function",
"used",
"to",
"build",
"the",
"monitoring",
"log",
"."
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/log.py#L256-L308 | train |
Alignak-monitoring/alignak | alignak/objects/contact.py | Contact.want_service_notification | 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:... | python | 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:... | [
"def",
"want_service_notification",
"(",
"self",
",",
"notifways",
",",
"timeperiods",
",",
"timestamp",
",",
"state",
",",
"n_type",
",",
"business_impact",
",",
"cmd",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"service_notifications_enabled",
":",
"re... | Check if notification options match the state of the service
:param timestamp: time we want to notify the contact (usually now)
:type timestamp: int
:param state: host or service state ("WARNING", "CRITICAL" ..)
:type state: str
:param n_type: type of notification ("PROBLEM", "R... | [
"Check",
"if",
"notification",
"options",
"match",
"the",
"state",
"of",
"the",
"service"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contact.py#L243-L281 | train |
Alignak-monitoring/alignak | alignak/objects/contact.py | Contact.want_host_notification | def want_host_notification(self, notifways, timeperiods, timestamp, state, n_type,
business_impact, cmd=None):
"""Check if notification options match the state of the host
:param timestamp: time we want to notify the contact (usually now)
:type timestamp: int
... | python | def want_host_notification(self, notifways, timeperiods, timestamp, state, n_type,
business_impact, cmd=None):
"""Check if notification options match the state of the host
:param timestamp: time we want to notify the contact (usually now)
:type timestamp: int
... | [
"def",
"want_host_notification",
"(",
"self",
",",
"notifways",
",",
"timeperiods",
",",
"timestamp",
",",
"state",
",",
"n_type",
",",
"business_impact",
",",
"cmd",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"host_notifications_enabled",
":",
"return",... | Check if notification options match the state of the host
:param timestamp: time we want to notify the contact (usually now)
:type timestamp: int
:param state: host or service state ("UP", "DOWN" ..)
:type state: str
:param n_type: type of notification ("PROBLEM", "RECOVERY" ..)... | [
"Check",
"if",
"notification",
"options",
"match",
"the",
"state",
"of",
"the",
"host"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contact.py#L283-L320 | train |
Alignak-monitoring/alignak | alignak/objects/contact.py | Contacts.explode | 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... | python | 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... | [
"def",
"explode",
"(",
"self",
",",
"contactgroups",
",",
"notificationways",
")",
":",
"self",
".",
"apply_partial_inheritance",
"(",
"'contactgroups'",
")",
"for",
"prop",
"in",
"Contact",
".",
"special_properties",
":",
"if",
"prop",
"==",
"'contact_name'",
"... | Explode all contact for each contactsgroup
:param contactgroups: contactgroups to explode
:type contactgroups: alignak.objects.contactgroup.Contactgroups
:param notificationways: notificationways to explode
:type notificationways: alignak.objects.notificationway.Notificationways
... | [
"Explode",
"all",
"contact",
"for",
"each",
"contactsgroup"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/contact.py#L481-L528 | train |
Alignak-monitoring/alignak | alignak/modules/inner_retention.py | InnerRetention.hook_save_retention | def hook_save_retention(self, scheduler):
"""Save retention data to a Json formated file
:param scheduler: scheduler instance of alignak
:type scheduler: object
:return: None
"""
if not self.enabled:
logger.warning("Alignak retention module is not enabled."
... | python | def hook_save_retention(self, scheduler):
"""Save retention data to a Json formated file
:param scheduler: scheduler instance of alignak
:type scheduler: object
:return: None
"""
if not self.enabled:
logger.warning("Alignak retention module is not enabled."
... | [
"def",
"hook_save_retention",
"(",
"self",
",",
"scheduler",
")",
":",
"if",
"not",
"self",
".",
"enabled",
":",
"logger",
".",
"warning",
"(",
"\"Alignak retention module is not enabled.\"",
"\"Saving objects state is not possible.\"",
")",
"return",
"None",
"try",
"... | Save retention data to a Json formated file
:param scheduler: scheduler instance of alignak
:type scheduler: object
:return: None | [
"Save",
"retention",
"data",
"to",
"a",
"Json",
"formated",
"file"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/modules/inner_retention.py#L259-L326 | train |
Alignak-monitoring/alignak | alignak/objects/checkmodulation.py | CheckModulation.get_check_command | def get_check_command(self, timeperiods, t_to_go):
"""Get the check_command if we are in the check period modulation
:param t_to_go: time to check if we are in the timeperiod
:type t_to_go:
:return: A check command if we are in the check period, None otherwise
:rtype: alignak.ob... | python | def get_check_command(self, timeperiods, t_to_go):
"""Get the check_command if we are in the check period modulation
:param t_to_go: time to check if we are in the timeperiod
:type t_to_go:
:return: A check command if we are in the check period, None otherwise
:rtype: alignak.ob... | [
"def",
"get_check_command",
"(",
"self",
",",
"timeperiods",
",",
"t_to_go",
")",
":",
"if",
"not",
"self",
".",
"check_period",
"or",
"timeperiods",
"[",
"self",
".",
"check_period",
"]",
".",
"is_time_valid",
"(",
"t_to_go",
")",
":",
"return",
"self",
"... | Get the check_command if we are in the check period modulation
:param t_to_go: time to check if we are in the timeperiod
:type t_to_go:
:return: A check command if we are in the check period, None otherwise
:rtype: alignak.objects.command.Command | [
"Get",
"the",
"check_command",
"if",
"we",
"are",
"in",
"the",
"check",
"period",
"modulation"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/checkmodulation.py#L113-L123 | train |
Alignak-monitoring/alignak | alignak/objects/checkmodulation.py | CheckModulations.linkify | def linkify(self, timeperiods, commands):
"""Replace check_period by real Timeperiod object into each CheckModulation
Replace check_command by real Command object into each CheckModulation
:param timeperiods: timeperiods to link to
:type timeperiods: alignak.objects.timeperiod.Timeperio... | python | def linkify(self, timeperiods, commands):
"""Replace check_period by real Timeperiod object into each CheckModulation
Replace check_command by real Command object into each CheckModulation
:param timeperiods: timeperiods to link to
:type timeperiods: alignak.objects.timeperiod.Timeperio... | [
"def",
"linkify",
"(",
"self",
",",
"timeperiods",
",",
"commands",
")",
":",
"self",
".",
"linkify_with_timeperiods",
"(",
"timeperiods",
",",
"'check_period'",
")",
"self",
".",
"linkify_one_command_with_commands",
"(",
"commands",
",",
"'check_command'",
")"
] | Replace check_period by real Timeperiod object into each CheckModulation
Replace check_command by real Command object into each CheckModulation
:param timeperiods: timeperiods to link to
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:param commands: commands to link to
... | [
"Replace",
"check_period",
"by",
"real",
"Timeperiod",
"object",
"into",
"each",
"CheckModulation",
"Replace",
"check_command",
"by",
"real",
"Command",
"object",
"into",
"each",
"CheckModulation"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/checkmodulation.py#L167-L178 | train |
Alignak-monitoring/alignak | alignak/objects/checkmodulation.py | CheckModulations.new_inner_member | def new_inner_member(self, name=None, params=None):
"""Create a CheckModulation object and add it to items
:param name: CheckModulation name
:type name: str
:param params: parameters to init CheckModulation
:type params: dict
:return: None
TODO: Remove this defau... | python | def new_inner_member(self, name=None, params=None):
"""Create a CheckModulation object and add it to items
:param name: CheckModulation name
:type name: str
:param params: parameters to init CheckModulation
:type params: dict
:return: None
TODO: Remove this defau... | [
"def",
"new_inner_member",
"(",
"self",
",",
"name",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"name",
"=",
"'Generated_checkmodulation_%s'",
"%",
"uuid",
".",
"uuid4",
"(",
")",
"if",
"params",
"is",
"None",
"... | Create a CheckModulation object and add it to items
:param name: CheckModulation name
:type name: str
:param params: parameters to init CheckModulation
:type params: dict
:return: None
TODO: Remove this default mutable argument. Usually result in unexpected behavior | [
"Create",
"a",
"CheckModulation",
"object",
"and",
"add",
"it",
"to",
"items"
] | f3c145207e83159b799d3714e4241399c7740a64 | https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/checkmodulation.py#L180-L198 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/arduino.py | ArduinoBoard.open | def open(self):
"""
Open the serial connection.
"""
if not self._is_connected:
print("Connecting to arduino on {}... ".format(self.device),end="")
self.comm = serial.Serial()
self.comm.port = self.device
self.comm.baudrate = ... | python | def open(self):
"""
Open the serial connection.
"""
if not self._is_connected:
print("Connecting to arduino on {}... ".format(self.device),end="")
self.comm = serial.Serial()
self.comm.port = self.device
self.comm.baudrate = ... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_is_connected",
":",
"print",
"(",
"\"Connecting to arduino on {}... \"",
".",
"format",
"(",
"self",
".",
"device",
")",
",",
"end",
"=",
"\"\"",
")",
"self",
".",
"comm",
"=",
"serial",
... | Open the serial connection. | [
"Open",
"the",
"serial",
"connection",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/arduino.py#L147-L166 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/arduino.py | ArduinoBoard.close | def close(self):
"""
Close serial connection.
"""
if self._is_connected:
self.comm.close()
self._is_connected = False | python | def close(self):
"""
Close serial connection.
"""
if self._is_connected:
self.comm.close()
self._is_connected = False | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_connected",
":",
"self",
".",
"comm",
".",
"close",
"(",
")",
"self",
".",
"_is_connected",
"=",
"False"
] | Close serial connection. | [
"Close",
"serial",
"connection",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/arduino.py#L189-L196 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger.receive | 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.
""... | python | 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.
""... | [
"def",
"receive",
"(",
"self",
",",
"arg_formats",
"=",
"None",
")",
":",
"msg",
"=",
"[",
"[",
"]",
"]",
"raw_msg",
"=",
"[",
"]",
"escaped",
"=",
"False",
"command_sep_found",
"=",
"False",
"while",
"True",
":",
"tmp",
"=",
"self",
".",
"board",
... | 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. | [
"Recieve",
"commands",
"coming",
"off",
"the",
"serial",
"port",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L175-L289 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_char | def _send_char(self,value):
"""
Convert a single char to a bytes object.
"""
if type(value) != str and type(value) != bytes:
err = "char requires a string or bytes array of length 1"
raise ValueError(err)
if len(value) != 1:
err = "char must ... | python | def _send_char(self,value):
"""
Convert a single char to a bytes object.
"""
if type(value) != str and type(value) != bytes:
err = "char requires a string or bytes array of length 1"
raise ValueError(err)
if len(value) != 1:
err = "char must ... | [
"def",
"_send_char",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"str",
"and",
"type",
"(",
"value",
")",
"!=",
"bytes",
":",
"err",
"=",
"\"char requires a string or bytes array of length 1\"",
"raise",
"ValueError",
"(",
"er... | Convert a single char to a bytes object. | [
"Convert",
"a",
"single",
"char",
"to",
"a",
"bytes",
"object",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L319-L339 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_byte | def _send_byte(self,value):
"""
Convert a numerical value into an integer, then to a byte object. Check
bounds for byte.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_value = i... | python | def _send_byte(self,value):
"""
Convert a numerical value into an integer, then to a byte object. Check
bounds for byte.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_value = i... | [
"def",
"_send_byte",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Coercing {} into int ({})\"",
".",
"format",
... | Convert a numerical value into an integer, then to a byte object. Check
bounds for byte. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"byte",
"object",
".",
"Check",
"bounds",
"for",
"byte",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L341-L362 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_int | def _send_int(self,value):
"""
Convert a numerical value into an integer, then to a bytes object Check
bounds for signed int.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_val... | python | def _send_int(self,value):
"""
Convert a numerical value into an integer, then to a bytes object Check
bounds for signed int.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_val... | [
"def",
"_send_int",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Coercing {} into int ({})\"",
".",
"format",
"... | Convert a numerical value into an integer, then to a bytes object Check
bounds for signed int. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"bytes",
"object",
"Check",
"bounds",
"for",
"signed",
"int",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L364-L385 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_unsigned_int | def _send_unsigned_int(self,value):
"""
Convert a numerical value into an integer, then to a bytes object. Check
bounds for unsigned int.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
... | python | def _send_unsigned_int(self,value):
"""
Convert a numerical value into an integer, then to a bytes object. Check
bounds for unsigned int.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
... | [
"def",
"_send_unsigned_int",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Coercing {} into int ({})\"",
".",
"for... | Convert a numerical value into an integer, then to a bytes object. Check
bounds for unsigned int. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"bytes",
"object",
".",
"Check",
"bounds",
"for",
"unsigned",
"int",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L387-L407 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_long | def _send_long(self,value):
"""
Convert a numerical value into an integer, then to a bytes object. Check
bounds for signed long.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_... | python | def _send_long(self,value):
"""
Convert a numerical value into an integer, then to a bytes object. Check
bounds for signed long.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
new_... | [
"def",
"_send_long",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Coercing {} into int ({})\"",
".",
"format",
... | Convert a numerical value into an integer, then to a bytes object. Check
bounds for signed long. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"bytes",
"object",
".",
"Check",
"bounds",
"for",
"signed",
"long",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L409-L430 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_unsigned_long | def _send_unsigned_long(self,value):
"""
Convert a numerical value into an integer, then to a bytes object.
Check bounds for unsigned long.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
... | python | def _send_unsigned_long(self,value):
"""
Convert a numerical value into an integer, then to a bytes object.
Check bounds for unsigned long.
"""
# Coerce to int. This will throw a ValueError if the value can't
# actually be converted.
if type(value) != int:
... | [
"def",
"_send_unsigned_long",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"int",
":",
"new_value",
"=",
"int",
"(",
"value",
")",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Coercing {} into int ({})\"",
".",
"fo... | Convert a numerical value into an integer, then to a bytes object.
Check bounds for unsigned long. | [
"Convert",
"a",
"numerical",
"value",
"into",
"an",
"integer",
"then",
"to",
"a",
"bytes",
"object",
".",
"Check",
"bounds",
"for",
"unsigned",
"long",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L432-L453 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_string | def _send_string(self,value):
"""
Convert a string to a bytes object. If value is not a string, it is
be converted to one with a standard string.format call.
"""
if type(value) != bytes:
value = "{}".format(value).encode("ascii")
return value | python | def _send_string(self,value):
"""
Convert a string to a bytes object. If value is not a string, it is
be converted to one with a standard string.format call.
"""
if type(value) != bytes:
value = "{}".format(value).encode("ascii")
return value | [
"def",
"_send_string",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"bytes",
":",
"value",
"=",
"\"{}\"",
".",
"format",
"(",
"value",
")",
".",
"encode",
"(",
"\"ascii\"",
")",
"return",
"value"
] | Convert a string to a bytes object. If value is not a string, it is
be converted to one with a standard string.format call. | [
"Convert",
"a",
"string",
"to",
"a",
"bytes",
"object",
".",
"If",
"value",
"is",
"not",
"a",
"string",
"it",
"is",
"be",
"converted",
"to",
"one",
"with",
"a",
"standard",
"string",
".",
"format",
"call",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L489-L498 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._send_bool | def _send_bool(self,value):
"""
Convert a boolean value into a bytes object. Uses 0 and 1 as output.
"""
# Sanity check.
if type(value) != bool and value not in [0,1]:
err = "{} is not boolean.".format(value)
raise ValueError(err)
return struct.... | python | def _send_bool(self,value):
"""
Convert a boolean value into a bytes object. Uses 0 and 1 as output.
"""
# Sanity check.
if type(value) != bool and value not in [0,1]:
err = "{} is not boolean.".format(value)
raise ValueError(err)
return struct.... | [
"def",
"_send_bool",
"(",
"self",
",",
"value",
")",
":",
"if",
"type",
"(",
"value",
")",
"!=",
"bool",
"and",
"value",
"not",
"in",
"[",
"0",
",",
"1",
"]",
":",
"err",
"=",
"\"{} is not boolean.\"",
".",
"format",
"(",
"value",
")",
"raise",
"Va... | Convert a boolean value into a bytes object. Uses 0 and 1 as output. | [
"Convert",
"a",
"boolean",
"value",
"into",
"a",
"bytes",
"object",
".",
"Uses",
"0",
"and",
"1",
"as",
"output",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L500-L510 | train |
harmsm/PyCmdMessenger | PyCmdMessenger/PyCmdMessenger.py | CmdMessenger._recv_guess | def _recv_guess(self,value):
"""
Take the binary spew and try to make it into a float or integer. If
that can't be done, return a string.
Note: this is generally a bad idea, as values can be seriously mangled
by going from float -> string -> float. You'll generally be bette... | python | def _recv_guess(self,value):
"""
Take the binary spew and try to make it into a float or integer. If
that can't be done, return a string.
Note: this is generally a bad idea, as values can be seriously mangled
by going from float -> string -> float. You'll generally be bette... | [
"def",
"_recv_guess",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"give_warnings",
":",
"w",
"=",
"\"Warning: Guessing input format for {}. This can give wildly incorrect values. Consider specifying a format and sending binary data.\"",
".",
"format",
"(",
"value",
... | Take the binary spew and try to make it into a float or integer. If
that can't be done, return a string.
Note: this is generally a bad idea, as values can be seriously mangled
by going from float -> string -> float. You'll generally be better off
using a format specifier and binary... | [
"Take",
"the",
"binary",
"spew",
"and",
"try",
"to",
"make",
"it",
"into",
"a",
"float",
"or",
"integer",
".",
"If",
"that",
"can",
"t",
"be",
"done",
"return",
"a",
"string",
"."
] | 215d6f9402262662a14a2996f532934339639a5b | https://github.com/harmsm/PyCmdMessenger/blob/215d6f9402262662a14a2996f532934339639a5b/PyCmdMessenger/PyCmdMessenger.py#L610-L640 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._add_full_message | def _add_full_message(gelf_dict, record):
"""Add the ``full_message`` field to the ``gelf_dict`` if any
traceback information exists within the logging record
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogReco... | python | def _add_full_message(gelf_dict, record):
"""Add the ``full_message`` field to the ``gelf_dict`` if any
traceback information exists within the logging record
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogReco... | [
"def",
"_add_full_message",
"(",
"gelf_dict",
",",
"record",
")",
":",
"full_message",
"=",
"None",
"if",
"record",
".",
"exc_info",
":",
"full_message",
"=",
"'\\n'",
".",
"join",
"(",
"traceback",
".",
"format_exception",
"(",
"*",
"record",
".",
"exc_info... | Add the ``full_message`` field to the ``gelf_dict`` if any
traceback information exists within the logging record
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogRecord` to extract a full
logging message fro... | [
"Add",
"the",
"full_message",
"field",
"to",
"the",
"gelf_dict",
"if",
"any",
"traceback",
"information",
"exists",
"within",
"the",
"logging",
"record"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L194-L216 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._resolve_host | def _resolve_host(fqdn, localname):
"""Resolve the ``host`` GELF field
:param fqdn: Boolean indicating whether to use :meth:`socket.getfqdn`
to obtain the ``host`` GELF field.
:type fqdn: bool
:param localname: Use specified hostname as the ``host`` GELF field.
:typ... | python | def _resolve_host(fqdn, localname):
"""Resolve the ``host`` GELF field
:param fqdn: Boolean indicating whether to use :meth:`socket.getfqdn`
to obtain the ``host`` GELF field.
:type fqdn: bool
:param localname: Use specified hostname as the ``host`` GELF field.
:typ... | [
"def",
"_resolve_host",
"(",
"fqdn",
",",
"localname",
")",
":",
"if",
"fqdn",
":",
"return",
"socket",
".",
"getfqdn",
"(",
")",
"elif",
"localname",
"is",
"not",
"None",
":",
"return",
"localname",
"return",
"socket",
".",
"gethostname",
"(",
")"
] | Resolve the ``host`` GELF field
:param fqdn: Boolean indicating whether to use :meth:`socket.getfqdn`
to obtain the ``host`` GELF field.
:type fqdn: bool
:param localname: Use specified hostname as the ``host`` GELF field.
:type localname: str or None
:return: Stri... | [
"Resolve",
"the",
"host",
"GELF",
"field"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L219-L236 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._add_debugging_fields | def _add_debugging_fields(gelf_dict, record):
"""Add debugging fields to the given ``gelf_dict``
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogRecord` to extract debugging
fields from to insert into the gi... | python | def _add_debugging_fields(gelf_dict, record):
"""Add debugging fields to the given ``gelf_dict``
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogRecord` to extract debugging
fields from to insert into the gi... | [
"def",
"_add_debugging_fields",
"(",
"gelf_dict",
",",
"record",
")",
":",
"gelf_dict",
".",
"update",
"(",
"{",
"'file'",
":",
"record",
".",
"pathname",
",",
"'line'",
":",
"record",
".",
"lineno",
",",
"'_function'",
":",
"record",
".",
"funcName",
",",... | Add debugging fields to the given ``gelf_dict``
:param gelf_dict: dictionary representation of a GELF log.
:type gelf_dict: dict
:param record: :class:`logging.LogRecord` to extract debugging
fields from to insert into the given ``gelf_dict``.
:type record: logging.LogRecor... | [
"Add",
"debugging",
"fields",
"to",
"the",
"given",
"gelf_dict"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L239-L259 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._add_extra_fields | def _add_extra_fields(gelf_dict, record):
"""Add extra fields to the given ``gelf_dict``
However, this does not add additional fields in to ``message_dict``
that are either duplicated from standard :class:`logging.LogRecord`
attributes, duplicated from the python logging module source
... | python | def _add_extra_fields(gelf_dict, record):
"""Add extra fields to the given ``gelf_dict``
However, this does not add additional fields in to ``message_dict``
that are either duplicated from standard :class:`logging.LogRecord`
attributes, duplicated from the python logging module source
... | [
"def",
"_add_extra_fields",
"(",
"gelf_dict",
",",
"record",
")",
":",
"skip_list",
"=",
"(",
"'args'",
",",
"'asctime'",
",",
"'created'",
",",
"'exc_info'",
",",
"'exc_text'",
",",
"'filename'",
",",
"'funcName'",
",",
"'id'",
",",
"'levelname'",
",",
"'le... | Add extra fields to the given ``gelf_dict``
However, this does not add additional fields in to ``message_dict``
that are either duplicated from standard :class:`logging.LogRecord`
attributes, duplicated from the python logging module source
(e.g. ``exc_text``), or violate GLEF format (i... | [
"Add",
"extra",
"fields",
"to",
"the",
"given",
"gelf_dict"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L262-L294 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._pack_gelf_dict | def _pack_gelf_dict(gelf_dict):
"""Convert a given ``gelf_dict`` to a JSON-encoded string, thus,
creating an uncompressed GELF log ready for consumption by Graylog.
Since we cannot be 100% sure of what is contained in the ``gelf_dict``
we have to do some sanitation.
:param gelf... | python | def _pack_gelf_dict(gelf_dict):
"""Convert a given ``gelf_dict`` to a JSON-encoded string, thus,
creating an uncompressed GELF log ready for consumption by Graylog.
Since we cannot be 100% sure of what is contained in the ``gelf_dict``
we have to do some sanitation.
:param gelf... | [
"def",
"_pack_gelf_dict",
"(",
"gelf_dict",
")",
":",
"gelf_dict",
"=",
"BaseGELFHandler",
".",
"_sanitize_to_unicode",
"(",
"gelf_dict",
")",
"packed",
"=",
"json",
".",
"dumps",
"(",
"gelf_dict",
",",
"separators",
"=",
"',:'",
",",
"default",
"=",
"BaseGELF... | Convert a given ``gelf_dict`` to a JSON-encoded string, thus,
creating an uncompressed GELF log ready for consumption by Graylog.
Since we cannot be 100% sure of what is contained in the ``gelf_dict``
we have to do some sanitation.
:param gelf_dict: dictionary representation of a GELF ... | [
"Convert",
"a",
"given",
"gelf_dict",
"to",
"a",
"JSON",
"-",
"encoded",
"string",
"thus",
"creating",
"an",
"uncompressed",
"GELF",
"log",
"ready",
"for",
"consumption",
"by",
"Graylog",
"."
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L297-L317 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._sanitize_to_unicode | def _sanitize_to_unicode(obj):
"""Convert all strings records of the object to unicode
:param obj: object to sanitize to unicode.
:type obj: object
:return: Unicode string representation of the given object.
:rtype: str
"""
if isinstance(obj, dict):
... | python | def _sanitize_to_unicode(obj):
"""Convert all strings records of the object to unicode
:param obj: object to sanitize to unicode.
:type obj: object
:return: Unicode string representation of the given object.
:rtype: str
"""
if isinstance(obj, dict):
... | [
"def",
"_sanitize_to_unicode",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"dict",
"(",
"(",
"BaseGELFHandler",
".",
"_sanitize_to_unicode",
"(",
"k",
")",
",",
"BaseGELFHandler",
".",
"_sanitize_to_unicode",
"(",
"... | Convert all strings records of the object to unicode
:param obj: object to sanitize to unicode.
:type obj: object
:return: Unicode string representation of the given object.
:rtype: str | [
"Convert",
"all",
"strings",
"records",
"of",
"the",
"object",
"to",
"unicode"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L320-L335 | train |
severb/graypy | graypy/handler.py | BaseGELFHandler._object_to_json | def _object_to_json(obj):
"""Convert objects that cannot be natively serialized into JSON
into their string representation
For datetime based objects convert them into their ISO formatted
string as specified by :meth:`datetime.datetime.isoformat`.
:param obj: object to convert ... | python | def _object_to_json(obj):
"""Convert objects that cannot be natively serialized into JSON
into their string representation
For datetime based objects convert them into their ISO formatted
string as specified by :meth:`datetime.datetime.isoformat`.
:param obj: object to convert ... | [
"def",
"_object_to_json",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"obj",
".",
"isoformat",
"(",
")",
"return",
"repr",
"(",
"obj",
")"
] | Convert objects that cannot be natively serialized into JSON
into their string representation
For datetime based objects convert them into their ISO formatted
string as specified by :meth:`datetime.datetime.isoformat`.
:param obj: object to convert into a JSON via getting its string
... | [
"Convert",
"objects",
"that",
"cannot",
"be",
"natively",
"serialized",
"into",
"JSON",
"into",
"their",
"string",
"representation"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L338-L355 | train |
severb/graypy | graypy/handler.py | GELFTLSHandler.makeSocket | def makeSocket(self, timeout=1):
"""Override SocketHandler.makeSocket, to allow creating wrapped
TLS sockets"""
plain_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if hasattr(plain_socket, 'settimeout'):
plain_socket.settimeout(timeout)
wrapped_socket =... | python | def makeSocket(self, timeout=1):
"""Override SocketHandler.makeSocket, to allow creating wrapped
TLS sockets"""
plain_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if hasattr(plain_socket, 'settimeout'):
plain_socket.settimeout(timeout)
wrapped_socket =... | [
"def",
"makeSocket",
"(",
"self",
",",
"timeout",
"=",
"1",
")",
":",
"plain_socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"if",
"hasattr",
"(",
"plain_socket",
",",
"'settimeout'",
")",
":"... | Override SocketHandler.makeSocket, to allow creating wrapped
TLS sockets | [
"Override",
"SocketHandler",
".",
"makeSocket",
"to",
"allow",
"creating",
"wrapped",
"TLS",
"sockets"
] | 32018c41a792e71a8de9f9e14f770d1bc60c2313 | https://github.com/severb/graypy/blob/32018c41a792e71a8de9f9e14f770d1bc60c2313/graypy/handler.py#L451-L468 | train |
codeinthehole/purl | purl/url.py | to_unicode | def to_unicode(string):
"""
Ensure a passed string is unicode
"""
if isinstance(string, six.binary_type):
return string.decode('utf8')
if isinstance(string, six.text_type):
return string
if six.PY2:
return unicode(string)
return str(string) | python | def to_unicode(string):
"""
Ensure a passed string is unicode
"""
if isinstance(string, six.binary_type):
return string.decode('utf8')
if isinstance(string, six.text_type):
return string
if six.PY2:
return unicode(string)
return str(string) | [
"def",
"to_unicode",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"six",
".",
"binary_type",
")",
":",
"return",
"string",
".",
"decode",
"(",
"'utf8'",
")",
"if",
"isinstance",
"(",
"string",
",",
"six",
".",
"text_type",
")",
":",... | Ensure a passed string is unicode | [
"Ensure",
"a",
"passed",
"string",
"is",
"unicode"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L22-L32 | train |
codeinthehole/purl | purl/url.py | to_utf8 | def to_utf8(string):
"""
Encode a string as a UTF8 bytestring. This function could be passed a
bytestring or unicode string so must distinguish between the two.
"""
if isinstance(string, six.text_type):
return string.encode('utf8')
if isinstance(string, six.binary_type):
return ... | python | def to_utf8(string):
"""
Encode a string as a UTF8 bytestring. This function could be passed a
bytestring or unicode string so must distinguish between the two.
"""
if isinstance(string, six.text_type):
return string.encode('utf8')
if isinstance(string, six.binary_type):
return ... | [
"def",
"to_utf8",
"(",
"string",
")",
":",
"if",
"isinstance",
"(",
"string",
",",
"six",
".",
"text_type",
")",
":",
"return",
"string",
".",
"encode",
"(",
"'utf8'",
")",
"if",
"isinstance",
"(",
"string",
",",
"six",
".",
"binary_type",
")",
":",
... | Encode a string as a UTF8 bytestring. This function could be passed a
bytestring or unicode string so must distinguish between the two. | [
"Encode",
"a",
"string",
"as",
"a",
"UTF8",
"bytestring",
".",
"This",
"function",
"could",
"be",
"passed",
"a",
"bytestring",
"or",
"unicode",
"string",
"so",
"must",
"distinguish",
"between",
"the",
"two",
"."
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L35-L44 | train |
codeinthehole/purl | purl/url.py | dict_to_unicode | def dict_to_unicode(raw_dict):
"""
Ensure all keys and values in a dict are unicode.
The passed dict is assumed to have lists for all values.
"""
decoded = {}
for key, value in raw_dict.items():
decoded[to_unicode(key)] = map(
to_unicode, value)
return decoded | python | def dict_to_unicode(raw_dict):
"""
Ensure all keys and values in a dict are unicode.
The passed dict is assumed to have lists for all values.
"""
decoded = {}
for key, value in raw_dict.items():
decoded[to_unicode(key)] = map(
to_unicode, value)
return decoded | [
"def",
"dict_to_unicode",
"(",
"raw_dict",
")",
":",
"decoded",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"raw_dict",
".",
"items",
"(",
")",
":",
"decoded",
"[",
"to_unicode",
"(",
"key",
")",
"]",
"=",
"map",
"(",
"to_unicode",
",",
"value",... | Ensure all keys and values in a dict are unicode.
The passed dict is assumed to have lists for all values. | [
"Ensure",
"all",
"keys",
"and",
"values",
"in",
"a",
"dict",
"are",
"unicode",
"."
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L47-L57 | train |
codeinthehole/purl | purl/url.py | unicode_urlencode | def unicode_urlencode(query, doseq=True):
"""
Custom wrapper around urlencode to support unicode
Python urlencode doesn't handle unicode well so we need to convert to
bytestrings before using it:
http://stackoverflow.com/questions/6480723/urllib-urlencode-doesnt-like-unicode-values-how-about-this-w... | python | def unicode_urlencode(query, doseq=True):
"""
Custom wrapper around urlencode to support unicode
Python urlencode doesn't handle unicode well so we need to convert to
bytestrings before using it:
http://stackoverflow.com/questions/6480723/urllib-urlencode-doesnt-like-unicode-values-how-about-this-w... | [
"def",
"unicode_urlencode",
"(",
"query",
",",
"doseq",
"=",
"True",
")",
":",
"pairs",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"query",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
... | Custom wrapper around urlencode to support unicode
Python urlencode doesn't handle unicode well so we need to convert to
bytestrings before using it:
http://stackoverflow.com/questions/6480723/urllib-urlencode-doesnt-like-unicode-values-how-about-this-workaround | [
"Custom",
"wrapper",
"around",
"urlencode",
"to",
"support",
"unicode"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L80-L97 | train |
codeinthehole/purl | purl/url.py | parse | def parse(url_str):
"""
Extract all parts from a URL string and return them as a dictionary
"""
url_str = to_unicode(url_str)
result = urlparse(url_str)
netloc_parts = result.netloc.rsplit('@', 1)
if len(netloc_parts) == 1:
username = password = None
host = netloc_parts[0]
... | python | def parse(url_str):
"""
Extract all parts from a URL string and return them as a dictionary
"""
url_str = to_unicode(url_str)
result = urlparse(url_str)
netloc_parts = result.netloc.rsplit('@', 1)
if len(netloc_parts) == 1:
username = password = None
host = netloc_parts[0]
... | [
"def",
"parse",
"(",
"url_str",
")",
":",
"url_str",
"=",
"to_unicode",
"(",
"url_str",
")",
"result",
"=",
"urlparse",
"(",
"url_str",
")",
"netloc_parts",
"=",
"result",
".",
"netloc",
".",
"rsplit",
"(",
"'@'",
",",
"1",
")",
"if",
"len",
"(",
"ne... | Extract all parts from a URL string and return them as a dictionary | [
"Extract",
"all",
"parts",
"from",
"a",
"URL",
"string",
"and",
"return",
"them",
"as",
"a",
"dictionary"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L100-L129 | train |
codeinthehole/purl | purl/url.py | URL.netloc | def netloc(self):
"""
Return the netloc
"""
url = self._tuple
if url.username and url.password:
netloc = '%s:%s@%s' % (url.username, url.password, url.host)
elif url.username and not url.password:
netloc = '%s@%s' % (url.username, url.host)
... | python | def netloc(self):
"""
Return the netloc
"""
url = self._tuple
if url.username and url.password:
netloc = '%s:%s@%s' % (url.username, url.password, url.host)
elif url.username and not url.password:
netloc = '%s@%s' % (url.username, url.host)
... | [
"def",
"netloc",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"_tuple",
"if",
"url",
".",
"username",
"and",
"url",
".",
"password",
":",
"netloc",
"=",
"'%s:%s@%s'",
"%",
"(",
"url",
".",
"username",
",",
"url",
".",
"password",
",",
"url",
"."... | Return the netloc | [
"Return",
"the",
"netloc"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L221-L234 | train |
codeinthehole/purl | purl/url.py | URL.host | def host(self, value=None):
"""
Return the host
:param string value: new host string
"""
if value is not None:
return URL._mutate(self, host=value)
return self._tuple.host | python | def host(self, value=None):
"""
Return the host
:param string value: new host string
"""
if value is not None:
return URL._mutate(self, host=value)
return self._tuple.host | [
"def",
"host",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"host",
"=",
"value",
")",
"return",
"self",
".",
"_tuple",
".",
"host"
] | Return the host
:param string value: new host string | [
"Return",
"the",
"host"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L236-L244 | train |
codeinthehole/purl | purl/url.py | URL.username | def username(self, value=None):
"""
Return or set the username
:param string value: the new username to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, username=value)
return unicode_unquote(self._t... | python | def username(self, value=None):
"""
Return or set the username
:param string value: the new username to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, username=value)
return unicode_unquote(self._t... | [
"def",
"username",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"username",
"=",
"value",
")",
"return",
"unicode_unquote",
"(",
"self",
".",
"_tuple",
"... | Return or set the username
:param string value: the new username to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"username"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L248-L257 | train |
codeinthehole/purl | purl/url.py | URL.password | def password(self, value=None):
"""
Return or set the password
:param string value: the new password to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, password=value)
return unicode_unquote(self._t... | python | def password(self, value=None):
"""
Return or set the password
:param string value: the new password to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, password=value)
return unicode_unquote(self._t... | [
"def",
"password",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"password",
"=",
"value",
")",
"return",
"unicode_unquote",
"(",
"self",
".",
"_tuple",
"... | Return or set the password
:param string value: the new password to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"password"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L259-L268 | train |
codeinthehole/purl | purl/url.py | URL.scheme | def scheme(self, value=None):
"""
Return or set the scheme.
:param string value: the new scheme to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, scheme=value)
return self._tuple.scheme | python | def scheme(self, value=None):
"""
Return or set the scheme.
:param string value: the new scheme to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, scheme=value)
return self._tuple.scheme | [
"def",
"scheme",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"scheme",
"=",
"value",
")",
"return",
"self",
".",
"_tuple",
".",
"scheme"
] | Return or set the scheme.
:param string value: the new scheme to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"scheme",
"."
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L295-L304 | train |
codeinthehole/purl | purl/url.py | URL.path | def path(self, value=None):
"""
Return or set the path
:param string value: the new path to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
if not value.startswith('/'):
value = '/' + value
encoded_value... | python | def path(self, value=None):
"""
Return or set the path
:param string value: the new path to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
if not value.startswith('/'):
value = '/' + value
encoded_value... | [
"def",
"path",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"if",
"not",
"value",
".",
"startswith",
"(",
"'/'",
")",
":",
"value",
"=",
"'/'",
"+",
"value",
"encoded_value",
"=",
"unicode_quote",
"(",
... | Return or set the path
:param string value: the new path to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"path"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L306-L318 | train |
codeinthehole/purl | purl/url.py | URL.query | def query(self, value=None):
"""
Return or set the query string
:param string value: the new query string to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, query=value)
return self._tuple.query | python | def query(self, value=None):
"""
Return or set the query string
:param string value: the new query string to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, query=value)
return self._tuple.query | [
"def",
"query",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"query",
"=",
"value",
")",
"return",
"self",
".",
"_tuple",
".",
"query"
] | Return or set the query string
:param string value: the new query string to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"query",
"string"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L320-L329 | train |
codeinthehole/purl | purl/url.py | URL.port | def port(self, value=None):
"""
Return or set the port
:param string value: the new port to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, port=value)
return self._tuple.port | python | def port(self, value=None):
"""
Return or set the port
:param string value: the new port to use
:returns: string or new :class:`URL` instance
"""
if value is not None:
return URL._mutate(self, port=value)
return self._tuple.port | [
"def",
"port",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"port",
"=",
"value",
")",
"return",
"self",
".",
"_tuple",
".",
"port"
] | Return or set the port
:param string value: the new port to use
:returns: string or new :class:`URL` instance | [
"Return",
"or",
"set",
"the",
"port"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L331-L340 | train |
codeinthehole/purl | purl/url.py | URL.path_segment | def path_segment(self, index, value=None, default=None):
"""
Return the path segment at the given index
:param integer index:
:param string value: the new segment value
:param string default: the default value to return if no path segment exists with the given index
"""
... | python | def path_segment(self, index, value=None, default=None):
"""
Return the path segment at the given index
:param integer index:
:param string value: the new segment value
:param string default: the default value to return if no path segment exists with the given index
"""
... | [
"def",
"path_segment",
"(",
"self",
",",
"index",
",",
"value",
"=",
"None",
",",
"default",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"segments",
"=",
"list",
"(",
"self",
".",
"path_segments",
"(",
")",
")",
"segments",
"[",
... | Return the path segment at the given index
:param integer index:
:param string value: the new segment value
:param string default: the default value to return if no path segment exists with the given index | [
"Return",
"the",
"path",
"segment",
"at",
"the",
"given",
"index"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L365-L383 | train |
codeinthehole/purl | purl/url.py | URL.path_segments | def path_segments(self, value=None):
"""
Return the path segments
:param list value: the new path segments to use
"""
if value is not None:
encoded_values = map(unicode_quote_path_segment, value)
new_path = '/' + '/'.join(encoded_values)
retur... | python | def path_segments(self, value=None):
"""
Return the path segments
:param list value: the new path segments to use
"""
if value is not None:
encoded_values = map(unicode_quote_path_segment, value)
new_path = '/' + '/'.join(encoded_values)
retur... | [
"def",
"path_segments",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"encoded_values",
"=",
"map",
"(",
"unicode_quote_path_segment",
",",
"value",
")",
"new_path",
"=",
"'/'",
"+",
"'/'",
".",
"join",
"(",
... | Return the path segments
:param list value: the new path segments to use | [
"Return",
"the",
"path",
"segments"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L385-L400 | train |
codeinthehole/purl | purl/url.py | URL.add_path_segment | def add_path_segment(self, value):
"""
Add a new path segment to the end of the current string
:param string value: the new path segment to use
Example::
>>> u = URL('http://example.com/foo/')
>>> u.add_path_segment('bar').as_string()
'http://exampl... | python | def add_path_segment(self, value):
"""
Add a new path segment to the end of the current string
:param string value: the new path segment to use
Example::
>>> u = URL('http://example.com/foo/')
>>> u.add_path_segment('bar').as_string()
'http://exampl... | [
"def",
"add_path_segment",
"(",
"self",
",",
"value",
")",
":",
"segments",
"=",
"self",
".",
"path_segments",
"(",
")",
"+",
"(",
"to_unicode",
"(",
"value",
")",
",",
")",
"return",
"self",
".",
"path_segments",
"(",
"segments",
")"
] | Add a new path segment to the end of the current string
:param string value: the new path segment to use
Example::
>>> u = URL('http://example.com/foo/')
>>> u.add_path_segment('bar').as_string()
'http://example.com/foo/bar' | [
"Add",
"a",
"new",
"path",
"segment",
"to",
"the",
"end",
"of",
"the",
"current",
"string"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L402-L415 | train |
codeinthehole/purl | purl/url.py | URL.query_param | def query_param(self, key, value=None, default=None, as_list=False):
"""
Return or set a query parameter for the given key
The value can be a list.
:param string key: key to look for
:param string default: value to return if ``key`` isn't found
:param boolean as_list: w... | python | def query_param(self, key, value=None, default=None, as_list=False):
"""
Return or set a query parameter for the given key
The value can be a list.
:param string key: key to look for
:param string default: value to return if ``key`` isn't found
:param boolean as_list: w... | [
"def",
"query_param",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
",",
"default",
"=",
"None",
",",
"as_list",
"=",
"False",
")",
":",
"parse_result",
"=",
"self",
".",
"query_params",
"(",
")",
"if",
"value",
"is",
"not",
"None",
":",
"if",
... | Return or set a query parameter for the given key
The value can be a list.
:param string key: key to look for
:param string default: value to return if ``key`` isn't found
:param boolean as_list: whether to return the values as a list
:param string value: the new query paramete... | [
"Return",
"or",
"set",
"a",
"query",
"parameter",
"for",
"the",
"given",
"key"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L437-L465 | train |
codeinthehole/purl | purl/url.py | URL.append_query_param | def append_query_param(self, key, value):
"""
Append a query parameter
:param string key: The query param key
:param string value: The new value
"""
values = self.query_param(key, as_list=True, default=[])
values.append(value)
return self.query_param(key,... | python | def append_query_param(self, key, value):
"""
Append a query parameter
:param string key: The query param key
:param string value: The new value
"""
values = self.query_param(key, as_list=True, default=[])
values.append(value)
return self.query_param(key,... | [
"def",
"append_query_param",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"values",
"=",
"self",
".",
"query_param",
"(",
"key",
",",
"as_list",
"=",
"True",
",",
"default",
"=",
"[",
"]",
")",
"values",
".",
"append",
"(",
"value",
")",
"return"... | Append a query parameter
:param string key: The query param key
:param string value: The new value | [
"Append",
"a",
"query",
"parameter"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L467-L476 | train |
codeinthehole/purl | purl/url.py | URL.query_params | def query_params(self, value=None):
"""
Return or set a dictionary of query params
:param dict value: new dictionary of values
"""
if value is not None:
return URL._mutate(self, query=unicode_urlencode(value, doseq=True))
query = '' if self._tuple.query is No... | python | def query_params(self, value=None):
"""
Return or set a dictionary of query params
:param dict value: new dictionary of values
"""
if value is not None:
return URL._mutate(self, query=unicode_urlencode(value, doseq=True))
query = '' if self._tuple.query is No... | [
"def",
"query_params",
"(",
"self",
",",
"value",
"=",
"None",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"return",
"URL",
".",
"_mutate",
"(",
"self",
",",
"query",
"=",
"unicode_urlencode",
"(",
"value",
",",
"doseq",
"=",
"True",
")",
")",... | Return or set a dictionary of query params
:param dict value: new dictionary of values | [
"Return",
"or",
"set",
"a",
"dictionary",
"of",
"query",
"params"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L478-L494 | train |
codeinthehole/purl | purl/url.py | URL.remove_query_param | def remove_query_param(self, key, value=None):
"""
Remove a query param from a URL
Set the value parameter if removing from a list.
:param string key: The key to delete
:param string value: The value of the param to delete (of more than one)
"""
parse_result = s... | python | def remove_query_param(self, key, value=None):
"""
Remove a query param from a URL
Set the value parameter if removing from a list.
:param string key: The key to delete
:param string value: The value of the param to delete (of more than one)
"""
parse_result = s... | [
"def",
"remove_query_param",
"(",
"self",
",",
"key",
",",
"value",
"=",
"None",
")",
":",
"parse_result",
"=",
"self",
".",
"query_params",
"(",
")",
"if",
"value",
"is",
"not",
"None",
":",
"index",
"=",
"parse_result",
"[",
"key",
"]",
".",
"index",... | Remove a query param from a URL
Set the value parameter if removing from a list.
:param string key: The key to delete
:param string value: The value of the param to delete (of more than one) | [
"Remove",
"a",
"query",
"param",
"from",
"a",
"URL"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/url.py#L496-L511 | train |
codeinthehole/purl | purl/template.py | expand | def expand(template, variables=None):
"""
Expand a URL template string using the passed variables
"""
if variables is None:
variables = {}
return patterns.sub(functools.partial(_replace, variables), template) | python | def expand(template, variables=None):
"""
Expand a URL template string using the passed variables
"""
if variables is None:
variables = {}
return patterns.sub(functools.partial(_replace, variables), template) | [
"def",
"expand",
"(",
"template",
",",
"variables",
"=",
"None",
")",
":",
"if",
"variables",
"is",
"None",
":",
"variables",
"=",
"{",
"}",
"return",
"patterns",
".",
"sub",
"(",
"functools",
".",
"partial",
"(",
"_replace",
",",
"variables",
")",
","... | Expand a URL template string using the passed variables | [
"Expand",
"a",
"URL",
"template",
"string",
"using",
"the",
"passed",
"variables"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/template.py#L31-L37 | train |
codeinthehole/purl | purl/template.py | _format_pair_no_equals | def _format_pair_no_equals(explode, separator, escape, key, value):
"""
Format a key, value pair but don't include the equals sign
when there is no value
"""
if not value:
return key
return _format_pair(explode, separator, escape, key, value) | python | def _format_pair_no_equals(explode, separator, escape, key, value):
"""
Format a key, value pair but don't include the equals sign
when there is no value
"""
if not value:
return key
return _format_pair(explode, separator, escape, key, value) | [
"def",
"_format_pair_no_equals",
"(",
"explode",
",",
"separator",
",",
"escape",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"key",
"return",
"_format_pair",
"(",
"explode",
",",
"separator",
",",
"escape",
",",
"key",
",",
... | Format a key, value pair but don't include the equals sign
when there is no value | [
"Format",
"a",
"key",
"value",
"pair",
"but",
"don",
"t",
"include",
"the",
"equals",
"sign",
"when",
"there",
"is",
"no",
"value"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/template.py#L56-L63 | train |
codeinthehole/purl | purl/template.py | _format_pair_with_equals | def _format_pair_with_equals(explode, separator, escape, key, value):
"""
Format a key, value pair including the equals sign
when there is no value
"""
if not value:
return key + '='
return _format_pair(explode, separator, escape, key, value) | python | def _format_pair_with_equals(explode, separator, escape, key, value):
"""
Format a key, value pair including the equals sign
when there is no value
"""
if not value:
return key + '='
return _format_pair(explode, separator, escape, key, value) | [
"def",
"_format_pair_with_equals",
"(",
"explode",
",",
"separator",
",",
"escape",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"value",
":",
"return",
"key",
"+",
"'='",
"return",
"_format_pair",
"(",
"explode",
",",
"separator",
",",
"escape",
",",
... | Format a key, value pair including the equals sign
when there is no value | [
"Format",
"a",
"key",
"value",
"pair",
"including",
"the",
"equals",
"sign",
"when",
"there",
"is",
"no",
"value"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/template.py#L66-L73 | train |
codeinthehole/purl | purl/template.py | _replace | def _replace(variables, match):
"""
Return the appropriate replacement for `match` using the passed variables
"""
expression = match.group(1)
# Look-up chars and functions for the specified operator
(prefix_char, separator_char, split_fn, escape_fn,
format_fn) = operator_map.get(expression... | python | def _replace(variables, match):
"""
Return the appropriate replacement for `match` using the passed variables
"""
expression = match.group(1)
# Look-up chars and functions for the specified operator
(prefix_char, separator_char, split_fn, escape_fn,
format_fn) = operator_map.get(expression... | [
"def",
"_replace",
"(",
"variables",
",",
"match",
")",
":",
"expression",
"=",
"match",
".",
"group",
"(",
"1",
")",
"(",
"prefix_char",
",",
"separator_char",
",",
"split_fn",
",",
"escape_fn",
",",
"format_fn",
")",
"=",
"operator_map",
".",
"get",
"(... | Return the appropriate replacement for `match` using the passed variables | [
"Return",
"the",
"appropriate",
"replacement",
"for",
"match",
"using",
"the",
"passed",
"variables"
] | e70ed132f1fdc17d00c78199cedb1e3adcb2bc55 | https://github.com/codeinthehole/purl/blob/e70ed132f1fdc17d00c78199cedb1e3adcb2bc55/purl/template.py#L195-L214 | train |
LucidtechAI/las-sdk-python | las/api_client.py | ApiClient.predict | def predict(self, document_path: str, model_name: str, consent_id: str = None) -> Prediction:
"""Run inference and create prediction on document.
This method takes care of creating and uploading a document specified by document_path.
as well as running inference using model specified by model_na... | python | def predict(self, document_path: str, model_name: str, consent_id: str = None) -> Prediction:
"""Run inference and create prediction on document.
This method takes care of creating and uploading a document specified by document_path.
as well as running inference using model specified by model_na... | [
"def",
"predict",
"(",
"self",
",",
"document_path",
":",
"str",
",",
"model_name",
":",
"str",
",",
"consent_id",
":",
"str",
"=",
"None",
")",
"->",
"Prediction",
":",
"content_type",
"=",
"self",
".",
"_get_content_type",
"(",
"document_path",
")",
"con... | Run inference and create prediction on document.
This method takes care of creating and uploading a document specified by document_path.
as well as running inference using model specified by model_name to create prediction on the document.
>>> from las import ApiClient
>>> api_client = ... | [
"Run",
"inference",
"and",
"create",
"prediction",
"on",
"document",
".",
"This",
"method",
"takes",
"care",
"of",
"creating",
"and",
"uploading",
"a",
"document",
"specified",
"by",
"document_path",
".",
"as",
"well",
"as",
"running",
"inference",
"using",
"m... | 5f39dee7983baff28a1deb93c12d36414d835d12 | https://github.com/LucidtechAI/las-sdk-python/blob/5f39dee7983baff28a1deb93c12d36414d835d12/las/api_client.py#L30-L57 | train |
LucidtechAI/las-sdk-python | las/api_client.py | ApiClient.send_feedback | def send_feedback(self, document_id: str, feedback: List[Field]) -> dict:
"""Send feedback to the model.
This method takes care of sending feedback related to document specified by document_id.
Feedback consists of ground truth values for the document specified as a list of Field instances.
... | python | def send_feedback(self, document_id: str, feedback: List[Field]) -> dict:
"""Send feedback to the model.
This method takes care of sending feedback related to document specified by document_id.
Feedback consists of ground truth values for the document specified as a list of Field instances.
... | [
"def",
"send_feedback",
"(",
"self",
",",
"document_id",
":",
"str",
",",
"feedback",
":",
"List",
"[",
"Field",
"]",
")",
"->",
"dict",
":",
"return",
"self",
".",
"post_document_id",
"(",
"document_id",
",",
"feedback",
")"
] | Send feedback to the model.
This method takes care of sending feedback related to document specified by document_id.
Feedback consists of ground truth values for the document specified as a list of Field instances.
>>> from las import ApiClient
>>> api_client = ApiClient(endpoint='<api ... | [
"Send",
"feedback",
"to",
"the",
"model",
".",
"This",
"method",
"takes",
"care",
"of",
"sending",
"feedback",
"related",
"to",
"document",
"specified",
"by",
"document_id",
".",
"Feedback",
"consists",
"of",
"ground",
"truth",
"values",
"for",
"the",
"documen... | 5f39dee7983baff28a1deb93c12d36414d835d12 | https://github.com/LucidtechAI/las-sdk-python/blob/5f39dee7983baff28a1deb93c12d36414d835d12/las/api_client.py#L59-L81 | train |
LucidtechAI/las-sdk-python | las/_extrahdr.py | extra_what | def extra_what(file, h=None):
"""Code mostly copied from imghdr.what"""
tests = []
def test_pdf(h, f):
if b'PDF' in h[0:10]:
return 'pdf'
tests.append(test_pdf)
f = None
try:
if h is None:
if isinstance(file, (str, PathLike)):
f = open(f... | python | def extra_what(file, h=None):
"""Code mostly copied from imghdr.what"""
tests = []
def test_pdf(h, f):
if b'PDF' in h[0:10]:
return 'pdf'
tests.append(test_pdf)
f = None
try:
if h is None:
if isinstance(file, (str, PathLike)):
f = open(f... | [
"def",
"extra_what",
"(",
"file",
",",
"h",
"=",
"None",
")",
":",
"tests",
"=",
"[",
"]",
"def",
"test_pdf",
"(",
"h",
",",
"f",
")",
":",
"if",
"b'PDF'",
"in",
"h",
"[",
"0",
":",
"10",
"]",
":",
"return",
"'pdf'",
"tests",
".",
"append",
"... | Code mostly copied from imghdr.what | [
"Code",
"mostly",
"copied",
"from",
"imghdr",
".",
"what"
] | 5f39dee7983baff28a1deb93c12d36414d835d12 | https://github.com/LucidtechAI/las-sdk-python/blob/5f39dee7983baff28a1deb93c12d36414d835d12/las/_extrahdr.py#L4-L31 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.