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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
spulec/moto | moto/iam/models.py | IAMBackend._validate_tag_key | def _validate_tag_key(self, tag_key, exception_param='tags.X.member.key'):
"""Validates the tag key.
:param all_tags: Dict to check if there is a duplicate tag.
:param tag_key: The tag key to check against.
:param exception_param: The exception parameter to send over to help format the ... | python | def _validate_tag_key(self, tag_key, exception_param='tags.X.member.key'):
"""Validates the tag key.
:param all_tags: Dict to check if there is a duplicate tag.
:param tag_key: The tag key to check against.
:param exception_param: The exception parameter to send over to help format the ... | [
"def",
"_validate_tag_key",
"(",
"self",
",",
"tag_key",
",",
"exception_param",
"=",
"'tags.X.member.key'",
")",
":",
"# Validate that the key length is correct:",
"if",
"len",
"(",
"tag_key",
")",
">",
"128",
":",
"raise",
"TagKeyTooBig",
"(",
"tag_key",
",",
"p... | Validates the tag key.
:param all_tags: Dict to check if there is a duplicate tag.
:param tag_key: The tag key to check against.
:param exception_param: The exception parameter to send over to help format the message. This is to reflect
the difference between the... | [
"Validates",
"the",
"tag",
"key",
"."
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L639-L657 | train |
spulec/moto | moto/iam/models.py | IAMBackend.enable_mfa_device | def enable_mfa_device(self,
user_name,
serial_number,
authentication_code_1,
authentication_code_2):
"""Enable MFA Device for user."""
user = self.get_user(user_name)
if serial_number in user.... | python | def enable_mfa_device(self,
user_name,
serial_number,
authentication_code_1,
authentication_code_2):
"""Enable MFA Device for user."""
user = self.get_user(user_name)
if serial_number in user.... | [
"def",
"enable_mfa_device",
"(",
"self",
",",
"user_name",
",",
"serial_number",
",",
"authentication_code_1",
",",
"authentication_code_2",
")",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
"user_name",
")",
"if",
"serial_number",
"in",
"user",
".",
"mfa_dev... | Enable MFA Device for user. | [
"Enable",
"MFA",
"Device",
"for",
"user",
"."
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L1066-L1083 | train |
spulec/moto | moto/iam/models.py | IAMBackend.deactivate_mfa_device | def deactivate_mfa_device(self, user_name, serial_number):
"""Deactivate and detach MFA Device from user if device exists."""
user = self.get_user(user_name)
if serial_number not in user.mfa_devices:
raise IAMNotFoundException(
"Device {0} not found".format(serial_num... | python | def deactivate_mfa_device(self, user_name, serial_number):
"""Deactivate and detach MFA Device from user if device exists."""
user = self.get_user(user_name)
if serial_number not in user.mfa_devices:
raise IAMNotFoundException(
"Device {0} not found".format(serial_num... | [
"def",
"deactivate_mfa_device",
"(",
"self",
",",
"user_name",
",",
"serial_number",
")",
":",
"user",
"=",
"self",
".",
"get_user",
"(",
"user_name",
")",
"if",
"serial_number",
"not",
"in",
"user",
".",
"mfa_devices",
":",
"raise",
"IAMNotFoundException",
"(... | Deactivate and detach MFA Device from user if device exists. | [
"Deactivate",
"and",
"detach",
"MFA",
"Device",
"from",
"user",
"if",
"device",
"exists",
"."
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/iam/models.py#L1085-L1093 | train |
spulec/moto | moto/route53/models.py | RecordSet.delete | def delete(self, *args, **kwargs):
''' Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored '''
hosted_zone = route53_backend.get_hosted_zone_by_name(
self.hosted_zone_name)
if not hosted_zone:
hosted_zone = route53_backend.get_hosted_zone(s... | python | def delete(self, *args, **kwargs):
''' Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored '''
hosted_zone = route53_backend.get_hosted_zone_by_name(
self.hosted_zone_name)
if not hosted_zone:
hosted_zone = route53_backend.get_hosted_zone(s... | [
"def",
"delete",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"hosted_zone",
"=",
"route53_backend",
".",
"get_hosted_zone_by_name",
"(",
"self",
".",
"hosted_zone_name",
")",
"if",
"not",
"hosted_zone",
":",
"hosted_zone",
"=",
"route53... | Not exposed as part of the Route 53 API - used for CloudFormation. args are ignored | [
"Not",
"exposed",
"as",
"part",
"of",
"the",
"Route",
"53",
"API",
"-",
"used",
"for",
"CloudFormation",
".",
"args",
"are",
"ignored"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/route53/models.py#L159-L165 | train |
spulec/moto | moto/packages/httpretty/http.py | last_requestline | def last_requestline(sent_data):
"""
Find the last line in sent_data that can be parsed with parse_requestline
"""
for line in reversed(sent_data):
try:
parse_requestline(decode_utf8(line))
except ValueError:
pass
else:
return line | python | def last_requestline(sent_data):
"""
Find the last line in sent_data that can be parsed with parse_requestline
"""
for line in reversed(sent_data):
try:
parse_requestline(decode_utf8(line))
except ValueError:
pass
else:
return line | [
"def",
"last_requestline",
"(",
"sent_data",
")",
":",
"for",
"line",
"in",
"reversed",
"(",
"sent_data",
")",
":",
"try",
":",
"parse_requestline",
"(",
"decode_utf8",
"(",
"line",
")",
")",
"except",
"ValueError",
":",
"pass",
"else",
":",
"return",
"lin... | Find the last line in sent_data that can be parsed with parse_requestline | [
"Find",
"the",
"last",
"line",
"in",
"sent_data",
"that",
"can",
"be",
"parsed",
"with",
"parse_requestline"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/packages/httpretty/http.py#L144-L154 | train |
spulec/moto | moto/sqs/models.py | Message.attribute_md5 | def attribute_md5(self):
"""
The MD5 of all attributes is calculated by first generating a
utf-8 string from each attribute and MD5-ing the concatenation
of them all. Each attribute is encoded with some bytes that
describe the length of each part and the type of attribute.
... | python | def attribute_md5(self):
"""
The MD5 of all attributes is calculated by first generating a
utf-8 string from each attribute and MD5-ing the concatenation
of them all. Each attribute is encoded with some bytes that
describe the length of each part and the type of attribute.
... | [
"def",
"attribute_md5",
"(",
"self",
")",
":",
"def",
"utf8",
"(",
"str",
")",
":",
"if",
"isinstance",
"(",
"str",
",",
"six",
".",
"string_types",
")",
":",
"return",
"str",
".",
"encode",
"(",
"'utf-8'",
")",
"return",
"str",
"md5",
"=",
"hashlib"... | The MD5 of all attributes is calculated by first generating a
utf-8 string from each attribute and MD5-ing the concatenation
of them all. Each attribute is encoded with some bytes that
describe the length of each part and the type of attribute.
Not yet implemented:
List type... | [
"The",
"MD5",
"of",
"all",
"attributes",
"is",
"calculated",
"by",
"first",
"generating",
"a",
"utf",
"-",
"8",
"string",
"from",
"each",
"attribute",
"and",
"MD5",
"-",
"ing",
"the",
"concatenation",
"of",
"them",
"all",
".",
"Each",
"attribute",
"is",
... | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L54-L100 | train |
spulec/moto | moto/sqs/models.py | Message.mark_received | def mark_received(self, visibility_timeout=None):
"""
When a message is received we will set the first receive timestamp,
tap the ``approximate_receive_count`` and the ``visible_at`` time.
"""
if visibility_timeout:
visibility_timeout = int(visibility_timeout)
... | python | def mark_received(self, visibility_timeout=None):
"""
When a message is received we will set the first receive timestamp,
tap the ``approximate_receive_count`` and the ``visible_at`` time.
"""
if visibility_timeout:
visibility_timeout = int(visibility_timeout)
... | [
"def",
"mark_received",
"(",
"self",
",",
"visibility_timeout",
"=",
"None",
")",
":",
"if",
"visibility_timeout",
":",
"visibility_timeout",
"=",
"int",
"(",
"visibility_timeout",
")",
"else",
":",
"visibility_timeout",
"=",
"0",
"if",
"not",
"self",
".",
"ap... | When a message is received we will set the first receive timestamp,
tap the ``approximate_receive_count`` and the ``visible_at`` time. | [
"When",
"a",
"message",
"is",
"received",
"we",
"will",
"set",
"the",
"first",
"receive",
"timestamp",
"tap",
"the",
"approximate_receive_count",
"and",
"the",
"visible_at",
"time",
"."
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L111-L131 | train |
spulec/moto | moto/sqs/models.py | SQSBackend.receive_messages | def receive_messages(self, queue_name, count, wait_seconds_timeout, visibility_timeout):
"""
Attempt to retrieve visible messages from a queue.
If a message was read by client and not deleted it is considered to be
"inflight" and cannot be read. We make attempts to obtain ``count``
... | python | def receive_messages(self, queue_name, count, wait_seconds_timeout, visibility_timeout):
"""
Attempt to retrieve visible messages from a queue.
If a message was read by client and not deleted it is considered to be
"inflight" and cannot be read. We make attempts to obtain ``count``
... | [
"def",
"receive_messages",
"(",
"self",
",",
"queue_name",
",",
"count",
",",
"wait_seconds_timeout",
",",
"visibility_timeout",
")",
":",
"queue",
"=",
"self",
".",
"get_queue",
"(",
"queue_name",
")",
"result",
"=",
"[",
"]",
"previous_result_count",
"=",
"l... | Attempt to retrieve visible messages from a queue.
If a message was read by client and not deleted it is considered to be
"inflight" and cannot be read. We make attempts to obtain ``count``
messages but we may return less if messages are in-flight or there
are simple not enough messages... | [
"Attempt",
"to",
"retrieve",
"visible",
"messages",
"from",
"a",
"queue",
"."
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/sqs/models.py#L469-L542 | train |
spulec/moto | moto/dynamodb2/models.py | DynamoDBBackend.get_table_keys_name | def get_table_keys_name(self, table_name, keys):
"""
Given a set of keys, extracts the key and range key
"""
table = self.tables.get(table_name)
if not table:
return None, None
else:
if len(keys) == 1:
for key in keys:
... | python | def get_table_keys_name(self, table_name, keys):
"""
Given a set of keys, extracts the key and range key
"""
table = self.tables.get(table_name)
if not table:
return None, None
else:
if len(keys) == 1:
for key in keys:
... | [
"def",
"get_table_keys_name",
"(",
"self",
",",
"table_name",
",",
"keys",
")",
":",
"table",
"=",
"self",
".",
"tables",
".",
"get",
"(",
"table_name",
")",
"if",
"not",
"table",
":",
"return",
"None",
",",
"None",
"else",
":",
"if",
"len",
"(",
"ke... | Given a set of keys, extracts the key and range key | [
"Given",
"a",
"set",
"of",
"keys",
"extracts",
"the",
"key",
"and",
"range",
"key"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb2/models.py#L834-L855 | train |
spulec/moto | moto/instance_metadata/responses.py | InstanceMetadataResponse.metadata_response | def metadata_response(self, request, full_url, headers):
"""
Mock response for localhost metadata
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
"""
parsed_url = urlparse(full_url)
tomorrow = datetime.datetime.utcnow() + datetime.time... | python | def metadata_response(self, request, full_url, headers):
"""
Mock response for localhost metadata
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html
"""
parsed_url = urlparse(full_url)
tomorrow = datetime.datetime.utcnow() + datetime.time... | [
"def",
"metadata_response",
"(",
"self",
",",
"request",
",",
"full_url",
",",
"headers",
")",
":",
"parsed_url",
"=",
"urlparse",
"(",
"full_url",
")",
"tomorrow",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"+",
"datetime",
".",
"timedelta... | Mock response for localhost metadata
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html | [
"Mock",
"response",
"for",
"localhost",
"metadata"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/instance_metadata/responses.py#L11-L49 | train |
spulec/moto | moto/cloudwatch/models.py | CloudWatchBackend._list_element_starts_with | def _list_element_starts_with(items, needle):
"""True of any of the list elements starts with needle"""
for item in items:
if item.startswith(needle):
return True
return False | python | def _list_element_starts_with(items, needle):
"""True of any of the list elements starts with needle"""
for item in items:
if item.startswith(needle):
return True
return False | [
"def",
"_list_element_starts_with",
"(",
"items",
",",
"needle",
")",
":",
"for",
"item",
"in",
"items",
":",
"if",
"item",
".",
"startswith",
"(",
"needle",
")",
":",
"return",
"True",
"return",
"False"
] | True of any of the list elements starts with needle | [
"True",
"of",
"any",
"of",
"the",
"list",
"elements",
"starts",
"with",
"needle"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/cloudwatch/models.py#L193-L198 | train |
spulec/moto | moto/batch/models.py | BatchBackend._validate_compute_resources | def _validate_compute_resources(self, cr):
"""
Checks contents of sub dictionary for managed clusters
:param cr: computeResources
:type cr: dict
"""
for param in ('instanceRole', 'maxvCpus', 'minvCpus', 'instanceTypes', 'securityGroupIds', 'subnets', 'type'):
... | python | def _validate_compute_resources(self, cr):
"""
Checks contents of sub dictionary for managed clusters
:param cr: computeResources
:type cr: dict
"""
for param in ('instanceRole', 'maxvCpus', 'minvCpus', 'instanceTypes', 'securityGroupIds', 'subnets', 'type'):
... | [
"def",
"_validate_compute_resources",
"(",
"self",
",",
"cr",
")",
":",
"for",
"param",
"in",
"(",
"'instanceRole'",
",",
"'maxvCpus'",
",",
"'minvCpus'",
",",
"'instanceTypes'",
",",
"'securityGroupIds'",
",",
"'subnets'",
",",
"'type'",
")",
":",
"if",
"para... | Checks contents of sub dictionary for managed clusters
:param cr: computeResources
:type cr: dict | [
"Checks",
"contents",
"of",
"sub",
"dictionary",
"for",
"managed",
"clusters"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L669-L716 | train |
spulec/moto | moto/batch/models.py | BatchBackend.find_min_instances_to_meet_vcpus | def find_min_instances_to_meet_vcpus(instance_types, target):
"""
Finds the minimum needed instances to meed a vcpu target
:param instance_types: Instance types, like ['t2.medium', 't2.small']
:type instance_types: list of str
:param target: VCPU target
:type target: flo... | python | def find_min_instances_to_meet_vcpus(instance_types, target):
"""
Finds the minimum needed instances to meed a vcpu target
:param instance_types: Instance types, like ['t2.medium', 't2.small']
:type instance_types: list of str
:param target: VCPU target
:type target: flo... | [
"def",
"find_min_instances_to_meet_vcpus",
"(",
"instance_types",
",",
"target",
")",
":",
"# vcpus = [ (vcpus, instance_type), (vcpus, instance_type), ... ]",
"instance_vcpus",
"=",
"[",
"]",
"instances",
"=",
"[",
"]",
"for",
"instance_type",
"in",
"instance_types",
":",
... | Finds the minimum needed instances to meed a vcpu target
:param instance_types: Instance types, like ['t2.medium', 't2.small']
:type instance_types: list of str
:param target: VCPU target
:type target: float
:return: List of instance types
:rtype: list of str | [
"Finds",
"the",
"minimum",
"needed",
"instances",
"to",
"meed",
"a",
"vcpu",
"target"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L719-L766 | train |
spulec/moto | moto/batch/models.py | BatchBackend.create_job_queue | def create_job_queue(self, queue_name, priority, state, compute_env_order):
"""
Create a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
... | python | def create_job_queue(self, queue_name, priority, state, compute_env_order):
"""
Create a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
... | [
"def",
"create_job_queue",
"(",
"self",
",",
"queue_name",
",",
"priority",
",",
"state",
",",
"compute_env_order",
")",
":",
"for",
"variable",
",",
"var_name",
"in",
"(",
"(",
"queue_name",
",",
"'jobQueueName'",
")",
",",
"(",
"priority",
",",
"'priority'... | Create a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
:param compute_env_order: Compute environment list
:type compute_env_order: list of di... | [
"Create",
"a",
"job",
"queue"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L814-L857 | train |
spulec/moto | moto/batch/models.py | BatchBackend.update_job_queue | def update_job_queue(self, queue_name, priority, state, compute_env_order):
"""
Update a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
... | python | def update_job_queue(self, queue_name, priority, state, compute_env_order):
"""
Update a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
... | [
"def",
"update_job_queue",
"(",
"self",
",",
"queue_name",
",",
"priority",
",",
"state",
",",
"compute_env_order",
")",
":",
"if",
"queue_name",
"is",
"None",
":",
"raise",
"ClientException",
"(",
"'jobQueueName must be provided'",
")",
"job_queue",
"=",
"self",
... | Update a job queue
:param queue_name: Queue name
:type queue_name: str
:param priority: Queue priority
:type priority: int
:param state: Queue state
:type state: string
:param compute_env_order: Compute environment list
:type compute_env_order: list of di... | [
"Update",
"a",
"job",
"queue"
] | 4a286c4bc288933bb023396e2784a6fdbb966bc9 | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/batch/models.py#L874-L924 | train |
chrismattmann/tika-python | tika/tika.py | toFilename | def toFilename(url):
'''
gets url and returns filename
'''
urlp = urlparse(url)
path = urlp.path
if not path:
path = "file_{}".format(int(time.time()))
value = re.sub(r'[^\w\s\.\-]', '-', path).strip().lower()
return re.sub(r'[-\s]+', '-', value).strip("-")[-200:] | python | def toFilename(url):
'''
gets url and returns filename
'''
urlp = urlparse(url)
path = urlp.path
if not path:
path = "file_{}".format(int(time.time()))
value = re.sub(r'[^\w\s\.\-]', '-', path).strip().lower()
return re.sub(r'[-\s]+', '-', value).strip("-")[-200:] | [
"def",
"toFilename",
"(",
"url",
")",
":",
"urlp",
"=",
"urlparse",
"(",
"url",
")",
"path",
"=",
"urlp",
".",
"path",
"if",
"not",
"path",
":",
"path",
"=",
"\"file_{}\"",
".",
"format",
"(",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
... | gets url and returns filename | [
"gets",
"url",
"and",
"returns",
"filename"
] | ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a | https://github.com/chrismattmann/tika-python/blob/ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a/tika/tika.py#L672-L681 | train |
chrismattmann/tika-python | tika/tika.py | main | def main(argv=None):
"""Run Tika from command line according to USAGE."""
global Verbose
global EncodeUtf8
global csvOutput
if argv is None:
argv = sys.argv
if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))):
log.exception('Bad args')
raise TikaException('... | python | def main(argv=None):
"""Run Tika from command line according to USAGE."""
global Verbose
global EncodeUtf8
global csvOutput
if argv is None:
argv = sys.argv
if (len(argv) < 3 and not (('-h' in argv) or ('--help' in argv))):
log.exception('Bad args')
raise TikaException('... | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"global",
"Verbose",
"global",
"EncodeUtf8",
"global",
"csvOutput",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"if",
"(",
"len",
"(",
"argv",
")",
"<",
"3",
"and",
"not",
"("... | Run Tika from command line according to USAGE. | [
"Run",
"Tika",
"from",
"command",
"line",
"according",
"to",
"USAGE",
"."
] | ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a | https://github.com/chrismattmann/tika-python/blob/ffd3879ac3eaa9142c0fb6557cc1dc52d458a75a/tika/tika.py#L771-L812 | train |
ahupp/python-magic | magic.py | from_file | def from_file(filename, mime=False):
""""
Accepts a filename and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
"""
m = _get_magic_type(mime)
return m.f... | python | def from_file(filename, mime=False):
""""
Accepts a filename and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
"""
m = _get_magic_type(mime)
return m.f... | [
"def",
"from_file",
"(",
"filename",
",",
"mime",
"=",
"False",
")",
":",
"m",
"=",
"_get_magic_type",
"(",
"mime",
")",
"return",
"m",
".",
"from_file",
"(",
"filename",
")"
] | Accepts a filename and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf' | [
"Accepts",
"a",
"filename",
"and",
"returns",
"the",
"detected",
"filetype",
".",
"Return",
"value",
"is",
"the",
"mimetype",
"if",
"mime",
"=",
"True",
"otherwise",
"a",
"human",
"readable",
"name",
"."
] | c5b386b08bfbc01330e2ba836d97749d242429dc | https://github.com/ahupp/python-magic/blob/c5b386b08bfbc01330e2ba836d97749d242429dc/magic.py#L133-L143 | train |
ahupp/python-magic | magic.py | from_buffer | def from_buffer(buffer, mime=False):
"""
Accepts a binary string and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
"""
m = _get_magic_typ... | python | def from_buffer(buffer, mime=False):
"""
Accepts a binary string and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
"""
m = _get_magic_typ... | [
"def",
"from_buffer",
"(",
"buffer",
",",
"mime",
"=",
"False",
")",
":",
"m",
"=",
"_get_magic_type",
"(",
"mime",
")",
"return",
"m",
".",
"from_buffer",
"(",
"buffer",
")"
] | Accepts a binary string and returns the detected filetype. Return
value is the mimetype if mime=True, otherwise a human readable
name.
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2' | [
"Accepts",
"a",
"binary",
"string",
"and",
"returns",
"the",
"detected",
"filetype",
".",
"Return",
"value",
"is",
"the",
"mimetype",
"if",
"mime",
"=",
"True",
"otherwise",
"a",
"human",
"readable",
"name",
"."
] | c5b386b08bfbc01330e2ba836d97749d242429dc | https://github.com/ahupp/python-magic/blob/c5b386b08bfbc01330e2ba836d97749d242429dc/magic.py#L146-L156 | train |
yhat/ggpy | ggplot/colors/palettes.py | desaturate | def desaturate(color, prop):
"""Decrease the saturation channel of a color by some percent.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
prop : float
saturation channel of color will be multiplied by this value
Returns
-------
new_co... | python | def desaturate(color, prop):
"""Decrease the saturation channel of a color by some percent.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
prop : float
saturation channel of color will be multiplied by this value
Returns
-------
new_co... | [
"def",
"desaturate",
"(",
"color",
",",
"prop",
")",
":",
"# Check inputs",
"if",
"not",
"0",
"<=",
"prop",
"<=",
"1",
":",
"raise",
"ValueError",
"(",
"\"prop must be between 0 and 1\"",
")",
"# Get rgb tuple rep",
"rgb",
"=",
"mplcol",
".",
"colorConverter",
... | Decrease the saturation channel of a color by some percent.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
prop : float
saturation channel of color will be multiplied by this value
Returns
-------
new_color : rgb tuple
desaturated ... | [
"Decrease",
"the",
"saturation",
"channel",
"of",
"a",
"color",
"by",
"some",
"percent",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L17-L49 | train |
yhat/ggpy | ggplot/colors/palettes.py | color_palette | def color_palette(name=None, n_colors=6, desat=None):
"""Return a list of colors defining a color palette.
Availible seaborn palette names:
deep, muted, bright, pastel, dark, colorblind
Other options:
hls, husl, any matplotlib palette
Matplotlib paletes can be specified as reversed pa... | python | def color_palette(name=None, n_colors=6, desat=None):
"""Return a list of colors defining a color palette.
Availible seaborn palette names:
deep, muted, bright, pastel, dark, colorblind
Other options:
hls, husl, any matplotlib palette
Matplotlib paletes can be specified as reversed pa... | [
"def",
"color_palette",
"(",
"name",
"=",
"None",
",",
"n_colors",
"=",
"6",
",",
"desat",
"=",
"None",
")",
":",
"seaborn_palettes",
"=",
"dict",
"(",
"deep",
"=",
"[",
"\"#4C72B0\"",
",",
"\"#55A868\"",
",",
"\"#C44E52\"",
",",
"\"#8172B2\"",
",",
"\"#... | Return a list of colors defining a color palette.
Availible seaborn palette names:
deep, muted, bright, pastel, dark, colorblind
Other options:
hls, husl, any matplotlib palette
Matplotlib paletes can be specified as reversed palettes by appending
"_r" to the name or as dark palettes ... | [
"Return",
"a",
"list",
"of",
"colors",
"defining",
"a",
"color",
"palette",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L67-L165 | train |
yhat/ggpy | ggplot/colors/palettes.py | mpl_palette | def mpl_palette(name, n_colors=6):
"""Return discrete colors from a matplotlib palette.
Note that this handles the qualitative colorbrewer palettes
properly, although if you ask for more colors than a particular
qualitative palette can provide you will fewer than you are
expecting.
Parameters
... | python | def mpl_palette(name, n_colors=6):
"""Return discrete colors from a matplotlib palette.
Note that this handles the qualitative colorbrewer palettes
properly, although if you ask for more colors than a particular
qualitative palette can provide you will fewer than you are
expecting.
Parameters
... | [
"def",
"mpl_palette",
"(",
"name",
",",
"n_colors",
"=",
"6",
")",
":",
"brewer_qual_pals",
"=",
"{",
"\"Accent\"",
":",
"8",
",",
"\"Dark2\"",
":",
"8",
",",
"\"Paired\"",
":",
"12",
",",
"\"Pastel1\"",
":",
"9",
",",
"\"Pastel2\"",
":",
"8",
",",
"... | Return discrete colors from a matplotlib palette.
Note that this handles the qualitative colorbrewer palettes
properly, although if you ask for more colors than a particular
qualitative palette can provide you will fewer than you are
expecting.
Parameters
----------
name : string
n... | [
"Return",
"discrete",
"colors",
"from",
"a",
"matplotlib",
"palette",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L232-L269 | train |
yhat/ggpy | ggplot/colors/palettes.py | dark_palette | def dark_palette(color, n_colors=6, reverse=False, as_cmap=False):
"""Make a palette that blends from a deep gray to `color`.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
reverse : bool... | python | def dark_palette(color, n_colors=6, reverse=False, as_cmap=False):
"""Make a palette that blends from a deep gray to `color`.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
reverse : bool... | [
"def",
"dark_palette",
"(",
"color",
",",
"n_colors",
"=",
"6",
",",
"reverse",
"=",
"False",
",",
"as_cmap",
"=",
"False",
")",
":",
"gray",
"=",
"\"#222222\"",
"colors",
"=",
"[",
"color",
",",
"gray",
"]",
"if",
"reverse",
"else",
"[",
"gray",
","... | Make a palette that blends from a deep gray to `color`.
Parameters
----------
color : matplotlib color
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
reverse : bool, optional
if True, reverse the direction of the blend
as_cmap... | [
"Make",
"a",
"palette",
"that",
"blends",
"from",
"a",
"deep",
"gray",
"to",
"color",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L272-L293 | train |
yhat/ggpy | ggplot/colors/palettes.py | blend_palette | def blend_palette(colors, n_colors=6, as_cmap=False):
"""Make a palette that blends between a list of colors.
Parameters
----------
colors : sequence of matplotlib colors
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
as_cmap : bool, ... | python | def blend_palette(colors, n_colors=6, as_cmap=False):
"""Make a palette that blends between a list of colors.
Parameters
----------
colors : sequence of matplotlib colors
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
as_cmap : bool, ... | [
"def",
"blend_palette",
"(",
"colors",
",",
"n_colors",
"=",
"6",
",",
"as_cmap",
"=",
"False",
")",
":",
"name",
"=",
"\"-\"",
".",
"join",
"(",
"map",
"(",
"str",
",",
"colors",
")",
")",
"pal",
"=",
"mpl",
".",
"colors",
".",
"LinearSegmentedColor... | Make a palette that blends between a list of colors.
Parameters
----------
colors : sequence of matplotlib colors
hex, rgb-tuple, or html color name
n_colors : int, optional
number of colors in the palette
as_cmap : bool, optional
if True, return as a matplotlib colormap ins... | [
"Make",
"a",
"palette",
"that",
"blends",
"between",
"a",
"list",
"of",
"colors",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L296-L317 | train |
yhat/ggpy | ggplot/colors/palettes.py | xkcd_palette | def xkcd_palette(colors):
"""Make a palette with color names from the xkcd color survey.
This is just a simple wrapper around the seaborn.xkcd_rbg dictionary.
See xkcd for the full list of colors: http://xkcd.com/color/rgb/
"""
palette = [xkcd_rgb[name] for name in colors]
return color_palett... | python | def xkcd_palette(colors):
"""Make a palette with color names from the xkcd color survey.
This is just a simple wrapper around the seaborn.xkcd_rbg dictionary.
See xkcd for the full list of colors: http://xkcd.com/color/rgb/
"""
palette = [xkcd_rgb[name] for name in colors]
return color_palett... | [
"def",
"xkcd_palette",
"(",
"colors",
")",
":",
"palette",
"=",
"[",
"xkcd_rgb",
"[",
"name",
"]",
"for",
"name",
"in",
"colors",
"]",
"return",
"color_palette",
"(",
"palette",
",",
"len",
"(",
"palette",
")",
")"
] | Make a palette with color names from the xkcd color survey.
This is just a simple wrapper around the seaborn.xkcd_rbg dictionary.
See xkcd for the full list of colors: http://xkcd.com/color/rgb/ | [
"Make",
"a",
"palette",
"with",
"color",
"names",
"from",
"the",
"xkcd",
"color",
"survey",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L320-L329 | train |
yhat/ggpy | ggplot/colors/palettes.py | cubehelix_palette | def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8,
light=.85, dark=.15, reverse=False, as_cmap=False):
"""Make a sequential palette from the cubehelix system.
This produces a colormap with linearly-decreasing (or increasing)
brightness. That means that information ... | python | def cubehelix_palette(n_colors=6, start=0, rot=.4, gamma=1.0, hue=0.8,
light=.85, dark=.15, reverse=False, as_cmap=False):
"""Make a sequential palette from the cubehelix system.
This produces a colormap with linearly-decreasing (or increasing)
brightness. That means that information ... | [
"def",
"cubehelix_palette",
"(",
"n_colors",
"=",
"6",
",",
"start",
"=",
"0",
",",
"rot",
"=",
".4",
",",
"gamma",
"=",
"1.0",
",",
"hue",
"=",
"0.8",
",",
"light",
"=",
".85",
",",
"dark",
"=",
".15",
",",
"reverse",
"=",
"False",
",",
"as_cmap... | Make a sequential palette from the cubehelix system.
This produces a colormap with linearly-decreasing (or increasing)
brightness. That means that information will be preserved if printed to
black and white or viewed by someone who is colorblind. "cubehelix" is
also availible as a matplotlib-based pal... | [
"Make",
"a",
"sequential",
"palette",
"from",
"the",
"cubehelix",
"system",
"."
] | b6d23c22d52557b983da8ce7a3a6992501dadcd6 | https://github.com/yhat/ggpy/blob/b6d23c22d52557b983da8ce7a3a6992501dadcd6/ggplot/colors/palettes.py#L332-L392 | train |
kkroening/ffmpeg-python | ffmpeg/_run.py | get_args | def get_args(stream_spec, overwrite_output=False):
"""Build command-line arguments to be passed to ffmpeg."""
nodes = get_stream_spec_nodes(stream_spec)
args = []
# TODO: group nodes together, e.g. `-i somefile -r somerate`.
sorted_nodes, outgoing_edge_maps = topo_sort(nodes)
input_nodes = [node... | python | def get_args(stream_spec, overwrite_output=False):
"""Build command-line arguments to be passed to ffmpeg."""
nodes = get_stream_spec_nodes(stream_spec)
args = []
# TODO: group nodes together, e.g. `-i somefile -r somerate`.
sorted_nodes, outgoing_edge_maps = topo_sort(nodes)
input_nodes = [node... | [
"def",
"get_args",
"(",
"stream_spec",
",",
"overwrite_output",
"=",
"False",
")",
":",
"nodes",
"=",
"get_stream_spec_nodes",
"(",
"stream_spec",
")",
"args",
"=",
"[",
"]",
"# TODO: group nodes together, e.g. `-i somefile -r somerate`.",
"sorted_nodes",
",",
"outgoing... | Build command-line arguments to be passed to ffmpeg. | [
"Build",
"command",
"-",
"line",
"arguments",
"to",
"be",
"passed",
"to",
"ffmpeg",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L135-L154 | train |
kkroening/ffmpeg-python | ffmpeg/_run.py | compile | def compile(stream_spec, cmd='ffmpeg', overwrite_output=False):
"""Build command-line for invoking ffmpeg.
The :meth:`run` function uses this to build the commnad line
arguments and should work in most cases, but calling this function
directly is useful for debugging or if you need to invoke ffmpeg
... | python | def compile(stream_spec, cmd='ffmpeg', overwrite_output=False):
"""Build command-line for invoking ffmpeg.
The :meth:`run` function uses this to build the commnad line
arguments and should work in most cases, but calling this function
directly is useful for debugging or if you need to invoke ffmpeg
... | [
"def",
"compile",
"(",
"stream_spec",
",",
"cmd",
"=",
"'ffmpeg'",
",",
"overwrite_output",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"cmd",
",",
"basestring",
")",
":",
"cmd",
"=",
"[",
"cmd",
"]",
"elif",
"type",
"(",
"cmd",
")",
"!=",
"list... | Build command-line for invoking ffmpeg.
The :meth:`run` function uses this to build the commnad line
arguments and should work in most cases, but calling this function
directly is useful for debugging or if you need to invoke ffmpeg
manually for whatever reason.
This is the same as calling :meth:`... | [
"Build",
"command",
"-",
"line",
"for",
"invoking",
"ffmpeg",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L158-L173 | train |
kkroening/ffmpeg-python | ffmpeg/_run.py | run_async | def run_async(
stream_spec, cmd='ffmpeg', pipe_stdin=False, pipe_stdout=False, pipe_stderr=False,
quiet=False, overwrite_output=False):
"""Asynchronously invoke ffmpeg for the supplied node graph.
Args:
pipe_stdin: if True, connect pipe to subprocess stdin (to be
used with `... | python | def run_async(
stream_spec, cmd='ffmpeg', pipe_stdin=False, pipe_stdout=False, pipe_stderr=False,
quiet=False, overwrite_output=False):
"""Asynchronously invoke ffmpeg for the supplied node graph.
Args:
pipe_stdin: if True, connect pipe to subprocess stdin (to be
used with `... | [
"def",
"run_async",
"(",
"stream_spec",
",",
"cmd",
"=",
"'ffmpeg'",
",",
"pipe_stdin",
"=",
"False",
",",
"pipe_stdout",
"=",
"False",
",",
"pipe_stderr",
"=",
"False",
",",
"quiet",
"=",
"False",
",",
"overwrite_output",
"=",
"False",
")",
":",
"args",
... | Asynchronously invoke ffmpeg for the supplied node graph.
Args:
pipe_stdin: if True, connect pipe to subprocess stdin (to be
used with ``pipe:`` ffmpeg inputs).
pipe_stdout: if True, connect pipe to subprocess stdout (to be
used with ``pipe:`` ffmpeg outputs).
pipe_s... | [
"Asynchronously",
"invoke",
"ffmpeg",
"for",
"the",
"supplied",
"node",
"graph",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L177-L262 | train |
kkroening/ffmpeg-python | ffmpeg/_run.py | run | def run(
stream_spec, cmd='ffmpeg', capture_stdout=False, capture_stderr=False, input=None,
quiet=False, overwrite_output=False):
"""Invoke ffmpeg for the supplied node graph.
Args:
capture_stdout: if True, capture stdout (to be used with
``pipe:`` ffmpeg outputs).
c... | python | def run(
stream_spec, cmd='ffmpeg', capture_stdout=False, capture_stderr=False, input=None,
quiet=False, overwrite_output=False):
"""Invoke ffmpeg for the supplied node graph.
Args:
capture_stdout: if True, capture stdout (to be used with
``pipe:`` ffmpeg outputs).
c... | [
"def",
"run",
"(",
"stream_spec",
",",
"cmd",
"=",
"'ffmpeg'",
",",
"capture_stdout",
"=",
"False",
",",
"capture_stderr",
"=",
"False",
",",
"input",
"=",
"None",
",",
"quiet",
"=",
"False",
",",
"overwrite_output",
"=",
"False",
")",
":",
"process",
"=... | Invoke ffmpeg for the supplied node graph.
Args:
capture_stdout: if True, capture stdout (to be used with
``pipe:`` ffmpeg outputs).
capture_stderr: if True, capture stderr.
quiet: shorthand for setting ``capture_stdout`` and ``capture_stderr``.
input: text to be sent to... | [
"Invoke",
"ffmpeg",
"for",
"the",
"supplied",
"node",
"graph",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_run.py#L266-L296 | train |
kkroening/ffmpeg-python | ffmpeg/_ffmpeg.py | output | def output(*streams_and_filename, **kwargs):
"""Output file URL
Syntax:
`ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)`
Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
etc.). Some k... | python | def output(*streams_and_filename, **kwargs):
"""Output file URL
Syntax:
`ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)`
Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
etc.). Some k... | [
"def",
"output",
"(",
"*",
"streams_and_filename",
",",
"*",
"*",
"kwargs",
")",
":",
"streams_and_filename",
"=",
"list",
"(",
"streams_and_filename",
")",
"if",
"'filename'",
"not",
"in",
"kwargs",
":",
"if",
"not",
"isinstance",
"(",
"streams_and_filename",
... | Output file URL
Syntax:
`ffmpeg.output(stream1[, stream2, stream3...], filename, **ffmpeg_args)`
Any supplied keyword arguments are passed to ffmpeg verbatim (e.g.
``t=20``, ``f='mp4'``, ``acodec='pcm'``, ``vcodec='rawvideo'``,
etc.). Some keyword-arguments are handled specially, as shown bel... | [
"Output",
"file",
"URL"
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_ffmpeg.py#L59-L94 | train |
kkroening/ffmpeg-python | examples/show_progress.py | _do_watch_progress | def _do_watch_progress(filename, sock, handler):
"""Function to run in a separate gevent greenlet to read progress
events from a unix-domain socket."""
connection, client_address = sock.accept()
data = b''
try:
while True:
more_data = connection.recv(16)
if not more_d... | python | def _do_watch_progress(filename, sock, handler):
"""Function to run in a separate gevent greenlet to read progress
events from a unix-domain socket."""
connection, client_address = sock.accept()
data = b''
try:
while True:
more_data = connection.recv(16)
if not more_d... | [
"def",
"_do_watch_progress",
"(",
"filename",
",",
"sock",
",",
"handler",
")",
":",
"connection",
",",
"client_address",
"=",
"sock",
".",
"accept",
"(",
")",
"data",
"=",
"b''",
"try",
":",
"while",
"True",
":",
"more_data",
"=",
"connection",
".",
"re... | Function to run in a separate gevent greenlet to read progress
events from a unix-domain socket. | [
"Function",
"to",
"run",
"in",
"a",
"separate",
"gevent",
"greenlet",
"to",
"read",
"progress",
"events",
"from",
"a",
"unix",
"-",
"domain",
"socket",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L42-L62 | train |
kkroening/ffmpeg-python | examples/show_progress.py | _watch_progress | def _watch_progress(handler):
"""Context manager for creating a unix-domain socket and listen for
ffmpeg progress events.
The socket filename is yielded from the context manager and the
socket is closed when the context manager is exited.
Args:
handler: a function to be called when progres... | python | def _watch_progress(handler):
"""Context manager for creating a unix-domain socket and listen for
ffmpeg progress events.
The socket filename is yielded from the context manager and the
socket is closed when the context manager is exited.
Args:
handler: a function to be called when progres... | [
"def",
"_watch_progress",
"(",
"handler",
")",
":",
"with",
"_tmpdir_scope",
"(",
")",
"as",
"tmpdir",
":",
"socket_filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tmpdir",
",",
"'sock'",
")",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
... | Context manager for creating a unix-domain socket and listen for
ffmpeg progress events.
The socket filename is yielded from the context manager and the
socket is closed when the context manager is exited.
Args:
handler: a function to be called when progress events are
received; re... | [
"Context",
"manager",
"for",
"creating",
"a",
"unix",
"-",
"domain",
"socket",
"and",
"listen",
"for",
"ffmpeg",
"progress",
"events",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L66-L92 | train |
kkroening/ffmpeg-python | examples/show_progress.py | show_progress | def show_progress(total_duration):
"""Create a unix-domain socket to watch progress and render tqdm
progress bar."""
with tqdm(total=round(total_duration, 2)) as bar:
def handler(key, value):
if key == 'out_time_ms':
time = round(float(value) / 1000000., 2)
... | python | def show_progress(total_duration):
"""Create a unix-domain socket to watch progress and render tqdm
progress bar."""
with tqdm(total=round(total_duration, 2)) as bar:
def handler(key, value):
if key == 'out_time_ms':
time = round(float(value) / 1000000., 2)
... | [
"def",
"show_progress",
"(",
"total_duration",
")",
":",
"with",
"tqdm",
"(",
"total",
"=",
"round",
"(",
"total_duration",
",",
"2",
")",
")",
"as",
"bar",
":",
"def",
"handler",
"(",
"key",
",",
"value",
")",
":",
"if",
"key",
"==",
"'out_time_ms'",
... | Create a unix-domain socket to watch progress and render tqdm
progress bar. | [
"Create",
"a",
"unix",
"-",
"domain",
"socket",
"to",
"watch",
"progress",
"and",
"render",
"tqdm",
"progress",
"bar",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/show_progress.py#L97-L108 | train |
kkroening/ffmpeg-python | ffmpeg/_probe.py | probe | def probe(filename, cmd='ffprobe', **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output.
Raises:
:class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,
an :class:`Error` is returned with a generic error message.
The stderr outpu... | python | def probe(filename, cmd='ffprobe', **kwargs):
"""Run ffprobe on the specified file and return a JSON representation of the output.
Raises:
:class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,
an :class:`Error` is returned with a generic error message.
The stderr outpu... | [
"def",
"probe",
"(",
"filename",
",",
"cmd",
"=",
"'ffprobe'",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"[",
"cmd",
",",
"'-show_format'",
",",
"'-show_streams'",
",",
"'-of'",
",",
"'json'",
"]",
"args",
"+=",
"convert_kwargs_to_cmd_line_args",
"("... | Run ffprobe on the specified file and return a JSON representation of the output.
Raises:
:class:`ffmpeg.Error`: if ffprobe returns a non-zero exit code,
an :class:`Error` is returned with a generic error message.
The stderr output can be retrieved by accessing the
``std... | [
"Run",
"ffprobe",
"on",
"the",
"specified",
"file",
"and",
"return",
"a",
"JSON",
"representation",
"of",
"the",
"output",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_probe.py#L7-L24 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | filter_multi_output | def filter_multi_output(stream_spec, filter_name, *args, **kwargs):
"""Apply custom filter with one or more outputs.
This is the same as ``filter_`` except that the filter can produce more than one output.
To reference an output stream, use either the ``.stream`` operator or bracket shorthand:
Exampl... | python | def filter_multi_output(stream_spec, filter_name, *args, **kwargs):
"""Apply custom filter with one or more outputs.
This is the same as ``filter_`` except that the filter can produce more than one output.
To reference an output stream, use either the ``.stream`` operator or bracket shorthand:
Exampl... | [
"def",
"filter_multi_output",
"(",
"stream_spec",
",",
"filter_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FilterNode",
"(",
"stream_spec",
",",
"filter_name",
",",
"args",
"=",
"args",
",",
"kwargs",
"=",
"kwargs",
",",
"max_inp... | Apply custom filter with one or more outputs.
This is the same as ``filter_`` except that the filter can produce more than one output.
To reference an output stream, use either the ``.stream`` operator or bracket shorthand:
Example:
```
split = ffmpeg.input('in.mp4').filter_multi_output(... | [
"Apply",
"custom",
"filter",
"with",
"one",
"or",
"more",
"outputs",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L8-L24 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | filter | def filter(stream_spec, filter_name, *args, **kwargs):
"""Apply custom filter.
``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation
is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name
... | python | def filter(stream_spec, filter_name, *args, **kwargs):
"""Apply custom filter.
``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation
is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name
... | [
"def",
"filter",
"(",
"stream_spec",
",",
"filter_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"filter_multi_output",
"(",
"stream_spec",
",",
"filter_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
".",
"stream",
"(",
"... | Apply custom filter.
``filter_`` is normally used by higher-level filter functions such as ``hflip``, but if a filter implementation
is missing from ``fmpeg-python``, you can call ``filter_`` directly to have ``fmpeg-python`` pass the filter name
and arguments to ffmpeg verbatim.
Args:
stream_... | [
"Apply",
"custom",
"filter",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L28-L47 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | filter_ | def filter_(stream_spec, filter_name, *args, **kwargs):
"""Alternate name for ``filter``, so as to not collide with the
built-in python ``filter`` operator.
"""
return filter(stream_spec, filter_name, *args, **kwargs) | python | def filter_(stream_spec, filter_name, *args, **kwargs):
"""Alternate name for ``filter``, so as to not collide with the
built-in python ``filter`` operator.
"""
return filter(stream_spec, filter_name, *args, **kwargs) | [
"def",
"filter_",
"(",
"stream_spec",
",",
"filter_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"filter",
"(",
"stream_spec",
",",
"filter_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Alternate name for ``filter``, so as to not collide with the
built-in python ``filter`` operator. | [
"Alternate",
"name",
"for",
"filter",
"so",
"as",
"to",
"not",
"collide",
"with",
"the",
"built",
"-",
"in",
"python",
"filter",
"operator",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L51-L55 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | trim | def trim(stream, **kwargs):
"""Trim the input so that the output contains one continuous subpart of the input.
Args:
start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the
first frame in the output.
end: Specify the time of the ... | python | def trim(stream, **kwargs):
"""Trim the input so that the output contains one continuous subpart of the input.
Args:
start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the
first frame in the output.
end: Specify the time of the ... | [
"def",
"trim",
"(",
"stream",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FilterNode",
"(",
"stream",
",",
"trim",
".",
"__name__",
",",
"kwargs",
"=",
"kwargs",
")",
".",
"stream",
"(",
")"
] | Trim the input so that the output contains one continuous subpart of the input.
Args:
start: Specify the time of the start of the kept section, i.e. the frame with the timestamp start will be the
first frame in the output.
end: Specify the time of the first frame that will be dropped, i... | [
"Trim",
"the",
"input",
"so",
"that",
"the",
"output",
"contains",
"one",
"continuous",
"subpart",
"of",
"the",
"input",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L81-L99 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | overlay | def overlay(main_parent_node, overlay_parent_node, eof_action='repeat', **kwargs):
"""Overlay one video on top of another.
Args:
x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In
case the expression is invalid, it is set to a huge va... | python | def overlay(main_parent_node, overlay_parent_node, eof_action='repeat', **kwargs):
"""Overlay one video on top of another.
Args:
x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In
case the expression is invalid, it is set to a huge va... | [
"def",
"overlay",
"(",
"main_parent_node",
",",
"overlay_parent_node",
",",
"eof_action",
"=",
"'repeat'",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'eof_action'",
"]",
"=",
"eof_action",
"return",
"FilterNode",
"(",
"[",
"main_parent_node",
",",
"ove... | Overlay one video on top of another.
Args:
x: Set the expression for the x coordinates of the overlaid video on the main video. Default value is 0. In
case the expression is invalid, it is set to a huge value (meaning that the overlay will not be displayed
within the output visible ... | [
"Overlay",
"one",
"video",
"on",
"top",
"of",
"another",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L103-L147 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | crop | def crop(stream, x, y, width, height, **kwargs):
"""Crop the input video.
Args:
x: The horizontal position, in the input video, of the left edge of
the output video.
y: The vertical position, in the input video, of the top edge of the
output video.
width: The width... | python | def crop(stream, x, y, width, height, **kwargs):
"""Crop the input video.
Args:
x: The horizontal position, in the input video, of the left edge of
the output video.
y: The vertical position, in the input video, of the top edge of the
output video.
width: The width... | [
"def",
"crop",
"(",
"stream",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FilterNode",
"(",
"stream",
",",
"crop",
".",
"__name__",
",",
"args",
"=",
"[",
"width",
",",
"height",
",",
"x",
",",
... | Crop the input video.
Args:
x: The horizontal position, in the input video, of the left edge of
the output video.
y: The vertical position, in the input video, of the top edge of the
output video.
width: The width of the output video. Must be greater than 0.
he... | [
"Crop",
"the",
"input",
"video",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L169-L187 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | drawbox | def drawbox(stream, x, y, width, height, color, thickness=None, **kwargs):
"""Draw a colored box on the input image.
Args:
x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0.
y: The expression which specifies the top left corner y coordinate of the b... | python | def drawbox(stream, x, y, width, height, color, thickness=None, **kwargs):
"""Draw a colored box on the input image.
Args:
x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0.
y: The expression which specifies the top left corner y coordinate of the b... | [
"def",
"drawbox",
"(",
"stream",
",",
"x",
",",
"y",
",",
"width",
",",
"height",
",",
"color",
",",
"thickness",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"thickness",
":",
"kwargs",
"[",
"'t'",
"]",
"=",
"thickness",
"return",
"Filter... | Draw a colored box on the input image.
Args:
x: The expression which specifies the top left corner x coordinate of the box. It defaults to 0.
y: The expression which specifies the top left corner y coordinate of the box. It defaults to 0.
width: Specify the width of the box; if 0 interprete... | [
"Draw",
"a",
"colored",
"box",
"on",
"the",
"input",
"image",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L191-L212 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | drawtext | def drawtext(stream, text=None, x=0, y=0, escape_text=True, **kwargs):
"""Draw a text string or text from a specified file on top of a video, using the libfreetype library.
To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default
font fallback and ... | python | def drawtext(stream, text=None, x=0, y=0, escape_text=True, **kwargs):
"""Draw a text string or text from a specified file on top of a video, using the libfreetype library.
To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default
font fallback and ... | [
"def",
"drawtext",
"(",
"stream",
",",
"text",
"=",
"None",
",",
"x",
"=",
"0",
",",
"y",
"=",
"0",
",",
"escape_text",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"text",
"is",
"not",
"None",
":",
"if",
"escape_text",
":",
"text",
"=... | Draw a text string or text from a specified file on top of a video, using the libfreetype library.
To enable compilation of this filter, you need to configure FFmpeg with ``--enable-libfreetype``. To enable default
font fallback and the font option you need to configure FFmpeg with ``--enable-libfontconfig``. ... | [
"Draw",
"a",
"text",
"string",
"or",
"text",
"from",
"a",
"specified",
"file",
"on",
"top",
"of",
"a",
"video",
"using",
"the",
"libfreetype",
"library",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L216-L354 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | concat | def concat(*streams, **kwargs):
"""Concatenate audio and video streams, joining them together one after the other.
The filter works on segments of synchronized video and audio streams. All segments must have the same number of
streams of each type, and that will also be the number of streams at output.
... | python | def concat(*streams, **kwargs):
"""Concatenate audio and video streams, joining them together one after the other.
The filter works on segments of synchronized video and audio streams. All segments must have the same number of
streams of each type, and that will also be the number of streams at output.
... | [
"def",
"concat",
"(",
"*",
"streams",
",",
"*",
"*",
"kwargs",
")",
":",
"video_stream_count",
"=",
"kwargs",
".",
"get",
"(",
"'v'",
",",
"1",
")",
"audio_stream_count",
"=",
"kwargs",
".",
"get",
"(",
"'a'",
",",
"0",
")",
"stream_count",
"=",
"vid... | Concatenate audio and video streams, joining them together one after the other.
The filter works on segments of synchronized video and audio streams. All segments must have the same number of
streams of each type, and that will also be the number of streams at output.
Args:
unsafe: Activate unsafe... | [
"Concatenate",
"audio",
"and",
"video",
"streams",
"joining",
"them",
"together",
"one",
"after",
"the",
"other",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L358-L391 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | zoompan | def zoompan(stream, **kwargs):
"""Apply Zoom & Pan effect.
Args:
zoom: Set the zoom expression. Default is 1.
x: Set the x expression. Default is 0.
y: Set the y expression. Default is 0.
d: Set the duration expression in number of frames. This sets for how many number of frames... | python | def zoompan(stream, **kwargs):
"""Apply Zoom & Pan effect.
Args:
zoom: Set the zoom expression. Default is 1.
x: Set the x expression. Default is 0.
y: Set the y expression. Default is 0.
d: Set the duration expression in number of frames. This sets for how many number of frames... | [
"def",
"zoompan",
"(",
"stream",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FilterNode",
"(",
"stream",
",",
"zoompan",
".",
"__name__",
",",
"kwargs",
"=",
"kwargs",
")",
".",
"stream",
"(",
")"
] | Apply Zoom & Pan effect.
Args:
zoom: Set the zoom expression. Default is 1.
x: Set the x expression. Default is 0.
y: Set the y expression. Default is 0.
d: Set the duration expression in number of frames. This sets for how many number of frames effect will last
for sing... | [
"Apply",
"Zoom",
"&",
"Pan",
"effect",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L395-L410 | train |
kkroening/ffmpeg-python | ffmpeg/_filters.py | colorchannelmixer | def colorchannelmixer(stream, *args, **kwargs):
"""Adjust video input frames by re-mixing color channels.
Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__
"""
return FilterNode(stream, colorchannelmixer.__name__, kwargs=kwargs).stream() | python | def colorchannelmixer(stream, *args, **kwargs):
"""Adjust video input frames by re-mixing color channels.
Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__
"""
return FilterNode(stream, colorchannelmixer.__name__, kwargs=kwargs).stream() | [
"def",
"colorchannelmixer",
"(",
"stream",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"FilterNode",
"(",
"stream",
",",
"colorchannelmixer",
".",
"__name__",
",",
"kwargs",
"=",
"kwargs",
")",
".",
"stream",
"(",
")"
] | Adjust video input frames by re-mixing color channels.
Official documentation: `colorchannelmixer <https://ffmpeg.org/ffmpeg-filters.html#colorchannelmixer>`__ | [
"Adjust",
"video",
"input",
"frames",
"by",
"re",
"-",
"mixing",
"color",
"channels",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_filters.py#L429-L434 | train |
kkroening/ffmpeg-python | ffmpeg/_utils.py | _recursive_repr | def _recursive_repr(item):
"""Hack around python `repr` to deterministically represent dictionaries.
This is able to represent more things than json.dumps, since it does not require things to be JSON serializable
(e.g. datetimes).
"""
if isinstance(item, basestring):
result = str(item)
... | python | def _recursive_repr(item):
"""Hack around python `repr` to deterministically represent dictionaries.
This is able to represent more things than json.dumps, since it does not require things to be JSON serializable
(e.g. datetimes).
"""
if isinstance(item, basestring):
result = str(item)
... | [
"def",
"_recursive_repr",
"(",
"item",
")",
":",
"if",
"isinstance",
"(",
"item",
",",
"basestring",
")",
":",
"result",
"=",
"str",
"(",
"item",
")",
"elif",
"isinstance",
"(",
"item",
",",
"list",
")",
":",
"result",
"=",
"'[{}]'",
".",
"format",
"... | Hack around python `repr` to deterministically represent dictionaries.
This is able to represent more things than json.dumps, since it does not require things to be JSON serializable
(e.g. datetimes). | [
"Hack",
"around",
"python",
"repr",
"to",
"deterministically",
"represent",
"dictionaries",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L44-L59 | train |
kkroening/ffmpeg-python | ffmpeg/_utils.py | escape_chars | def escape_chars(text, chars):
"""Helper function to escape uncomfortable characters."""
text = str(text)
chars = list(set(chars))
if '\\' in chars:
chars.remove('\\')
chars.insert(0, '\\')
for ch in chars:
text = text.replace(ch, '\\' + ch)
return text | python | def escape_chars(text, chars):
"""Helper function to escape uncomfortable characters."""
text = str(text)
chars = list(set(chars))
if '\\' in chars:
chars.remove('\\')
chars.insert(0, '\\')
for ch in chars:
text = text.replace(ch, '\\' + ch)
return text | [
"def",
"escape_chars",
"(",
"text",
",",
"chars",
")",
":",
"text",
"=",
"str",
"(",
"text",
")",
"chars",
"=",
"list",
"(",
"set",
"(",
"chars",
")",
")",
"if",
"'\\\\'",
"in",
"chars",
":",
"chars",
".",
"remove",
"(",
"'\\\\'",
")",
"chars",
"... | Helper function to escape uncomfortable characters. | [
"Helper",
"function",
"to",
"escape",
"uncomfortable",
"characters",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L71-L80 | train |
kkroening/ffmpeg-python | ffmpeg/_utils.py | convert_kwargs_to_cmd_line_args | def convert_kwargs_to_cmd_line_args(kwargs):
"""Helper function to build command line arguments out of dict."""
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
args.append('-{}'.format(k))
if v is not None:
args.append('{}'.format(v))
return args | python | def convert_kwargs_to_cmd_line_args(kwargs):
"""Helper function to build command line arguments out of dict."""
args = []
for k in sorted(kwargs.keys()):
v = kwargs[k]
args.append('-{}'.format(k))
if v is not None:
args.append('{}'.format(v))
return args | [
"def",
"convert_kwargs_to_cmd_line_args",
"(",
"kwargs",
")",
":",
"args",
"=",
"[",
"]",
"for",
"k",
"in",
"sorted",
"(",
"kwargs",
".",
"keys",
"(",
")",
")",
":",
"v",
"=",
"kwargs",
"[",
"k",
"]",
"args",
".",
"append",
"(",
"'-{}'",
".",
"form... | Helper function to build command line arguments out of dict. | [
"Helper",
"function",
"to",
"build",
"command",
"line",
"arguments",
"out",
"of",
"dict",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/_utils.py#L83-L91 | train |
kkroening/ffmpeg-python | ffmpeg/nodes.py | Node.stream | def stream(self, label=None, selector=None):
"""Create an outgoing stream originating from this node.
More nodes may be attached onto the outgoing stream.
"""
return self.__outgoing_stream_type(self, label, upstream_selector=selector) | python | def stream(self, label=None, selector=None):
"""Create an outgoing stream originating from this node.
More nodes may be attached onto the outgoing stream.
"""
return self.__outgoing_stream_type(self, label, upstream_selector=selector) | [
"def",
"stream",
"(",
"self",
",",
"label",
"=",
"None",
",",
"selector",
"=",
"None",
")",
":",
"return",
"self",
".",
"__outgoing_stream_type",
"(",
"self",
",",
"label",
",",
"upstream_selector",
"=",
"selector",
")"
] | Create an outgoing stream originating from this node.
More nodes may be attached onto the outgoing stream. | [
"Create",
"an",
"outgoing",
"stream",
"originating",
"from",
"this",
"node",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/ffmpeg/nodes.py#L128-L133 | train |
kkroening/ffmpeg-python | examples/tensorflow_stream.py | DeepDream._tffunc | def _tffunc(*argtypes):
'''Helper that transforms TF-graph generating function into a regular one.
See `_resize` function below.
'''
placeholders = list(map(tf.placeholder, argtypes))
def wrap(f):
out = f(*placeholders)
def wrapper(*args, **kw):
... | python | def _tffunc(*argtypes):
'''Helper that transforms TF-graph generating function into a regular one.
See `_resize` function below.
'''
placeholders = list(map(tf.placeholder, argtypes))
def wrap(f):
out = f(*placeholders)
def wrapper(*args, **kw):
... | [
"def",
"_tffunc",
"(",
"*",
"argtypes",
")",
":",
"placeholders",
"=",
"list",
"(",
"map",
"(",
"tf",
".",
"placeholder",
",",
"argtypes",
")",
")",
"def",
"wrap",
"(",
"f",
")",
":",
"out",
"=",
"f",
"(",
"*",
"placeholders",
")",
"def",
"wrapper"... | Helper that transforms TF-graph generating function into a regular one.
See `_resize` function below. | [
"Helper",
"that",
"transforms",
"TF",
"-",
"graph",
"generating",
"function",
"into",
"a",
"regular",
"one",
".",
"See",
"_resize",
"function",
"below",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L159-L169 | train |
kkroening/ffmpeg-python | examples/tensorflow_stream.py | DeepDream._base_resize | def _base_resize(img, size):
'''Helper function that uses TF to resize an image'''
img = tf.expand_dims(img, 0)
return tf.image.resize_bilinear(img, size)[0,:,:,:] | python | def _base_resize(img, size):
'''Helper function that uses TF to resize an image'''
img = tf.expand_dims(img, 0)
return tf.image.resize_bilinear(img, size)[0,:,:,:] | [
"def",
"_base_resize",
"(",
"img",
",",
"size",
")",
":",
"img",
"=",
"tf",
".",
"expand_dims",
"(",
"img",
",",
"0",
")",
"return",
"tf",
".",
"image",
".",
"resize_bilinear",
"(",
"img",
",",
"size",
")",
"[",
"0",
",",
":",
",",
":",
",",
":... | Helper function that uses TF to resize an image | [
"Helper",
"function",
"that",
"uses",
"TF",
"to",
"resize",
"an",
"image"
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L172-L175 | train |
kkroening/ffmpeg-python | examples/tensorflow_stream.py | DeepDream._calc_grad_tiled | def _calc_grad_tiled(self, img, t_grad, tile_size=512):
'''Compute the value of tensor t_grad over the image in a tiled way.
Random shifts are applied to the image to blur tile boundaries over
multiple iterations.'''
sz = tile_size
h, w = img.shape[:2]
sx, sy = np.random... | python | def _calc_grad_tiled(self, img, t_grad, tile_size=512):
'''Compute the value of tensor t_grad over the image in a tiled way.
Random shifts are applied to the image to blur tile boundaries over
multiple iterations.'''
sz = tile_size
h, w = img.shape[:2]
sx, sy = np.random... | [
"def",
"_calc_grad_tiled",
"(",
"self",
",",
"img",
",",
"t_grad",
",",
"tile_size",
"=",
"512",
")",
":",
"sz",
"=",
"tile_size",
"h",
",",
"w",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"sx",
",",
"sy",
"=",
"np",
".",
"random",
".",
"ran... | Compute the value of tensor t_grad over the image in a tiled way.
Random shifts are applied to the image to blur tile boundaries over
multiple iterations. | [
"Compute",
"the",
"value",
"of",
"tensor",
"t_grad",
"over",
"the",
"image",
"in",
"a",
"tiled",
"way",
".",
"Random",
"shifts",
"are",
"applied",
"to",
"the",
"image",
"to",
"blur",
"tile",
"boundaries",
"over",
"multiple",
"iterations",
"."
] | ac111dc3a976ddbb872bc7d6d4fe24a267c1a956 | https://github.com/kkroening/ffmpeg-python/blob/ac111dc3a976ddbb872bc7d6d4fe24a267c1a956/examples/tensorflow_stream.py#L199-L213 | train |
python-diamond/Diamond | src/collectors/xen_collector/xen_collector.py | XENCollector.collect | def collect(self):
"""
Collect libvirt data
"""
if libvirt is None:
self.log.error('Unable to import either libvirt')
return {}
# Open a restricted (non-root) connection to the hypervisor
conn = libvirt.openReadOnly(None)
# Get hardware inf... | python | def collect(self):
"""
Collect libvirt data
"""
if libvirt is None:
self.log.error('Unable to import either libvirt')
return {}
# Open a restricted (non-root) connection to the hypervisor
conn = libvirt.openReadOnly(None)
# Get hardware inf... | [
"def",
"collect",
"(",
"self",
")",
":",
"if",
"libvirt",
"is",
"None",
":",
"self",
".",
"log",
".",
"error",
"(",
"'Unable to import either libvirt'",
")",
"return",
"{",
"}",
"# Open a restricted (non-root) connection to the hypervisor",
"conn",
"=",
"libvirt",
... | Collect libvirt data | [
"Collect",
"libvirt",
"data"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/xen_collector/xen_collector.py#L38-L82 | train |
python-diamond/Diamond | src/collectors/elb/elb.py | ElbCollector.publish_delayed_metric | def publish_delayed_metric(self, name, value, timestamp, raw_value=None,
precision=0, metric_type='GAUGE',
instance=None):
"""
Metrics may not be immediately available when querying cloudwatch.
Hence, allow the ability to publish a me... | python | def publish_delayed_metric(self, name, value, timestamp, raw_value=None,
precision=0, metric_type='GAUGE',
instance=None):
"""
Metrics may not be immediately available when querying cloudwatch.
Hence, allow the ability to publish a me... | [
"def",
"publish_delayed_metric",
"(",
"self",
",",
"name",
",",
"value",
",",
"timestamp",
",",
"raw_value",
"=",
"None",
",",
"precision",
"=",
"0",
",",
"metric_type",
"=",
"'GAUGE'",
",",
"instance",
"=",
"None",
")",
":",
"# Get metric Path",
"path",
"... | Metrics may not be immediately available when querying cloudwatch.
Hence, allow the ability to publish a metric from some the past given
its timestamp. | [
"Metrics",
"may",
"not",
"be",
"immediately",
"available",
"when",
"querying",
"cloudwatch",
".",
"Hence",
"allow",
"the",
"ability",
"to",
"publish",
"a",
"metric",
"from",
"some",
"the",
"past",
"given",
"its",
"timestamp",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/elb/elb.py#L184-L205 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol.agr_busy | def agr_busy(self):
""" Collector for average disk busyness per aggregate
As of Nov 22nd 2013 there is no API call for agr busyness.
You have to collect all disk busyness and then compute agr
busyness. #fml
"""
c1 = {} # Counters from time a
c2 = {... | python | def agr_busy(self):
""" Collector for average disk busyness per aggregate
As of Nov 22nd 2013 there is no API call for agr busyness.
You have to collect all disk busyness and then compute agr
busyness. #fml
"""
c1 = {} # Counters from time a
c2 = {... | [
"def",
"agr_busy",
"(",
"self",
")",
":",
"c1",
"=",
"{",
"}",
"# Counters from time a",
"c2",
"=",
"{",
"}",
"# Counters from time b",
"disk_results",
"=",
"{",
"}",
"# Disk busyness results %",
"agr_results",
"=",
"{",
"}",
"# Aggregate busyness results $",
"nam... | Collector for average disk busyness per aggregate
As of Nov 22nd 2013 there is no API call for agr busyness.
You have to collect all disk busyness and then compute agr
busyness. #fml | [
"Collector",
"for",
"average",
"disk",
"busyness",
"per",
"aggregate"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L71-L135 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol.consistency_point | def consistency_point(self):
""" Collector for getting count of consistancy points
"""
cp_delta = {}
xml_path = 'instances/instance-data/counters'
netapp_api = NaElement('perf-object-get-instances')
netapp_api.child_add_string('objectname', 'wafl')
instance = NaE... | python | def consistency_point(self):
""" Collector for getting count of consistancy points
"""
cp_delta = {}
xml_path = 'instances/instance-data/counters'
netapp_api = NaElement('perf-object-get-instances')
netapp_api.child_add_string('objectname', 'wafl')
instance = NaE... | [
"def",
"consistency_point",
"(",
"self",
")",
":",
"cp_delta",
"=",
"{",
"}",
"xml_path",
"=",
"'instances/instance-data/counters'",
"netapp_api",
"=",
"NaElement",
"(",
"'perf-object-get-instances'",
")",
"netapp_api",
".",
"child_add_string",
"(",
"'objectname'",
",... | Collector for getting count of consistancy points | [
"Collector",
"for",
"getting",
"count",
"of",
"consistancy",
"points"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L137-L206 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol.zero_disk | def zero_disk(self, disk_xml=None):
""" Collector and publish not zeroed disk metrics
"""
troubled_disks = 0
for filer_disk in disk_xml:
raid_state = filer_disk.find('raid-state').text
if not raid_state == 'spare':
continue
is_zeroed =... | python | def zero_disk(self, disk_xml=None):
""" Collector and publish not zeroed disk metrics
"""
troubled_disks = 0
for filer_disk in disk_xml:
raid_state = filer_disk.find('raid-state').text
if not raid_state == 'spare':
continue
is_zeroed =... | [
"def",
"zero_disk",
"(",
"self",
",",
"disk_xml",
"=",
"None",
")",
":",
"troubled_disks",
"=",
"0",
"for",
"filer_disk",
"in",
"disk_xml",
":",
"raid_state",
"=",
"filer_disk",
".",
"find",
"(",
"'raid-state'",
")",
".",
"text",
"if",
"not",
"raid_state",... | Collector and publish not zeroed disk metrics | [
"Collector",
"and",
"publish",
"not",
"zeroed",
"disk",
"metrics"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L225-L238 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol.spare_disk | def spare_disk(self, disk_xml=None):
""" Number of spare disk per type.
For example: storage.ontap.filer201.disk.SATA
"""
spare_disk = {}
disk_types = set()
for filer_disk in disk_xml:
disk_types.add(filer_disk.find('effective-disk-type').text)
... | python | def spare_disk(self, disk_xml=None):
""" Number of spare disk per type.
For example: storage.ontap.filer201.disk.SATA
"""
spare_disk = {}
disk_types = set()
for filer_disk in disk_xml:
disk_types.add(filer_disk.find('effective-disk-type').text)
... | [
"def",
"spare_disk",
"(",
"self",
",",
"disk_xml",
"=",
"None",
")",
":",
"spare_disk",
"=",
"{",
"}",
"disk_types",
"=",
"set",
"(",
")",
"for",
"filer_disk",
"in",
"disk_xml",
":",
"disk_types",
".",
"add",
"(",
"filer_disk",
".",
"find",
"(",
"'effe... | Number of spare disk per type.
For example: storage.ontap.filer201.disk.SATA | [
"Number",
"of",
"spare",
"disk",
"per",
"type",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L240-L265 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol.get_netapp_elem | def get_netapp_elem(self, netapp_api=None, sub_element=None):
""" Retrieve netapp elem
"""
netapp_data = self.server.invoke_elem(netapp_api)
if netapp_data.results_status() == 'failed':
self.log.error(
'While using netapp API failed to retrieve '
... | python | def get_netapp_elem(self, netapp_api=None, sub_element=None):
""" Retrieve netapp elem
"""
netapp_data = self.server.invoke_elem(netapp_api)
if netapp_data.results_status() == 'failed':
self.log.error(
'While using netapp API failed to retrieve '
... | [
"def",
"get_netapp_elem",
"(",
"self",
",",
"netapp_api",
"=",
"None",
",",
"sub_element",
"=",
"None",
")",
":",
"netapp_data",
"=",
"self",
".",
"server",
".",
"invoke_elem",
"(",
"netapp_api",
")",
"if",
"netapp_data",
".",
"results_status",
"(",
")",
"... | Retrieve netapp elem | [
"Retrieve",
"netapp",
"elem"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L267-L282 | train |
python-diamond/Diamond | src/collectors/netapp/netappDisk.py | netappDiskCol._netapp_login | def _netapp_login(self):
""" Login to our netapp filer
"""
self.server = NaServer(self.ip, 1, 3)
self.server.set_transport_type('HTTPS')
self.server.set_style('LOGIN')
self.server.set_admin_user(self.netapp_user, self.netapp_password) | python | def _netapp_login(self):
""" Login to our netapp filer
"""
self.server = NaServer(self.ip, 1, 3)
self.server.set_transport_type('HTTPS')
self.server.set_style('LOGIN')
self.server.set_admin_user(self.netapp_user, self.netapp_password) | [
"def",
"_netapp_login",
"(",
"self",
")",
":",
"self",
".",
"server",
"=",
"NaServer",
"(",
"self",
".",
"ip",
",",
"1",
",",
"3",
")",
"self",
".",
"server",
".",
"set_transport_type",
"(",
"'HTTPS'",
")",
"self",
".",
"server",
".",
"set_style",
"(... | Login to our netapp filer | [
"Login",
"to",
"our",
"netapp",
"filer"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/netapp/netappDisk.py#L284-L291 | train |
python-diamond/Diamond | src/collectors/ceph/ceph.py | CephCollector._get_socket_paths | def _get_socket_paths(self):
"""Return a sequence of paths to sockets for communicating
with ceph daemons.
"""
socket_pattern = os.path.join(self.config['socket_path'],
(self.config['socket_prefix'] +
'*.' + sel... | python | def _get_socket_paths(self):
"""Return a sequence of paths to sockets for communicating
with ceph daemons.
"""
socket_pattern = os.path.join(self.config['socket_path'],
(self.config['socket_prefix'] +
'*.' + sel... | [
"def",
"_get_socket_paths",
"(",
"self",
")",
":",
"socket_pattern",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"config",
"[",
"'socket_path'",
"]",
",",
"(",
"self",
".",
"config",
"[",
"'socket_prefix'",
"]",
"+",
"'*.'",
"+",
"self",
"."... | Return a sequence of paths to sockets for communicating
with ceph daemons. | [
"Return",
"a",
"sequence",
"of",
"paths",
"to",
"sockets",
"for",
"communicating",
"with",
"ceph",
"daemons",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L78-L85 | train |
python-diamond/Diamond | src/collectors/ceph/ceph.py | CephCollector._get_counter_prefix_from_socket_name | def _get_counter_prefix_from_socket_name(self, name):
"""Given the name of a UDS socket, return the prefix
for counters coming from that source.
"""
base = os.path.splitext(os.path.basename(name))[0]
if base.startswith(self.config['socket_prefix']):
base = base[len(se... | python | def _get_counter_prefix_from_socket_name(self, name):
"""Given the name of a UDS socket, return the prefix
for counters coming from that source.
"""
base = os.path.splitext(os.path.basename(name))[0]
if base.startswith(self.config['socket_prefix']):
base = base[len(se... | [
"def",
"_get_counter_prefix_from_socket_name",
"(",
"self",
",",
"name",
")",
":",
"base",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basename",
"(",
"name",
")",
")",
"[",
"0",
"]",
"if",
"base",
".",
"startswith",
"(",
"... | Given the name of a UDS socket, return the prefix
for counters coming from that source. | [
"Given",
"the",
"name",
"of",
"a",
"UDS",
"socket",
"return",
"the",
"prefix",
"for",
"counters",
"coming",
"from",
"that",
"source",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L87-L94 | train |
python-diamond/Diamond | src/collectors/ceph/ceph.py | CephCollector._get_stats_from_socket | def _get_stats_from_socket(self, name):
"""Return the parsed JSON data returned when ceph is told to
dump the stats from the named socket.
In the event of an error error, the exception is logged, and
an empty result set is returned.
"""
try:
json_blob = subpr... | python | def _get_stats_from_socket(self, name):
"""Return the parsed JSON data returned when ceph is told to
dump the stats from the named socket.
In the event of an error error, the exception is logged, and
an empty result set is returned.
"""
try:
json_blob = subpr... | [
"def",
"_get_stats_from_socket",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"json_blob",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"self",
".",
"config",
"[",
"'ceph_binary'",
"]",
",",
"'--admin-daemon'",
",",
"name",
",",
"'perf'",
",",
"'du... | Return the parsed JSON data returned when ceph is told to
dump the stats from the named socket.
In the event of an error error, the exception is logged, and
an empty result set is returned. | [
"Return",
"the",
"parsed",
"JSON",
"data",
"returned",
"when",
"ceph",
"is",
"told",
"to",
"dump",
"the",
"stats",
"from",
"the",
"named",
"socket",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L96-L125 | train |
python-diamond/Diamond | src/collectors/ceph/ceph.py | CephCollector._publish_stats | def _publish_stats(self, counter_prefix, stats):
"""Given a stats dictionary from _get_stats_from_socket,
publish the individual values.
"""
for stat_name, stat_value in flatten_dictionary(
stats,
prefix=counter_prefix,
):
self.publish_gauge(st... | python | def _publish_stats(self, counter_prefix, stats):
"""Given a stats dictionary from _get_stats_from_socket,
publish the individual values.
"""
for stat_name, stat_value in flatten_dictionary(
stats,
prefix=counter_prefix,
):
self.publish_gauge(st... | [
"def",
"_publish_stats",
"(",
"self",
",",
"counter_prefix",
",",
"stats",
")",
":",
"for",
"stat_name",
",",
"stat_value",
"in",
"flatten_dictionary",
"(",
"stats",
",",
"prefix",
"=",
"counter_prefix",
",",
")",
":",
"self",
".",
"publish_gauge",
"(",
"sta... | Given a stats dictionary from _get_stats_from_socket,
publish the individual values. | [
"Given",
"a",
"stats",
"dictionary",
"from",
"_get_stats_from_socket",
"publish",
"the",
"individual",
"values",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ceph/ceph.py#L127-L135 | train |
python-diamond/Diamond | src/diamond/handler/graphitepickle.py | GraphitePickleHandler._pickle_batch | def _pickle_batch(self):
"""
Pickle the metrics into a form that can be understood
by the graphite pickle connector.
"""
# Pickle
payload = pickle.dumps(self.batch)
# Pack Message
header = struct.pack("!L", len(payload))
message = header + payload... | python | def _pickle_batch(self):
"""
Pickle the metrics into a form that can be understood
by the graphite pickle connector.
"""
# Pickle
payload = pickle.dumps(self.batch)
# Pack Message
header = struct.pack("!L", len(payload))
message = header + payload... | [
"def",
"_pickle_batch",
"(",
"self",
")",
":",
"# Pickle",
"payload",
"=",
"pickle",
".",
"dumps",
"(",
"self",
".",
"batch",
")",
"# Pack Message",
"header",
"=",
"struct",
".",
"pack",
"(",
"\"!L\"",
",",
"len",
"(",
"payload",
")",
")",
"message",
"... | Pickle the metrics into a form that can be understood
by the graphite pickle connector. | [
"Pickle",
"the",
"metrics",
"into",
"a",
"form",
"that",
"can",
"be",
"understood",
"by",
"the",
"graphite",
"pickle",
"connector",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/graphitepickle.py#L88-L101 | train |
python-diamond/Diamond | src/diamond/handler/g_metric.py | GmetricHandler._send | def _send(self, metric):
"""
Send data to gmond.
"""
metric_name = self.get_name_from_path(metric.path)
tmax = "60"
dmax = "0"
slope = "both"
# FIXME: Badness, shouldn't *assume* double type
metric_type = "double"
units = ""
group =... | python | def _send(self, metric):
"""
Send data to gmond.
"""
metric_name = self.get_name_from_path(metric.path)
tmax = "60"
dmax = "0"
slope = "both"
# FIXME: Badness, shouldn't *assume* double type
metric_type = "double"
units = ""
group =... | [
"def",
"_send",
"(",
"self",
",",
"metric",
")",
":",
"metric_name",
"=",
"self",
".",
"get_name_from_path",
"(",
"metric",
".",
"path",
")",
"tmax",
"=",
"\"60\"",
"dmax",
"=",
"\"0\"",
"slope",
"=",
"\"both\"",
"# FIXME: Badness, shouldn't *assume* double type... | Send data to gmond. | [
"Send",
"data",
"to",
"gmond",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/g_metric.py#L87-L106 | train |
python-diamond/Diamond | src/diamond/handler/mqtt.py | MQTTHandler.process | def process(self, metric):
"""
Process a metric by converting metric name to MQTT topic name;
the payload is metric and timestamp.
"""
if not mosquitto:
return
line = str(metric)
topic, value, timestamp = line.split()
if len(self.prefix):
... | python | def process(self, metric):
"""
Process a metric by converting metric name to MQTT topic name;
the payload is metric and timestamp.
"""
if not mosquitto:
return
line = str(metric)
topic, value, timestamp = line.split()
if len(self.prefix):
... | [
"def",
"process",
"(",
"self",
",",
"metric",
")",
":",
"if",
"not",
"mosquitto",
":",
"return",
"line",
"=",
"str",
"(",
"metric",
")",
"topic",
",",
"value",
",",
"timestamp",
"=",
"line",
".",
"split",
"(",
")",
"if",
"len",
"(",
"self",
".",
... | Process a metric by converting metric name to MQTT topic name;
the payload is metric and timestamp. | [
"Process",
"a",
"metric",
"by",
"converting",
"metric",
"name",
"to",
"MQTT",
"topic",
"name",
";",
"the",
"payload",
"is",
"metric",
"and",
"timestamp",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/mqtt.py#L175-L194 | train |
python-diamond/Diamond | src/diamond/handler/tsdb.py | TSDBHandler.process | def process(self, metric):
"""
Process a metric by sending it to TSDB
"""
entry = {'timestamp': metric.timestamp, 'value': metric.value,
"tags": {}}
entry["tags"]["hostname"] = metric.host
if self.cleanMetrics:
metric = MetricWrapper(metric, ... | python | def process(self, metric):
"""
Process a metric by sending it to TSDB
"""
entry = {'timestamp': metric.timestamp, 'value': metric.value,
"tags": {}}
entry["tags"]["hostname"] = metric.host
if self.cleanMetrics:
metric = MetricWrapper(metric, ... | [
"def",
"process",
"(",
"self",
",",
"metric",
")",
":",
"entry",
"=",
"{",
"'timestamp'",
":",
"metric",
".",
"timestamp",
",",
"'value'",
":",
"metric",
".",
"value",
",",
"\"tags\"",
":",
"{",
"}",
"}",
"entry",
"[",
"\"tags\"",
"]",
"[",
"\"hostna... | Process a metric by sending it to TSDB | [
"Process",
"a",
"metric",
"by",
"sending",
"it",
"to",
"TSDB"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/tsdb.py#L189-L225 | train |
python-diamond/Diamond | src/diamond/handler/tsdb.py | TSDBHandler._send | def _send(self, content):
"""
Send content to TSDB.
"""
retry = 0
success = False
while retry < 3 and success is False:
self.log.debug(content)
try:
request = urllib2.Request("http://"+self.host+":" +
... | python | def _send(self, content):
"""
Send content to TSDB.
"""
retry = 0
success = False
while retry < 3 and success is False:
self.log.debug(content)
try:
request = urllib2.Request("http://"+self.host+":" +
... | [
"def",
"_send",
"(",
"self",
",",
"content",
")",
":",
"retry",
"=",
"0",
"success",
"=",
"False",
"while",
"retry",
"<",
"3",
"and",
"success",
"is",
"False",
":",
"self",
".",
"log",
".",
"debug",
"(",
"content",
")",
"try",
":",
"request",
"=",
... | Send content to TSDB. | [
"Send",
"content",
"to",
"TSDB",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/tsdb.py#L227-L252 | train |
python-diamond/Diamond | src/collectors/snmp/snmp.py | SNMPCollector.get | def get(self, oid, host, port, community):
"""
Perform SNMP get for a given OID
"""
# Initialize return value
ret = {}
# Convert OID to tuple if necessary
if not isinstance(oid, tuple):
oid = self._convert_to_oid(oid)
# Convert Host to IP if ... | python | def get(self, oid, host, port, community):
"""
Perform SNMP get for a given OID
"""
# Initialize return value
ret = {}
# Convert OID to tuple if necessary
if not isinstance(oid, tuple):
oid = self._convert_to_oid(oid)
# Convert Host to IP if ... | [
"def",
"get",
"(",
"self",
",",
"oid",
",",
"host",
",",
"port",
",",
"community",
")",
":",
"# Initialize return value",
"ret",
"=",
"{",
"}",
"# Convert OID to tuple if necessary",
"if",
"not",
"isinstance",
"(",
"oid",
",",
"tuple",
")",
":",
"oid",
"="... | Perform SNMP get for a given OID | [
"Perform",
"SNMP",
"get",
"for",
"a",
"given",
"OID"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/snmp/snmp.py#L75-L109 | train |
python-diamond/Diamond | src/collectors/snmp/snmp.py | SNMPCollector.walk | def walk(self, oid, host, port, community):
"""
Perform an SNMP walk on a given OID
"""
# Initialize return value
ret = {}
# Convert OID to tuple if necessary
if not isinstance(oid, tuple):
oid = self._convert_to_oid(oid)
# Convert Host to IP... | python | def walk(self, oid, host, port, community):
"""
Perform an SNMP walk on a given OID
"""
# Initialize return value
ret = {}
# Convert OID to tuple if necessary
if not isinstance(oid, tuple):
oid = self._convert_to_oid(oid)
# Convert Host to IP... | [
"def",
"walk",
"(",
"self",
",",
"oid",
",",
"host",
",",
"port",
",",
"community",
")",
":",
"# Initialize return value",
"ret",
"=",
"{",
"}",
"# Convert OID to tuple if necessary",
"if",
"not",
"isinstance",
"(",
"oid",
",",
"tuple",
")",
":",
"oid",
"=... | Perform an SNMP walk on a given OID | [
"Perform",
"an",
"SNMP",
"walk",
"on",
"a",
"given",
"OID"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/snmp/snmp.py#L111-L148 | train |
python-diamond/Diamond | src/collectors/diskusage/diskusage.py | DiskUsageCollector.get_disk_statistics | def get_disk_statistics(self):
"""
Create a map of disks in the machine.
http://www.kernel.org/doc/Documentation/iostats.txt
Returns:
(major, minor) -> DiskStatistics(device, ...)
"""
result = {}
if os.access('/proc/diskstats', os.R_OK):
s... | python | def get_disk_statistics(self):
"""
Create a map of disks in the machine.
http://www.kernel.org/doc/Documentation/iostats.txt
Returns:
(major, minor) -> DiskStatistics(device, ...)
"""
result = {}
if os.access('/proc/diskstats', os.R_OK):
s... | [
"def",
"get_disk_statistics",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"if",
"os",
".",
"access",
"(",
"'/proc/diskstats'",
",",
"os",
".",
"R_OK",
")",
":",
"self",
".",
"proc_diskstats",
"=",
"True",
"fp",
"=",
"open",
"(",
"'/proc/diskstats'",
... | Create a map of disks in the machine.
http://www.kernel.org/doc/Documentation/iostats.txt
Returns:
(major, minor) -> DiskStatistics(device, ...) | [
"Create",
"a",
"map",
"of",
"disks",
"in",
"the",
"machine",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/diskusage/diskusage.py#L72-L145 | train |
python-diamond/Diamond | src/diamond/handler/riemann.py | RiemannHandler.process | def process(self, metric):
"""
Send a metric to Riemann.
"""
event = self._metric_to_riemann_event(metric)
try:
self.client.send_event(event)
except Exception as e:
self.log.error(
"RiemannHandler: Error sending event to Riemann: %s... | python | def process(self, metric):
"""
Send a metric to Riemann.
"""
event = self._metric_to_riemann_event(metric)
try:
self.client.send_event(event)
except Exception as e:
self.log.error(
"RiemannHandler: Error sending event to Riemann: %s... | [
"def",
"process",
"(",
"self",
",",
"metric",
")",
":",
"event",
"=",
"self",
".",
"_metric_to_riemann_event",
"(",
"metric",
")",
"try",
":",
"self",
".",
"client",
".",
"send_event",
"(",
"event",
")",
"except",
"Exception",
"as",
"e",
":",
"self",
"... | Send a metric to Riemann. | [
"Send",
"a",
"metric",
"to",
"Riemann",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/riemann.py#L83-L92 | train |
python-diamond/Diamond | src/diamond/handler/riemann.py | RiemannHandler._metric_to_riemann_event | def _metric_to_riemann_event(self, metric):
"""
Convert a metric to a dictionary representing a Riemann event.
"""
# Riemann has a separate "host" field, so remove from the path.
path = '%s.%s.%s' % (
metric.getPathPrefix(),
metric.getCollectorPath(),
... | python | def _metric_to_riemann_event(self, metric):
"""
Convert a metric to a dictionary representing a Riemann event.
"""
# Riemann has a separate "host" field, so remove from the path.
path = '%s.%s.%s' % (
metric.getPathPrefix(),
metric.getCollectorPath(),
... | [
"def",
"_metric_to_riemann_event",
"(",
"self",
",",
"metric",
")",
":",
"# Riemann has a separate \"host\" field, so remove from the path.",
"path",
"=",
"'%s.%s.%s'",
"%",
"(",
"metric",
".",
"getPathPrefix",
"(",
")",
",",
"metric",
".",
"getCollectorPath",
"(",
")... | Convert a metric to a dictionary representing a Riemann event. | [
"Convert",
"a",
"metric",
"to",
"a",
"dictionary",
"representing",
"a",
"Riemann",
"event",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/riemann.py#L94-L111 | train |
python-diamond/Diamond | src/collectors/s3/s3.py | S3BucketCollector.collect | def collect(self):
"""
Collect s3 bucket stats
"""
if boto is None:
self.log.error("Unable to import boto python module")
return {}
for s3instance in self.config['s3']:
self.log.info("S3: byte_unit: %s" % self.config['byte_unit'])
a... | python | def collect(self):
"""
Collect s3 bucket stats
"""
if boto is None:
self.log.error("Unable to import boto python module")
return {}
for s3instance in self.config['s3']:
self.log.info("S3: byte_unit: %s" % self.config['byte_unit'])
a... | [
"def",
"collect",
"(",
"self",
")",
":",
"if",
"boto",
"is",
"None",
":",
"self",
".",
"log",
".",
"error",
"(",
"\"Unable to import boto python module\"",
")",
"return",
"{",
"}",
"for",
"s3instance",
"in",
"self",
".",
"config",
"[",
"'s3'",
"]",
":",
... | Collect s3 bucket stats | [
"Collect",
"s3",
"bucket",
"stats"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/s3/s3.py#L51-L74 | train |
python-diamond/Diamond | src/collectors/scribe/scribe.py | ScribeCollector.key_to_metric | def key_to_metric(self, key):
"""Replace all non-letter characters with underscores"""
return ''.join(l if l in string.letters else '_' for l in key) | python | def key_to_metric(self, key):
"""Replace all non-letter characters with underscores"""
return ''.join(l if l in string.letters else '_' for l in key) | [
"def",
"key_to_metric",
"(",
"self",
",",
"key",
")",
":",
"return",
"''",
".",
"join",
"(",
"l",
"if",
"l",
"in",
"string",
".",
"letters",
"else",
"'_'",
"for",
"l",
"in",
"key",
")"
] | Replace all non-letter characters with underscores | [
"Replace",
"all",
"non",
"-",
"letter",
"characters",
"with",
"underscores"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/scribe/scribe.py#L37-L39 | train |
python-diamond/Diamond | src/collectors/ipmisensor/ipmisensor.py | IPMISensorCollector.parse_value | def parse_value(self, value):
"""
Convert value string to float for reporting
"""
value = value.strip()
# Skip missing sensors
if value == 'na':
return None
# Try just getting the float value
try:
return float(value)
excep... | python | def parse_value(self, value):
"""
Convert value string to float for reporting
"""
value = value.strip()
# Skip missing sensors
if value == 'na':
return None
# Try just getting the float value
try:
return float(value)
excep... | [
"def",
"parse_value",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"# Skip missing sensors",
"if",
"value",
"==",
"'na'",
":",
"return",
"None",
"# Try just getting the float value",
"try",
":",
"return",
"float",
"(",
... | Convert value string to float for reporting | [
"Convert",
"value",
"string",
"to",
"float",
"for",
"reporting"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/ipmisensor/ipmisensor.py#L51-L74 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector.collect | def collect(self):
"""Collect statistics from a Nagios perfdata directory.
"""
perfdata_dir = self.config['perfdata_dir']
try:
filenames = os.listdir(perfdata_dir)
except OSError:
self.log.error("Cannot read directory `{dir}'".format(
dir=... | python | def collect(self):
"""Collect statistics from a Nagios perfdata directory.
"""
perfdata_dir = self.config['perfdata_dir']
try:
filenames = os.listdir(perfdata_dir)
except OSError:
self.log.error("Cannot read directory `{dir}'".format(
dir=... | [
"def",
"collect",
"(",
"self",
")",
":",
"perfdata_dir",
"=",
"self",
".",
"config",
"[",
"'perfdata_dir'",
"]",
"try",
":",
"filenames",
"=",
"os",
".",
"listdir",
"(",
"perfdata_dir",
")",
"except",
"OSError",
":",
"self",
".",
"log",
".",
"error",
"... | Collect statistics from a Nagios perfdata directory. | [
"Collect",
"statistics",
"from",
"a",
"Nagios",
"perfdata",
"directory",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L99-L112 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector._fields_valid | def _fields_valid(self, d):
"""Verify that all necessary fields are present
Determine whether the fields parsed represent a host or
service perfdata. If the perfdata is unknown, return False.
If the perfdata does not contain all fields required for that
type, return False. Other... | python | def _fields_valid(self, d):
"""Verify that all necessary fields are present
Determine whether the fields parsed represent a host or
service perfdata. If the perfdata is unknown, return False.
If the perfdata does not contain all fields required for that
type, return False. Other... | [
"def",
"_fields_valid",
"(",
"self",
",",
"d",
")",
":",
"if",
"'DATATYPE'",
"not",
"in",
"d",
":",
"return",
"False",
"datatype",
"=",
"d",
"[",
"'DATATYPE'",
"]",
"if",
"datatype",
"==",
"'HOSTPERFDATA'",
":",
"fields",
"=",
"self",
".",
"GENERIC_FIELD... | Verify that all necessary fields are present
Determine whether the fields parsed represent a host or
service perfdata. If the perfdata is unknown, return False.
If the perfdata does not contain all fields required for that
type, return False. Otherwise, return True. | [
"Verify",
"that",
"all",
"necessary",
"fields",
"are",
"present"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L127-L150 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector._normalize_to_unit | def _normalize_to_unit(self, value, unit):
"""Normalize the value to the unit returned.
We use base-1000 for second-based units, and base-1024 for
byte-based units. Sadly, the Nagios-Plugins specification doesn't
disambiguate base-1000 (KB) and base-1024 (KiB).
"""
if un... | python | def _normalize_to_unit(self, value, unit):
"""Normalize the value to the unit returned.
We use base-1000 for second-based units, and base-1024 for
byte-based units. Sadly, the Nagios-Plugins specification doesn't
disambiguate base-1000 (KB) and base-1024 (KiB).
"""
if un... | [
"def",
"_normalize_to_unit",
"(",
"self",
",",
"value",
",",
"unit",
")",
":",
"if",
"unit",
"==",
"'ms'",
":",
"return",
"value",
"/",
"1000.0",
"if",
"unit",
"==",
"'us'",
":",
"return",
"value",
"/",
"1000000.0",
"if",
"unit",
"==",
"'KB'",
":",
"... | Normalize the value to the unit returned.
We use base-1000 for second-based units, and base-1024 for
byte-based units. Sadly, the Nagios-Plugins specification doesn't
disambiguate base-1000 (KB) and base-1024 (KiB). | [
"Normalize",
"the",
"value",
"to",
"the",
"unit",
"returned",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L152-L172 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector._parse_perfdata | def _parse_perfdata(self, s):
"""Parse performance data from a perfdata string
"""
metrics = []
counters = re.findall(self.TOKENIZER_RE, s)
if counters is None:
self.log.warning("Failed to parse performance data: {s}".format(
s=s))
return m... | python | def _parse_perfdata(self, s):
"""Parse performance data from a perfdata string
"""
metrics = []
counters = re.findall(self.TOKENIZER_RE, s)
if counters is None:
self.log.warning("Failed to parse performance data: {s}".format(
s=s))
return m... | [
"def",
"_parse_perfdata",
"(",
"self",
",",
"s",
")",
":",
"metrics",
"=",
"[",
"]",
"counters",
"=",
"re",
".",
"findall",
"(",
"self",
".",
"TOKENIZER_RE",
",",
"s",
")",
"if",
"counters",
"is",
"None",
":",
"self",
".",
"log",
".",
"warning",
"(... | Parse performance data from a perfdata string | [
"Parse",
"performance",
"data",
"from",
"a",
"perfdata",
"string"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L174-L193 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector._process_file | def _process_file(self, path):
"""Parse and submit the metrics from a file
"""
try:
f = open(path)
for line in f:
self._process_line(line)
os.remove(path)
except IOError as ex:
self.log.error("Could not open file `{path}': ... | python | def _process_file(self, path):
"""Parse and submit the metrics from a file
"""
try:
f = open(path)
for line in f:
self._process_line(line)
os.remove(path)
except IOError as ex:
self.log.error("Could not open file `{path}': ... | [
"def",
"_process_file",
"(",
"self",
",",
"path",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"path",
")",
"for",
"line",
"in",
"f",
":",
"self",
".",
"_process_line",
"(",
"line",
")",
"os",
".",
"remove",
"(",
"path",
")",
"except",
"IOError",
... | Parse and submit the metrics from a file | [
"Parse",
"and",
"submit",
"the",
"metrics",
"from",
"a",
"file"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L195-L206 | train |
python-diamond/Diamond | src/collectors/nagiosperfdata/nagiosperfdata.py | NagiosPerfdataCollector._process_line | def _process_line(self, line):
"""Parse and submit the metrics from a line of perfdata output
"""
fields = self._extract_fields(line)
if not self._fields_valid(fields):
self.log.warning("Missing required fields for line: {line}".format(
line=line))
me... | python | def _process_line(self, line):
"""Parse and submit the metrics from a line of perfdata output
"""
fields = self._extract_fields(line)
if not self._fields_valid(fields):
self.log.warning("Missing required fields for line: {line}".format(
line=line))
me... | [
"def",
"_process_line",
"(",
"self",
",",
"line",
")",
":",
"fields",
"=",
"self",
".",
"_extract_fields",
"(",
"line",
")",
"if",
"not",
"self",
".",
"_fields_valid",
"(",
"fields",
")",
":",
"self",
".",
"log",
".",
"warning",
"(",
"\"Missing required ... | Parse and submit the metrics from a line of perfdata output | [
"Parse",
"and",
"submit",
"the",
"metrics",
"from",
"a",
"line",
"of",
"perfdata",
"output"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/nagiosperfdata/nagiosperfdata.py#L208-L244 | train |
python-diamond/Diamond | src/diamond/handler/rabbitmq_topic.py | rmqHandler._bind | def _bind(self):
"""
Create socket and bind
"""
credentials = pika.PlainCredentials(self.user, self.password)
params = pika.ConnectionParameters(credentials=credentials,
host=self.server,
v... | python | def _bind(self):
"""
Create socket and bind
"""
credentials = pika.PlainCredentials(self.user, self.password)
params = pika.ConnectionParameters(credentials=credentials,
host=self.server,
v... | [
"def",
"_bind",
"(",
"self",
")",
":",
"credentials",
"=",
"pika",
".",
"PlainCredentials",
"(",
"self",
".",
"user",
",",
"self",
".",
"password",
")",
"params",
"=",
"pika",
".",
"ConnectionParameters",
"(",
"credentials",
"=",
"credentials",
",",
"host"... | Create socket and bind | [
"Create",
"socket",
"and",
"bind"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_topic.py#L95-L112 | train |
python-diamond/Diamond | src/diamond/handler/rabbitmq_topic.py | rmqHandler.process | def process(self, metric):
"""
Process a metric and send it to RabbitMQ topic exchange
"""
# Send the data as ......
if not pika:
return
routingKeyDic = {
'metric': lambda: metric.path,
'custom': lambda: self.custom_routing_key,
... | python | def process(self, metric):
"""
Process a metric and send it to RabbitMQ topic exchange
"""
# Send the data as ......
if not pika:
return
routingKeyDic = {
'metric': lambda: metric.path,
'custom': lambda: self.custom_routing_key,
... | [
"def",
"process",
"(",
"self",
",",
"metric",
")",
":",
"# Send the data as ......",
"if",
"not",
"pika",
":",
"return",
"routingKeyDic",
"=",
"{",
"'metric'",
":",
"lambda",
":",
"metric",
".",
"path",
",",
"'custom'",
":",
"lambda",
":",
"self",
".",
"... | Process a metric and send it to RabbitMQ topic exchange | [
"Process",
"a",
"metric",
"and",
"send",
"it",
"to",
"RabbitMQ",
"topic",
"exchange"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/diamond/handler/rabbitmq_topic.py#L123-L155 | train |
python-diamond/Diamond | src/collectors/pgq/pgq.py | PgQCollector._collect_for_instance | def _collect_for_instance(self, instance, connection):
"""Collects metrics for a named connection."""
with connection.cursor() as cursor:
for queue, metrics in self.get_queue_info(instance, cursor):
for name, metric in metrics.items():
self.publish('.'.joi... | python | def _collect_for_instance(self, instance, connection):
"""Collects metrics for a named connection."""
with connection.cursor() as cursor:
for queue, metrics in self.get_queue_info(instance, cursor):
for name, metric in metrics.items():
self.publish('.'.joi... | [
"def",
"_collect_for_instance",
"(",
"self",
",",
"instance",
",",
"connection",
")",
":",
"with",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"for",
"queue",
",",
"metrics",
"in",
"self",
".",
"get_queue_info",
"(",
"instance",
",",
"curso... | Collects metrics for a named connection. | [
"Collects",
"metrics",
"for",
"a",
"named",
"connection",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L62-L74 | train |
python-diamond/Diamond | src/collectors/pgq/pgq.py | PgQCollector.get_queue_info | def get_queue_info(self, instance, cursor):
"""Collects metrics for all queues on the connected database."""
cursor.execute(self.QUEUE_INFO_STATEMENT)
for queue_name, ticker_lag, ev_per_sec in cursor:
yield queue_name, {
'ticker_lag': ticker_lag,
'ev_p... | python | def get_queue_info(self, instance, cursor):
"""Collects metrics for all queues on the connected database."""
cursor.execute(self.QUEUE_INFO_STATEMENT)
for queue_name, ticker_lag, ev_per_sec in cursor:
yield queue_name, {
'ticker_lag': ticker_lag,
'ev_p... | [
"def",
"get_queue_info",
"(",
"self",
",",
"instance",
",",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"self",
".",
"QUEUE_INFO_STATEMENT",
")",
"for",
"queue_name",
",",
"ticker_lag",
",",
"ev_per_sec",
"in",
"cursor",
":",
"yield",
"queue_name",
",... | Collects metrics for all queues on the connected database. | [
"Collects",
"metrics",
"for",
"all",
"queues",
"on",
"the",
"connected",
"database",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L84-L91 | train |
python-diamond/Diamond | src/collectors/pgq/pgq.py | PgQCollector.get_consumer_info | def get_consumer_info(self, instance, cursor):
"""Collects metrics for all consumers on the connected database."""
cursor.execute(self.CONSUMER_INFO_STATEMENT)
for queue_name, consumer_name, lag, pending_events, last_seen in cursor:
yield queue_name, consumer_name, {
... | python | def get_consumer_info(self, instance, cursor):
"""Collects metrics for all consumers on the connected database."""
cursor.execute(self.CONSUMER_INFO_STATEMENT)
for queue_name, consumer_name, lag, pending_events, last_seen in cursor:
yield queue_name, consumer_name, {
... | [
"def",
"get_consumer_info",
"(",
"self",
",",
"instance",
",",
"cursor",
")",
":",
"cursor",
".",
"execute",
"(",
"self",
".",
"CONSUMER_INFO_STATEMENT",
")",
"for",
"queue_name",
",",
"consumer_name",
",",
"lag",
",",
"pending_events",
",",
"last_seen",
"in",... | Collects metrics for all consumers on the connected database. | [
"Collects",
"metrics",
"for",
"all",
"consumers",
"on",
"the",
"connected",
"database",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/pgq/pgq.py#L103-L111 | train |
python-diamond/Diamond | src/collectors/mdstat/mdstat.py | MdStatCollector.collect | def collect(self):
"""Publish all mdstat metrics."""
def traverse(d, metric_name=''):
"""
Traverse the given nested dict using depth-first search.
If a value is reached it will be published with a metric name
consisting of the hierarchically concatenated ... | python | def collect(self):
"""Publish all mdstat metrics."""
def traverse(d, metric_name=''):
"""
Traverse the given nested dict using depth-first search.
If a value is reached it will be published with a metric name
consisting of the hierarchically concatenated ... | [
"def",
"collect",
"(",
"self",
")",
":",
"def",
"traverse",
"(",
"d",
",",
"metric_name",
"=",
"''",
")",
":",
"\"\"\"\n Traverse the given nested dict using depth-first search.\n\n If a value is reached it will be published with a metric name\n consi... | Publish all mdstat metrics. | [
"Publish",
"all",
"mdstat",
"metrics",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L70-L97 | train |
python-diamond/Diamond | src/collectors/mdstat/mdstat.py | MdStatCollector._parse_array_member_state | def _parse_array_member_state(self, block):
"""
Parse the state of the the md array members.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
... | python | def _parse_array_member_state(self, block):
"""
Parse the state of the the md array members.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
... | [
"def",
"_parse_array_member_state",
"(",
"self",
",",
"block",
")",
":",
"members",
"=",
"block",
".",
"split",
"(",
"'\\n'",
")",
"[",
"0",
"]",
".",
"split",
"(",
"' : '",
")",
"[",
"1",
"]",
".",
"split",
"(",
"' '",
")",
"[",
"2",
":",
"]",
... | Parse the state of the the md array members.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>> print _parse_array_member_state(block)
{
... | [
"Parse",
"the",
"state",
"of",
"the",
"the",
"md",
"array",
"members",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L176-L216 | train |
python-diamond/Diamond | src/collectors/mdstat/mdstat.py | MdStatCollector._parse_array_status | def _parse_array_status(self, block):
"""
Parse the status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>> print ... | python | def _parse_array_status(self, block):
"""
Parse the status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>> print ... | [
"def",
"_parse_array_status",
"(",
"self",
",",
"block",
")",
":",
"array_status_regexp",
"=",
"re",
".",
"compile",
"(",
"'^ *(?P<blocks>\\d*) blocks '",
"'(?:super (?P<superblock_version>\\d\\.\\d) )?'",
"'(?:level (?P<raid_level>\\d), '",
"'(?P<chunk_size>\\d*)k chunk, '",
"'a... | Parse the status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>> print _parse_array_status(block)
{
'total_me... | [
"Parse",
"the",
"status",
"of",
"the",
"md",
"array",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L218-L268 | train |
python-diamond/Diamond | src/collectors/mdstat/mdstat.py | MdStatCollector._parse_array_bitmap | def _parse_array_bitmap(self, block):
"""
Parse the bitmap status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>>... | python | def _parse_array_bitmap(self, block):
"""
Parse the bitmap status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>>... | [
"def",
"_parse_array_bitmap",
"(",
"self",
",",
"block",
")",
":",
"array_bitmap_regexp",
"=",
"re",
".",
"compile",
"(",
"'^ *bitmap: (?P<allocated_pages>[0-9]*)/'",
"'(?P<total_pages>[0-9]*) pages '",
"'\\[(?P<page_size>[0-9]*)KB\\], '",
"'(?P<chunk_size>[0-9]*)KB chunk.*$'",
"... | Parse the bitmap status of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' bitmap: 1/1 pages [4KB], 65536KB chunk\n\n'
>>> print _parse_array_bitmap(block)
{
't... | [
"Parse",
"the",
"bitmap",
"status",
"of",
"the",
"md",
"array",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L270-L317 | train |
python-diamond/Diamond | src/collectors/mdstat/mdstat.py | MdStatCollector._parse_array_recovery | def _parse_array_recovery(self, block):
"""
Parse the recovery progress of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' [===================>.] recovery = 99.5% '
... | python | def _parse_array_recovery(self, block):
"""
Parse the recovery progress of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' [===================>.] recovery = 99.5% '
... | [
"def",
"_parse_array_recovery",
"(",
"self",
",",
"block",
")",
":",
"array_recovery_regexp",
"=",
"re",
".",
"compile",
"(",
"'^ *\\[.*\\] *recovery = (?P<percent>\\d*\\.?\\d*)%'",
"' \\(\\d*/\\d*\\) finish=(?P<remaining_time>\\d*\\.?\\d*)min '",
"'speed=(?P<speed>\\d*)K/sec$'",
"... | Parse the recovery progress of the md array.
>>> block = 'md0 : active raid1 sdd2[0] sdb2[2](S) sdc2[1]\n'
>>> ' 100171776 blocks super 1.2 [2/2] [UU]\n'
>>> ' [===================>.] recovery = 99.5% '
>>> '(102272/102272) finish=13.37min speed=102272... | [
"Parse",
"the",
"recovery",
"progress",
"of",
"the",
"md",
"array",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/mdstat/mdstat.py#L319-L364 | train |
python-diamond/Diamond | src/collectors/passenger_stats/passenger_stats.py | PassengerCollector.get_passenger_memory_stats | def get_passenger_memory_stats(self):
"""
Execute passenger-memory-stats, parse its output, return dictionary with
stats.
"""
command = [self.config["passenger_memory_stats_bin"]]
if str_to_bool(self.config["use_sudo"]):
command.insert(0, self.config["sudo_cmd... | python | def get_passenger_memory_stats(self):
"""
Execute passenger-memory-stats, parse its output, return dictionary with
stats.
"""
command = [self.config["passenger_memory_stats_bin"]]
if str_to_bool(self.config["use_sudo"]):
command.insert(0, self.config["sudo_cmd... | [
"def",
"get_passenger_memory_stats",
"(",
"self",
")",
":",
"command",
"=",
"[",
"self",
".",
"config",
"[",
"\"passenger_memory_stats_bin\"",
"]",
"]",
"if",
"str_to_bool",
"(",
"self",
".",
"config",
"[",
"\"use_sudo\"",
"]",
")",
":",
"command",
".",
"ins... | Execute passenger-memory-stats, parse its output, return dictionary with
stats. | [
"Execute",
"passenger",
"-",
"memory",
"-",
"stats",
"parse",
"its",
"output",
"return",
"dictionary",
"with",
"stats",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L69-L128 | train |
python-diamond/Diamond | src/collectors/passenger_stats/passenger_stats.py | PassengerCollector.get_passenger_cpu_usage | def get_passenger_cpu_usage(self, dict_stats):
"""
Execute % top; and return STDOUT.
"""
try:
proc1 = subprocess.Popen(
["top", "-b", "-n", "2"],
stdout=subprocess.PIPE)
(std_out, std_err) = proc1.communicate()
except OSErro... | python | def get_passenger_cpu_usage(self, dict_stats):
"""
Execute % top; and return STDOUT.
"""
try:
proc1 = subprocess.Popen(
["top", "-b", "-n", "2"],
stdout=subprocess.PIPE)
(std_out, std_err) = proc1.communicate()
except OSErro... | [
"def",
"get_passenger_cpu_usage",
"(",
"self",
",",
"dict_stats",
")",
":",
"try",
":",
"proc1",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"\"top\"",
",",
"\"-b\"",
",",
"\"-n\"",
",",
"\"2\"",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
... | Execute % top; and return STDOUT. | [
"Execute",
"%",
"top",
";",
"and",
"return",
"STDOUT",
"."
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L130-L158 | train |
python-diamond/Diamond | src/collectors/passenger_stats/passenger_stats.py | PassengerCollector.get_passenger_queue_stats | def get_passenger_queue_stats(self):
"""
Execute passenger-stats, parse its output, returnand requests in queue
"""
queue_stats = {
"top_level_queue_size": 0.0,
"passenger_queue_size": 0.0,
}
command = [self.config["passenger_status_bin"]]
... | python | def get_passenger_queue_stats(self):
"""
Execute passenger-stats, parse its output, returnand requests in queue
"""
queue_stats = {
"top_level_queue_size": 0.0,
"passenger_queue_size": 0.0,
}
command = [self.config["passenger_status_bin"]]
... | [
"def",
"get_passenger_queue_stats",
"(",
"self",
")",
":",
"queue_stats",
"=",
"{",
"\"top_level_queue_size\"",
":",
"0.0",
",",
"\"passenger_queue_size\"",
":",
"0.0",
",",
"}",
"command",
"=",
"[",
"self",
".",
"config",
"[",
"\"passenger_status_bin\"",
"]",
"... | Execute passenger-stats, parse its output, returnand requests in queue | [
"Execute",
"passenger",
"-",
"stats",
"parse",
"its",
"output",
"returnand",
"requests",
"in",
"queue"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L160-L209 | train |
python-diamond/Diamond | src/collectors/passenger_stats/passenger_stats.py | PassengerCollector.collect | def collect(self):
"""
Collector Passenger stats
"""
if not os.access(self.config["bin"], os.X_OK):
self.log.error("Path %s does not exist or is not executable",
self.config["bin"])
return {}
dict_stats = self.get_passenger_memo... | python | def collect(self):
"""
Collector Passenger stats
"""
if not os.access(self.config["bin"], os.X_OK):
self.log.error("Path %s does not exist or is not executable",
self.config["bin"])
return {}
dict_stats = self.get_passenger_memo... | [
"def",
"collect",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"access",
"(",
"self",
".",
"config",
"[",
"\"bin\"",
"]",
",",
"os",
".",
"X_OK",
")",
":",
"self",
".",
"log",
".",
"error",
"(",
"\"Path %s does not exist or is not executable\"",
",",
... | Collector Passenger stats | [
"Collector",
"Passenger",
"stats"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/passenger_stats/passenger_stats.py#L211-L243 | train |
python-diamond/Diamond | src/collectors/haproxy/haproxy.py | HAProxyCollector._collect | def _collect(self, section=None):
"""
Collect HAProxy Stats
"""
if self.config['method'] == 'http':
csv_data = self.http_get_csv_data(section)
elif self.config['method'] == 'unix':
csv_data = self.unix_get_csv_data()
else:
self.log.erro... | python | def _collect(self, section=None):
"""
Collect HAProxy Stats
"""
if self.config['method'] == 'http':
csv_data = self.http_get_csv_data(section)
elif self.config['method'] == 'unix':
csv_data = self.unix_get_csv_data()
else:
self.log.erro... | [
"def",
"_collect",
"(",
"self",
",",
"section",
"=",
"None",
")",
":",
"if",
"self",
".",
"config",
"[",
"'method'",
"]",
"==",
"'http'",
":",
"csv_data",
"=",
"self",
".",
"http_get_csv_data",
"(",
"section",
")",
"elif",
"self",
".",
"config",
"[",
... | Collect HAProxy Stats | [
"Collect",
"HAProxy",
"Stats"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/haproxy/haproxy.py#L137-L170 | train |
python-diamond/Diamond | src/collectors/processresources/processresources.py | match_process | def match_process(pid, name, cmdline, exe, cfg):
"""
Decides whether a process matches with a given process descriptor
:param pid: process pid
:param exe: process executable
:param name: process name
:param cmdline: process cmdline
:param cfg: the dictionary from processes that describes wi... | python | def match_process(pid, name, cmdline, exe, cfg):
"""
Decides whether a process matches with a given process descriptor
:param pid: process pid
:param exe: process executable
:param name: process name
:param cmdline: process cmdline
:param cfg: the dictionary from processes that describes wi... | [
"def",
"match_process",
"(",
"pid",
",",
"name",
",",
"cmdline",
",",
"exe",
",",
"cfg",
")",
":",
"if",
"cfg",
"[",
"'selfmon'",
"]",
"and",
"pid",
"==",
"os",
".",
"getpid",
"(",
")",
":",
"return",
"True",
"for",
"exe_re",
"in",
"cfg",
"[",
"'... | Decides whether a process matches with a given process descriptor
:param pid: process pid
:param exe: process executable
:param name: process name
:param cmdline: process cmdline
:param cfg: the dictionary from processes that describes with the
process group we're testing for
:return: T... | [
"Decides",
"whether",
"a",
"process",
"matches",
"with",
"a",
"given",
"process",
"descriptor"
] | 0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47 | https://github.com/python-diamond/Diamond/blob/0f3eb04327d6d3ed5e53a9967d6c9d2c09714a47/src/collectors/processresources/processresources.py#L49-L73 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.