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
diux-dev/ncluster
ncluster/local_backend.py
Run.run_with_output
def run_with_output(self, *args, **kwargs): """Runs command on every first job in the run, returns stdout.""" for job in self.jobs: job.run_with_output(*args, **kwargs)
python
def run_with_output(self, *args, **kwargs): """Runs command on every first job in the run, returns stdout.""" for job in self.jobs: job.run_with_output(*args, **kwargs)
[ "def", "run_with_output", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "job", "in", "self", ".", "jobs", ":", "job", ".", "run_with_output", "(", "*", "args", ",", "**", "kwargs", ")" ]
Runs command on every first job in the run, returns stdout.
[ "Runs", "command", "on", "every", "first", "job", "in", "the", "run", "returns", "stdout", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/local_backend.py#L428-L431
train
diux-dev/ncluster
ncluster/local_backend.py
Run._run_raw
def _run_raw(self, *args, **kwargs): """_run_raw on every job in the run.""" for job in self.jobs: job._run_raw(*args, **kwargs)
python
def _run_raw(self, *args, **kwargs): """_run_raw on every job in the run.""" for job in self.jobs: job._run_raw(*args, **kwargs)
[ "def", "_run_raw", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "for", "job", "in", "self", ".", "jobs", ":", "job", ".", "_run_raw", "(", "*", "args", ",", "**", "kwargs", ")" ]
_run_raw on every job in the run.
[ "_run_raw", "on", "every", "job", "in", "the", "run", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/local_backend.py#L433-L436
train
diux-dev/ncluster
ncluster/aws_create_resources.py
keypair_setup
def keypair_setup(): """Creates keypair if necessary, saves private key locally, returns contents of private key file.""" os.system('mkdir -p ' + u.PRIVATE_KEY_LOCATION) keypair_name = u.get_keypair_name() keypair = u.get_keypair_dict().get(keypair_name, None) keypair_fn = u.get_keypair_fn() if keypair:...
python
def keypair_setup(): """Creates keypair if necessary, saves private key locally, returns contents of private key file.""" os.system('mkdir -p ' + u.PRIVATE_KEY_LOCATION) keypair_name = u.get_keypair_name() keypair = u.get_keypair_dict().get(keypair_name, None) keypair_fn = u.get_keypair_fn() if keypair:...
[ "def", "keypair_setup", "(", ")", ":", "os", ".", "system", "(", "'mkdir -p '", "+", "u", ".", "PRIVATE_KEY_LOCATION", ")", "keypair_name", "=", "u", ".", "get_keypair_name", "(", ")", "keypair", "=", "u", ".", "get_keypair_dict", "(", ")", ".", "get", "...
Creates keypair if necessary, saves private key locally, returns contents of private key file.
[ "Creates", "keypair", "if", "necessary", "saves", "private", "key", "locally", "returns", "contents", "of", "private", "key", "file", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_create_resources.py#L226-L254
train
diux-dev/ncluster
ncluster/aws_create_resources.py
placement_group_setup
def placement_group_setup(group_name): """Creates placement_group group if necessary. Returns True if new placement_group group was created, False otherwise.""" existing_placement_groups = u.get_placement_group_dict() group = existing_placement_groups.get(group_name, None) if group: assert group.state =...
python
def placement_group_setup(group_name): """Creates placement_group group if necessary. Returns True if new placement_group group was created, False otherwise.""" existing_placement_groups = u.get_placement_group_dict() group = existing_placement_groups.get(group_name, None) if group: assert group.state =...
[ "def", "placement_group_setup", "(", "group_name", ")", ":", "existing_placement_groups", "=", "u", ".", "get_placement_group_dict", "(", ")", "group", "=", "existing_placement_groups", ".", "get", "(", "group_name", ",", "None", ")", "if", "group", ":", "assert",...
Creates placement_group group if necessary. Returns True if new placement_group group was created, False otherwise.
[ "Creates", "placement_group", "group", "if", "necessary", ".", "Returns", "True", "if", "new", "placement_group", "group", "was", "created", "False", "otherwise", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_create_resources.py#L257-L273
train
diux-dev/ncluster
ncluster/backend.py
Task.upload
def upload(self, local_fn: str, remote_fn: str = '', dont_overwrite: bool = False): """Uploads given file to the task. If remote_fn is not specified, dumps it into task current directory with the same name. Args: local_fn: location of file locally remote_fn: location of file on tas...
python
def upload(self, local_fn: str, remote_fn: str = '', dont_overwrite: bool = False): """Uploads given file to the task. If remote_fn is not specified, dumps it into task current directory with the same name. Args: local_fn: location of file locally remote_fn: location of file on tas...
[ "def", "upload", "(", "self", ",", "local_fn", ":", "str", ",", "remote_fn", ":", "str", "=", "''", ",", "dont_overwrite", ":", "bool", "=", "False", ")", ":", "raise", "NotImplementedError", "(", ")" ]
Uploads given file to the task. If remote_fn is not specified, dumps it into task current directory with the same name. Args: local_fn: location of file locally remote_fn: location of file on task dont_overwrite: if True, will be no-op if target file exists
[ "Uploads", "given", "file", "to", "the", "task", ".", "If", "remote_fn", "is", "not", "specified", "dumps", "it", "into", "task", "current", "directory", "with", "the", "same", "name", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/backend.py#L139-L149
train
diux-dev/ncluster
ncluster/backend.py
Job._non_blocking_wrapper
def _non_blocking_wrapper(self, method, *args, **kwargs): """Runs given method on every task in the job. Blocks until all tasks finish. Propagates exception from first failed task.""" exceptions = [] def task_run(task): try: getattr(task, method)(*args, **kwargs) except Exception a...
python
def _non_blocking_wrapper(self, method, *args, **kwargs): """Runs given method on every task in the job. Blocks until all tasks finish. Propagates exception from first failed task.""" exceptions = [] def task_run(task): try: getattr(task, method)(*args, **kwargs) except Exception a...
[ "def", "_non_blocking_wrapper", "(", "self", ",", "method", ",", "*", "args", ",", "**", "kwargs", ")", ":", "exceptions", "=", "[", "]", "def", "task_run", "(", "task", ")", ":", "try", ":", "getattr", "(", "task", ",", "method", ")", "(", "*", "a...
Runs given method on every task in the job. Blocks until all tasks finish. Propagates exception from first failed task.
[ "Runs", "given", "method", "on", "every", "task", "in", "the", "job", ".", "Blocks", "until", "all", "tasks", "finish", ".", "Propagates", "exception", "from", "first", "failed", "task", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/backend.py#L202-L222
train
diux-dev/ncluster
ncluster/aws_util.py
get_default_vpc
def get_default_vpc(): """ Return default VPC or none if not present """ ec2 = get_ec2_resource() for vpc in ec2.vpcs.all(): if vpc.is_default: return vpc
python
def get_default_vpc(): """ Return default VPC or none if not present """ ec2 = get_ec2_resource() for vpc in ec2.vpcs.all(): if vpc.is_default: return vpc
[ "def", "get_default_vpc", "(", ")", ":", "ec2", "=", "get_ec2_resource", "(", ")", "for", "vpc", "in", "ec2", ".", "vpcs", ".", "all", "(", ")", ":", "if", "vpc", ".", "is_default", ":", "return", "vpc" ]
Return default VPC or none if not present
[ "Return", "default", "VPC", "or", "none", "if", "not", "present" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L75-L83
train
diux-dev/ncluster
ncluster/aws_util.py
get_subnet_dict
def get_subnet_dict(): """Returns dictionary of "availability zone" -> subnet for current VPC.""" subnet_dict = {} vpc = get_vpc() for subnet in vpc.subnets.all(): zone = subnet.availability_zone assert zone not in subnet_dict, "More than one subnet in %s, why?" % (zone,) subnet_dict[zone] = subnet ...
python
def get_subnet_dict(): """Returns dictionary of "availability zone" -> subnet for current VPC.""" subnet_dict = {} vpc = get_vpc() for subnet in vpc.subnets.all(): zone = subnet.availability_zone assert zone not in subnet_dict, "More than one subnet in %s, why?" % (zone,) subnet_dict[zone] = subnet ...
[ "def", "get_subnet_dict", "(", ")", ":", "subnet_dict", "=", "{", "}", "vpc", "=", "get_vpc", "(", ")", "for", "subnet", "in", "vpc", ".", "subnets", ".", "all", "(", ")", ":", "zone", "=", "subnet", ".", "availability_zone", "assert", "zone", "not", ...
Returns dictionary of "availability zone" -> subnet for current VPC.
[ "Returns", "dictionary", "of", "availability", "zone", "-", ">", "subnet", "for", "current", "VPC", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L86-L94
train
diux-dev/ncluster
ncluster/aws_util.py
get_keypair_name
def get_keypair_name(): """Returns current keypair name.""" username = get_username() assert '-' not in username, "username must not contain -, change $USER" validate_aws_name(username) assert len(username) < 30 # to avoid exceeding AWS 127 char limit return get_prefix() + '-' + username
python
def get_keypair_name(): """Returns current keypair name.""" username = get_username() assert '-' not in username, "username must not contain -, change $USER" validate_aws_name(username) assert len(username) < 30 # to avoid exceeding AWS 127 char limit return get_prefix() + '-' + username
[ "def", "get_keypair_name", "(", ")", ":", "username", "=", "get_username", "(", ")", "assert", "'-'", "not", "in", "username", ",", "\"username must not contain -, change $USER\"", "validate_aws_name", "(", "username", ")", "assert", "len", "(", "username", ")", "...
Returns current keypair name.
[ "Returns", "current", "keypair", "name", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L247-L254
train
diux-dev/ncluster
ncluster/aws_util.py
get_keypair_fn
def get_keypair_fn(): """Location of .pem file for current keypair""" keypair_name = get_keypair_name() account = get_account_number() region = get_region() fn = f'{PRIVATE_KEY_LOCATION}/{keypair_name}-{account}-{region}.pem' return fn
python
def get_keypair_fn(): """Location of .pem file for current keypair""" keypair_name = get_keypair_name() account = get_account_number() region = get_region() fn = f'{PRIVATE_KEY_LOCATION}/{keypair_name}-{account}-{region}.pem' return fn
[ "def", "get_keypair_fn", "(", ")", ":", "keypair_name", "=", "get_keypair_name", "(", ")", "account", "=", "get_account_number", "(", ")", "region", "=", "get_region", "(", ")", "fn", "=", "f'{PRIVATE_KEY_LOCATION}/{keypair_name}-{account}-{region}.pem'", "return", "f...
Location of .pem file for current keypair
[ "Location", "of", ".", "pem", "file", "for", "current", "keypair" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L266-L273
train
diux-dev/ncluster
ncluster/aws_util.py
lookup_instance
def lookup_instance(name: str, instance_type: str = '', image_name: str = '', states: tuple = ('running', 'stopped', 'initializing')): """Looks up AWS instance for given instance name, like simple.worker. If no instance found in current AWS environment, returns None. """ ec2 = get_ec2_resour...
python
def lookup_instance(name: str, instance_type: str = '', image_name: str = '', states: tuple = ('running', 'stopped', 'initializing')): """Looks up AWS instance for given instance name, like simple.worker. If no instance found in current AWS environment, returns None. """ ec2 = get_ec2_resour...
[ "def", "lookup_instance", "(", "name", ":", "str", ",", "instance_type", ":", "str", "=", "''", ",", "image_name", ":", "str", "=", "''", ",", "states", ":", "tuple", "=", "(", "'running'", ",", "'stopped'", ",", "'initializing'", ")", ")", ":", "ec2",...
Looks up AWS instance for given instance name, like simple.worker. If no instance found in current AWS environment, returns None.
[ "Looks", "up", "AWS", "instance", "for", "given", "instance", "name", "like", "simple", ".", "worker", ".", "If", "no", "instance", "found", "in", "current", "AWS", "environment", "returns", "None", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L326-L366
train
diux-dev/ncluster
ncluster/aws_util.py
ssh_to_task
def ssh_to_task(task) -> paramiko.SSHClient: """Create ssh connection to task's machine returns Paramiko SSH client connected to host. """ username = task.ssh_username hostname = task.public_ip ssh_key_fn = get_keypair_fn() print(f"ssh -i {ssh_key_fn} {username}@{hostname}") pkey = paramiko.RSAKey.fr...
python
def ssh_to_task(task) -> paramiko.SSHClient: """Create ssh connection to task's machine returns Paramiko SSH client connected to host. """ username = task.ssh_username hostname = task.public_ip ssh_key_fn = get_keypair_fn() print(f"ssh -i {ssh_key_fn} {username}@{hostname}") pkey = paramiko.RSAKey.fr...
[ "def", "ssh_to_task", "(", "task", ")", "->", "paramiko", ".", "SSHClient", ":", "username", "=", "task", ".", "ssh_username", "hostname", "=", "task", ".", "public_ip", "ssh_key_fn", "=", "get_keypair_fn", "(", ")", "print", "(", "f\"ssh -i {ssh_key_fn} {userna...
Create ssh connection to task's machine returns Paramiko SSH client connected to host.
[ "Create", "ssh", "connection", "to", "task", "s", "machine" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L369-L398
train
diux-dev/ncluster
ncluster/aws_util.py
delete_efs_by_id
def delete_efs_by_id(efs_id): """Deletion sometimes fails, try several times.""" start_time = time.time() efs_client = get_efs_client() sys.stdout.write("deleting %s ... " % (efs_id,)) while True: try: response = efs_client.delete_file_system(FileSystemId=efs_id) if is_good_response(response):...
python
def delete_efs_by_id(efs_id): """Deletion sometimes fails, try several times.""" start_time = time.time() efs_client = get_efs_client() sys.stdout.write("deleting %s ... " % (efs_id,)) while True: try: response = efs_client.delete_file_system(FileSystemId=efs_id) if is_good_response(response):...
[ "def", "delete_efs_by_id", "(", "efs_id", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "efs_client", "=", "get_efs_client", "(", ")", "sys", ".", "stdout", ".", "write", "(", "\"deleting %s ... \"", "%", "(", "efs_id", ",", ")", ")", "whil...
Deletion sometimes fails, try several times.
[ "Deletion", "sometimes", "fails", "try", "several", "times", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L488-L507
train
diux-dev/ncluster
ncluster/aws_util.py
extract_attr_for_match
def extract_attr_for_match(items, **kwargs): """Helper method to get attribute value for an item matching some criterion. Specify target criteria value as dict, with target attribute having value -1 Example: to extract state of vpc matching given vpc id response = [{'State': 'available', 'VpcId': 'vpc-2bb...
python
def extract_attr_for_match(items, **kwargs): """Helper method to get attribute value for an item matching some criterion. Specify target criteria value as dict, with target attribute having value -1 Example: to extract state of vpc matching given vpc id response = [{'State': 'available', 'VpcId': 'vpc-2bb...
[ "def", "extract_attr_for_match", "(", "items", ",", "**", "kwargs", ")", ":", "query_arg", "=", "None", "for", "arg", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "value", "==", "-", "1", ":", "assert", "query_arg", "is", "None", ...
Helper method to get attribute value for an item matching some criterion. Specify target criteria value as dict, with target attribute having value -1 Example: to extract state of vpc matching given vpc id response = [{'State': 'available', 'VpcId': 'vpc-2bb1584c'}] extract_attr_for_match(response, State=...
[ "Helper", "method", "to", "get", "attribute", "value", "for", "an", "item", "matching", "some", "criterion", ".", "Specify", "target", "criteria", "value", "as", "dict", "with", "target", "attribute", "having", "value", "-", "1" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L510-L548
train
diux-dev/ncluster
ncluster/aws_util.py
get_instance_property
def get_instance_property(instance, property_name): """Retrieves property of an instance, keeps retrying until getting a non-None""" name = get_name(instance) while True: try: value = getattr(instance, property_name) if value is not None: break print(f"retrieving {property_name} on ...
python
def get_instance_property(instance, property_name): """Retrieves property of an instance, keeps retrying until getting a non-None""" name = get_name(instance) while True: try: value = getattr(instance, property_name) if value is not None: break print(f"retrieving {property_name} on ...
[ "def", "get_instance_property", "(", "instance", ",", "property_name", ")", ":", "name", "=", "get_name", "(", "instance", ")", "while", "True", ":", "try", ":", "value", "=", "getattr", "(", "instance", ",", "property_name", ")", "if", "value", "is", "not...
Retrieves property of an instance, keeps retrying until getting a non-None
[ "Retrieves", "property", "of", "an", "instance", "keeps", "retrying", "until", "getting", "a", "non", "-", "None" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L565-L587
train
diux-dev/ncluster
ncluster/aws_util.py
wait_until_available
def wait_until_available(resource): """Waits until interval state becomes 'available'""" while True: resource.load() if resource.state == 'available': break time.sleep(RETRY_INTERVAL_SEC)
python
def wait_until_available(resource): """Waits until interval state becomes 'available'""" while True: resource.load() if resource.state == 'available': break time.sleep(RETRY_INTERVAL_SEC)
[ "def", "wait_until_available", "(", "resource", ")", ":", "while", "True", ":", "resource", ".", "load", "(", ")", "if", "resource", ".", "state", "==", "'available'", ":", "break", "time", ".", "sleep", "(", "RETRY_INTERVAL_SEC", ")" ]
Waits until interval state becomes 'available
[ "Waits", "until", "interval", "state", "becomes", "available" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L675-L681
train
diux-dev/ncluster
ncluster/aws_util.py
maybe_create_placement_group
def maybe_create_placement_group(name='', max_retries=10): """Creates placement_group group or reuses existing one. Crash if unable to create placement_group group. If name is empty, ignores request.""" if not name: return client = get_ec2_client() while True: try: client.describe_placement_...
python
def maybe_create_placement_group(name='', max_retries=10): """Creates placement_group group or reuses existing one. Crash if unable to create placement_group group. If name is empty, ignores request.""" if not name: return client = get_ec2_client() while True: try: client.describe_placement_...
[ "def", "maybe_create_placement_group", "(", "name", "=", "''", ",", "max_retries", "=", "10", ")", ":", "if", "not", "name", ":", "return", "client", "=", "get_ec2_client", "(", ")", "while", "True", ":", "try", ":", "client", ".", "describe_placement_groups...
Creates placement_group group or reuses existing one. Crash if unable to create placement_group group. If name is empty, ignores request.
[ "Creates", "placement_group", "group", "or", "reuses", "existing", "one", ".", "Crash", "if", "unable", "to", "create", "placement_group", "group", ".", "If", "name", "is", "empty", "ignores", "request", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_util.py#L684-L719
train
diux-dev/ncluster
ncluster/ncluster_globals.py
is_chief
def is_chief(task: backend.Task, run_name: str): """Returns True if task is chief task in the corresponding run""" global run_task_dict if run_name not in run_task_dict: return True task_list = run_task_dict[run_name] assert task in task_list, f"Task {task.name} doesn't belong to run {run_name}" return ...
python
def is_chief(task: backend.Task, run_name: str): """Returns True if task is chief task in the corresponding run""" global run_task_dict if run_name not in run_task_dict: return True task_list = run_task_dict[run_name] assert task in task_list, f"Task {task.name} doesn't belong to run {run_name}" return ...
[ "def", "is_chief", "(", "task", ":", "backend", ".", "Task", ",", "run_name", ":", "str", ")", ":", "global", "run_task_dict", "if", "run_name", "not", "in", "run_task_dict", ":", "return", "True", "task_list", "=", "run_task_dict", "[", "run_name", "]", "...
Returns True if task is chief task in the corresponding run
[ "Returns", "True", "if", "task", "is", "chief", "task", "in", "the", "corresponding", "run" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/ncluster_globals.py#L88-L95
train
diux-dev/ncluster
benchmarks/util.py
ossystem
def ossystem(cmd): """Like os.system, but returns output of command as string.""" p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (stdout, stderr) = p.communicate() return stdout.decode('ascii')
python
def ossystem(cmd): """Like os.system, but returns output of command as string.""" p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) (stdout, stderr) = p.communicate() return stdout.decode('ascii')
[ "def", "ossystem", "(", "cmd", ")", ":", "p", "=", "subprocess", ".", "Popen", "(", "cmd", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "stderr", "=", "subprocess", ".", "STDOUT", ")", "(", "stdout", ",", "stderr", ...
Like os.system, but returns output of command as string.
[ "Like", "os", ".", "system", "but", "returns", "output", "of", "command", "as", "string", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/benchmarks/util.py#L40-L45
train
diux-dev/ncluster
ncluster/aws_backend.py
_maybe_create_resources
def _maybe_create_resources(logging_task: Task = None): """Use heuristics to decide to possibly create resources""" def log(*args): if logging_task: logging_task.log(*args) else: util.log(*args) def should_create_resources(): """Check if gateway, keypair, vpc exist.""" prefix = u.get...
python
def _maybe_create_resources(logging_task: Task = None): """Use heuristics to decide to possibly create resources""" def log(*args): if logging_task: logging_task.log(*args) else: util.log(*args) def should_create_resources(): """Check if gateway, keypair, vpc exist.""" prefix = u.get...
[ "def", "_maybe_create_resources", "(", "logging_task", ":", "Task", "=", "None", ")", ":", "def", "log", "(", "*", "args", ")", ":", "if", "logging_task", ":", "logging_task", ".", "log", "(", "*", "args", ")", "else", ":", "util", ".", "log", "(", "...
Use heuristics to decide to possibly create resources
[ "Use", "heuristics", "to", "decide", "to", "possibly", "create", "resources" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_backend.py#L933-L990
train
diux-dev/ncluster
ncluster/aws_backend.py
_set_aws_environment
def _set_aws_environment(task: Task = None): """Sets up AWS environment from NCLUSTER environment variables""" current_zone = os.environ.get('NCLUSTER_ZONE', '') current_region = os.environ.get('AWS_DEFAULT_REGION', '') def log(*args): if task: task.log(*args) else: util.log(*args) if cu...
python
def _set_aws_environment(task: Task = None): """Sets up AWS environment from NCLUSTER environment variables""" current_zone = os.environ.get('NCLUSTER_ZONE', '') current_region = os.environ.get('AWS_DEFAULT_REGION', '') def log(*args): if task: task.log(*args) else: util.log(*args) if cu...
[ "def", "_set_aws_environment", "(", "task", ":", "Task", "=", "None", ")", ":", "current_zone", "=", "os", ".", "environ", ".", "get", "(", "'NCLUSTER_ZONE'", ",", "''", ")", "current_region", "=", "os", ".", "environ", ".", "get", "(", "'AWS_DEFAULT_REGIO...
Sets up AWS environment from NCLUSTER environment variables
[ "Sets", "up", "AWS", "environment", "from", "NCLUSTER", "environment", "variables" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_backend.py#L993-L1030
train
diux-dev/ncluster
ncluster/aws_backend.py
Task.join
def join(self, ignore_errors=False): """Waits until last executed command completed.""" assert self._status_fn, "Asked to join a task which hasn't had any commands executed on it" check_interval = 0.2 status_fn = self._status_fn if not self.wait_for_file(status_fn, max_wait_sec=30): self.log(f...
python
def join(self, ignore_errors=False): """Waits until last executed command completed.""" assert self._status_fn, "Asked to join a task which hasn't had any commands executed on it" check_interval = 0.2 status_fn = self._status_fn if not self.wait_for_file(status_fn, max_wait_sec=30): self.log(f...
[ "def", "join", "(", "self", ",", "ignore_errors", "=", "False", ")", ":", "assert", "self", ".", "_status_fn", ",", "\"Asked to join a task which hasn't had any commands executed on it\"", "check_interval", "=", "0.2", "status_fn", "=", "self", ".", "_status_fn", "if"...
Waits until last executed command completed.
[ "Waits", "until", "last", "executed", "command", "completed", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_backend.py#L272-L302
train
diux-dev/ncluster
ncluster/aws_backend.py
Task._run_with_output_on_failure
def _run_with_output_on_failure(self, cmd, non_blocking=False, ignore_errors=False, max_wait_sec=365 * 24 * 3600, check_interval=0.2) -> str: """Experimental version of run propagates error messages to client. This...
python
def _run_with_output_on_failure(self, cmd, non_blocking=False, ignore_errors=False, max_wait_sec=365 * 24 * 3600, check_interval=0.2) -> str: """Experimental version of run propagates error messages to client. This...
[ "def", "_run_with_output_on_failure", "(", "self", ",", "cmd", ",", "non_blocking", "=", "False", ",", "ignore_errors", "=", "False", ",", "max_wait_sec", "=", "365", "*", "24", "*", "3600", ",", "check_interval", "=", "0.2", ")", "->", "str", ":", "if", ...
Experimental version of run propagates error messages to client. This command will be default "run" eventually
[ "Experimental", "version", "of", "run", "propagates", "error", "messages", "to", "client", ".", "This", "command", "will", "be", "default", "run", "eventually" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_backend.py#L304-L373
train
diux-dev/ncluster
ncluster/aws_backend.py
Task.upload
def upload(self, local_fn: str, remote_fn: str = '', dont_overwrite: bool = False) -> None: """Uploads file to remote instance. If location not specified, dumps it into default directory. If remote location has files or directories with the same name, behavior is undefined.""" # support w...
python
def upload(self, local_fn: str, remote_fn: str = '', dont_overwrite: bool = False) -> None: """Uploads file to remote instance. If location not specified, dumps it into default directory. If remote location has files or directories with the same name, behavior is undefined.""" # support w...
[ "def", "upload", "(", "self", ",", "local_fn", ":", "str", ",", "remote_fn", ":", "str", "=", "''", ",", "dont_overwrite", ":", "bool", "=", "False", ")", "->", "None", ":", "if", "'*'", "in", "local_fn", ":", "for", "local_subfn", "in", "glob", ".",...
Uploads file to remote instance. If location not specified, dumps it into default directory. If remote location has files or directories with the same name, behavior is undefined.
[ "Uploads", "file", "to", "remote", "instance", ".", "If", "location", "not", "specified", "dumps", "it", "into", "default", "directory", ".", "If", "remote", "location", "has", "files", "or", "directories", "with", "the", "same", "name", "behavior", "is", "u...
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/aws_backend.py#L398-L475
train
diux-dev/ncluster
examples/gpubox.py
_replace_lines
def _replace_lines(fn, startswith, new_line): """Replace lines starting with starts_with in fn with new_line.""" new_lines = [] for line in open(fn): if line.startswith(startswith): new_lines.append(new_line) else: new_lines.append(line) with open(fn, 'w') as f: f.write('\n'.join(new_lin...
python
def _replace_lines(fn, startswith, new_line): """Replace lines starting with starts_with in fn with new_line.""" new_lines = [] for line in open(fn): if line.startswith(startswith): new_lines.append(new_line) else: new_lines.append(line) with open(fn, 'w') as f: f.write('\n'.join(new_lin...
[ "def", "_replace_lines", "(", "fn", ",", "startswith", ",", "new_line", ")", ":", "new_lines", "=", "[", "]", "for", "line", "in", "open", "(", "fn", ")", ":", "if", "line", ".", "startswith", "(", "startswith", ")", ":", "new_lines", ".", "append", ...
Replace lines starting with starts_with in fn with new_line.
[ "Replace", "lines", "starting", "with", "starts_with", "in", "fn", "with", "new_line", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/examples/gpubox.py#L59-L68
train
diux-dev/ncluster
ncluster/util.py
now_micros
def now_micros(absolute=False) -> int: """Return current micros since epoch as integer.""" micros = int(time.time() * 1e6) if absolute: return micros return micros - EPOCH_MICROS
python
def now_micros(absolute=False) -> int: """Return current micros since epoch as integer.""" micros = int(time.time() * 1e6) if absolute: return micros return micros - EPOCH_MICROS
[ "def", "now_micros", "(", "absolute", "=", "False", ")", "->", "int", ":", "micros", "=", "int", "(", "time", ".", "time", "(", ")", "*", "1e6", ")", "if", "absolute", ":", "return", "micros", "return", "micros", "-", "EPOCH_MICROS" ]
Return current micros since epoch as integer.
[ "Return", "current", "micros", "since", "epoch", "as", "integer", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L23-L28
train
diux-dev/ncluster
ncluster/util.py
now_millis
def now_millis(absolute=False) -> int: """Return current millis since epoch as integer.""" millis = int(time.time() * 1e3) if absolute: return millis return millis - EPOCH_MICROS // 1000
python
def now_millis(absolute=False) -> int: """Return current millis since epoch as integer.""" millis = int(time.time() * 1e3) if absolute: return millis return millis - EPOCH_MICROS // 1000
[ "def", "now_millis", "(", "absolute", "=", "False", ")", "->", "int", ":", "millis", "=", "int", "(", "time", ".", "time", "(", ")", "*", "1e3", ")", "if", "absolute", ":", "return", "millis", "return", "millis", "-", "EPOCH_MICROS", "//", "1000" ]
Return current millis since epoch as integer.
[ "Return", "current", "millis", "since", "epoch", "as", "integer", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L31-L36
train
diux-dev/ncluster
ncluster/util.py
install_pdb_handler
def install_pdb_handler(): """Make CTRL+\ break into gdb.""" import signal import pdb def handler(_signum, _frame): pdb.set_trace() signal.signal(signal.SIGQUIT, handler)
python
def install_pdb_handler(): """Make CTRL+\ break into gdb.""" import signal import pdb def handler(_signum, _frame): pdb.set_trace() signal.signal(signal.SIGQUIT, handler)
[ "def", "install_pdb_handler", "(", ")", ":", "import", "signal", "import", "pdb", "def", "handler", "(", "_signum", ",", "_frame", ")", ":", "pdb", ".", "set_trace", "(", ")", "signal", ".", "signal", "(", "signal", ".", "SIGQUIT", ",", "handler", ")" ]
Make CTRL+\ break into gdb.
[ "Make", "CTRL", "+", "\\", "break", "into", "gdb", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L56-L65
train
diux-dev/ncluster
ncluster/util.py
shell_add_echo
def shell_add_echo(script): """Goes over each line script, adds "echo cmd" in front of each cmd. ls a becomes echo * ls a ls a """ new_script = "" for cmd in script.split('\n'): cmd = cmd.strip() if not cmd: continue new_script += "echo \\* " + shlex.quote(cmd) + "\n" new_script...
python
def shell_add_echo(script): """Goes over each line script, adds "echo cmd" in front of each cmd. ls a becomes echo * ls a ls a """ new_script = "" for cmd in script.split('\n'): cmd = cmd.strip() if not cmd: continue new_script += "echo \\* " + shlex.quote(cmd) + "\n" new_script...
[ "def", "shell_add_echo", "(", "script", ")", ":", "new_script", "=", "\"\"", "for", "cmd", "in", "script", ".", "split", "(", "'\\n'", ")", ":", "cmd", "=", "cmd", ".", "strip", "(", ")", "if", "not", "cmd", ":", "continue", "new_script", "+=", "\"ec...
Goes over each line script, adds "echo cmd" in front of each cmd. ls a becomes echo * ls a ls a
[ "Goes", "over", "each", "line", "script", "adds", "echo", "cmd", "in", "front", "of", "each", "cmd", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L68-L85
train
diux-dev/ncluster
ncluster/util.py
random_id
def random_id(k=5): """Random id to use for AWS identifiers.""" # https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python return ''.join(random.choices(string.ascii_lowercase + string.digits, k=k))
python
def random_id(k=5): """Random id to use for AWS identifiers.""" # https://stackoverflow.com/questions/2257441/random-string-generation-with-upper-case-letters-and-digits-in-python return ''.join(random.choices(string.ascii_lowercase + string.digits, k=k))
[ "def", "random_id", "(", "k", "=", "5", ")", ":", "return", "''", ".", "join", "(", "random", ".", "choices", "(", "string", ".", "ascii_lowercase", "+", "string", ".", "digits", ",", "k", "=", "k", ")", ")" ]
Random id to use for AWS identifiers.
[ "Random", "id", "to", "use", "for", "AWS", "identifiers", "." ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L96-L99
train
diux-dev/ncluster
ncluster/util.py
alphanumeric_hash
def alphanumeric_hash(s: str, size=5): """Short alphanumeric string derived from hash of given string""" import hashlib import base64 hash_object = hashlib.md5(s.encode('ascii')) s = base64.b32encode(hash_object.digest()) result = s[:size].decode('ascii').lower() return result
python
def alphanumeric_hash(s: str, size=5): """Short alphanumeric string derived from hash of given string""" import hashlib import base64 hash_object = hashlib.md5(s.encode('ascii')) s = base64.b32encode(hash_object.digest()) result = s[:size].decode('ascii').lower() return result
[ "def", "alphanumeric_hash", "(", "s", ":", "str", ",", "size", "=", "5", ")", ":", "import", "hashlib", "import", "base64", "hash_object", "=", "hashlib", ".", "md5", "(", "s", ".", "encode", "(", "'ascii'", ")", ")", "s", "=", "base64", ".", "b32enc...
Short alphanumeric string derived from hash of given string
[ "Short", "alphanumeric", "string", "derived", "from", "hash", "of", "given", "string" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L102-L109
train
diux-dev/ncluster
ncluster/util.py
is_bash_builtin
def is_bash_builtin(cmd): """Return true if command is invoking bash built-in """ # from compgen -b bash_builtins = ['alias', 'bg', 'bind', 'alias', 'bg', 'bind', 'break', 'builtin', 'caller', 'cd', 'command', 'compgen', 'complete', 'compopt', 'continue', 'declare', 'dirs',...
python
def is_bash_builtin(cmd): """Return true if command is invoking bash built-in """ # from compgen -b bash_builtins = ['alias', 'bg', 'bind', 'alias', 'bg', 'bind', 'break', 'builtin', 'caller', 'cd', 'command', 'compgen', 'complete', 'compopt', 'continue', 'declare', 'dirs',...
[ "def", "is_bash_builtin", "(", "cmd", ")", ":", "bash_builtins", "=", "[", "'alias'", ",", "'bg'", ",", "'bind'", ",", "'alias'", ",", "'bg'", ",", "'bind'", ",", "'break'", ",", "'builtin'", ",", "'caller'", ",", "'cd'", ",", "'command'", ",", "'compgen...
Return true if command is invoking bash built-in
[ "Return", "true", "if", "command", "is", "invoking", "bash", "built", "-", "in" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L130-L147
train
diux-dev/ncluster
ncluster/util.py
is_set
def is_set(name): """Helper method to check if given property is set""" val = os.environ.get(name, '0') assert val == '0' or val == '1', f"env var {name} has value {val}, expected 0 or 1" return val == '1'
python
def is_set(name): """Helper method to check if given property is set""" val = os.environ.get(name, '0') assert val == '0' or val == '1', f"env var {name} has value {val}, expected 0 or 1" return val == '1'
[ "def", "is_set", "(", "name", ")", ":", "val", "=", "os", ".", "environ", ".", "get", "(", "name", ",", "'0'", ")", "assert", "val", "==", "'0'", "or", "val", "==", "'1'", ",", "f\"env var {name} has value {val}, expected 0 or 1\"", "return", "val", "==", ...
Helper method to check if given property is set
[ "Helper", "method", "to", "check", "if", "given", "property", "is", "set" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L150-L154
train
diux-dev/ncluster
ncluster/util.py
assert_script_in_current_directory
def assert_script_in_current_directory(): """Assert fail if current directory is different from location of the script""" script = sys.argv[0] assert os.path.abspath(os.path.dirname(script)) == os.path.abspath( '.'), f"Change into directory of script {script} and run again."
python
def assert_script_in_current_directory(): """Assert fail if current directory is different from location of the script""" script = sys.argv[0] assert os.path.abspath(os.path.dirname(script)) == os.path.abspath( '.'), f"Change into directory of script {script} and run again."
[ "def", "assert_script_in_current_directory", "(", ")", ":", "script", "=", "sys", ".", "argv", "[", "0", "]", "assert", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "script", ")", ")", "==", "os", ".", "path", ".", ...
Assert fail if current directory is different from location of the script
[ "Assert", "fail", "if", "current", "directory", "is", "different", "from", "location", "of", "the", "script" ]
2fd359621896717197b479c7174d06d80df1529b
https://github.com/diux-dev/ncluster/blob/2fd359621896717197b479c7174d06d80df1529b/ncluster/util.py#L157-L162
train
croach/Flask-Fixtures
flask_fixtures/__init__.py
load_fixtures
def load_fixtures(db, fixtures): """Loads the given fixtures into the database. """ conn = db.engine.connect() metadata = db.metadata for fixture in fixtures: if 'model' in fixture: module_name, class_name = fixture['model'].rsplit('.', 1) module = importlib.import_m...
python
def load_fixtures(db, fixtures): """Loads the given fixtures into the database. """ conn = db.engine.connect() metadata = db.metadata for fixture in fixtures: if 'model' in fixture: module_name, class_name = fixture['model'].rsplit('.', 1) module = importlib.import_m...
[ "def", "load_fixtures", "(", "db", ",", "fixtures", ")", ":", "conn", "=", "db", ".", "engine", ".", "connect", "(", ")", "metadata", "=", "db", ".", "metadata", "for", "fixture", "in", "fixtures", ":", "if", "'model'", "in", "fixture", ":", "module_na...
Loads the given fixtures into the database.
[ "Loads", "the", "given", "fixtures", "into", "the", "database", "." ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/__init__.py#L130-L149
train
croach/Flask-Fixtures
flask_fixtures/__init__.py
MetaFixturesMixin.setup_handler
def setup_handler(setup_fixtures_fn, setup_fn): """Returns a function that adds fixtures handling to the setup method. Makes sure that fixtures are setup before calling the given setup method. """ def handler(obj): setup_fixtures_fn(obj) setup_fn(obj) ret...
python
def setup_handler(setup_fixtures_fn, setup_fn): """Returns a function that adds fixtures handling to the setup method. Makes sure that fixtures are setup before calling the given setup method. """ def handler(obj): setup_fixtures_fn(obj) setup_fn(obj) ret...
[ "def", "setup_handler", "(", "setup_fixtures_fn", ",", "setup_fn", ")", ":", "def", "handler", "(", "obj", ")", ":", "setup_fixtures_fn", "(", "obj", ")", "setup_fn", "(", "obj", ")", "return", "handler" ]
Returns a function that adds fixtures handling to the setup method. Makes sure that fixtures are setup before calling the given setup method.
[ "Returns", "a", "function", "that", "adds", "fixtures", "handling", "to", "the", "setup", "method", "." ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/__init__.py#L180-L188
train
croach/Flask-Fixtures
flask_fixtures/__init__.py
MetaFixturesMixin.teardown_handler
def teardown_handler(teardown_fixtures_fn, teardown_fn): """Returns a function that adds fixtures handling to the teardown method. Calls the given teardown method first before calling the fixtures teardown. """ def handler(obj): teardown_fn(obj) teardown_fixtures...
python
def teardown_handler(teardown_fixtures_fn, teardown_fn): """Returns a function that adds fixtures handling to the teardown method. Calls the given teardown method first before calling the fixtures teardown. """ def handler(obj): teardown_fn(obj) teardown_fixtures...
[ "def", "teardown_handler", "(", "teardown_fixtures_fn", ",", "teardown_fn", ")", ":", "def", "handler", "(", "obj", ")", ":", "teardown_fn", "(", "obj", ")", "teardown_fixtures_fn", "(", "obj", ")", "return", "handler" ]
Returns a function that adds fixtures handling to the teardown method. Calls the given teardown method first before calling the fixtures teardown.
[ "Returns", "a", "function", "that", "adds", "fixtures", "handling", "to", "the", "teardown", "method", "." ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/__init__.py#L191-L199
train
croach/Flask-Fixtures
flask_fixtures/__init__.py
MetaFixturesMixin.get_child_fn
def get_child_fn(attrs, names, bases): """Returns a function from the child class that matches one of the names. Searches the child class's set of methods (i.e., the attrs dict) for all the functions matching the given list of names. If more than one is found, an exception is raised, if...
python
def get_child_fn(attrs, names, bases): """Returns a function from the child class that matches one of the names. Searches the child class's set of methods (i.e., the attrs dict) for all the functions matching the given list of names. If more than one is found, an exception is raised, if...
[ "def", "get_child_fn", "(", "attrs", ",", "names", ",", "bases", ")", ":", "def", "call_method", "(", "obj", ",", "method", ")", ":", "if", "isinstance", "(", "obj", ",", "type", ")", ":", "instance", "=", "None", "owner", "=", "obj", "else", ":", ...
Returns a function from the child class that matches one of the names. Searches the child class's set of methods (i.e., the attrs dict) for all the functions matching the given list of names. If more than one is found, an exception is raised, if one is found, it is returned, and if none are ...
[ "Returns", "a", "function", "from", "the", "child", "class", "that", "matches", "one", "of", "the", "names", "." ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/__init__.py#L202-L252
train
croach/Flask-Fixtures
flask_fixtures/utils.py
print_msg
def print_msg(msg, header, file=sys.stdout): """Prints a boardered message to the screen""" DEFAULT_MSG_BLOCK_WIDTH = 60 # Calculate the length of the boarder on each side of the header and the # total length of the bottom boarder side_boarder_length = (DEFAULT_MSG_BLOCK_WIDTH - (len(header) + 2)) ...
python
def print_msg(msg, header, file=sys.stdout): """Prints a boardered message to the screen""" DEFAULT_MSG_BLOCK_WIDTH = 60 # Calculate the length of the boarder on each side of the header and the # total length of the bottom boarder side_boarder_length = (DEFAULT_MSG_BLOCK_WIDTH - (len(header) + 2)) ...
[ "def", "print_msg", "(", "msg", ",", "header", ",", "file", "=", "sys", ".", "stdout", ")", ":", "DEFAULT_MSG_BLOCK_WIDTH", "=", "60", "side_boarder_length", "=", "(", "DEFAULT_MSG_BLOCK_WIDTH", "-", "(", "len", "(", "header", ")", "+", "2", ")", ")", "/...
Prints a boardered message to the screen
[ "Prints", "a", "boardered", "message", "to", "the", "screen" ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/utils.py#L20-L60
train
croach/Flask-Fixtures
flask_fixtures/utils.py
can_persist_fixtures
def can_persist_fixtures(): """Returns True if it's possible to persist fixtures across tests. Flask-Fixtures uses the setUpClass and tearDownClass methods to persist fixtures across tests. These methods were added to unittest.TestCase in python 2.7. So, we can only persist fixtures when using python 2...
python
def can_persist_fixtures(): """Returns True if it's possible to persist fixtures across tests. Flask-Fixtures uses the setUpClass and tearDownClass methods to persist fixtures across tests. These methods were added to unittest.TestCase in python 2.7. So, we can only persist fixtures when using python 2...
[ "def", "can_persist_fixtures", "(", ")", ":", "if", "sys", ".", "hexversion", ">=", "0x02070000", ":", "return", "True", "filename", "=", "inspect", ".", "stack", "(", ")", "[", "-", "1", "]", "[", "1", "]", "executable", "=", "os", ".", "path", ".",...
Returns True if it's possible to persist fixtures across tests. Flask-Fixtures uses the setUpClass and tearDownClass methods to persist fixtures across tests. These methods were added to unittest.TestCase in python 2.7. So, we can only persist fixtures when using python 2.7. However, the nose and py.te...
[ "Returns", "True", "if", "it", "s", "possible", "to", "persist", "fixtures", "across", "tests", "." ]
b34597d165b33cc47cdd632ac0f3cf8a07428675
https://github.com/croach/Flask-Fixtures/blob/b34597d165b33cc47cdd632ac0f3cf8a07428675/flask_fixtures/utils.py#L65-L84
train
shichao-an/twitter-photos
twphotos/increment.py
read_since_ids
def read_since_ids(users): """ Read max ids of the last downloads :param users: A list of users Return a dictionary mapping users to ids """ since_ids = {} for user in users: if config.has_option(SECTIONS['INCREMENTS'], user): since_ids[user] = config.getint(SECTIONS['I...
python
def read_since_ids(users): """ Read max ids of the last downloads :param users: A list of users Return a dictionary mapping users to ids """ since_ids = {} for user in users: if config.has_option(SECTIONS['INCREMENTS'], user): since_ids[user] = config.getint(SECTIONS['I...
[ "def", "read_since_ids", "(", "users", ")", ":", "since_ids", "=", "{", "}", "for", "user", "in", "users", ":", "if", "config", ".", "has_option", "(", "SECTIONS", "[", "'INCREMENTS'", "]", ",", "user", ")", ":", "since_ids", "[", "user", "]", "=", "...
Read max ids of the last downloads :param users: A list of users Return a dictionary mapping users to ids
[ "Read", "max", "ids", "of", "the", "last", "downloads" ]
32de6e8805edcbb431d08af861e9d2f0ab221106
https://github.com/shichao-an/twitter-photos/blob/32de6e8805edcbb431d08af861e9d2f0ab221106/twphotos/increment.py#L19-L31
train
shichao-an/twitter-photos
twphotos/increment.py
set_max_ids
def set_max_ids(max_ids): """ Set max ids of the current downloads :param max_ids: A dictionary mapping users to ids """ config.read(CONFIG) for user, max_id in max_ids.items(): config.set(SECTIONS['INCREMENTS'], user, str(max_id)) with open(CONFIG, 'w') as f: config.write(f...
python
def set_max_ids(max_ids): """ Set max ids of the current downloads :param max_ids: A dictionary mapping users to ids """ config.read(CONFIG) for user, max_id in max_ids.items(): config.set(SECTIONS['INCREMENTS'], user, str(max_id)) with open(CONFIG, 'w') as f: config.write(f...
[ "def", "set_max_ids", "(", "max_ids", ")", ":", "config", ".", "read", "(", "CONFIG", ")", "for", "user", ",", "max_id", "in", "max_ids", ".", "items", "(", ")", ":", "config", ".", "set", "(", "SECTIONS", "[", "'INCREMENTS'", "]", ",", "user", ",", ...
Set max ids of the current downloads :param max_ids: A dictionary mapping users to ids
[ "Set", "max", "ids", "of", "the", "current", "downloads" ]
32de6e8805edcbb431d08af861e9d2f0ab221106
https://github.com/shichao-an/twitter-photos/blob/32de6e8805edcbb431d08af861e9d2f0ab221106/twphotos/increment.py#L34-L44
train
davedoesdev/dxf
dxf/__init__.py
DXFBase.authenticate
def authenticate(self, username=None, password=None, actions=None, response=None, authorization=None): # pylint: disable=too-many-arguments,too-many-locals """ Authenticate to the registry using a username and password, an au...
python
def authenticate(self, username=None, password=None, actions=None, response=None, authorization=None): # pylint: disable=too-many-arguments,too-many-locals """ Authenticate to the registry using a username and password, an au...
[ "def", "authenticate", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ",", "actions", "=", "None", ",", "response", "=", "None", ",", "authorization", "=", "None", ")", ":", "if", "response", "is", "None", ":", "with", "warnin...
Authenticate to the registry using a username and password, an authorization header or otherwise as the anonymous user. :param username: User name to authenticate as. :type username: str :param password: User's password. :type password: str :param actions: If you know ...
[ "Authenticate", "to", "the", "registry", "using", "a", "username", "and", "password", "an", "authorization", "header", "or", "otherwise", "as", "the", "anonymous", "user", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L228-L312
train
davedoesdev/dxf
dxf/__init__.py
DXFBase.list_repos
def list_repos(self, batch_size=None, iterate=False): """ List all repositories in the registry. :param batch_size: Number of repository names to ask the server for at a time. :type batch_size: int :param iterate: Whether to return iterator over the names or a list of all the n...
python
def list_repos(self, batch_size=None, iterate=False): """ List all repositories in the registry. :param batch_size: Number of repository names to ask the server for at a time. :type batch_size: int :param iterate: Whether to return iterator over the names or a list of all the n...
[ "def", "list_repos", "(", "self", ",", "batch_size", "=", "None", ",", "iterate", "=", "False", ")", ":", "it", "=", "PaginatingResponse", "(", "self", ",", "'_base_request'", ",", "'_catalog'", ",", "'repositories'", ",", "params", "=", "{", "'n'", ":", ...
List all repositories in the registry. :param batch_size: Number of repository names to ask the server for at a time. :type batch_size: int :param iterate: Whether to return iterator over the names or a list of all the names. :type iterate: bool :rtype: list or iterator of str...
[ "List", "all", "repositories", "in", "the", "registry", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L314-L330
train
davedoesdev/dxf
dxf/__init__.py
DXF.pull_blob
def pull_blob(self, digest, size=False, chunk_size=None): """ Download a blob from the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :param size: Whether to return the size of the blob too. ...
python
def pull_blob(self, digest, size=False, chunk_size=None): """ Download a blob from the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :param size: Whether to return the size of the blob too. ...
[ "def", "pull_blob", "(", "self", ",", "digest", ",", "size", "=", "False", ",", "chunk_size", "=", "None", ")", ":", "if", "chunk_size", "is", "None", ":", "chunk_size", "=", "8192", "r", "=", "self", ".", "_request", "(", "'get'", ",", "'blobs/'", "...
Download a blob from the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :param size: Whether to return the size of the blob too. :type size: bool :param chunk_size: Number of bytes to download at a...
[ "Download", "a", "blob", "from", "the", "registry", "given", "the", "hash", "of", "its", "content", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L438-L467
train
davedoesdev/dxf
dxf/__init__.py
DXF.blob_size
def blob_size(self, digest): """ Return the size of a blob in the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :rtype: long :returns: Whether the blob exists. """ r = self....
python
def blob_size(self, digest): """ Return the size of a blob in the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :rtype: long :returns: Whether the blob exists. """ r = self....
[ "def", "blob_size", "(", "self", ",", "digest", ")", ":", "r", "=", "self", ".", "_request", "(", "'head'", ",", "'blobs/'", "+", "digest", ")", "return", "long", "(", "r", ".", "headers", "[", "'content-length'", "]", ")" ]
Return the size of a blob in the registry given the hash of its content. :param digest: Hash of the blob's content (prefixed by ``sha256:``). :type digest: str :rtype: long :returns: Whether the blob exists.
[ "Return", "the", "size", "of", "a", "blob", "in", "the", "registry", "given", "the", "hash", "of", "its", "content", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L469-L480
train
davedoesdev/dxf
dxf/__init__.py
DXF.get_manifest_and_response
def get_manifest_and_response(self, alias): """ Request the manifest for an alias and return the manifest and the response. :param alias: Alias name. :type alias: str :rtype: tuple :returns: Tuple containing the manifest as a string (JSON) and the `requests.Resp...
python
def get_manifest_and_response(self, alias): """ Request the manifest for an alias and return the manifest and the response. :param alias: Alias name. :type alias: str :rtype: tuple :returns: Tuple containing the manifest as a string (JSON) and the `requests.Resp...
[ "def", "get_manifest_and_response", "(", "self", ",", "alias", ")", ":", "r", "=", "self", ".", "_request", "(", "'get'", ",", "'manifests/'", "+", "alias", ",", "headers", "=", "{", "'Accept'", ":", "_schema2_mimetype", "+", "', '", "+", "_schema1_mimetype"...
Request the manifest for an alias and return the manifest and the response. :param alias: Alias name. :type alias: str :rtype: tuple :returns: Tuple containing the manifest as a string (JSON) and the `requests.Response <http://docs.python-requests.org/en/master/api/#requests.Re...
[ "Request", "the", "manifest", "for", "an", "alias", "and", "return", "the", "manifest", "and", "the", "response", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L555-L570
train
davedoesdev/dxf
dxf/__init__.py
DXF.get_alias
def get_alias(self, alias=None, manifest=None, verify=True, sizes=False, dcd=None): # pylint: disable=too-many-arguments """ Get the blob hashes assigned to an alias. :param alias: Alias name. You ...
python
def get_alias(self, alias=None, manifest=None, verify=True, sizes=False, dcd=None): # pylint: disable=too-many-arguments """ Get the blob hashes assigned to an alias. :param alias: Alias name. You ...
[ "def", "get_alias", "(", "self", ",", "alias", "=", "None", ",", "manifest", "=", "None", ",", "verify", "=", "True", ",", "sizes", "=", "False", ",", "dcd", "=", "None", ")", ":", "return", "self", ".", "_get_alias", "(", "alias", ",", "manifest", ...
Get the blob hashes assigned to an alias. :param alias: Alias name. You almost definitely will only need to pass this argument. :type alias: str :param manifest: If you previously obtained a manifest, specify it here instead of ``alias``. You almost definitely won't need to do this. :t...
[ "Get", "the", "blob", "hashes", "assigned", "to", "an", "alias", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L630-L658
train
davedoesdev/dxf
dxf/__init__.py
DXF._get_dcd
def _get_dcd(self, alias): """ Get the Docker-Content-Digest header for an alias. :param alias: Alias name. :type alias: str :rtype: str :returns: DCD header for the alias. """ # https://docs.docker.com/registry/spec/api/#deleting-an-image # Note...
python
def _get_dcd(self, alias): """ Get the Docker-Content-Digest header for an alias. :param alias: Alias name. :type alias: str :rtype: str :returns: DCD header for the alias. """ # https://docs.docker.com/registry/spec/api/#deleting-an-image # Note...
[ "def", "_get_dcd", "(", "self", ",", "alias", ")", ":", "return", "self", ".", "_request", "(", "'head'", ",", "'manifests/{}'", ".", "format", "(", "alias", ")", ",", "headers", "=", "{", "'Accept'", ":", "_schema2_mimetype", "}", ",", ")", ".", "head...
Get the Docker-Content-Digest header for an alias. :param alias: Alias name. :type alias: str :rtype: str :returns: DCD header for the alias.
[ "Get", "the", "Docker", "-", "Content", "-", "Digest", "header", "for", "an", "alias", "." ]
63fad55e0f0086e5f6d3511670db1ef23b5298f6
https://github.com/davedoesdev/dxf/blob/63fad55e0f0086e5f6d3511670db1ef23b5298f6/dxf/__init__.py#L691-L710
train
shinichi-takii/ddlparse
ddlparse/ddlparse.py
DdlParseTableColumnBase.get_name
def get_name(self, name_case=DdlParseBase.NAME_CASE.original): """ Get Name converted case :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.NAME_CASE.upper : Return t...
python
def get_name(self, name_case=DdlParseBase.NAME_CASE.original): """ Get Name converted case :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.NAME_CASE.upper : Return t...
[ "def", "get_name", "(", "self", ",", "name_case", "=", "DdlParseBase", ".", "NAME_CASE", ".", "original", ")", ":", "if", "name_case", "==", "self", ".", "NAME_CASE", ".", "lower", ":", "return", "self", ".", "_name", ".", "lower", "(", ")", "elif", "n...
Get Name converted case :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.NAME_CASE.upper : Return to upper :return: name
[ "Get", "Name", "converted", "case" ]
7328656ee807d14960999a98ace8cd76f0fe3ff8
https://github.com/shinichi-takii/ddlparse/blob/7328656ee807d14960999a98ace8cd76f0fe3ff8/ddlparse/ddlparse.py#L55-L71
train
shinichi-takii/ddlparse
ddlparse/ddlparse.py
DdlParseColumn.bigquery_data_type
def bigquery_data_type(self): """Get BigQuery Legacy SQL data type""" # BigQuery data type = {source_database: [data type, ...], ...} BQ_DATA_TYPE_DIC = OrderedDict() BQ_DATA_TYPE_DIC["STRING"] = {None: [re.compile(r"(CHAR|TEXT|CLOB|JSON|UUID)")]} BQ_DATA_TYPE_DIC["INTEGER"] = {...
python
def bigquery_data_type(self): """Get BigQuery Legacy SQL data type""" # BigQuery data type = {source_database: [data type, ...], ...} BQ_DATA_TYPE_DIC = OrderedDict() BQ_DATA_TYPE_DIC["STRING"] = {None: [re.compile(r"(CHAR|TEXT|CLOB|JSON|UUID)")]} BQ_DATA_TYPE_DIC["INTEGER"] = {...
[ "def", "bigquery_data_type", "(", "self", ")", ":", "BQ_DATA_TYPE_DIC", "=", "OrderedDict", "(", ")", "BQ_DATA_TYPE_DIC", "[", "\"STRING\"", "]", "=", "{", "None", ":", "[", "re", ".", "compile", "(", "r\"(CHAR|TEXT|CLOB|JSON|UUID)\"", ")", "]", "}", "BQ_DATA_...
Get BigQuery Legacy SQL data type
[ "Get", "BigQuery", "Legacy", "SQL", "data", "type" ]
7328656ee807d14960999a98ace8cd76f0fe3ff8
https://github.com/shinichi-takii/ddlparse/blob/7328656ee807d14960999a98ace8cd76f0fe3ff8/ddlparse/ddlparse.py#L173-L216
train
shinichi-takii/ddlparse
ddlparse/ddlparse.py
DdlParseColumn.to_bigquery_field
def to_bigquery_field(self, name_case=DdlParseBase.NAME_CASE.original): """Generate BigQuery JSON field define""" col_name = self.get_name(name_case) mode = self.bigquery_mode if self.array_dimensional <= 1: # no or one dimensional array data type type = self.bi...
python
def to_bigquery_field(self, name_case=DdlParseBase.NAME_CASE.original): """Generate BigQuery JSON field define""" col_name = self.get_name(name_case) mode = self.bigquery_mode if self.array_dimensional <= 1: # no or one dimensional array data type type = self.bi...
[ "def", "to_bigquery_field", "(", "self", ",", "name_case", "=", "DdlParseBase", ".", "NAME_CASE", ".", "original", ")", ":", "col_name", "=", "self", ".", "get_name", "(", "name_case", ")", "mode", "=", "self", ".", "bigquery_mode", "if", "self", ".", "arr...
Generate BigQuery JSON field define
[ "Generate", "BigQuery", "JSON", "field", "define" ]
7328656ee807d14960999a98ace8cd76f0fe3ff8
https://github.com/shinichi-takii/ddlparse/blob/7328656ee807d14960999a98ace8cd76f0fe3ff8/ddlparse/ddlparse.py#L250-L284
train
shinichi-takii/ddlparse
ddlparse/ddlparse.py
DdlParseTable.to_bigquery_ddl
def to_bigquery_ddl(self, name_case=DdlParseBase.NAME_CASE.original): """ Generate BigQuery CREATE TABLE statements :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.N...
python
def to_bigquery_ddl(self, name_case=DdlParseBase.NAME_CASE.original): """ Generate BigQuery CREATE TABLE statements :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.N...
[ "def", "to_bigquery_ddl", "(", "self", ",", "name_case", "=", "DdlParseBase", ".", "NAME_CASE", ".", "original", ")", ":", "if", "self", ".", "schema", "is", "None", ":", "dataset", "=", "\"dataset\"", "elif", "name_case", "==", "self", ".", "NAME_CASE", "...
Generate BigQuery CREATE TABLE statements :param name_case: name case type * DdlParse.NAME_CASE.original : Return to no convert * DdlParse.NAME_CASE.lower : Return to lower * DdlParse.NAME_CASE.upper : Return to upper :return: BigQuery CREATE TABLE statements
[ "Generate", "BigQuery", "CREATE", "TABLE", "statements" ]
7328656ee807d14960999a98ace8cd76f0fe3ff8
https://github.com/shinichi-takii/ddlparse/blob/7328656ee807d14960999a98ace8cd76f0fe3ff8/ddlparse/ddlparse.py#L393-L450
train
shinichi-takii/ddlparse
ddlparse/ddlparse.py
DdlParse.parse
def parse(self, ddl=None, source_database=None): """ Parse DDL script. :param ddl: DDL script :return: DdlParseTable, Parsed table define info. """ if ddl is not None: self._ddl = ddl if source_database is not None: self.source_database ...
python
def parse(self, ddl=None, source_database=None): """ Parse DDL script. :param ddl: DDL script :return: DdlParseTable, Parsed table define info. """ if ddl is not None: self._ddl = ddl if source_database is not None: self.source_database ...
[ "def", "parse", "(", "self", ",", "ddl", "=", "None", ",", "source_database", "=", "None", ")", ":", "if", "ddl", "is", "not", "None", ":", "self", ".", "_ddl", "=", "ddl", "if", "source_database", "is", "not", "None", ":", "self", ".", "source_datab...
Parse DDL script. :param ddl: DDL script :return: DdlParseTable, Parsed table define info.
[ "Parse", "DDL", "script", "." ]
7328656ee807d14960999a98ace8cd76f0fe3ff8
https://github.com/shinichi-takii/ddlparse/blob/7328656ee807d14960999a98ace8cd76f0fe3ff8/ddlparse/ddlparse.py#L540-L591
train
rhelmot/nclib
nclib/process.py
Process.launch
def launch(program, sock, stderr=True, cwd=None, env=None): """ A static method for launching a process that is connected to a given socket. Same rules from the Process constructor apply. """ if stderr is True: err = sock # redirect to socket elif stderr is Fa...
python
def launch(program, sock, stderr=True, cwd=None, env=None): """ A static method for launching a process that is connected to a given socket. Same rules from the Process constructor apply. """ if stderr is True: err = sock # redirect to socket elif stderr is Fa...
[ "def", "launch", "(", "program", ",", "sock", ",", "stderr", "=", "True", ",", "cwd", "=", "None", ",", "env", "=", "None", ")", ":", "if", "stderr", "is", "True", ":", "err", "=", "sock", "elif", "stderr", "is", "False", ":", "err", "=", "open",...
A static method for launching a process that is connected to a given socket. Same rules from the Process constructor apply.
[ "A", "static", "method", "for", "launching", "a", "process", "that", "is", "connected", "to", "a", "given", "socket", ".", "Same", "rules", "from", "the", "Process", "constructor", "apply", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/process.py#L85-L104
train
rhelmot/nclib
nclib/server.py
UDPServer.respond
def respond(self, packet, peer, flags=0): """ Send a message back to a peer. :param packet: The data to send :param peer: The address to send to, as a tuple (host, port) :param flags: Any sending flags you want to use for some reason """ self.so...
python
def respond(self, packet, peer, flags=0): """ Send a message back to a peer. :param packet: The data to send :param peer: The address to send to, as a tuple (host, port) :param flags: Any sending flags you want to use for some reason """ self.so...
[ "def", "respond", "(", "self", ",", "packet", ",", "peer", ",", "flags", "=", "0", ")", ":", "self", ".", "sock", ".", "sendto", "(", "packet", ",", "flags", ",", "peer", ")" ]
Send a message back to a peer. :param packet: The data to send :param peer: The address to send to, as a tuple (host, port) :param flags: Any sending flags you want to use for some reason
[ "Send", "a", "message", "back", "to", "a", "peer", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/server.py#L75-L83
train
rhelmot/nclib
nclib/netcat.py
Netcat.shutdown_rd
def shutdown_rd(self): """ Send a shutdown signal for reading - you may no longer read from this socket. """ if self._sock_send is not None: self.sock.close() else: return self.shutdown(socket.SHUT_RD)
python
def shutdown_rd(self): """ Send a shutdown signal for reading - you may no longer read from this socket. """ if self._sock_send is not None: self.sock.close() else: return self.shutdown(socket.SHUT_RD)
[ "def", "shutdown_rd", "(", "self", ")", ":", "if", "self", ".", "_sock_send", "is", "not", "None", ":", "self", ".", "sock", ".", "close", "(", ")", "else", ":", "return", "self", ".", "shutdown", "(", "socket", ".", "SHUT_RD", ")" ]
Send a shutdown signal for reading - you may no longer read from this socket.
[ "Send", "a", "shutdown", "signal", "for", "reading", "-", "you", "may", "no", "longer", "read", "from", "this", "socket", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L443-L451
train
rhelmot/nclib
nclib/netcat.py
Netcat.shutdown_wr
def shutdown_wr(self): """ Send a shutdown signal for writing - you may no longer write to this socket. """ if self._sock_send is not None: self._sock_send.close() else: return self.shutdown(socket.SHUT_WR)
python
def shutdown_wr(self): """ Send a shutdown signal for writing - you may no longer write to this socket. """ if self._sock_send is not None: self._sock_send.close() else: return self.shutdown(socket.SHUT_WR)
[ "def", "shutdown_wr", "(", "self", ")", ":", "if", "self", ".", "_sock_send", "is", "not", "None", ":", "self", ".", "_sock_send", ".", "close", "(", ")", "else", ":", "return", "self", ".", "shutdown", "(", "socket", ".", "SHUT_WR", ")" ]
Send a shutdown signal for writing - you may no longer write to this socket.
[ "Send", "a", "shutdown", "signal", "for", "writing", "-", "you", "may", "no", "longer", "write", "to", "this", "socket", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L453-L461
train
rhelmot/nclib
nclib/netcat.py
Netcat._recv_predicate
def _recv_predicate(self, predicate, timeout='default', raise_eof=True): """ Receive until predicate returns a positive integer. The returned number is the size to return. """ if timeout == 'default': timeout = self._timeout self.timed_out = False s...
python
def _recv_predicate(self, predicate, timeout='default', raise_eof=True): """ Receive until predicate returns a positive integer. The returned number is the size to return. """ if timeout == 'default': timeout = self._timeout self.timed_out = False s...
[ "def", "_recv_predicate", "(", "self", ",", "predicate", ",", "timeout", "=", "'default'", ",", "raise_eof", "=", "True", ")", ":", "if", "timeout", "==", "'default'", ":", "timeout", "=", "self", ".", "_timeout", "self", ".", "timed_out", "=", "False", ...
Receive until predicate returns a positive integer. The returned number is the size to return.
[ "Receive", "until", "predicate", "returns", "a", "positive", "integer", ".", "The", "returned", "number", "is", "the", "size", "to", "return", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L569-L618
train
rhelmot/nclib
nclib/netcat.py
Netcat.recv_until
def recv_until(self, s, max_size=None, timeout='default'): """ Recieve data from the socket until the given substring is observed. Data in the same datagram as the substring, following the substring, will not be returned and will be cached for future receives. Aliases: read_unti...
python
def recv_until(self, s, max_size=None, timeout='default'): """ Recieve data from the socket until the given substring is observed. Data in the same datagram as the substring, following the substring, will not be returned and will be cached for future receives. Aliases: read_unti...
[ "def", "recv_until", "(", "self", ",", "s", ",", "max_size", "=", "None", ",", "timeout", "=", "'default'", ")", ":", "self", ".", "_print_recv_header", "(", "'======== Receiving until {0}{timeout_text} ========'", ",", "timeout", ",", "repr", "(", "s", ")", "...
Recieve data from the socket until the given substring is observed. Data in the same datagram as the substring, following the substring, will not be returned and will be cached for future receives. Aliases: read_until, readuntil, recvuntil
[ "Recieve", "data", "from", "the", "socket", "until", "the", "given", "substring", "is", "observed", ".", "Data", "in", "the", "same", "datagram", "as", "the", "substring", "following", "the", "substring", "will", "not", "be", "returned", "and", "will", "be",...
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L652-L672
train
rhelmot/nclib
nclib/netcat.py
Netcat.recv_all
def recv_all(self, timeout='default'): """ Return all data recieved until connection closes. Aliases: read_all, readall, recvall """ self._print_recv_header('======== Receiving until close{timeout_text} ========', timeout) return self._recv_predicate(lambda s: 0, timeo...
python
def recv_all(self, timeout='default'): """ Return all data recieved until connection closes. Aliases: read_all, readall, recvall """ self._print_recv_header('======== Receiving until close{timeout_text} ========', timeout) return self._recv_predicate(lambda s: 0, timeo...
[ "def", "recv_all", "(", "self", ",", "timeout", "=", "'default'", ")", ":", "self", ".", "_print_recv_header", "(", "'======== Receiving until close{timeout_text} ========'", ",", "timeout", ")", "return", "self", ".", "_recv_predicate", "(", "lambda", "s", ":", "...
Return all data recieved until connection closes. Aliases: read_all, readall, recvall
[ "Return", "all", "data", "recieved", "until", "connection", "closes", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L674-L683
train
rhelmot/nclib
nclib/netcat.py
Netcat.recv_exactly
def recv_exactly(self, n, timeout='default'): """ Recieve exactly n bytes Aliases: read_exactly, readexactly, recvexactly """ self._print_recv_header( '======== Receiving until exactly {0}B{timeout_text} ========', timeout, n) return self._recv_predicate(la...
python
def recv_exactly(self, n, timeout='default'): """ Recieve exactly n bytes Aliases: read_exactly, readexactly, recvexactly """ self._print_recv_header( '======== Receiving until exactly {0}B{timeout_text} ========', timeout, n) return self._recv_predicate(la...
[ "def", "recv_exactly", "(", "self", ",", "n", ",", "timeout", "=", "'default'", ")", ":", "self", ".", "_print_recv_header", "(", "'======== Receiving until exactly {0}B{timeout_text} ========'", ",", "timeout", ",", "n", ")", "return", "self", ".", "_recv_predicate...
Recieve exactly n bytes Aliases: read_exactly, readexactly, recvexactly
[ "Recieve", "exactly", "n", "bytes" ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L685-L695
train
rhelmot/nclib
nclib/netcat.py
Netcat.send
def send(self, s): """ Sends all the given data to the socket. Aliases: write, put, sendall, send_all """ self._print_header('======== Sending ({0}) ========'.format(len(s))) self._log_send(s) out = len(s) while s: s = s[self._send(s):] ...
python
def send(self, s): """ Sends all the given data to the socket. Aliases: write, put, sendall, send_all """ self._print_header('======== Sending ({0}) ========'.format(len(s))) self._log_send(s) out = len(s) while s: s = s[self._send(s):] ...
[ "def", "send", "(", "self", ",", "s", ")", ":", "self", ".", "_print_header", "(", "'======== Sending ({0}) ========'", ".", "format", "(", "len", "(", "s", ")", ")", ")", "self", ".", "_log_send", "(", "s", ")", "out", "=", "len", "(", "s", ")", "...
Sends all the given data to the socket. Aliases: write, put, sendall, send_all
[ "Sends", "all", "the", "given", "data", "to", "the", "socket", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L697-L710
train
rhelmot/nclib
nclib/netcat.py
Netcat.interact
def interact(self, insock=sys.stdin, outsock=sys.stdout): """ Connects the socket to the terminal for user interaction. Alternate input and output files may be specified. This method cannot be used with a timeout. Aliases: interactive, interaction """ self._prin...
python
def interact(self, insock=sys.stdin, outsock=sys.stdout): """ Connects the socket to the terminal for user interaction. Alternate input and output files may be specified. This method cannot be used with a timeout. Aliases: interactive, interaction """ self._prin...
[ "def", "interact", "(", "self", ",", "insock", "=", "sys", ".", "stdin", ",", "outsock", "=", "sys", ".", "stdout", ")", ":", "self", ".", "_print_header", "(", "'======== Beginning interactive session ========'", ")", "if", "hasattr", "(", "outsock", ",", "...
Connects the socket to the terminal for user interaction. Alternate input and output files may be specified. This method cannot be used with a timeout. Aliases: interactive, interaction
[ "Connects", "the", "socket", "to", "the", "terminal", "for", "user", "interaction", ".", "Alternate", "input", "and", "output", "files", "may", "be", "specified", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L712-L758
train
rhelmot/nclib
nclib/netcat.py
Netcat.recv_line
def recv_line(self, max_size=None, timeout='default', ending=None): """ Recieve until the next newline , default "\\n". The newline string can be changed by changing ``nc.LINE_ENDING``. The newline will be returned as part of the string. Aliases: recvline, readline, read_line, r...
python
def recv_line(self, max_size=None, timeout='default', ending=None): """ Recieve until the next newline , default "\\n". The newline string can be changed by changing ``nc.LINE_ENDING``. The newline will be returned as part of the string. Aliases: recvline, readline, read_line, r...
[ "def", "recv_line", "(", "self", ",", "max_size", "=", "None", ",", "timeout", "=", "'default'", ",", "ending", "=", "None", ")", ":", "if", "ending", "is", "None", ":", "ending", "=", "self", ".", "LINE_ENDING", "return", "self", ".", "recv_until", "(...
Recieve until the next newline , default "\\n". The newline string can be changed by changing ``nc.LINE_ENDING``. The newline will be returned as part of the string. Aliases: recvline, readline, read_line, readln, recvln
[ "Recieve", "until", "the", "next", "newline", "default", "\\\\", "n", ".", "The", "newline", "string", "can", "be", "changed", "by", "changing", "nc", ".", "LINE_ENDING", ".", "The", "newline", "will", "be", "returned", "as", "part", "of", "the", "string",...
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L762-L772
train
rhelmot/nclib
nclib/netcat.py
Netcat.send_line
def send_line(self, line, ending=None): """ Write the string to the wire, followed by a newline. The newline string can be changed by changing ``nc.LINE_ENDING``. Aliases: sendline, writeline, write_line, writeln, sendln """ if ending is None: ending = self.L...
python
def send_line(self, line, ending=None): """ Write the string to the wire, followed by a newline. The newline string can be changed by changing ``nc.LINE_ENDING``. Aliases: sendline, writeline, write_line, writeln, sendln """ if ending is None: ending = self.L...
[ "def", "send_line", "(", "self", ",", "line", ",", "ending", "=", "None", ")", ":", "if", "ending", "is", "None", ":", "ending", "=", "self", ".", "LINE_ENDING", "return", "self", ".", "send", "(", "line", "+", "ending", ")" ]
Write the string to the wire, followed by a newline. The newline string can be changed by changing ``nc.LINE_ENDING``. Aliases: sendline, writeline, write_line, writeln, sendln
[ "Write", "the", "string", "to", "the", "wire", "followed", "by", "a", "newline", ".", "The", "newline", "string", "can", "be", "changed", "by", "changing", "nc", ".", "LINE_ENDING", "." ]
6147779766557ee4fafcbae683bdd2f74157e825
https://github.com/rhelmot/nclib/blob/6147779766557ee4fafcbae683bdd2f74157e825/nclib/netcat.py#L774-L783
train
Alignak-monitoring/alignak
alignak/objects/resultmodulation.py
Resultmodulation.is_active
def is_active(self, timperiods): """ Know if this result modulation is active now :return: True is we are in the period, otherwise False :rtype: bool """ now = int(time.time()) timperiod = timperiods[self.modulation_period] if not timperiod or timperiod.i...
python
def is_active(self, timperiods): """ Know if this result modulation is active now :return: True is we are in the period, otherwise False :rtype: bool """ now = int(time.time()) timperiod = timperiods[self.modulation_period] if not timperiod or timperiod.i...
[ "def", "is_active", "(", "self", ",", "timperiods", ")", ":", "now", "=", "int", "(", "time", ".", "time", "(", ")", ")", "timperiod", "=", "timperiods", "[", "self", ".", "modulation_period", "]", "if", "not", "timperiod", "or", "timperiod", ".", "is_...
Know if this result modulation is active now :return: True is we are in the period, otherwise False :rtype: bool
[ "Know", "if", "this", "result", "modulation", "is", "active", "now" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/resultmodulation.py#L93-L104
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface.object
def object(self, o_type, o_name=None): """Get an object from the scheduler. The result is a serialized object which is a Json structure containing: - content: the serialized object content - __sys_python_module__: the python class of the returned object The Alignak unserialize ...
python
def object(self, o_type, o_name=None): """Get an object from the scheduler. The result is a serialized object which is a Json structure containing: - content: the serialized object content - __sys_python_module__: the python class of the returned object The Alignak unserialize ...
[ "def", "object", "(", "self", ",", "o_type", ",", "o_name", "=", "None", ")", ":", "o_found", "=", "self", ".", "_get_object", "(", "o_type", "=", "o_type", ",", "o_name", "=", "o_name", ")", "if", "not", "o_found", ":", "return", "{", "'_status'", "...
Get an object from the scheduler. The result is a serialized object which is a Json structure containing: - content: the serialized object content - __sys_python_module__: the python class of the returned object The Alignak unserialize function of the alignak.misc.serialization package...
[ "Get", "an", "object", "from", "the", "scheduler", "." ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L48-L113
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface.monitoring_problems
def monitoring_problems(self): """Get Alignak scheduler monitoring status Returns an object with the scheduler livesynthesis and the known problems :return: scheduler live synthesis :rtype: dict """ if self.app.type != 'scheduler': return {'_status':...
python
def monitoring_problems(self): """Get Alignak scheduler monitoring status Returns an object with the scheduler livesynthesis and the known problems :return: scheduler live synthesis :rtype: dict """ if self.app.type != 'scheduler': return {'_status':...
[ "def", "monitoring_problems", "(", "self", ")", ":", "if", "self", ".", "app", ".", "type", "!=", "'scheduler'", ":", "return", "{", "'_status'", ":", "u'ERR'", ",", "'_message'", ":", "u\"This service is only available for a scheduler daemon\"", "}", "res", "=", ...
Get Alignak scheduler monitoring status Returns an object with the scheduler livesynthesis and the known problems :return: scheduler live synthesis :rtype: dict
[ "Get", "Alignak", "scheduler", "monitoring", "status" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L329-L344
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface._wait_new_conf
def _wait_new_conf(self): """Ask the scheduler to drop its configuration and wait for a new one. This overrides the default method from GenericInterface :return: None """ # Stop the scheduling loop self.app.sched.stop_scheduling() super(SchedulerInterface, self)...
python
def _wait_new_conf(self): """Ask the scheduler to drop its configuration and wait for a new one. This overrides the default method from GenericInterface :return: None """ # Stop the scheduling loop self.app.sched.stop_scheduling() super(SchedulerInterface, self)...
[ "def", "_wait_new_conf", "(", "self", ")", ":", "self", ".", "app", ".", "sched", ".", "stop_scheduling", "(", ")", "super", "(", "SchedulerInterface", ",", "self", ")", ".", "_wait_new_conf", "(", ")" ]
Ask the scheduler to drop its configuration and wait for a new one. This overrides the default method from GenericInterface :return: None
[ "Ask", "the", "scheduler", "to", "drop", "its", "configuration", "and", "wait", "for", "a", "new", "one", "." ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L357-L366
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface._initial_broks
def _initial_broks(self, broker_name): """Get initial_broks from the scheduler This is used by the brokers to prepare the initial status broks This do not send broks, it only makes scheduler internal processing. Then the broker must use the *_broks* API to get all the stuff :p...
python
def _initial_broks(self, broker_name): """Get initial_broks from the scheduler This is used by the brokers to prepare the initial status broks This do not send broks, it only makes scheduler internal processing. Then the broker must use the *_broks* API to get all the stuff :p...
[ "def", "_initial_broks", "(", "self", ",", "broker_name", ")", ":", "with", "self", ".", "app", ".", "conf_lock", ":", "logger", ".", "info", "(", "\"A new broker just connected : %s\"", ",", "broker_name", ")", "return", "self", ".", "app", ".", "sched", "....
Get initial_broks from the scheduler This is used by the brokers to prepare the initial status broks This do not send broks, it only makes scheduler internal processing. Then the broker must use the *_broks* API to get all the stuff :param broker_name: broker name, used to filter brok...
[ "Get", "initial_broks", "from", "the", "scheduler" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L370-L384
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface._broks
def _broks(self, broker_name): """Get the broks from a scheduler, used by brokers This is used by the brokers to get the broks list of a scheduler :param broker_name: broker name, used to filter broks :type broker_name: str :return: serialized brok list :rtype: dict ...
python
def _broks(self, broker_name): """Get the broks from a scheduler, used by brokers This is used by the brokers to get the broks list of a scheduler :param broker_name: broker name, used to filter broks :type broker_name: str :return: serialized brok list :rtype: dict ...
[ "def", "_broks", "(", "self", ",", "broker_name", ")", ":", "logger", ".", "debug", "(", "\"Getting broks for %s from the scheduler\"", ",", "broker_name", ")", "for", "broker_link", "in", "list", "(", "self", ".", "app", ".", "brokers", ".", "values", "(", ...
Get the broks from a scheduler, used by brokers This is used by the brokers to get the broks list of a scheduler :param broker_name: broker name, used to filter broks :type broker_name: str :return: serialized brok list :rtype: dict
[ "Get", "the", "broks", "from", "a", "scheduler", "used", "by", "brokers" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L388-L410
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface._get_objects
def _get_objects(self, o_type): """Get an object list from the scheduler Returns None if the required object type (`o_type`) is not known or an exception is raised. Else returns the objects list :param o_type: searched object type :type o_type: str :return: objects list...
python
def _get_objects(self, o_type): """Get an object list from the scheduler Returns None if the required object type (`o_type`) is not known or an exception is raised. Else returns the objects list :param o_type: searched object type :type o_type: str :return: objects list...
[ "def", "_get_objects", "(", "self", ",", "o_type", ")", ":", "if", "o_type", "not", "in", "[", "t", "for", "t", "in", "self", ".", "app", ".", "sched", ".", "pushed_conf", ".", "types_creations", "]", ":", "return", "None", "try", ":", "_", ",", "_...
Get an object list from the scheduler Returns None if the required object type (`o_type`) is not known or an exception is raised. Else returns the objects list :param o_type: searched object type :type o_type: str :return: objects list :rtype: alignak.objects.item.Items
[ "Get", "an", "object", "list", "from", "the", "scheduler" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L498-L518
train
Alignak-monitoring/alignak
alignak/http/scheduler_interface.py
SchedulerInterface._get_object
def _get_object(self, o_type, o_name=None): """Get an object from the scheduler Returns None if the required object type (`o_type`) is not known. Else returns the serialized object if found. The object is searched first with o_name as its name and then with o_name as its uuid. ...
python
def _get_object(self, o_type, o_name=None): """Get an object from the scheduler Returns None if the required object type (`o_type`) is not known. Else returns the serialized object if found. The object is searched first with o_name as its name and then with o_name as its uuid. ...
[ "def", "_get_object", "(", "self", ",", "o_type", ",", "o_name", "=", "None", ")", ":", "try", ":", "o_found", "=", "None", "o_list", "=", "self", ".", "_get_objects", "(", "o_type", ")", "if", "o_list", ":", "if", "o_name", "is", "None", ":", "retur...
Get an object from the scheduler Returns None if the required object type (`o_type`) is not known. Else returns the serialized object if found. The object is searched first with o_name as its name and then with o_name as its uuid. :param o_type: searched object type :type o_typ...
[ "Get", "an", "object", "from", "the", "scheduler" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/http/scheduler_interface.py#L520-L547
train
Alignak-monitoring/alignak
alignak/objects/module.py
Module.is_a_module
def is_a_module(self, module_type): """ Is the module of the required type? :param module_type: module type to check :type: str :return: True / False """ if hasattr(self, 'type'): return module_type in self.type return module_type in self.modu...
python
def is_a_module(self, module_type): """ Is the module of the required type? :param module_type: module type to check :type: str :return: True / False """ if hasattr(self, 'type'): return module_type in self.type return module_type in self.modu...
[ "def", "is_a_module", "(", "self", ",", "module_type", ")", ":", "if", "hasattr", "(", "self", ",", "'type'", ")", ":", "return", "module_type", "in", "self", ".", "type", "return", "module_type", "in", "self", ".", "module_types" ]
Is the module of the required type? :param module_type: module type to check :type: str :return: True / False
[ "Is", "the", "module", "of", "the", "required", "type?" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/module.py#L198-L208
train
Alignak-monitoring/alignak
alignak/objects/module.py
Module.serialize
def serialize(self): """A module may have some properties that are not defined in the class properties list. Serializing a module is the same as serializing an Item but we also also include all the existing properties that are not defined in the properties or running_properties class lis...
python
def serialize(self): """A module may have some properties that are not defined in the class properties list. Serializing a module is the same as serializing an Item but we also also include all the existing properties that are not defined in the properties or running_properties class lis...
[ "def", "serialize", "(", "self", ")", ":", "res", "=", "super", "(", "Module", ",", "self", ")", ".", "serialize", "(", ")", "cls", "=", "self", ".", "__class__", "for", "prop", "in", "self", ".", "__dict__", ":", "if", "prop", "in", "cls", ".", ...
A module may have some properties that are not defined in the class properties list. Serializing a module is the same as serializing an Item but we also also include all the existing properties that are not defined in the properties or running_properties class list. We must also exclude...
[ "A", "module", "may", "have", "some", "properties", "that", "are", "not", "defined", "in", "the", "class", "properties", "list", ".", "Serializing", "a", "module", "is", "the", "same", "as", "serializing", "an", "Item", "but", "we", "also", "also", "includ...
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/module.py#L210-L227
train
Alignak-monitoring/alignak
alignak/objects/module.py
Modules.linkify_s_by_plug
def linkify_s_by_plug(self): """Link a module to some other modules :return: None """ for module in self: new_modules = [] for related in getattr(module, 'modules', []): related = related.strip() if not related: ...
python
def linkify_s_by_plug(self): """Link a module to some other modules :return: None """ for module in self: new_modules = [] for related in getattr(module, 'modules', []): related = related.strip() if not related: ...
[ "def", "linkify_s_by_plug", "(", "self", ")", ":", "for", "module", "in", "self", ":", "new_modules", "=", "[", "]", "for", "related", "in", "getattr", "(", "module", ",", "'modules'", ",", "[", "]", ")", ":", "related", "=", "related", ".", "strip", ...
Link a module to some other modules :return: None
[ "Link", "a", "module", "to", "some", "other", "modules" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/module.py#L245-L262
train
Alignak-monitoring/alignak
alignak/daterange.py
get_start_of_day
def get_start_of_day(year, month, day): """Get the timestamp associated to the first second of a specific day :param year: date year :type year: int :param month: date month :type month: int :param day: date day :type day: int :return: timestamp :rtype: int """ # DST is not ...
python
def get_start_of_day(year, month, day): """Get the timestamp associated to the first second of a specific day :param year: date year :type year: int :param month: date month :type month: int :param day: date day :type day: int :return: timestamp :rtype: int """ # DST is not ...
[ "def", "get_start_of_day", "(", "year", ",", "month", ",", "day", ")", ":", "try", ":", "timestamp", "=", "time", ".", "mktime", "(", "(", "year", ",", "month", ",", "day", ",", "00", ",", "00", ",", "00", ",", "0", ",", "0", ",", "-", "1", "...
Get the timestamp associated to the first second of a specific day :param year: date year :type year: int :param month: date month :type month: int :param day: date day :type day: int :return: timestamp :rtype: int
[ "Get", "the", "timestamp", "associated", "to", "the", "first", "second", "of", "a", "specific", "day" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L63-L82
train
Alignak-monitoring/alignak
alignak/daterange.py
get_end_of_day
def get_end_of_day(year, month, day): """Get the timestamp associated to the last second of a specific day :param year: date year :type year: int :param month: date month (int) :type month: int :param day: date day :type day: int :return: timestamp :rtype: int """ # DST is n...
python
def get_end_of_day(year, month, day): """Get the timestamp associated to the last second of a specific day :param year: date year :type year: int :param month: date month (int) :type month: int :param day: date day :type day: int :return: timestamp :rtype: int """ # DST is n...
[ "def", "get_end_of_day", "(", "year", ",", "month", ",", "day", ")", ":", "timestamp", "=", "time", ".", "mktime", "(", "(", "year", ",", "month", ",", "day", ",", "23", ",", "59", ",", "59", ",", "0", ",", "0", ",", "-", "1", ")", ")", "retu...
Get the timestamp associated to the last second of a specific day :param year: date year :type year: int :param month: date month (int) :type month: int :param day: date day :type day: int :return: timestamp :rtype: int
[ "Get", "the", "timestamp", "associated", "to", "the", "last", "second", "of", "a", "specific", "day" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L85-L99
train
Alignak-monitoring/alignak
alignak/daterange.py
get_sec_from_morning
def get_sec_from_morning(timestamp): """Get the number of seconds elapsed since the beginning of the day deducted from the provided timestamp :param timestamp: time to use for computation :type timestamp: int :return: timestamp :rtype: int """ t_lt = time.localtime(timestamp) return...
python
def get_sec_from_morning(timestamp): """Get the number of seconds elapsed since the beginning of the day deducted from the provided timestamp :param timestamp: time to use for computation :type timestamp: int :return: timestamp :rtype: int """ t_lt = time.localtime(timestamp) return...
[ "def", "get_sec_from_morning", "(", "timestamp", ")", ":", "t_lt", "=", "time", ".", "localtime", "(", "timestamp", ")", "return", "t_lt", ".", "tm_hour", "*", "3600", "+", "t_lt", ".", "tm_min", "*", "60", "+", "t_lt", ".", "tm_sec" ]
Get the number of seconds elapsed since the beginning of the day deducted from the provided timestamp :param timestamp: time to use for computation :type timestamp: int :return: timestamp :rtype: int
[ "Get", "the", "number", "of", "seconds", "elapsed", "since", "the", "beginning", "of", "the", "day", "deducted", "from", "the", "provided", "timestamp" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L126-L136
train
Alignak-monitoring/alignak
alignak/daterange.py
find_day_by_weekday_offset
def find_day_by_weekday_offset(year, month, weekday, offset): """Get the day number based on a date and offset :param year: date year :type year: int :param month: date month :type month: int :param weekday: date week day :type weekday: int :param offset: offset (-1 is last, 1 is first ...
python
def find_day_by_weekday_offset(year, month, weekday, offset): """Get the day number based on a date and offset :param year: date year :type year: int :param month: date month :type month: int :param weekday: date week day :type weekday: int :param offset: offset (-1 is last, 1 is first ...
[ "def", "find_day_by_weekday_offset", "(", "year", ",", "month", ",", "weekday", ",", "offset", ")", ":", "cal", "=", "calendar", ".", "monthcalendar", "(", "year", ",", "month", ")", "if", "offset", "<", "0", ":", "offset", "=", "abs", "(", "offset", "...
Get the day number based on a date and offset :param year: date year :type year: int :param month: date month :type month: int :param weekday: date week day :type weekday: int :param offset: offset (-1 is last, 1 is first etc) :type offset: int :return: day number in the month :...
[ "Get", "the", "day", "number", "based", "on", "a", "date", "and", "offset" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L139-L175
train
Alignak-monitoring/alignak
alignak/daterange.py
find_day_by_offset
def find_day_by_offset(year, month, offset): """Get the month day based on date and offset :param year: date year :type year: int :param month: date month :type month: int :param offset: offset in day to compute (usually negative) :type offset: int :return: day number in the month :...
python
def find_day_by_offset(year, month, offset): """Get the month day based on date and offset :param year: date year :type year: int :param month: date month :type month: int :param offset: offset in day to compute (usually negative) :type offset: int :return: day number in the month :...
[ "def", "find_day_by_offset", "(", "year", ",", "month", ",", "offset", ")", ":", "(", "_", ",", "days_in_month", ")", "=", "calendar", ".", "monthrange", "(", "year", ",", "month", ")", "if", "offset", ">=", "0", ":", "return", "min", "(", "offset", ...
Get the month day based on date and offset :param year: date year :type year: int :param month: date month :type month: int :param offset: offset in day to compute (usually negative) :type offset: int :return: day number in the month :rtype: int >>> find_day_by_offset(2015, 7, -1) ...
[ "Get", "the", "month", "day", "based", "on", "date", "and", "offset" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L178-L197
train
Alignak-monitoring/alignak
alignak/daterange.py
Timerange.is_time_valid
def is_time_valid(self, timestamp): """Check if time is valid for this Timerange If sec_from_morning is not provided, get the value. :param timestamp: time to check :type timestamp: int :return: True if time is valid (in interval), False otherwise :rtype: bool "...
python
def is_time_valid(self, timestamp): """Check if time is valid for this Timerange If sec_from_morning is not provided, get the value. :param timestamp: time to check :type timestamp: int :return: True if time is valid (in interval), False otherwise :rtype: bool "...
[ "def", "is_time_valid", "(", "self", ",", "timestamp", ")", ":", "sec_from_morning", "=", "get_sec_from_morning", "(", "timestamp", ")", "return", "(", "self", ".", "is_valid", "and", "self", ".", "hstart", "*", "3600", "+", "self", ".", "mstart", "*", "60...
Check if time is valid for this Timerange If sec_from_morning is not provided, get the value. :param timestamp: time to check :type timestamp: int :return: True if time is valid (in interval), False otherwise :rtype: bool
[ "Check", "if", "time", "is", "valid", "for", "this", "Timerange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L268-L282
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.is_time_valid
def is_time_valid(self, timestamp): """Check if time is valid for one of the timerange. :param timestamp: time to check :type timestamp: int :return: True if one of the timerange is valid for t, False otherwise :rtype: bool """ if self.is_time_day_valid(timestamp...
python
def is_time_valid(self, timestamp): """Check if time is valid for one of the timerange. :param timestamp: time to check :type timestamp: int :return: True if one of the timerange is valid for t, False otherwise :rtype: bool """ if self.is_time_day_valid(timestamp...
[ "def", "is_time_valid", "(", "self", ",", "timestamp", ")", ":", "if", "self", ".", "is_time_day_valid", "(", "timestamp", ")", ":", "for", "timerange", "in", "self", ".", "timeranges", ":", "if", "timerange", ".", "is_time_valid", "(", "timestamp", ")", "...
Check if time is valid for one of the timerange. :param timestamp: time to check :type timestamp: int :return: True if one of the timerange is valid for t, False otherwise :rtype: bool
[ "Check", "if", "time", "is", "valid", "for", "one", "of", "the", "timerange", "." ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L379-L391
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_min_sec_from_morning
def get_min_sec_from_morning(self): """Get the first second from midnight where a timerange is effective :return: smallest amount of second from midnight of all timerange :rtype: int """ mins = [] for timerange in self.timeranges: mins.append(timerange.get_se...
python
def get_min_sec_from_morning(self): """Get the first second from midnight where a timerange is effective :return: smallest amount of second from midnight of all timerange :rtype: int """ mins = [] for timerange in self.timeranges: mins.append(timerange.get_se...
[ "def", "get_min_sec_from_morning", "(", "self", ")", ":", "mins", "=", "[", "]", "for", "timerange", "in", "self", ".", "timeranges", ":", "mins", ".", "append", "(", "timerange", ".", "get_sec_from_morning", "(", ")", ")", "return", "min", "(", "mins", ...
Get the first second from midnight where a timerange is effective :return: smallest amount of second from midnight of all timerange :rtype: int
[ "Get", "the", "first", "second", "from", "midnight", "where", "a", "timerange", "is", "effective" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L393-L402
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.is_time_day_valid
def is_time_day_valid(self, timestamp): """Check if it is within start time and end time of the DateRange :param timestamp: time to check :type timestamp: int :return: True if t in range, False otherwise :rtype: bool """ (start_time, end_time) = self.get_start_an...
python
def is_time_day_valid(self, timestamp): """Check if it is within start time and end time of the DateRange :param timestamp: time to check :type timestamp: int :return: True if t in range, False otherwise :rtype: bool """ (start_time, end_time) = self.get_start_an...
[ "def", "is_time_day_valid", "(", "self", ",", "timestamp", ")", ":", "(", "start_time", ",", "end_time", ")", "=", "self", ".", "get_start_and_end_time", "(", "timestamp", ")", "return", "start_time", "<=", "timestamp", "<=", "end_time" ]
Check if it is within start time and end time of the DateRange :param timestamp: time to check :type timestamp: int :return: True if t in range, False otherwise :rtype: bool
[ "Check", "if", "it", "is", "within", "start", "time", "and", "end", "time", "of", "the", "DateRange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L428-L437
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_next_future_timerange_invalid
def get_next_future_timerange_invalid(self, timestamp): """Get next invalid time for timeranges :param timestamp: time to check :type timestamp: int :return: next time when a timerange is not valid :rtype: None | int """ sec_from_morning = get_sec_from_morning(ti...
python
def get_next_future_timerange_invalid(self, timestamp): """Get next invalid time for timeranges :param timestamp: time to check :type timestamp: int :return: next time when a timerange is not valid :rtype: None | int """ sec_from_morning = get_sec_from_morning(ti...
[ "def", "get_next_future_timerange_invalid", "(", "self", ",", "timestamp", ")", ":", "sec_from_morning", "=", "get_sec_from_morning", "(", "timestamp", ")", "ends", "=", "[", "]", "for", "timerange", "in", "self", ".", "timeranges", ":", "tr_end", "=", "timerang...
Get next invalid time for timeranges :param timestamp: time to check :type timestamp: int :return: next time when a timerange is not valid :rtype: None | int
[ "Get", "next", "invalid", "time", "for", "timeranges" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L468-L488
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_next_valid_day
def get_next_valid_day(self, timestamp): """Get next valid day for timerange :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid day (midnight) in LOCAL time. :rtype: int | None """ if self.get_next_future_timerange_va...
python
def get_next_valid_day(self, timestamp): """Get next valid day for timerange :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid day (midnight) in LOCAL time. :rtype: int | None """ if self.get_next_future_timerange_va...
[ "def", "get_next_valid_day", "(", "self", ",", "timestamp", ")", ":", "if", "self", ".", "get_next_future_timerange_valid", "(", "timestamp", ")", "is", "None", ":", "(", "start_time", ",", "_", ")", "=", "self", ".", "get_start_and_end_time", "(", "get_day", ...
Get next valid day for timerange :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid day (midnight) in LOCAL time. :rtype: int | None
[ "Get", "next", "valid", "day", "for", "timerange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L490-L510
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_next_valid_time_from_t
def get_next_valid_time_from_t(self, timestamp): """Get next valid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid time (LOCAL TIME) :rtype: int | None """ if self.is_time_valid(timestamp): ...
python
def get_next_valid_time_from_t(self, timestamp): """Get next valid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid time (LOCAL TIME) :rtype: int | None """ if self.is_time_valid(timestamp): ...
[ "def", "get_next_valid_time_from_t", "(", "self", ",", "timestamp", ")", ":", "if", "self", ".", "is_time_valid", "(", "timestamp", ")", ":", "return", "timestamp", "t_day", "=", "self", ".", "get_next_valid_day", "(", "timestamp", ")", "if", "t_day", "is", ...
Get next valid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next valid time (LOCAL TIME) :rtype: int | None
[ "Get", "next", "valid", "time", "for", "time", "range" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L512-L548
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_next_invalid_day
def get_next_invalid_day(self, timestamp): # pylint: disable=no-else-return """Get next day where timerange is not active :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid day (midnight) in LOCAL time. :rtype: int | None ...
python
def get_next_invalid_day(self, timestamp): # pylint: disable=no-else-return """Get next day where timerange is not active :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid day (midnight) in LOCAL time. :rtype: int | None ...
[ "def", "get_next_invalid_day", "(", "self", ",", "timestamp", ")", ":", "if", "self", ".", "is_time_day_invalid", "(", "timestamp", ")", ":", "return", "timestamp", "next_future_timerange_invalid", "=", "self", ".", "get_next_future_timerange_invalid", "(", "timestamp...
Get next day where timerange is not active :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid day (midnight) in LOCAL time. :rtype: int | None
[ "Get", "next", "day", "where", "timerange", "is", "not", "active" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L550-L584
train
Alignak-monitoring/alignak
alignak/daterange.py
AbstractDaterange.get_next_invalid_time_from_t
def get_next_invalid_time_from_t(self, timestamp): """Get next invalid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid time (LOCAL TIME) :rtype: int """ if not self.is_time_valid(timestamp): ...
python
def get_next_invalid_time_from_t(self, timestamp): """Get next invalid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid time (LOCAL TIME) :rtype: int """ if not self.is_time_valid(timestamp): ...
[ "def", "get_next_invalid_time_from_t", "(", "self", ",", "timestamp", ")", ":", "if", "not", "self", ".", "is_time_valid", "(", "timestamp", ")", ":", "return", "timestamp", "t_day", "=", "self", ".", "get_next_invalid_day", "(", "timestamp", ")", "if", "times...
Get next invalid time for time range :param timestamp: time we compute from :type timestamp: int :return: timestamp of the next invalid time (LOCAL TIME) :rtype: int
[ "Get", "next", "invalid", "time", "for", "time", "range" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L586-L632
train
Alignak-monitoring/alignak
alignak/daterange.py
CalendarDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for CalendarDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ return (get_start_of_day(self.syea...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for CalendarDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ return (get_start_of_day(self.syea...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "return", "(", "get_start_of_day", "(", "self", ".", "syear", ",", "int", "(", "self", ".", "smon", ")", ",", "self", ".", "smday", ")", ",", "get_end_of_day", "(", "self"...
Specific function to get start time and end time for CalendarDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "CalendarDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L728-L737
train
Alignak-monitoring/alignak
alignak/daterange.py
StandardDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for StandardDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for StandardDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "self", ".", "syear", "=", "now", ".", "tm_year", "self", ".", "month", "=", "now", ".", "tm_mon", "self", ".", ...
Specific function to get start time and end time for StandardDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "StandardDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L794-L812
train
Alignak-monitoring/alignak
alignak/daterange.py
MonthWeekDayDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthWeekDayDaterange :param ref: time in seconds :type ref: int | None :return: tuple with start and end time :rtype: tuple """ now = time.localtime(ref) ...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthWeekDayDaterange :param ref: time in seconds :type ref: int | None :return: tuple with start and end time :rtype: tuple """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "tm_year", "day_start", "=", ...
Specific function to get start time and end time for MonthWeekDayDaterange :param ref: time in seconds :type ref: int | None :return: tuple with start and end time :rtype: tuple
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "MonthWeekDayDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L837-L878
train
Alignak-monitoring/alignak
alignak/daterange.py
MonthDateDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDateDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDateDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "tm_year", "day_start", "=", ...
Specific function to get start time and end time for MonthDateDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "MonthDateDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L885-L922
train
Alignak-monitoring/alignak
alignak/daterange.py
WeekDayDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "tm_year", "month_start_id", "=...
Specific function to get start time and end time for WeekDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "WeekDayDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L929-L986
train
Alignak-monitoring/alignak
alignak/daterange.py
MonthDayDaterange.get_start_and_end_time
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
python
def get_start_and_end_time(self, ref=None): """Specific function to get start time and end time for MonthDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int) """ now = time.localtime(ref) ...
[ "def", "get_start_and_end_time", "(", "self", ",", "ref", "=", "None", ")", ":", "now", "=", "time", ".", "localtime", "(", "ref", ")", "if", "self", ".", "syear", "==", "0", ":", "self", ".", "syear", "=", "now", ".", "tm_year", "month_start_id", "=...
Specific function to get start time and end time for MonthDayDaterange :param ref: time in seconds :type ref: int :return: tuple with start and end time :rtype: tuple (int, int)
[ "Specific", "function", "to", "get", "start", "time", "and", "end", "time", "for", "MonthDayDaterange" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/daterange.py#L993-L1042
train
Alignak-monitoring/alignak
alignak/external_command.py
ExternalCommandManager.get_unknown_check_result_brok
def get_unknown_check_result_brok(cmd_line): """Create unknown check result brok and fill it with command data :param cmd_line: command line to extract data :type cmd_line: str :return: unknown check result brok :rtype: alignak.objects.brok.Brok """ match = re.ma...
python
def get_unknown_check_result_brok(cmd_line): """Create unknown check result brok and fill it with command data :param cmd_line: command line to extract data :type cmd_line: str :return: unknown check result brok :rtype: alignak.objects.brok.Brok """ match = re.ma...
[ "def", "get_unknown_check_result_brok", "(", "cmd_line", ")", ":", "match", "=", "re", ".", "match", "(", "r'^\\[([0-9]{10})] PROCESS_(SERVICE)_CHECK_RESULT;'", "r'([^\\;]*);([^\\;]*);([^\\;]*);([^\\|]*)(?:\\|(.*))?'", ",", "cmd_line", ")", "if", "not", "match", ":", "match...
Create unknown check result brok and fill it with command data :param cmd_line: command line to extract data :type cmd_line: str :return: unknown check result brok :rtype: alignak.objects.brok.Brok
[ "Create", "unknown", "check", "result", "brok", "and", "fill", "it", "with", "command", "data" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/external_command.py#L676-L710
train
Alignak-monitoring/alignak
alignak/objects/hostdependency.py
Hostdependency.get_name
def get_name(self): """Get name based on dependent_host_name and host_name attributes Each attribute is substituted by 'unknown' if attribute does not exist :return: dependent_host_name/host_name :rtype: str """ dependent_host_name = 'unknown' if getattr(self, 'd...
python
def get_name(self): """Get name based on dependent_host_name and host_name attributes Each attribute is substituted by 'unknown' if attribute does not exist :return: dependent_host_name/host_name :rtype: str """ dependent_host_name = 'unknown' if getattr(self, 'd...
[ "def", "get_name", "(", "self", ")", ":", "dependent_host_name", "=", "'unknown'", "if", "getattr", "(", "self", ",", "'dependent_host_name'", ",", "None", ")", ":", "dependent_host_name", "=", "getattr", "(", "getattr", "(", "self", ",", "'dependent_host_name'"...
Get name based on dependent_host_name and host_name attributes Each attribute is substituted by 'unknown' if attribute does not exist :return: dependent_host_name/host_name :rtype: str
[ "Get", "name", "based", "on", "dependent_host_name", "and", "host_name", "attributes", "Each", "attribute", "is", "substituted", "by", "unknown", "if", "attribute", "does", "not", "exist" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostdependency.py#L110-L125
train
Alignak-monitoring/alignak
alignak/objects/hostdependency.py
Hostdependencies.linkify_hd_by_h
def linkify_hd_by_h(self, hosts): """Replace dependent_host_name and host_name in host dependency by the real object :param hosts: host list, used to look for a specific one :type hosts: alignak.objects.host.Hosts :return: None """ for hostdep in self: ...
python
def linkify_hd_by_h(self, hosts): """Replace dependent_host_name and host_name in host dependency by the real object :param hosts: host list, used to look for a specific one :type hosts: alignak.objects.host.Hosts :return: None """ for hostdep in self: ...
[ "def", "linkify_hd_by_h", "(", "self", ",", "hosts", ")", ":", "for", "hostdep", "in", "self", ":", "try", ":", "h_name", "=", "hostdep", ".", "host_name", "dh_name", "=", "hostdep", ".", "dependent_host_name", "host", "=", "hosts", ".", "find_by_name", "(...
Replace dependent_host_name and host_name in host dependency by the real object :param hosts: host list, used to look for a specific one :type hosts: alignak.objects.host.Hosts :return: None
[ "Replace", "dependent_host_name", "and", "host_name", "in", "host", "dependency", "by", "the", "real", "object" ]
f3c145207e83159b799d3714e4241399c7740a64
https://github.com/Alignak-monitoring/alignak/blob/f3c145207e83159b799d3714e4241399c7740a64/alignak/objects/hostdependency.py#L224-L251
train