_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q235900 | read_since_ids | train | def read_since_ids(users):
"""
Read max ids of the last downloads
:param users: A list of users
Return a dictionary mapping users to ids
"""
since_ids = {}
for user in users:
if config.has_option(SECTIONS['INCREMENTS'], user):
since_ids[user] = config.getint(SECTIONS['I... | python | {
"resource": ""
} |
q235901 | set_max_ids | train | def set_max_ids(max_ids):
"""
Set max ids of the current downloads
:param max_ids: A dictionary mapping users to ids
"""
config.read(CONFIG)
for user, max_id in max_ids.items():
config.set(SECTIONS['INCREMENTS'], user, str(max_id))
with open(CONFIG, 'w') as f:
config.write(f... | python | {
"resource": ""
} |
q235902 | DXFBase.authenticate | train | def authenticate(self,
username=None, password=None,
actions=None, response=None,
authorization=None):
# pylint: disable=too-many-arguments,too-many-locals
"""
Authenticate to the registry using a username and password,
an au... | python | {
"resource": ""
} |
q235903 | DXFBase.list_repos | train | def list_repos(self, batch_size=None, iterate=False):
"""
List all repositories in the registry.
:param batch_size: Number of repository names to ask the server for at a time.
:type batch_size: int
:param iterate: Whether to return iterator over the names or a list of all the n... | python | {
"resource": ""
} |
q235904 | DXF.pull_blob | train | def pull_blob(self, digest, size=False, chunk_size=None):
"""
Download a blob from the registry given the hash of its content.
:param digest: Hash of the blob's content (prefixed by ``sha256:``).
:type digest: str
:param size: Whether to return the size of the blob too.
... | python | {
"resource": ""
} |
q235905 | DXF.blob_size | train | def blob_size(self, digest):
"""
Return the size of a blob in the registry given the hash of its content.
:param digest: Hash of the blob's content (prefixed by ``sha256:``).
:type digest: str
:rtype: long
:returns: Whether the blob exists.
"""
r = self.... | python | {
"resource": ""
} |
q235906 | DXF.get_manifest_and_response | train | def get_manifest_and_response(self, alias):
"""
Request the manifest for an alias and return the manifest and the
response.
:param alias: Alias name.
:type alias: str
:rtype: tuple
:returns: Tuple containing the manifest as a string (JSON) and the `requests.Resp... | python | {
"resource": ""
} |
q235907 | DXF.get_alias | train | def get_alias(self,
alias=None,
manifest=None,
verify=True,
sizes=False,
dcd=None):
# pylint: disable=too-many-arguments
"""
Get the blob hashes assigned to an alias.
:param alias: Alias name. You ... | python | {
"resource": ""
} |
q235908 | DXF._get_dcd | train | def _get_dcd(self, alias):
"""
Get the Docker-Content-Digest header for an alias.
:param alias: Alias name.
:type alias: str
:rtype: str
:returns: DCD header for the alias.
"""
# https://docs.docker.com/registry/spec/api/#deleting-an-image
# Note... | python | {
"resource": ""
} |
q235909 | DdlParseTableColumnBase.get_name | train | def get_name(self, name_case=DdlParseBase.NAME_CASE.original):
"""
Get Name converted case
:param name_case: name case type
* DdlParse.NAME_CASE.original : Return to no convert
* DdlParse.NAME_CASE.lower : Return to lower
* DdlParse.NAME_CASE.upper : Return t... | python | {
"resource": ""
} |
q235910 | DdlParseColumn.bigquery_data_type | train | def bigquery_data_type(self):
"""Get BigQuery Legacy SQL data type"""
# BigQuery data type = {source_database: [data type, ...], ...}
BQ_DATA_TYPE_DIC = OrderedDict()
BQ_DATA_TYPE_DIC["STRING"] = {None: [re.compile(r"(CHAR|TEXT|CLOB|JSON|UUID)")]}
BQ_DATA_TYPE_DIC["INTEGER"] = {... | python | {
"resource": ""
} |
q235911 | DdlParseColumn.to_bigquery_field | train | def to_bigquery_field(self, name_case=DdlParseBase.NAME_CASE.original):
"""Generate BigQuery JSON field define"""
col_name = self.get_name(name_case)
mode = self.bigquery_mode
if self.array_dimensional <= 1:
# no or one dimensional array data type
type = self.bi... | python | {
"resource": ""
} |
q235912 | DdlParseTable.to_bigquery_ddl | train | def to_bigquery_ddl(self, name_case=DdlParseBase.NAME_CASE.original):
"""
Generate BigQuery CREATE TABLE statements
:param name_case: name case type
* DdlParse.NAME_CASE.original : Return to no convert
* DdlParse.NAME_CASE.lower : Return to lower
* DdlParse.N... | python | {
"resource": ""
} |
q235913 | DdlParse.parse | train | def parse(self, ddl=None, source_database=None):
"""
Parse DDL script.
:param ddl: DDL script
:return: DdlParseTable, Parsed table define info.
"""
if ddl is not None:
self._ddl = ddl
if source_database is not None:
self.source_database ... | python | {
"resource": ""
} |
q235914 | Process.launch | train | def launch(program, sock, stderr=True, cwd=None, env=None):
"""
A static method for launching a process that is connected to a given
socket. Same rules from the Process constructor apply.
"""
if stderr is True:
err = sock # redirect to socket
elif stderr is Fa... | python | {
"resource": ""
} |
q235915 | UDPServer.respond | train | def respond(self, packet, peer, flags=0):
"""
Send a message back to a peer.
:param packet: The data to send
:param peer: The address to send to, as a tuple (host, port)
:param flags: Any sending flags you want to use for some reason
"""
self.so... | python | {
"resource": ""
} |
q235916 | Netcat.shutdown_rd | train | def shutdown_rd(self):
"""
Send a shutdown signal for reading - you may no longer read from this
socket.
"""
if self._sock_send is not None:
self.sock.close()
else:
return self.shutdown(socket.SHUT_RD) | python | {
"resource": ""
} |
q235917 | Netcat.shutdown_wr | train | def shutdown_wr(self):
"""
Send a shutdown signal for writing - you may no longer write to this
socket.
"""
if self._sock_send is not None:
self._sock_send.close()
else:
return self.shutdown(socket.SHUT_WR) | python | {
"resource": ""
} |
q235918 | Netcat._recv_predicate | train | def _recv_predicate(self, predicate, timeout='default', raise_eof=True):
"""
Receive until predicate returns a positive integer.
The returned number is the size to return.
"""
if timeout == 'default':
timeout = self._timeout
self.timed_out = False
s... | python | {
"resource": ""
} |
q235919 | Netcat.recv_until | train | def recv_until(self, s, max_size=None, timeout='default'):
"""
Recieve data from the socket until the given substring is observed.
Data in the same datagram as the substring, following the substring,
will not be returned and will be cached for future receives.
Aliases: read_unti... | python | {
"resource": ""
} |
q235920 | Netcat.recv_all | train | def recv_all(self, timeout='default'):
"""
Return all data recieved until connection closes.
Aliases: read_all, readall, recvall
"""
self._print_recv_header('======== Receiving until close{timeout_text} ========', timeout)
return self._recv_predicate(lambda s: 0, timeo... | python | {
"resource": ""
} |
q235921 | Netcat.recv_exactly | train | def recv_exactly(self, n, timeout='default'):
"""
Recieve exactly n bytes
Aliases: read_exactly, readexactly, recvexactly
"""
self._print_recv_header(
'======== Receiving until exactly {0}B{timeout_text} ========', timeout, n)
return self._recv_predicate(la... | python | {
"resource": ""
} |
q235922 | Netcat.send | train | def send(self, s):
"""
Sends all the given data to the socket.
Aliases: write, put, sendall, send_all
"""
self._print_header('======== Sending ({0}) ========'.format(len(s)))
self._log_send(s)
out = len(s)
while s:
s = s[self._send(s):]
... | python | {
"resource": ""
} |
q235923 | Netcat.interact | train | def interact(self, insock=sys.stdin, outsock=sys.stdout):
"""
Connects the socket to the terminal for user interaction.
Alternate input and output files may be specified.
This method cannot be used with a timeout.
Aliases: interactive, interaction
"""
self._prin... | python | {
"resource": ""
} |
q235924 | Netcat.recv_line | train | def recv_line(self, max_size=None, timeout='default', ending=None):
"""
Recieve until the next newline , default "\\n". The newline string can
be changed by changing ``nc.LINE_ENDING``. The newline will be returned
as part of the string.
Aliases: recvline, readline, read_line, r... | python | {
"resource": ""
} |
q235925 | Netcat.send_line | train | def send_line(self, line, ending=None):
"""
Write the string to the wire, followed by a newline. The newline string
can be changed by changing ``nc.LINE_ENDING``.
Aliases: sendline, writeline, write_line, writeln, sendln
"""
if ending is None:
ending = self.L... | python | {
"resource": ""
} |
q235926 | Resultmodulation.is_active | train | def is_active(self, timperiods):
"""
Know if this result modulation is active now
:return: True is we are in the period, otherwise False
:rtype: bool
"""
now = int(time.time())
timperiod = timperiods[self.modulation_period]
if not timperiod or timperiod.i... | python | {
"resource": ""
} |
q235927 | SchedulerInterface.object | train | def object(self, o_type, o_name=None):
"""Get an object from the scheduler.
The result is a serialized object which is a Json structure containing:
- content: the serialized object content
- __sys_python_module__: the python class of the returned object
The Alignak unserialize ... | python | {
"resource": ""
} |
q235928 | SchedulerInterface.monitoring_problems | train | def monitoring_problems(self):
"""Get Alignak scheduler monitoring status
Returns an object with the scheduler livesynthesis
and the known problems
:return: scheduler live synthesis
:rtype: dict
"""
if self.app.type != 'scheduler':
return {'_status':... | python | {
"resource": ""
} |
q235929 | SchedulerInterface._wait_new_conf | train | def _wait_new_conf(self):
"""Ask the scheduler to drop its configuration and wait for a new one.
This overrides the default method from GenericInterface
:return: None
"""
# Stop the scheduling loop
self.app.sched.stop_scheduling()
super(SchedulerInterface, self)... | python | {
"resource": ""
} |
q235930 | SchedulerInterface._initial_broks | train | def _initial_broks(self, broker_name):
"""Get initial_broks from the scheduler
This is used by the brokers to prepare the initial status broks
This do not send broks, it only makes scheduler internal processing. Then the broker
must use the *_broks* API to get all the stuff
:p... | python | {
"resource": ""
} |
q235931 | SchedulerInterface._broks | train | def _broks(self, broker_name):
"""Get the broks from a scheduler, used by brokers
This is used by the brokers to get the broks list of a scheduler
:param broker_name: broker name, used to filter broks
:type broker_name: str
:return: serialized brok list
:rtype: dict
... | python | {
"resource": ""
} |
q235932 | SchedulerInterface._get_objects | train | def _get_objects(self, o_type):
"""Get an object list from the scheduler
Returns None if the required object type (`o_type`) is not known or an exception is raised.
Else returns the objects list
:param o_type: searched object type
:type o_type: str
:return: objects list... | python | {
"resource": ""
} |
q235933 | SchedulerInterface._get_object | train | def _get_object(self, o_type, o_name=None):
"""Get an object from the scheduler
Returns None if the required object type (`o_type`) is not known.
Else returns the serialized object if found. The object is searched first with
o_name as its name and then with o_name as its uuid.
... | python | {
"resource": ""
} |
q235934 | Module.is_a_module | train | def is_a_module(self, module_type):
"""
Is the module of the required type?
:param module_type: module type to check
:type: str
:return: True / False
"""
if hasattr(self, 'type'):
return module_type in self.type
return module_type in self.modu... | python | {
"resource": ""
} |
q235935 | Module.serialize | train | def serialize(self):
"""A module may have some properties that are not defined in the class properties list.
Serializing a module is the same as serializing an Item but we also also include all the
existing properties that are not defined in the properties or running_properties
class lis... | python | {
"resource": ""
} |
q235936 | Modules.linkify_s_by_plug | train | def linkify_s_by_plug(self):
"""Link a module to some other modules
:return: None
"""
for module in self:
new_modules = []
for related in getattr(module, 'modules', []):
related = related.strip()
if not related:
... | python | {
"resource": ""
} |
q235937 | get_start_of_day | train | def get_start_of_day(year, month, day):
"""Get the timestamp associated to the first second of a specific day
:param year: date year
:type year: int
:param month: date month
:type month: int
:param day: date day
:type day: int
:return: timestamp
:rtype: int
"""
# DST is not ... | python | {
"resource": ""
} |
q235938 | get_end_of_day | train | def get_end_of_day(year, month, day):
"""Get the timestamp associated to the last second of a specific day
:param year: date year
:type year: int
:param month: date month (int)
:type month: int
:param day: date day
:type day: int
:return: timestamp
:rtype: int
"""
# DST is n... | python | {
"resource": ""
} |
q235939 | get_sec_from_morning | train | def get_sec_from_morning(timestamp):
"""Get the number of seconds elapsed since the beginning of the
day deducted from the provided timestamp
:param timestamp: time to use for computation
:type timestamp: int
:return: timestamp
:rtype: int
"""
t_lt = time.localtime(timestamp)
return... | python | {
"resource": ""
} |
q235940 | find_day_by_weekday_offset | train | def find_day_by_weekday_offset(year, month, weekday, offset):
"""Get the day number based on a date and offset
:param year: date year
:type year: int
:param month: date month
:type month: int
:param weekday: date week day
:type weekday: int
:param offset: offset (-1 is last, 1 is first ... | python | {
"resource": ""
} |
q235941 | find_day_by_offset | train | def find_day_by_offset(year, month, offset):
"""Get the month day based on date and offset
:param year: date year
:type year: int
:param month: date month
:type month: int
:param offset: offset in day to compute (usually negative)
:type offset: int
:return: day number in the month
:... | python | {
"resource": ""
} |
q235942 | Timerange.is_time_valid | train | def is_time_valid(self, timestamp):
"""Check if time is valid for this Timerange
If sec_from_morning is not provided, get the value.
:param timestamp: time to check
:type timestamp: int
:return: True if time is valid (in interval), False otherwise
:rtype: bool
"... | python | {
"resource": ""
} |
q235943 | AbstractDaterange.is_time_valid | train | def is_time_valid(self, timestamp):
"""Check if time is valid for one of the timerange.
:param timestamp: time to check
:type timestamp: int
:return: True if one of the timerange is valid for t, False otherwise
:rtype: bool
"""
if self.is_time_day_valid(timestamp... | python | {
"resource": ""
} |
q235944 | AbstractDaterange.get_min_sec_from_morning | train | def get_min_sec_from_morning(self):
"""Get the first second from midnight where a timerange is effective
:return: smallest amount of second from midnight of all timerange
:rtype: int
"""
mins = []
for timerange in self.timeranges:
mins.append(timerange.get_se... | python | {
"resource": ""
} |
q235945 | AbstractDaterange.is_time_day_valid | train | def is_time_day_valid(self, timestamp):
"""Check if it is within start time and end time of the DateRange
:param timestamp: time to check
:type timestamp: int
:return: True if t in range, False otherwise
:rtype: bool
"""
(start_time, end_time) = self.get_start_an... | python | {
"resource": ""
} |
q235946 | AbstractDaterange.get_next_future_timerange_invalid | train | def get_next_future_timerange_invalid(self, timestamp):
"""Get next invalid time for timeranges
:param timestamp: time to check
:type timestamp: int
:return: next time when a timerange is not valid
:rtype: None | int
"""
sec_from_morning = get_sec_from_morning(ti... | python | {
"resource": ""
} |
q235947 | AbstractDaterange.get_next_valid_day | train | def get_next_valid_day(self, timestamp):
"""Get next valid day for timerange
:param timestamp: time we compute from
:type timestamp: int
:return: timestamp of the next valid day (midnight) in LOCAL time.
:rtype: int | None
"""
if self.get_next_future_timerange_va... | python | {
"resource": ""
} |
q235948 | AbstractDaterange.get_next_valid_time_from_t | train | def get_next_valid_time_from_t(self, timestamp):
"""Get next valid time for time range
:param timestamp: time we compute from
:type timestamp: int
:return: timestamp of the next valid time (LOCAL TIME)
:rtype: int | None
"""
if self.is_time_valid(timestamp):
... | python | {
"resource": ""
} |
q235949 | AbstractDaterange.get_next_invalid_day | train | def get_next_invalid_day(self, timestamp):
# pylint: disable=no-else-return
"""Get next day where timerange is not active
:param timestamp: time we compute from
:type timestamp: int
:return: timestamp of the next invalid day (midnight) in LOCAL time.
:rtype: int | None
... | python | {
"resource": ""
} |
q235950 | AbstractDaterange.get_next_invalid_time_from_t | train | def get_next_invalid_time_from_t(self, timestamp):
"""Get next invalid time for time range
:param timestamp: time we compute from
:type timestamp: int
:return: timestamp of the next invalid time (LOCAL TIME)
:rtype: int
"""
if not self.is_time_valid(timestamp):
... | python | {
"resource": ""
} |
q235951 | CalendarDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for CalendarDaterange
:param ref: time in seconds
:type ref: int
:return: tuple with start and end time
:rtype: tuple (int, int)
"""
return (get_start_of_day(self.syea... | python | {
"resource": ""
} |
q235952 | StandardDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for StandardDaterange
:param ref: time in seconds
:type ref: int
:return: tuple with start and end time
:rtype: tuple (int, int)
"""
now = time.localtime(ref)
... | python | {
"resource": ""
} |
q235953 | MonthWeekDayDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for MonthWeekDayDaterange
:param ref: time in seconds
:type ref: int | None
:return: tuple with start and end time
:rtype: tuple
"""
now = time.localtime(ref)
... | python | {
"resource": ""
} |
q235954 | MonthDateDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for MonthDateDaterange
:param ref: time in seconds
:type ref: int
:return: tuple with start and end time
:rtype: tuple (int, int)
"""
now = time.localtime(ref)
... | python | {
"resource": ""
} |
q235955 | WeekDayDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for WeekDayDaterange
:param ref: time in seconds
:type ref: int
:return: tuple with start and end time
:rtype: tuple (int, int)
"""
now = time.localtime(ref)
... | python | {
"resource": ""
} |
q235956 | MonthDayDaterange.get_start_and_end_time | train | def get_start_and_end_time(self, ref=None):
"""Specific function to get start time and end time for MonthDayDaterange
:param ref: time in seconds
:type ref: int
:return: tuple with start and end time
:rtype: tuple (int, int)
"""
now = time.localtime(ref)
... | python | {
"resource": ""
} |
q235957 | ExternalCommandManager.get_unknown_check_result_brok | train | def get_unknown_check_result_brok(cmd_line):
"""Create unknown check result brok and fill it with command data
:param cmd_line: command line to extract data
:type cmd_line: str
:return: unknown check result brok
:rtype: alignak.objects.brok.Brok
"""
match = re.ma... | python | {
"resource": ""
} |
q235958 | Hostdependency.get_name | train | def get_name(self):
"""Get name based on dependent_host_name and host_name attributes
Each attribute is substituted by 'unknown' if attribute does not exist
:return: dependent_host_name/host_name
:rtype: str
"""
dependent_host_name = 'unknown'
if getattr(self, 'd... | python | {
"resource": ""
} |
q235959 | Hostdependencies.linkify_hd_by_h | train | def linkify_hd_by_h(self, hosts):
"""Replace dependent_host_name and host_name
in host dependency by the real object
:param hosts: host list, used to look for a specific one
:type hosts: alignak.objects.host.Hosts
:return: None
"""
for hostdep in self:
... | python | {
"resource": ""
} |
q235960 | Hostdependencies.linkify_hd_by_tp | train | def linkify_hd_by_tp(self, timeperiods):
"""Replace dependency_period by a real object in host dependency
:param timeperiods: list of timeperiod, used to look for a specific one
:type timeperiods: alignak.objects.timeperiod.Timeperiods
:return: None
"""
for hostdep in se... | python | {
"resource": ""
} |
q235961 | HostsExtInfo.merge_extinfo | train | def merge_extinfo(host, extinfo):
"""Merge extended host information into a host
:param host: the host to edit
:type host: alignak.objects.host.Host
:param extinfo: the external info we get data from
:type extinfo: alignak.objects.hostextinfo.HostExtInfo
:return: None
... | python | {
"resource": ""
} |
q235962 | HTTPClient.set_proxy | train | def set_proxy(self, proxy): # pragma: no cover, not with unit tests
"""Set HTTP proxy
:param proxy: proxy url
:type proxy: str
:return: None
"""
if proxy:
logger.debug('PROXY SETTING PROXY %s', proxy)
self._requests_con.proxies = {
... | python | {
"resource": ""
} |
q235963 | HTTPClient.post | train | def post(self, path, args, wait=False):
"""POST an HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: args to add in the request
:type args: dict
:param wait: True for a long timeout
:type wait: bool
:return: Content... | python | {
"resource": ""
} |
q235964 | HTTPClient.put | train | def put(self, path, args, wait=False): # pragma: no cover, looks never used!
# todo: remove this because it looks never used anywhere...
"""PUT and HTTP request to a daemon
:param path: path to do the request
:type path: str
:param args: data to send in the request
:typ... | python | {
"resource": ""
} |
q235965 | Hostescalations.explode | train | def explode(self, escalations):
"""Create instance of Escalation for each HostEscalation object
:param escalations: list of escalation, used to add new ones
:type escalations: alignak.objects.escalation.Escalations
:return: None
"""
# Now we explode all escalations (host... | python | {
"resource": ""
} |
q235966 | Stats.register | train | def register(self, name, _type, statsd_host='localhost', statsd_port=8125,
statsd_prefix='alignak', statsd_enabled=False, broks_enabled=False):
"""Init instance with real values
:param name: daemon name
:type name: str
:param _type: daemon type
:type _type:
... | python | {
"resource": ""
} |
q235967 | Stats.load_statsd | train | def load_statsd(self):
"""Create socket connection to statsd host
Note that because of the UDP protocol used by StatsD, if no server is listening the
socket connection will be accepted anyway :)
:return: True if socket got created else False and an exception log is raised
"""
... | python | {
"resource": ""
} |
q235968 | Stats.flush | train | def flush(self, log=False):
"""Send inner stored metrics to the defined Graphite
Returns False if the sending failed with a warning log if log parameter is set
:return: bool
"""
if not self.my_metrics:
logger.debug("Flushing - no metrics to send")
return... | python | {
"resource": ""
} |
q235969 | Stats.send_to_graphite | train | def send_to_graphite(self, metric, value, timestamp=None):
"""
Inner store a new metric and flush to Graphite if the flush threshold is reached.
If no timestamp is provided, get the current time for the metric timestam.
:param metric: metric name in dotted format
:type metric: ... | python | {
"resource": ""
} |
q235970 | Stats.counter | train | def counter(self, key, value, timestamp=None):
"""Set a counter value
If the inner key does not exist is is created
:param key: counter to update
:type key: str
:param value: counter value
:type value: float
:return: An alignak_stat brok if broks are enabled els... | python | {
"resource": ""
} |
q235971 | BaseSatellite.get_managed_configurations | train | def get_managed_configurations(self):
"""Get the configurations managed by this satellite
The configurations managed by a satellite is a list of the configuration attached to
the schedulers related to the satellites. A broker linked to several schedulers
will return the list of the conf... | python | {
"resource": ""
} |
q235972 | BaseSatellite.get_scheduler_from_hostname | train | def get_scheduler_from_hostname(self, host_name):
"""Get scheduler linked to the given host_name
:param host_name: host_name we want the scheduler from
:type host_name: str
:return: scheduler with id corresponding to the mapping table
:rtype: dict
"""
scheduler_u... | python | {
"resource": ""
} |
q235973 | BaseSatellite.get_external_commands | train | def get_external_commands(self):
"""Get the external commands
:return: External commands list
:rtype: list
"""
res = self.external_commands
logger.debug("Get and clear external commands list: %s", res)
self.external_commands = []
return res | python | {
"resource": ""
} |
q235974 | BaseSatellite.get_results_from_passive | train | def get_results_from_passive(self, scheduler_instance_id):
"""Get executed actions results from a passive satellite for a specific scheduler
:param scheduler_instance_id: scheduler id
:type scheduler_instance_id: int
:return: Results list
:rtype: list
"""
# Do I ... | python | {
"resource": ""
} |
q235975 | BaseSatellite.get_events | train | def get_events(self):
"""Get event list from satellite
:return: A copy of the events list
:rtype: list
"""
res = copy.copy(self.events)
del self.events[:]
return res | python | {
"resource": ""
} |
q235976 | Satellite.manage_action_return | train | def manage_action_return(self, action):
"""Manage action return from Workers
We just put them into the corresponding sched
and we clean unused properties like my_scheduler
:param action: the action to manage
:type action: alignak.action.Action
:return: None
"""
... | python | {
"resource": ""
} |
q235977 | Satellite.create_and_launch_worker | train | def create_and_launch_worker(self, module_name='fork'):
"""Create and launch a new worker, and put it into self.workers
It can be mortal or not
:param module_name: the module name related to the worker
default is "fork" for no module
Inde... | python | {
"resource": ""
} |
q235978 | Satellite.do_stop_workers | train | def do_stop_workers(self):
"""Stop all workers
:return: None
"""
logger.info("Stopping all workers (%d)", len(self.workers))
for worker in list(self.workers.values()):
try:
logger.info(" - stopping '%s'", worker.get_id())
worker.termin... | python | {
"resource": ""
} |
q235979 | Satellite.get_broks | train | def get_broks(self):
"""Get brok list from satellite
:return: A copy of the broks list
:rtype: list
"""
res = copy.copy(self.broks)
del self.broks[:]
return res | python | {
"resource": ""
} |
q235980 | Satellite.check_and_del_zombie_workers | train | def check_and_del_zombie_workers(self): # pragma: no cover, not with unit tests...
# pylint: disable= not-callable
"""Check if worker are fine and kill them if not.
Dispatch the actions in the worker to another one
TODO: see if unit tests would allow to check this code?
:retur... | python | {
"resource": ""
} |
q235981 | Satellite.adjust_worker_number_by_load | train | def adjust_worker_number_by_load(self):
"""Try to create the minimum workers specified in the configuration
:return: None
"""
if self.interrupted:
logger.debug("Trying to adjust worker number. Ignoring because we are stopping.")
return
to_del = []
... | python | {
"resource": ""
} |
q235982 | Satellite._get_queue_for_the_action | train | def _get_queue_for_the_action(self, action):
"""Find action queue for the action depending on the module.
The id is found with action modulo on action id
:param a: the action that need action queue to be assigned
:type action: object
:return: worker id and queue. (0, None) if no... | python | {
"resource": ""
} |
q235983 | Satellite.add_actions | train | def add_actions(self, actions_list, scheduler_instance_id):
"""Add a list of actions to the satellite queues
:param actions_list: Actions list to add
:type actions_list: list
:param scheduler_instance_id: sheduler link to assign the actions to
:type scheduler_instance_id: Schedu... | python | {
"resource": ""
} |
q235984 | Satellite.assign_to_a_queue | train | def assign_to_a_queue(self, action):
"""Take an action and put it to a worker actions queue
:param action: action to put
:type action: alignak.action.Action
:return: None
"""
(worker_id, queue) = self._get_queue_for_the_action(action)
if not worker_id:
... | python | {
"resource": ""
} |
q235985 | Satellite.get_new_actions | train | def get_new_actions(self):
""" Wrapper function for do_get_new_actions
For stats purpose
:return: None
TODO: Use a decorator for timing this function
"""
try:
_t0 = time.time()
self.do_get_new_actions()
statsmgr.timer('actions.got.time... | python | {
"resource": ""
} |
q235986 | Satellite.main | train | def main(self):
"""Main satellite function. Do init and then mainloop
:return: None
"""
try:
# Start the daemon mode
if not self.do_daemon_init_and_start():
self.exit_on_error(message="Daemon initialization error", exit_code=3)
self.d... | python | {
"resource": ""
} |
q235987 | ContactDowntime.check_activation | train | def check_activation(self, contacts):
"""Enter or exit downtime if necessary
:return: None
"""
now = time.time()
was_is_in_effect = self.is_in_effect
self.is_in_effect = (self.start_time <= now <= self.end_time)
# Raise a log entry when we get in the downtime
... | python | {
"resource": ""
} |
q235988 | split_semicolon | train | def split_semicolon(line, maxsplit=None):
r"""Split a line on semicolons characters but not on the escaped semicolons
:param line: line to split
:type line: str
:param maxsplit: maximal number of split (if None, no limit)
:type maxsplit: None | int
:return: split line
:rtype: list
>>> ... | python | {
"resource": ""
} |
q235989 | format_t_into_dhms_format | train | def format_t_into_dhms_format(timestamp):
""" Convert an amount of second into day, hour, min and sec
:param timestamp: seconds
:type timestamp: int
:return: 'Ad Bh Cm Ds'
:rtype: str
>>> format_t_into_dhms_format(456189)
'5d 6h 43m 9s'
>>> format_t_into_dhms_format(3600)
'0d 1h 0... | python | {
"resource": ""
} |
q235990 | merge_periods | train | def merge_periods(data):
"""
Merge periods to have better continous periods.
Like 350-450, 400-600 => 350-600
:param data: list of periods
:type data: list
:return: better continous periods
:rtype: list
"""
# sort by start date
newdata = sorted(data, key=lambda drange: drange[0]... | python | {
"resource": ""
} |
q235991 | list_split | train | def list_split(val, split_on_comma=True):
"""Try to split each member of a list with comma separator.
If we don't have to split just return val
:param val: value to split
:type val:
:param split_on_comma:
:type split_on_comma: bool
:return: list with members split on comma
:rtype: list
... | python | {
"resource": ""
} |
q235992 | to_best_int_float | train | def to_best_int_float(val):
"""Get best type for value between int and float
:param val: value
:type val:
:return: int(float(val)) if int(float(val)) == float(val), else float(val)
:rtype: int | float
>>> to_best_int_float("20.1")
20.1
>>> to_best_int_float("20.0")
20
>>> to_... | python | {
"resource": ""
} |
q235993 | dict_to_serialized_dict | train | def dict_to_serialized_dict(ref, the_dict):
"""Serialize the list of elements to a dictionary
Used for the retention store
:param ref: Not used
:type ref:
:param the_dict: dictionary to convert
:type the_dict: dict
:return: dict of serialized
:rtype: dict
"""
result = {}
fo... | python | {
"resource": ""
} |
q235994 | list_to_serialized | train | def list_to_serialized(ref, the_list):
"""Serialize the list of elements
Used for the retention store
:param ref: Not used
:type ref:
:param the_list: dictionary to convert
:type the_list: dict
:return: dict of serialized
:rtype: dict
"""
result = []
for elt in the_list:
... | python | {
"resource": ""
} |
q235995 | to_hostnames_list | train | def to_hostnames_list(ref, tab): # pragma: no cover, to be deprecated?
"""Convert Host list into a list of host_name
:param ref: Not used
:type ref:
:param tab: Host list
:type tab: list[alignak.objects.host.Host]
:return: host_name list
:rtype: list
"""
res = []
for host in t... | python | {
"resource": ""
} |
q235996 | sort_by_number_values | train | def sort_by_number_values(x00, y00): # pragma: no cover, looks like not used!
"""Compare x00, y00 base on number of values
:param x00: first elem to compare
:type x00: list
:param y00: second elem to compare
:type y00: list
:return: x00 > y00 (-1) if len(x00) > len(y00), x00 == y00 (0) if id e... | python | {
"resource": ""
} |
q235997 | strip_and_uniq | train | def strip_and_uniq(tab):
"""Strip every element of a list and keep a list of ordered unique values
:param tab: list to strip
:type tab: list
:return: stripped list with unique values
:rtype: list
"""
_list = []
for elt in tab:
val = elt.strip()
if val and val not in _lis... | python | {
"resource": ""
} |
q235998 | filter_host_by_name | train | def filter_host_by_name(name):
"""Filter for host
Filter on name
:param name: name to filter
:type name: str
:return: Filter
:rtype: bool
"""
def inner_filter(items):
"""Inner filter for host. Accept if host_name == name"""
host = items["host"]
if host is None:
... | python | {
"resource": ""
} |
q235999 | filter_host_by_regex | train | def filter_host_by_regex(regex):
"""Filter for host
Filter on regex
:param regex: regex to filter
:type regex: str
:return: Filter
:rtype: bool
"""
host_re = re.compile(regex)
def inner_filter(items):
"""Inner filter for host. Accept if regex match host_name"""
host... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.