id
int32
0
252k
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
29,700
Miserlou/Zappa
zappa/core.py
Zappa.stack_outputs
def stack_outputs(self, name): """ Given a name, describes CloudFront stacks and returns dict of the stack Outputs , else returns an empty dict. """ try: stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0] return {x['OutputKey']: x['OutputV...
python
def stack_outputs(self, name): """ Given a name, describes CloudFront stacks and returns dict of the stack Outputs , else returns an empty dict. """ try: stack = self.cf_client.describe_stacks(StackName=name)['Stacks'][0] return {x['OutputKey']: x['OutputV...
[ "def", "stack_outputs", "(", "self", ",", "name", ")", ":", "try", ":", "stack", "=", "self", ".", "cf_client", ".", "describe_stacks", "(", "StackName", "=", "name", ")", "[", "'Stacks'", "]", "[", "0", "]", "return", "{", "x", "[", "'OutputKey'", "...
Given a name, describes CloudFront stacks and returns dict of the stack Outputs , else returns an empty dict.
[ "Given", "a", "name", "describes", "CloudFront", "stacks", "and", "returns", "dict", "of", "the", "stack", "Outputs", "else", "returns", "an", "empty", "dict", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2239-L2248
29,701
Miserlou/Zappa
zappa/core.py
Zappa.get_api_url
def get_api_url(self, lambda_name, stage_name): """ Given a lambda_name and stage_name, return a valid API URL. """ api_id = self.get_api_id(lambda_name) if api_id: return "https://{}.execute-api.{}.amazonaws.com/{}".format(api_id, self.boto_session.region_name, stage...
python
def get_api_url(self, lambda_name, stage_name): """ Given a lambda_name and stage_name, return a valid API URL. """ api_id = self.get_api_id(lambda_name) if api_id: return "https://{}.execute-api.{}.amazonaws.com/{}".format(api_id, self.boto_session.region_name, stage...
[ "def", "get_api_url", "(", "self", ",", "lambda_name", ",", "stage_name", ")", ":", "api_id", "=", "self", ".", "get_api_id", "(", "lambda_name", ")", "if", "api_id", ":", "return", "\"https://{}.execute-api.{}.amazonaws.com/{}\"", ".", "format", "(", "api_id", ...
Given a lambda_name and stage_name, return a valid API URL.
[ "Given", "a", "lambda_name", "and", "stage_name", "return", "a", "valid", "API", "URL", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2251-L2259
29,702
Miserlou/Zappa
zappa/core.py
Zappa.get_api_id
def get_api_id(self, lambda_name): """ Given a lambda_name, return the API id. """ try: response = self.cf_client.describe_stack_resource(StackName=lambda_name, LogicalResourceId='Api') return response[...
python
def get_api_id(self, lambda_name): """ Given a lambda_name, return the API id. """ try: response = self.cf_client.describe_stack_resource(StackName=lambda_name, LogicalResourceId='Api') return response[...
[ "def", "get_api_id", "(", "self", ",", "lambda_name", ")", ":", "try", ":", "response", "=", "self", ".", "cf_client", ".", "describe_stack_resource", "(", "StackName", "=", "lambda_name", ",", "LogicalResourceId", "=", "'Api'", ")", "return", "response", "[",...
Given a lambda_name, return the API id.
[ "Given", "a", "lambda_name", "return", "the", "API", "id", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2261-L2282
29,703
Miserlou/Zappa
zappa/core.py
Zappa.create_domain_name
def create_domain_name(self, domain_name, certificate_name, certificate_body=None, certificate_private_key=None, certificate_chain=None, certificate_arn=None,...
python
def create_domain_name(self, domain_name, certificate_name, certificate_body=None, certificate_private_key=None, certificate_chain=None, certificate_arn=None,...
[ "def", "create_domain_name", "(", "self", ",", "domain_name", ",", "certificate_name", ",", "certificate_body", "=", "None", ",", "certificate_private_key", "=", "None", ",", "certificate_chain", "=", "None", ",", "certificate_arn", "=", "None", ",", "lambda_name", ...
Creates the API GW domain and returns the resulting DNS name.
[ "Creates", "the", "API", "GW", "domain", "and", "returns", "the", "resulting", "DNS", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2284-L2326
29,704
Miserlou/Zappa
zappa/core.py
Zappa.update_route53_records
def update_route53_records(self, domain_name, dns_name): """ Updates Route53 Records following GW domain creation """ zone_id = self.get_hosted_zone_id_for_domain(domain_name) is_apex = self.route53.get_hosted_zone(Id=zone_id)['HostedZone']['Name'][:-1] == domain_name if...
python
def update_route53_records(self, domain_name, dns_name): """ Updates Route53 Records following GW domain creation """ zone_id = self.get_hosted_zone_id_for_domain(domain_name) is_apex = self.route53.get_hosted_zone(Id=zone_id)['HostedZone']['Name'][:-1] == domain_name if...
[ "def", "update_route53_records", "(", "self", ",", "domain_name", ",", "dns_name", ")", ":", "zone_id", "=", "self", ".", "get_hosted_zone_id_for_domain", "(", "domain_name", ")", "is_apex", "=", "self", ".", "route53", ".", "get_hosted_zone", "(", "Id", "=", ...
Updates Route53 Records following GW domain creation
[ "Updates", "Route53", "Records", "following", "GW", "domain", "creation" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2328-L2377
29,705
Miserlou/Zappa
zappa/core.py
Zappa.update_domain_name
def update_domain_name(self, domain_name, certificate_name=None, certificate_body=None, certificate_private_key=None, certificate_chain=None, certificate_arn=...
python
def update_domain_name(self, domain_name, certificate_name=None, certificate_body=None, certificate_private_key=None, certificate_chain=None, certificate_arn=...
[ "def", "update_domain_name", "(", "self", ",", "domain_name", ",", "certificate_name", "=", "None", ",", "certificate_body", "=", "None", ",", "certificate_private_key", "=", "None", ",", "certificate_chain", "=", "None", ",", "certificate_arn", "=", "None", ",", ...
This updates your certificate information for an existing domain, with similar arguments to boto's update_domain_name API Gateway api. It returns the resulting new domain information including the new certificate's ARN if created during this process. Previously, this method involved do...
[ "This", "updates", "your", "certificate", "information", "for", "an", "existing", "domain", "with", "similar", "arguments", "to", "boto", "s", "update_domain_name", "API", "Gateway", "api", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2379-L2429
29,706
Miserlou/Zappa
zappa/core.py
Zappa.update_domain_base_path_mapping
def update_domain_base_path_mapping(self, domain_name, lambda_name, stage, base_path): """ Update domain base path mapping on API Gateway if it was changed """ api_id = self.get_api_id(lambda_name) if not api_id: print("Warning! Can't update base path mapping!") ...
python
def update_domain_base_path_mapping(self, domain_name, lambda_name, stage, base_path): """ Update domain base path mapping on API Gateway if it was changed """ api_id = self.get_api_id(lambda_name) if not api_id: print("Warning! Can't update base path mapping!") ...
[ "def", "update_domain_base_path_mapping", "(", "self", ",", "domain_name", ",", "lambda_name", ",", "stage", ",", "base_path", ")", ":", "api_id", "=", "self", ".", "get_api_id", "(", "lambda_name", ")", "if", "not", "api_id", ":", "print", "(", "\"Warning! Ca...
Update domain base path mapping on API Gateway if it was changed
[ "Update", "domain", "base", "path", "mapping", "on", "API", "Gateway", "if", "it", "was", "changed" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2431-L2458
29,707
Miserlou/Zappa
zappa/core.py
Zappa.get_all_zones
def get_all_zones(self): """Same behaviour of list_host_zones, but transparently handling pagination.""" zones = {'HostedZones': []} new_zones = self.route53.list_hosted_zones(MaxItems='100') while new_zones['IsTruncated']: zones['HostedZones'] += new_zones['HostedZones'] ...
python
def get_all_zones(self): """Same behaviour of list_host_zones, but transparently handling pagination.""" zones = {'HostedZones': []} new_zones = self.route53.list_hosted_zones(MaxItems='100') while new_zones['IsTruncated']: zones['HostedZones'] += new_zones['HostedZones'] ...
[ "def", "get_all_zones", "(", "self", ")", ":", "zones", "=", "{", "'HostedZones'", ":", "[", "]", "}", "new_zones", "=", "self", ".", "route53", ".", "list_hosted_zones", "(", "MaxItems", "=", "'100'", ")", "while", "new_zones", "[", "'IsTruncated'", "]", ...
Same behaviour of list_host_zones, but transparently handling pagination.
[ "Same", "behaviour", "of", "list_host_zones", "but", "transparently", "handling", "pagination", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2460-L2470
29,708
Miserlou/Zappa
zappa/core.py
Zappa.get_domain_name
def get_domain_name(self, domain_name, route53=True): """ Scan our hosted zones for the record of a given name. Returns the record entry, else None. """ # Make sure api gateway domain is present try: self.apigateway_client.get_domain_name(domainName=domain_n...
python
def get_domain_name(self, domain_name, route53=True): """ Scan our hosted zones for the record of a given name. Returns the record entry, else None. """ # Make sure api gateway domain is present try: self.apigateway_client.get_domain_name(domainName=domain_n...
[ "def", "get_domain_name", "(", "self", ",", "domain_name", ",", "route53", "=", "True", ")", ":", "# Make sure api gateway domain is present", "try", ":", "self", ".", "apigateway_client", ".", "get_domain_name", "(", "domainName", "=", "domain_name", ")", "except",...
Scan our hosted zones for the record of a given name. Returns the record entry, else None.
[ "Scan", "our", "hosted", "zones", "for", "the", "record", "of", "a", "given", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2472-L2513
29,709
Miserlou/Zappa
zappa/core.py
Zappa.get_credentials_arn
def get_credentials_arn(self): """ Given our role name, get and set the credentials_arn. """ role = self.iam.Role(self.role_name) self.credentials_arn = role.arn return role, self.credentials_arn
python
def get_credentials_arn(self): """ Given our role name, get and set the credentials_arn. """ role = self.iam.Role(self.role_name) self.credentials_arn = role.arn return role, self.credentials_arn
[ "def", "get_credentials_arn", "(", "self", ")", ":", "role", "=", "self", ".", "iam", ".", "Role", "(", "self", ".", "role_name", ")", "self", ".", "credentials_arn", "=", "role", ".", "arn", "return", "role", ",", "self", ".", "credentials_arn" ]
Given our role name, get and set the credentials_arn.
[ "Given", "our", "role", "name", "get", "and", "set", "the", "credentials_arn", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2519-L2526
29,710
Miserlou/Zappa
zappa/core.py
Zappa.create_iam_roles
def create_iam_roles(self): """ Create and defines the IAM roles and policies necessary for Zappa. If the IAM role already exists, it will be updated if necessary. """ attach_policy_obj = json.loads(self.attach_policy) assume_policy_obj = json.loads(self.assume_policy) ...
python
def create_iam_roles(self): """ Create and defines the IAM roles and policies necessary for Zappa. If the IAM role already exists, it will be updated if necessary. """ attach_policy_obj = json.loads(self.attach_policy) assume_policy_obj = json.loads(self.assume_policy) ...
[ "def", "create_iam_roles", "(", "self", ")", ":", "attach_policy_obj", "=", "json", ".", "loads", "(", "self", ".", "attach_policy", ")", "assume_policy_obj", "=", "json", ".", "loads", "(", "self", ".", "assume_policy", ")", "if", "self", ".", "extra_permis...
Create and defines the IAM roles and policies necessary for Zappa. If the IAM role already exists, it will be updated if necessary.
[ "Create", "and", "defines", "the", "IAM", "roles", "and", "policies", "necessary", "for", "Zappa", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2528-L2581
29,711
Miserlou/Zappa
zappa/core.py
Zappa._clear_policy
def _clear_policy(self, lambda_name): """ Remove obsolete policy statements to prevent policy from bloating over the limit after repeated updates. """ try: policy_response = self.lambda_client.get_policy( FunctionName=lambda_name ) if p...
python
def _clear_policy(self, lambda_name): """ Remove obsolete policy statements to prevent policy from bloating over the limit after repeated updates. """ try: policy_response = self.lambda_client.get_policy( FunctionName=lambda_name ) if p...
[ "def", "_clear_policy", "(", "self", ",", "lambda_name", ")", ":", "try", ":", "policy_response", "=", "self", ".", "lambda_client", ".", "get_policy", "(", "FunctionName", "=", "lambda_name", ")", "if", "policy_response", "[", "'ResponseMetadata'", "]", "[", ...
Remove obsolete policy statements to prevent policy from bloating over the limit after repeated updates.
[ "Remove", "obsolete", "policy", "statements", "to", "prevent", "policy", "from", "bloating", "over", "the", "limit", "after", "repeated", "updates", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2583-L2606
29,712
Miserlou/Zappa
zappa/core.py
Zappa.create_event_permission
def create_event_permission(self, lambda_name, principal, source_arn): """ Create permissions to link to an event. Related: http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-configure-event-source.html """ logger.debug('Adding new permission to invoke Lambda function: ...
python
def create_event_permission(self, lambda_name, principal, source_arn): """ Create permissions to link to an event. Related: http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-configure-event-source.html """ logger.debug('Adding new permission to invoke Lambda function: ...
[ "def", "create_event_permission", "(", "self", ",", "lambda_name", ",", "principal", ",", "source_arn", ")", ":", "logger", ".", "debug", "(", "'Adding new permission to invoke Lambda function: {}'", ".", "format", "(", "lambda_name", ")", ")", "permission_response", ...
Create permissions to link to an event. Related: http://docs.aws.amazon.com/lambda/latest/dg/with-s3-example-configure-event-source.html
[ "Create", "permissions", "to", "link", "to", "an", "event", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2612-L2631
29,713
Miserlou/Zappa
zappa/core.py
Zappa.get_event_name
def get_event_name(lambda_name, name): """ Returns an AWS-valid Lambda event name. """ return '{prefix:.{width}}-{postfix}'.format(prefix=lambda_name, width=max(0, 63 - len(name)), postfix=name)[:64]
python
def get_event_name(lambda_name, name): """ Returns an AWS-valid Lambda event name. """ return '{prefix:.{width}}-{postfix}'.format(prefix=lambda_name, width=max(0, 63 - len(name)), postfix=name)[:64]
[ "def", "get_event_name", "(", "lambda_name", ",", "name", ")", ":", "return", "'{prefix:.{width}}-{postfix}'", ".", "format", "(", "prefix", "=", "lambda_name", ",", "width", "=", "max", "(", "0", ",", "63", "-", "len", "(", "name", ")", ")", ",", "postf...
Returns an AWS-valid Lambda event name.
[ "Returns", "an", "AWS", "-", "valid", "Lambda", "event", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2790-L2795
29,714
Miserlou/Zappa
zappa/core.py
Zappa.get_hashed_rule_name
def get_hashed_rule_name(event, function, lambda_name): """ Returns an AWS-valid CloudWatch rule name using a digest of the event name, lambda name, and function. This allows support for rule names that may be longer than the 64 char limit. """ event_name = event.get('name', func...
python
def get_hashed_rule_name(event, function, lambda_name): """ Returns an AWS-valid CloudWatch rule name using a digest of the event name, lambda name, and function. This allows support for rule names that may be longer than the 64 char limit. """ event_name = event.get('name', func...
[ "def", "get_hashed_rule_name", "(", "event", ",", "function", ",", "lambda_name", ")", ":", "event_name", "=", "event", ".", "get", "(", "'name'", ",", "function", ")", "name_hash", "=", "hashlib", ".", "sha1", "(", "'{}-{}'", ".", "format", "(", "lambda_n...
Returns an AWS-valid CloudWatch rule name using a digest of the event name, lambda name, and function. This allows support for rule names that may be longer than the 64 char limit.
[ "Returns", "an", "AWS", "-", "valid", "CloudWatch", "rule", "name", "using", "a", "digest", "of", "the", "event", "name", "lambda", "name", "and", "function", ".", "This", "allows", "support", "for", "rule", "names", "that", "may", "be", "longer", "than", ...
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2798-L2805
29,715
Miserlou/Zappa
zappa/core.py
Zappa.delete_rule
def delete_rule(self, rule_name): """ Delete a CWE rule. This deletes them, but they will still show up in the AWS console. Annoying. """ logger.debug('Deleting existing rule {}'.format(rule_name)) # All targets must be removed before # we can actually...
python
def delete_rule(self, rule_name): """ Delete a CWE rule. This deletes them, but they will still show up in the AWS console. Annoying. """ logger.debug('Deleting existing rule {}'.format(rule_name)) # All targets must be removed before # we can actually...
[ "def", "delete_rule", "(", "self", ",", "rule_name", ")", ":", "logger", ".", "debug", "(", "'Deleting existing rule {}'", ".", "format", "(", "rule_name", ")", ")", "# All targets must be removed before", "# we can actually delete the rule.", "try", ":", "targets", "...
Delete a CWE rule. This deletes them, but they will still show up in the AWS console. Annoying.
[ "Delete", "a", "CWE", "rule", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2807-L2836
29,716
Miserlou/Zappa
zappa/core.py
Zappa.get_event_rule_names_for_lambda
def get_event_rule_names_for_lambda(self, lambda_arn): """ Get all of the rule names associated with a lambda function. """ response = self.events_client.list_rule_names_by_target(TargetArn=lambda_arn) rule_names = response['RuleNames'] # Iterate when the results are pagi...
python
def get_event_rule_names_for_lambda(self, lambda_arn): """ Get all of the rule names associated with a lambda function. """ response = self.events_client.list_rule_names_by_target(TargetArn=lambda_arn) rule_names = response['RuleNames'] # Iterate when the results are pagi...
[ "def", "get_event_rule_names_for_lambda", "(", "self", ",", "lambda_arn", ")", ":", "response", "=", "self", ".", "events_client", ".", "list_rule_names_by_target", "(", "TargetArn", "=", "lambda_arn", ")", "rule_names", "=", "response", "[", "'RuleNames'", "]", "...
Get all of the rule names associated with a lambda function.
[ "Get", "all", "of", "the", "rule", "names", "associated", "with", "a", "lambda", "function", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2838-L2849
29,717
Miserlou/Zappa
zappa/core.py
Zappa.get_event_rules_for_lambda
def get_event_rules_for_lambda(self, lambda_arn): """ Get all of the rule details associated with this function. """ rule_names = self.get_event_rule_names_for_lambda(lambda_arn=lambda_arn) return [self.events_client.describe_rule(Name=r) for r in rule_names]
python
def get_event_rules_for_lambda(self, lambda_arn): """ Get all of the rule details associated with this function. """ rule_names = self.get_event_rule_names_for_lambda(lambda_arn=lambda_arn) return [self.events_client.describe_rule(Name=r) for r in rule_names]
[ "def", "get_event_rules_for_lambda", "(", "self", ",", "lambda_arn", ")", ":", "rule_names", "=", "self", ".", "get_event_rule_names_for_lambda", "(", "lambda_arn", "=", "lambda_arn", ")", "return", "[", "self", ".", "events_client", ".", "describe_rule", "(", "Na...
Get all of the rule details associated with this function.
[ "Get", "all", "of", "the", "rule", "details", "associated", "with", "this", "function", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2851-L2856
29,718
Miserlou/Zappa
zappa/core.py
Zappa.unschedule_events
def unschedule_events(self, events, lambda_arn=None, lambda_name=None, excluded_source_services=None): excluded_source_services = excluded_source_services or [] """ Given a list of events, unschedule these CloudWatch Events. 'events' is a list of dictionaries, where the dict must contai...
python
def unschedule_events(self, events, lambda_arn=None, lambda_name=None, excluded_source_services=None): excluded_source_services = excluded_source_services or [] """ Given a list of events, unschedule these CloudWatch Events. 'events' is a list of dictionaries, where the dict must contai...
[ "def", "unschedule_events", "(", "self", ",", "events", ",", "lambda_arn", "=", "None", ",", "lambda_name", "=", "None", ",", "excluded_source_services", "=", "None", ")", ":", "excluded_source_services", "=", "excluded_source_services", "or", "[", "]", "self", ...
Given a list of events, unschedule these CloudWatch Events. 'events' is a list of dictionaries, where the dict must contains the string of a 'function' and the string of the event 'expression', and an optional 'name' and 'description'.
[ "Given", "a", "list", "of", "events", "unschedule", "these", "CloudWatch", "Events", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2858-L2895
29,719
Miserlou/Zappa
zappa/core.py
Zappa.create_async_sns_topic
def create_async_sns_topic(self, lambda_name, lambda_arn): """ Create the SNS-based async topic. """ topic_name = get_topic_name(lambda_name) # Create SNS topic topic_arn = self.sns_client.create_topic( Name=topic_name)['TopicArn'] # Create subscriptio...
python
def create_async_sns_topic(self, lambda_name, lambda_arn): """ Create the SNS-based async topic. """ topic_name = get_topic_name(lambda_name) # Create SNS topic topic_arn = self.sns_client.create_topic( Name=topic_name)['TopicArn'] # Create subscriptio...
[ "def", "create_async_sns_topic", "(", "self", ",", "lambda_name", ",", "lambda_arn", ")", ":", "topic_name", "=", "get_topic_name", "(", "lambda_name", ")", "# Create SNS topic", "topic_arn", "=", "self", ".", "sns_client", ".", "create_topic", "(", "Name", "=", ...
Create the SNS-based async topic.
[ "Create", "the", "SNS", "-", "based", "async", "topic", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2901-L2931
29,720
Miserlou/Zappa
zappa/core.py
Zappa.remove_async_sns_topic
def remove_async_sns_topic(self, lambda_name): """ Remove the async SNS topic. """ topic_name = get_topic_name(lambda_name) removed_arns = [] for sub in self.sns_client.list_subscriptions()['Subscriptions']: if topic_name in sub['TopicArn']: se...
python
def remove_async_sns_topic(self, lambda_name): """ Remove the async SNS topic. """ topic_name = get_topic_name(lambda_name) removed_arns = [] for sub in self.sns_client.list_subscriptions()['Subscriptions']: if topic_name in sub['TopicArn']: se...
[ "def", "remove_async_sns_topic", "(", "self", ",", "lambda_name", ")", ":", "topic_name", "=", "get_topic_name", "(", "lambda_name", ")", "removed_arns", "=", "[", "]", "for", "sub", "in", "self", ".", "sns_client", ".", "list_subscriptions", "(", ")", "[", ...
Remove the async SNS topic.
[ "Remove", "the", "async", "SNS", "topic", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2933-L2943
29,721
Miserlou/Zappa
zappa/core.py
Zappa.create_async_dynamodb_table
def create_async_dynamodb_table(self, table_name, read_capacity, write_capacity): """ Create the DynamoDB table for async task return values """ try: dynamodb_table = self.dynamodb_client.describe_table(TableName=table_name) return False, dynamodb_table #...
python
def create_async_dynamodb_table(self, table_name, read_capacity, write_capacity): """ Create the DynamoDB table for async task return values """ try: dynamodb_table = self.dynamodb_client.describe_table(TableName=table_name) return False, dynamodb_table #...
[ "def", "create_async_dynamodb_table", "(", "self", ",", "table_name", ",", "read_capacity", ",", "write_capacity", ")", ":", "try", ":", "dynamodb_table", "=", "self", ".", "dynamodb_client", ".", "describe_table", "(", "TableName", "=", "table_name", ")", "return...
Create the DynamoDB table for async task return values
[ "Create", "the", "DynamoDB", "table", "for", "async", "task", "return", "values" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L2960-L2997
29,722
Miserlou/Zappa
zappa/core.py
Zappa.fetch_logs
def fetch_logs(self, lambda_name, filter_pattern='', limit=10000, start_time=0): """ Fetch the CloudWatch logs for a given Lambda name. """ log_name = '/aws/lambda/' + lambda_name streams = self.logs_client.describe_log_streams( logGroupName=log_name, desc...
python
def fetch_logs(self, lambda_name, filter_pattern='', limit=10000, start_time=0): """ Fetch the CloudWatch logs for a given Lambda name. """ log_name = '/aws/lambda/' + lambda_name streams = self.logs_client.describe_log_streams( logGroupName=log_name, desc...
[ "def", "fetch_logs", "(", "self", ",", "lambda_name", ",", "filter_pattern", "=", "''", ",", "limit", "=", "10000", ",", "start_time", "=", "0", ")", ":", "log_name", "=", "'/aws/lambda/'", "+", "lambda_name", "streams", "=", "self", ".", "logs_client", "....
Fetch the CloudWatch logs for a given Lambda name.
[ "Fetch", "the", "CloudWatch", "logs", "for", "a", "given", "Lambda", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3010-L3049
29,723
Miserlou/Zappa
zappa/core.py
Zappa.remove_log_group
def remove_log_group(self, group_name): """ Filter all log groups that match the name given in log_filter. """ print("Removing log group: {}".format(group_name)) try: self.logs_client.delete_log_group(logGroupName=group_name) except botocore.exceptions.ClientE...
python
def remove_log_group(self, group_name): """ Filter all log groups that match the name given in log_filter. """ print("Removing log group: {}".format(group_name)) try: self.logs_client.delete_log_group(logGroupName=group_name) except botocore.exceptions.ClientE...
[ "def", "remove_log_group", "(", "self", ",", "group_name", ")", ":", "print", "(", "\"Removing log group: {}\"", ".", "format", "(", "group_name", ")", ")", "try", ":", "self", ".", "logs_client", ".", "delete_log_group", "(", "logGroupName", "=", "group_name", ...
Filter all log groups that match the name given in log_filter.
[ "Filter", "all", "log", "groups", "that", "match", "the", "name", "given", "in", "log_filter", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3051-L3059
29,724
Miserlou/Zappa
zappa/core.py
Zappa.remove_api_gateway_logs
def remove_api_gateway_logs(self, project_name): """ Removed all logs that are assigned to a given rest api id. """ for rest_api in self.get_rest_apis(project_name): for stage in self.apigateway_client.get_stages(restApiId=rest_api['id'])['item']: self.remove_...
python
def remove_api_gateway_logs(self, project_name): """ Removed all logs that are assigned to a given rest api id. """ for rest_api in self.get_rest_apis(project_name): for stage in self.apigateway_client.get_stages(restApiId=rest_api['id'])['item']: self.remove_...
[ "def", "remove_api_gateway_logs", "(", "self", ",", "project_name", ")", ":", "for", "rest_api", "in", "self", ".", "get_rest_apis", "(", "project_name", ")", ":", "for", "stage", "in", "self", ".", "apigateway_client", ".", "get_stages", "(", "restApiId", "="...
Removed all logs that are assigned to a given rest api id.
[ "Removed", "all", "logs", "that", "are", "assigned", "to", "a", "given", "rest", "api", "id", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3067-L3073
29,725
Miserlou/Zappa
zappa/core.py
Zappa.get_hosted_zone_id_for_domain
def get_hosted_zone_id_for_domain(self, domain): """ Get the Hosted Zone ID for a given domain. """ all_zones = self.get_all_zones() return self.get_best_match_zone(all_zones, domain)
python
def get_hosted_zone_id_for_domain(self, domain): """ Get the Hosted Zone ID for a given domain. """ all_zones = self.get_all_zones() return self.get_best_match_zone(all_zones, domain)
[ "def", "get_hosted_zone_id_for_domain", "(", "self", ",", "domain", ")", ":", "all_zones", "=", "self", ".", "get_all_zones", "(", ")", "return", "self", ".", "get_best_match_zone", "(", "all_zones", ",", "domain", ")" ]
Get the Hosted Zone ID for a given domain.
[ "Get", "the", "Hosted", "Zone", "ID", "for", "a", "given", "domain", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3079-L3085
29,726
Miserlou/Zappa
zappa/core.py
Zappa.get_best_match_zone
def get_best_match_zone(all_zones, domain): """Return zone id which name is closer matched with domain name.""" # Related: https://github.com/Miserlou/Zappa/issues/459 public_zones = [zone for zone in all_zones['HostedZones'] if not zone['Config']['PrivateZone']] zones = {zone['Name'][...
python
def get_best_match_zone(all_zones, domain): """Return zone id which name is closer matched with domain name.""" # Related: https://github.com/Miserlou/Zappa/issues/459 public_zones = [zone for zone in all_zones['HostedZones'] if not zone['Config']['PrivateZone']] zones = {zone['Name'][...
[ "def", "get_best_match_zone", "(", "all_zones", ",", "domain", ")", ":", "# Related: https://github.com/Miserlou/Zappa/issues/459", "public_zones", "=", "[", "zone", "for", "zone", "in", "all_zones", "[", "'HostedZones'", "]", "if", "not", "zone", "[", "'Config'", "...
Return zone id which name is closer matched with domain name.
[ "Return", "zone", "id", "which", "name", "is", "closer", "matched", "with", "domain", "name", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3088-L3099
29,727
Miserlou/Zappa
zappa/core.py
Zappa.remove_dns_challenge_txt
def remove_dns_challenge_txt(self, zone_id, domain, txt_challenge): """ Remove DNS challenge TXT. """ print("Deleting DNS challenge..") resp = self.route53.change_resource_record_sets( HostedZoneId=zone_id, ChangeBatch=self.get_dns_challenge_change_batch('...
python
def remove_dns_challenge_txt(self, zone_id, domain, txt_challenge): """ Remove DNS challenge TXT. """ print("Deleting DNS challenge..") resp = self.route53.change_resource_record_sets( HostedZoneId=zone_id, ChangeBatch=self.get_dns_challenge_change_batch('...
[ "def", "remove_dns_challenge_txt", "(", "self", ",", "zone_id", ",", "domain", ",", "txt_challenge", ")", ":", "print", "(", "\"Deleting DNS challenge..\"", ")", "resp", "=", "self", ".", "route53", ".", "change_resource_record_sets", "(", "HostedZoneId", "=", "zo...
Remove DNS challenge TXT.
[ "Remove", "DNS", "challenge", "TXT", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3113-L3123
29,728
Miserlou/Zappa
zappa/core.py
Zappa.load_credentials
def load_credentials(self, boto_session=None, profile_name=None): """ Load AWS credentials. An optional boto_session can be provided, but that's usually for testing. An optional profile_name can be provided for config files that have multiple sets of credentials. """ ...
python
def load_credentials(self, boto_session=None, profile_name=None): """ Load AWS credentials. An optional boto_session can be provided, but that's usually for testing. An optional profile_name can be provided for config files that have multiple sets of credentials. """ ...
[ "def", "load_credentials", "(", "self", ",", "boto_session", "=", "None", ",", "profile_name", "=", "None", ")", ":", "# Automatically load credentials from config or environment", "if", "not", "boto_session", ":", "# If provided, use the supplied profile name.", "if", "pro...
Load AWS credentials. An optional boto_session can be provided, but that's usually for testing. An optional profile_name can be provided for config files that have multiple sets of credentials.
[ "Load", "AWS", "credentials", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/core.py#L3161-L3204
29,729
Miserlou/Zappa
zappa/letsencrypt.py
get_cert_and_update_domain
def get_cert_and_update_domain( zappa_instance, lambda_name, api_stage, domain=None, manual=False, ): """ Main cert installe...
python
def get_cert_and_update_domain( zappa_instance, lambda_name, api_stage, domain=None, manual=False, ): """ Main cert installe...
[ "def", "get_cert_and_update_domain", "(", "zappa_instance", ",", "lambda_name", ",", "api_stage", ",", "domain", "=", "None", ",", "manual", "=", "False", ",", ")", ":", "try", ":", "create_domain_key", "(", ")", "create_domain_csr", "(", "domain", ")", "get_c...
Main cert installer path.
[ "Main", "cert", "installer", "path", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L47-L112
29,730
Miserlou/Zappa
zappa/letsencrypt.py
parse_account_key
def parse_account_key(): """Parse account key to get public key""" LOGGER.info("Parsing account key...") cmd = [ 'openssl', 'rsa', '-in', os.path.join(gettempdir(), 'account.key'), '-noout', '-text' ] devnull = open(os.devnull, 'wb') return subprocess.check_output...
python
def parse_account_key(): """Parse account key to get public key""" LOGGER.info("Parsing account key...") cmd = [ 'openssl', 'rsa', '-in', os.path.join(gettempdir(), 'account.key'), '-noout', '-text' ] devnull = open(os.devnull, 'wb') return subprocess.check_output...
[ "def", "parse_account_key", "(", ")", ":", "LOGGER", ".", "info", "(", "\"Parsing account key...\"", ")", "cmd", "=", "[", "'openssl'", ",", "'rsa'", ",", "'-in'", ",", "os", ".", "path", ".", "join", "(", "gettempdir", "(", ")", ",", "'account.key'", ")...
Parse account key to get public key
[ "Parse", "account", "key", "to", "get", "public", "key" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L151-L161
29,731
Miserlou/Zappa
zappa/letsencrypt.py
parse_csr
def parse_csr(): """ Parse certificate signing request for domains """ LOGGER.info("Parsing CSR...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-noout', '-text' ] devnull = open(os.devnull, 'wb') out = subprocess.check_outp...
python
def parse_csr(): """ Parse certificate signing request for domains """ LOGGER.info("Parsing CSR...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-noout', '-text' ] devnull = open(os.devnull, 'wb') out = subprocess.check_outp...
[ "def", "parse_csr", "(", ")", ":", "LOGGER", ".", "info", "(", "\"Parsing CSR...\"", ")", "cmd", "=", "[", "'openssl'", ",", "'req'", ",", "'-in'", ",", "os", ".", "path", ".", "join", "(", "gettempdir", "(", ")", ",", "'domain.csr'", ")", ",", "'-no...
Parse certificate signing request for domains
[ "Parse", "certificate", "signing", "request", "for", "domains" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L164-L187
29,732
Miserlou/Zappa
zappa/letsencrypt.py
get_boulder_header
def get_boulder_header(key_bytes): """ Use regular expressions to find crypto values from parsed account key, and return a header we can send to our Boulder instance. """ pub_hex, pub_exp = re.search( r"modulus:\n\s+00:([a-f0-9\:\s]+?)\npublicExponent: ([0-9]+)", key_bytes.decode('ut...
python
def get_boulder_header(key_bytes): """ Use regular expressions to find crypto values from parsed account key, and return a header we can send to our Boulder instance. """ pub_hex, pub_exp = re.search( r"modulus:\n\s+00:([a-f0-9\:\s]+?)\npublicExponent: ([0-9]+)", key_bytes.decode('ut...
[ "def", "get_boulder_header", "(", "key_bytes", ")", ":", "pub_hex", ",", "pub_exp", "=", "re", ".", "search", "(", "r\"modulus:\\n\\s+00:([a-f0-9\\:\\s]+?)\\npublicExponent: ([0-9]+)\"", ",", "key_bytes", ".", "decode", "(", "'utf8'", ")", ",", "re", ".", "MULTILINE...
Use regular expressions to find crypto values from parsed account key, and return a header we can send to our Boulder instance.
[ "Use", "regular", "expressions", "to", "find", "crypto", "values", "from", "parsed", "account", "key", "and", "return", "a", "header", "we", "can", "send", "to", "our", "Boulder", "instance", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L190-L209
29,733
Miserlou/Zappa
zappa/letsencrypt.py
register_account
def register_account(): """ Agree to LE TOS """ LOGGER.info("Registering account...") code, result = _send_signed_request(DEFAULT_CA + "/acme/new-reg", { "resource": "new-reg", "agreement": "https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf", }) if code == 201...
python
def register_account(): """ Agree to LE TOS """ LOGGER.info("Registering account...") code, result = _send_signed_request(DEFAULT_CA + "/acme/new-reg", { "resource": "new-reg", "agreement": "https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf", }) if code == 201...
[ "def", "register_account", "(", ")", ":", "LOGGER", ".", "info", "(", "\"Registering account...\"", ")", "code", ",", "result", "=", "_send_signed_request", "(", "DEFAULT_CA", "+", "\"/acme/new-reg\"", ",", "{", "\"resource\"", ":", "\"new-reg\"", ",", "\"agreemen...
Agree to LE TOS
[ "Agree", "to", "LE", "TOS" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L212-L226
29,734
Miserlou/Zappa
zappa/letsencrypt.py
get_cert
def get_cert(zappa_instance, log=LOGGER, CA=DEFAULT_CA): """ Call LE to get a new signed CA. """ out = parse_account_key() header = get_boulder_header(out) accountkey_json = json.dumps(header['jwk'], sort_keys=True, separators=(',', ':')) thumbprint = _b64(hashlib.sha256(accountkey_json.enco...
python
def get_cert(zappa_instance, log=LOGGER, CA=DEFAULT_CA): """ Call LE to get a new signed CA. """ out = parse_account_key() header = get_boulder_header(out) accountkey_json = json.dumps(header['jwk'], sort_keys=True, separators=(',', ':')) thumbprint = _b64(hashlib.sha256(accountkey_json.enco...
[ "def", "get_cert", "(", "zappa_instance", ",", "log", "=", "LOGGER", ",", "CA", "=", "DEFAULT_CA", ")", ":", "out", "=", "parse_account_key", "(", ")", "header", "=", "get_boulder_header", "(", "out", ")", "accountkey_json", "=", "json", ".", "dumps", "(",...
Call LE to get a new signed CA.
[ "Call", "LE", "to", "get", "a", "new", "signed", "CA", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L229-L293
29,735
Miserlou/Zappa
zappa/letsencrypt.py
verify_challenge
def verify_challenge(uri): """ Loop until our challenge is verified, else fail. """ while True: try: resp = urlopen(uri) challenge_status = json.loads(resp.read().decode('utf8')) except IOError as e: raise ValueError("Error checking challenge: {0} {1}"...
python
def verify_challenge(uri): """ Loop until our challenge is verified, else fail. """ while True: try: resp = urlopen(uri) challenge_status = json.loads(resp.read().decode('utf8')) except IOError as e: raise ValueError("Error checking challenge: {0} {1}"...
[ "def", "verify_challenge", "(", "uri", ")", ":", "while", "True", ":", "try", ":", "resp", "=", "urlopen", "(", "uri", ")", "challenge_status", "=", "json", ".", "loads", "(", "resp", ".", "read", "(", ")", ".", "decode", "(", "'utf8'", ")", ")", "...
Loop until our challenge is verified, else fail.
[ "Loop", "until", "our", "challenge", "is", "verified", "else", "fail", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L296-L314
29,736
Miserlou/Zappa
zappa/letsencrypt.py
sign_certificate
def sign_certificate(): """ Get the new certificate. Returns the signed bytes. """ LOGGER.info("Signing certificate...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-outform', 'DER' ] devnull = open(os.devnull, 'wb') csr_der = ...
python
def sign_certificate(): """ Get the new certificate. Returns the signed bytes. """ LOGGER.info("Signing certificate...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-outform', 'DER' ] devnull = open(os.devnull, 'wb') csr_der = ...
[ "def", "sign_certificate", "(", ")", ":", "LOGGER", ".", "info", "(", "\"Signing certificate...\"", ")", "cmd", "=", "[", "'openssl'", ",", "'req'", ",", "'-in'", ",", "os", ".", "path", ".", "join", "(", "gettempdir", "(", ")", ",", "'domain.csr'", ")",...
Get the new certificate. Returns the signed bytes.
[ "Get", "the", "new", "certificate", ".", "Returns", "the", "signed", "bytes", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L317-L339
29,737
Miserlou/Zappa
zappa/letsencrypt.py
_send_signed_request
def _send_signed_request(url, payload): """ Helper function to make signed requests to Boulder """ payload64 = _b64(json.dumps(payload).encode('utf8')) out = parse_account_key() header = get_boulder_header(out) protected = copy.deepcopy(header) protected["nonce"] = urlopen(DEFAULT_CA +...
python
def _send_signed_request(url, payload): """ Helper function to make signed requests to Boulder """ payload64 = _b64(json.dumps(payload).encode('utf8')) out = parse_account_key() header = get_boulder_header(out) protected = copy.deepcopy(header) protected["nonce"] = urlopen(DEFAULT_CA +...
[ "def", "_send_signed_request", "(", "url", ",", "payload", ")", ":", "payload64", "=", "_b64", "(", "json", ".", "dumps", "(", "payload", ")", ".", "encode", "(", "'utf8'", ")", ")", "out", "=", "parse_account_key", "(", ")", "header", "=", "get_boulder_...
Helper function to make signed requests to Boulder
[ "Helper", "function", "to", "make", "signed", "requests", "to", "Boulder" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L366-L398
29,738
Miserlou/Zappa
zappa/cli.py
shamelessly_promote
def shamelessly_promote(): """ Shamelessly promote our little community. """ click.echo("Need " + click.style("help", fg='green', bold=True) + "? Found a " + click.style("bug", fg='green', bold=True) + "? Let us " + click.style("know", fg='green', bold=True) + "! :D") ...
python
def shamelessly_promote(): """ Shamelessly promote our little community. """ click.echo("Need " + click.style("help", fg='green', bold=True) + "? Found a " + click.style("bug", fg='green', bold=True) + "? Let us " + click.style("know", fg='green', bold=True) + "! :D") ...
[ "def", "shamelessly_promote", "(", ")", ":", "click", ".", "echo", "(", "\"Need \"", "+", "click", ".", "style", "(", "\"help\"", ",", "fg", "=", "'green'", ",", "bold", "=", "True", ")", "+", "\"? Found a \"", "+", "click", ".", "style", "(", "\"bug\"...
Shamelessly promote our little community.
[ "Shamelessly", "promote", "our", "little", "community", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2744-L2757
29,739
Miserlou/Zappa
zappa/cli.py
handle
def handle(): # pragma: no cover """ Main program execution handler. """ try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: # pragma: no cover cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: # pragma: no cover cli.on_exit() ...
python
def handle(): # pragma: no cover """ Main program execution handler. """ try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: # pragma: no cover cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: # pragma: no cover cli.on_exit() ...
[ "def", "handle", "(", ")", ":", "# pragma: no cover", "try", ":", "cli", "=", "ZappaCLI", "(", ")", "sys", ".", "exit", "(", "cli", ".", "handle", "(", ")", ")", "except", "SystemExit", "as", "e", ":", "# pragma: no cover", "cli", ".", "on_exit", "(", ...
Main program execution handler.
[ "Main", "program", "execution", "handler", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2772-L2797
29,740
Miserlou/Zappa
zappa/cli.py
ZappaCLI.stage_config
def stage_config(self): """ A shortcut property for settings of a stage. """ def get_stage_setting(stage, extended_stages=None): if extended_stages is None: extended_stages = [] if stage in extended_stages: raise RuntimeError(stag...
python
def stage_config(self): """ A shortcut property for settings of a stage. """ def get_stage_setting(stage, extended_stages=None): if extended_stages is None: extended_stages = [] if stage in extended_stages: raise RuntimeError(stag...
[ "def", "stage_config", "(", "self", ")", ":", "def", "get_stage_setting", "(", "stage", ",", "extended_stages", "=", "None", ")", ":", "if", "extended_stages", "is", "None", ":", "extended_stages", "=", "[", "]", "if", "stage", "in", "extended_stages", ":", ...
A shortcut property for settings of a stage.
[ "A", "shortcut", "property", "for", "settings", "of", "a", "stage", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L127-L161
29,741
Miserlou/Zappa
zappa/cli.py
ZappaCLI.package
def package(self, output=None): """ Only build the package """ # Make sure we're in a venv. self.check_venv() # force not to delete the local zip self.override_stage_config_setting('delete_local_zip', False) # Execute the prebuild script if self.p...
python
def package(self, output=None): """ Only build the package """ # Make sure we're in a venv. self.check_venv() # force not to delete the local zip self.override_stage_config_setting('delete_local_zip', False) # Execute the prebuild script if self.p...
[ "def", "package", "(", "self", ",", "output", "=", "None", ")", ":", "# Make sure we're in a venv.", "self", ".", "check_venv", "(", ")", "# force not to delete the local zip", "self", ".", "override_stage_config_setting", "(", "'delete_local_zip'", ",", "False", ")",...
Only build the package
[ "Only", "build", "the", "package" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L626-L642
29,742
Miserlou/Zappa
zappa/cli.py
ZappaCLI.template
def template(self, lambda_arn, role_arn, output=None, json=False): """ Only build the template file. """ if not lambda_arn: raise ClickException("Lambda ARN is required to template.") if not role_arn: raise ClickException("Role ARN is required to templat...
python
def template(self, lambda_arn, role_arn, output=None, json=False): """ Only build the template file. """ if not lambda_arn: raise ClickException("Lambda ARN is required to template.") if not role_arn: raise ClickException("Role ARN is required to templat...
[ "def", "template", "(", "self", ",", "lambda_arn", ",", "role_arn", ",", "output", "=", "None", ",", "json", "=", "False", ")", ":", "if", "not", "lambda_arn", ":", "raise", "ClickException", "(", "\"Lambda ARN is required to template.\"", ")", "if", "not", ...
Only build the template file.
[ "Only", "build", "the", "template", "file", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L644-L681
29,743
Miserlou/Zappa
zappa/cli.py
ZappaCLI.rollback
def rollback(self, revision): """ Rollsback the currently deploy lambda code to a previous revision. """ print("Rolling back..") self.zappa.rollback_lambda_function_version( self.lambda_name, versions_back=revision) print("Done!")
python
def rollback(self, revision): """ Rollsback the currently deploy lambda code to a previous revision. """ print("Rolling back..") self.zappa.rollback_lambda_function_version( self.lambda_name, versions_back=revision) print("Done!")
[ "def", "rollback", "(", "self", ",", "revision", ")", ":", "print", "(", "\"Rolling back..\"", ")", "self", ".", "zappa", ".", "rollback_lambda_function_version", "(", "self", ".", "lambda_name", ",", "versions_back", "=", "revision", ")", "print", "(", "\"Don...
Rollsback the currently deploy lambda code to a previous revision.
[ "Rollsback", "the", "currently", "deploy", "lambda", "code", "to", "a", "previous", "revision", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1057-L1066
29,744
Miserlou/Zappa
zappa/cli.py
ZappaCLI.tail
def tail(self, since, filter_pattern, limit=10000, keep_open=True, colorize=True, http=False, non_http=False, force_colorize=False): """ Tail this function's logs. if keep_open, do so repeatedly, printing any new logs """ try: since_stamp = string_to_timestamp(since...
python
def tail(self, since, filter_pattern, limit=10000, keep_open=True, colorize=True, http=False, non_http=False, force_colorize=False): """ Tail this function's logs. if keep_open, do so repeatedly, printing any new logs """ try: since_stamp = string_to_timestamp(since...
[ "def", "tail", "(", "self", ",", "since", ",", "filter_pattern", ",", "limit", "=", "10000", ",", "keep_open", "=", "True", ",", "colorize", "=", "True", ",", "http", "=", "False", ",", "non_http", "=", "False", ",", "force_colorize", "=", "False", ")"...
Tail this function's logs. if keep_open, do so repeatedly, printing any new logs
[ "Tail", "this", "function", "s", "logs", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1068-L1100
29,745
Miserlou/Zappa
zappa/cli.py
ZappaCLI.undeploy
def undeploy(self, no_confirm=False, remove_logs=False): """ Tear down an existing deployment. """ if not no_confirm: # pragma: no cover confirm = input("Are you sure you want to undeploy? [y/n] ") if confirm != 'y': return if self.use_al...
python
def undeploy(self, no_confirm=False, remove_logs=False): """ Tear down an existing deployment. """ if not no_confirm: # pragma: no cover confirm = input("Are you sure you want to undeploy? [y/n] ") if confirm != 'y': return if self.use_al...
[ "def", "undeploy", "(", "self", ",", "no_confirm", "=", "False", ",", "remove_logs", "=", "False", ")", ":", "if", "not", "no_confirm", ":", "# pragma: no cover", "confirm", "=", "input", "(", "\"Are you sure you want to undeploy? [y/n] \"", ")", "if", "confirm", ...
Tear down an existing deployment.
[ "Tear", "down", "an", "existing", "deployment", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1102-L1139
29,746
Miserlou/Zappa
zappa/cli.py
ZappaCLI.update_cognito_triggers
def update_cognito_triggers(self): """ Update any cognito triggers """ if self.cognito: user_pool = self.cognito.get('user_pool') triggers = self.cognito.get('triggers', []) lambda_configs = set() for trigger in triggers: la...
python
def update_cognito_triggers(self): """ Update any cognito triggers """ if self.cognito: user_pool = self.cognito.get('user_pool') triggers = self.cognito.get('triggers', []) lambda_configs = set() for trigger in triggers: la...
[ "def", "update_cognito_triggers", "(", "self", ")", ":", "if", "self", ".", "cognito", ":", "user_pool", "=", "self", ".", "cognito", ".", "get", "(", "'user_pool'", ")", "triggers", "=", "self", ".", "cognito", ".", "get", "(", "'triggers'", ",", "[", ...
Update any cognito triggers
[ "Update", "any", "cognito", "triggers" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1141-L1151
29,747
Miserlou/Zappa
zappa/cli.py
ZappaCLI.schedule
def schedule(self): """ Given a a list of functions and a schedule to execute them, setup up regular execution. """ events = self.stage_config.get('events', []) if events: if not isinstance(events, list): # pragma: no cover print("Events must...
python
def schedule(self): """ Given a a list of functions and a schedule to execute them, setup up regular execution. """ events = self.stage_config.get('events', []) if events: if not isinstance(events, list): # pragma: no cover print("Events must...
[ "def", "schedule", "(", "self", ")", ":", "events", "=", "self", ".", "stage_config", ".", "get", "(", "'events'", ",", "[", "]", ")", "if", "events", ":", "if", "not", "isinstance", "(", "events", ",", "list", ")", ":", "# pragma: no cover", "print", ...
Given a a list of functions and a schedule to execute them, setup up regular execution.
[ "Given", "a", "a", "list", "of", "functions", "and", "a", "schedule", "to", "execute", "them", "setup", "up", "regular", "execution", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1153-L1223
29,748
Miserlou/Zappa
zappa/cli.py
ZappaCLI.unschedule
def unschedule(self): """ Given a a list of scheduled functions, tear down their regular execution. """ # Run even if events are not defined to remove previously existing ones (thus default to []). events = self.stage_config.get('events', []) if not isinstance(...
python
def unschedule(self): """ Given a a list of scheduled functions, tear down their regular execution. """ # Run even if events are not defined to remove previously existing ones (thus default to []). events = self.stage_config.get('events', []) if not isinstance(...
[ "def", "unschedule", "(", "self", ")", ":", "# Run even if events are not defined to remove previously existing ones (thus default to []).", "events", "=", "self", ".", "stage_config", ".", "get", "(", "'events'", ",", "[", "]", ")", "if", "not", "isinstance", "(", "e...
Given a a list of scheduled functions, tear down their regular execution.
[ "Given", "a", "a", "list", "of", "scheduled", "functions", "tear", "down", "their", "regular", "execution", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1225-L1258
29,749
Miserlou/Zappa
zappa/cli.py
ZappaCLI.invoke
def invoke(self, function_name, raw_python=False, command=None, no_color=False): """ Invoke a remote function. """ # There are three likely scenarios for 'command' here: # command, which is a modular function path # raw_command, which is a string of python to execute...
python
def invoke(self, function_name, raw_python=False, command=None, no_color=False): """ Invoke a remote function. """ # There are three likely scenarios for 'command' here: # command, which is a modular function path # raw_command, which is a string of python to execute...
[ "def", "invoke", "(", "self", ",", "function_name", ",", "raw_python", "=", "False", ",", "command", "=", "None", ",", "no_color", "=", "False", ")", ":", "# There are three likely scenarios for 'command' here:", "# command, which is a modular function path", "# raw_c...
Invoke a remote function.
[ "Invoke", "a", "remote", "function", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1260-L1300
29,750
Miserlou/Zappa
zappa/cli.py
ZappaCLI.colorize_invoke_command
def colorize_invoke_command(self, string): """ Apply various heuristics to return a colorized version the invoke command string. If these fail, simply return the string in plaintext. Inspired by colorize_log_entry(). """ final_string = string try: ...
python
def colorize_invoke_command(self, string): """ Apply various heuristics to return a colorized version the invoke command string. If these fail, simply return the string in plaintext. Inspired by colorize_log_entry(). """ final_string = string try: ...
[ "def", "colorize_invoke_command", "(", "self", ",", "string", ")", ":", "final_string", "=", "string", "try", ":", "# Line headers", "try", ":", "for", "token", "in", "[", "'START'", ",", "'END'", ",", "'REPORT'", ",", "'[DEBUG]'", "]", ":", "if", "token",...
Apply various heuristics to return a colorized version the invoke command string. If these fail, simply return the string in plaintext. Inspired by colorize_log_entry().
[ "Apply", "various", "heuristics", "to", "return", "a", "colorized", "version", "the", "invoke", "command", "string", ".", "If", "these", "fail", "simply", "return", "the", "string", "in", "plaintext", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1321-L1387
29,751
Miserlou/Zappa
zappa/cli.py
ZappaCLI.check_environment
def check_environment(self, environment): """ Make sure the environment contains only strings (since putenv needs a string) """ non_strings = [] for (k,v) in environment.items(): if not isinstance(v, basestring): non_strings.append(k) ...
python
def check_environment(self, environment): """ Make sure the environment contains only strings (since putenv needs a string) """ non_strings = [] for (k,v) in environment.items(): if not isinstance(v, basestring): non_strings.append(k) ...
[ "def", "check_environment", "(", "self", ",", "environment", ")", ":", "non_strings", "=", "[", "]", "for", "(", "k", ",", "v", ")", "in", "environment", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "v", ",", "basestring", ")", ":", ...
Make sure the environment contains only strings (since putenv needs a string)
[ "Make", "sure", "the", "environment", "contains", "only", "strings" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1534-L1548
29,752
Miserlou/Zappa
zappa/cli.py
ZappaCLI.shell
def shell(self): """ Spawn a debug shell. """ click.echo(click.style("NOTICE!", fg="yellow", bold=True) + " This is a " + click.style("local", fg="green", bold=True) + " shell, inside a " + click.style("Zappa", bold=True) + " object!") self.zappa.shell() return
python
def shell(self): """ Spawn a debug shell. """ click.echo(click.style("NOTICE!", fg="yellow", bold=True) + " This is a " + click.style("local", fg="green", bold=True) + " shell, inside a " + click.style("Zappa", bold=True) + " object!") self.zappa.shell() return
[ "def", "shell", "(", "self", ")", ":", "click", ".", "echo", "(", "click", ".", "style", "(", "\"NOTICE!\"", ",", "fg", "=", "\"yellow\"", ",", "bold", "=", "True", ")", "+", "\" This is a \"", "+", "click", ".", "style", "(", "\"local\"", ",", "fg",...
Spawn a debug shell.
[ "Spawn", "a", "debug", "shell", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1924-L1930
29,753
Miserlou/Zappa
zappa/cli.py
ZappaCLI.callback
def callback(self, position): """ Allows the execution of custom code between creation of the zip file and deployment to AWS. :return: None """ callbacks = self.stage_config.get('callbacks', {}) callback = callbacks.get(position) if callback: (mod_p...
python
def callback(self, position): """ Allows the execution of custom code between creation of the zip file and deployment to AWS. :return: None """ callbacks = self.stage_config.get('callbacks', {}) callback = callbacks.get(position) if callback: (mod_p...
[ "def", "callback", "(", "self", ",", "position", ")", ":", "callbacks", "=", "self", ".", "stage_config", ".", "get", "(", "'callbacks'", ",", "{", "}", ")", "callback", "=", "callbacks", ".", "get", "(", "position", ")", "if", "callback", ":", "(", ...
Allows the execution of custom code between creation of the zip file and deployment to AWS. :return: None
[ "Allows", "the", "execution", "of", "custom", "code", "between", "creation", "of", "the", "zip", "file", "and", "deployment", "to", "AWS", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1936-L1977
29,754
Miserlou/Zappa
zappa/cli.py
ZappaCLI.check_for_update
def check_for_update(self): """ Print a warning if there's a new Zappa version available. """ try: version = pkg_resources.require("zappa")[0].version updateable = check_new_version_available(version) if updateable: click.echo(click.sty...
python
def check_for_update(self): """ Print a warning if there's a new Zappa version available. """ try: version = pkg_resources.require("zappa")[0].version updateable = check_new_version_available(version) if updateable: click.echo(click.sty...
[ "def", "check_for_update", "(", "self", ")", ":", "try", ":", "version", "=", "pkg_resources", ".", "require", "(", "\"zappa\"", ")", "[", "0", "]", ".", "version", "updateable", "=", "check_new_version_available", "(", "version", ")", "if", "updateable", ":...
Print a warning if there's a new Zappa version available.
[ "Print", "a", "warning", "if", "there", "s", "a", "new", "Zappa", "version", "available", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1979-L1994
29,755
Miserlou/Zappa
zappa/cli.py
ZappaCLI.load_settings_file
def load_settings_file(self, settings_file=None): """ Load our settings file. """ if not settings_file: settings_file = self.get_json_or_yaml_settings() if not os.path.isfile(settings_file): raise ClickException("Please configure your zappa_settings file ...
python
def load_settings_file(self, settings_file=None): """ Load our settings file. """ if not settings_file: settings_file = self.get_json_or_yaml_settings() if not os.path.isfile(settings_file): raise ClickException("Please configure your zappa_settings file ...
[ "def", "load_settings_file", "(", "self", ",", "settings_file", "=", "None", ")", ":", "if", "not", "settings_file", ":", "settings_file", "=", "self", ".", "get_json_or_yaml_settings", "(", ")", "if", "not", "os", ".", "path", ".", "isfile", "(", "settings_...
Load our settings file.
[ "Load", "our", "settings", "file", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2163-L2191
29,756
Miserlou/Zappa
zappa/cli.py
ZappaCLI.print_logs
def print_logs(self, logs, colorize=True, http=False, non_http=False, force_colorize=None): """ Parse, filter and print logs to the console. """ for log in logs: timestamp = log['timestamp'] message = log['message'] if "START RequestId" in message: ...
python
def print_logs(self, logs, colorize=True, http=False, non_http=False, force_colorize=None): """ Parse, filter and print logs to the console. """ for log in logs: timestamp = log['timestamp'] message = log['message'] if "START RequestId" in message: ...
[ "def", "print_logs", "(", "self", ",", "logs", ",", "colorize", "=", "True", ",", "http", "=", "False", ",", "non_http", "=", "False", ",", "force_colorize", "=", "None", ")", ":", "for", "log", "in", "logs", ":", "timestamp", "=", "log", "[", "'time...
Parse, filter and print logs to the console.
[ "Parse", "filter", "and", "print", "logs", "to", "the", "console", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2481-L2514
29,757
Miserlou/Zappa
zappa/cli.py
ZappaCLI.is_http_log_entry
def is_http_log_entry(self, string): """ Determines if a log entry is an HTTP-formatted log string or not. """ # Debug event filter if 'Zappa Event' in string: return False # IP address filter for token in string.replace('\t', ' ').split(' '): ...
python
def is_http_log_entry(self, string): """ Determines if a log entry is an HTTP-formatted log string or not. """ # Debug event filter if 'Zappa Event' in string: return False # IP address filter for token in string.replace('\t', ' ').split(' '): ...
[ "def", "is_http_log_entry", "(", "self", ",", "string", ")", ":", "# Debug event filter", "if", "'Zappa Event'", "in", "string", ":", "return", "False", "# IP address filter", "for", "token", "in", "string", ".", "replace", "(", "'\\t'", ",", "' '", ")", ".", ...
Determines if a log entry is an HTTP-formatted log string or not.
[ "Determines", "if", "a", "log", "entry", "is", "an", "HTTP", "-", "formatted", "log", "string", "or", "not", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2516-L2532
29,758
Miserlou/Zappa
zappa/cli.py
ZappaCLI.colorize_log_entry
def colorize_log_entry(self, string): """ Apply various heuristics to return a colorized version of a string. If these fail, simply return the string in plaintext. """ final_string = string try: # First, do stuff in square brackets inside_squares...
python
def colorize_log_entry(self, string): """ Apply various heuristics to return a colorized version of a string. If these fail, simply return the string in plaintext. """ final_string = string try: # First, do stuff in square brackets inside_squares...
[ "def", "colorize_log_entry", "(", "self", ",", "string", ")", ":", "final_string", "=", "string", "try", ":", "# First, do stuff in square brackets", "inside_squares", "=", "re", ".", "findall", "(", "r'\\[([^]]*)\\]'", ",", "string", ")", "for", "token", "in", ...
Apply various heuristics to return a colorized version of a string. If these fail, simply return the string in plaintext.
[ "Apply", "various", "heuristics", "to", "return", "a", "colorized", "version", "of", "a", "string", ".", "If", "these", "fail", "simply", "return", "the", "string", "in", "plaintext", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2537-L2603
29,759
Miserlou/Zappa
zappa/cli.py
ZappaCLI.execute_prebuild_script
def execute_prebuild_script(self): """ Parse and execute the prebuild_script from the zappa_settings. """ (pb_mod_path, pb_func) = self.prebuild_script.rsplit('.', 1) try: # Prefer prebuild script in working directory if pb_mod_path.count('.') >= 1: # Prebuild sc...
python
def execute_prebuild_script(self): """ Parse and execute the prebuild_script from the zappa_settings. """ (pb_mod_path, pb_func) = self.prebuild_script.rsplit('.', 1) try: # Prefer prebuild script in working directory if pb_mod_path.count('.') >= 1: # Prebuild sc...
[ "def", "execute_prebuild_script", "(", "self", ")", ":", "(", "pb_mod_path", ",", "pb_func", ")", "=", "self", ".", "prebuild_script", ".", "rsplit", "(", "'.'", ",", "1", ")", "try", ":", "# Prefer prebuild script in working directory", "if", "pb_mod_path", "."...
Parse and execute the prebuild_script from the zappa_settings.
[ "Parse", "and", "execute", "the", "prebuild_script", "from", "the", "zappa_settings", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2605-L2641
29,760
Miserlou/Zappa
zappa/cli.py
ZappaCLI.collision_warning
def collision_warning(self, item): """ Given a string, print a warning if this could collide with a Zappa core package module. Use for app functions and events. """ namespace_collisions = [ "zappa.", "wsgi.", "middleware.", "handler.", "util.", "letsencrypt....
python
def collision_warning(self, item): """ Given a string, print a warning if this could collide with a Zappa core package module. Use for app functions and events. """ namespace_collisions = [ "zappa.", "wsgi.", "middleware.", "handler.", "util.", "letsencrypt....
[ "def", "collision_warning", "(", "self", ",", "item", ")", ":", "namespace_collisions", "=", "[", "\"zappa.\"", ",", "\"wsgi.\"", ",", "\"middleware.\"", ",", "\"handler.\"", ",", "\"util.\"", ",", "\"letsencrypt.\"", ",", "\"cli.\"", "]", "for", "namespace_collis...
Given a string, print a warning if this could collide with a Zappa core package module. Use for app functions and events.
[ "Given", "a", "string", "print", "a", "warning", "if", "this", "could", "collide", "with", "a", "Zappa", "core", "package", "module", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2643-L2661
29,761
Miserlou/Zappa
zappa/cli.py
ZappaCLI.check_venv
def check_venv(self): """ Ensure we're inside a virtualenv. """ if self.zappa: venv = self.zappa.get_current_venv() else: # Just for `init`, when we don't have settings yet. venv = Zappa.get_current_venv() if not venv: raise ClickException(...
python
def check_venv(self): """ Ensure we're inside a virtualenv. """ if self.zappa: venv = self.zappa.get_current_venv() else: # Just for `init`, when we don't have settings yet. venv = Zappa.get_current_venv() if not venv: raise ClickException(...
[ "def", "check_venv", "(", "self", ")", ":", "if", "self", ".", "zappa", ":", "venv", "=", "self", ".", "zappa", ".", "get_current_venv", "(", ")", "else", ":", "# Just for `init`, when we don't have settings yet.", "venv", "=", "Zappa", ".", "get_current_venv", ...
Ensure we're inside a virtualenv.
[ "Ensure", "we", "re", "inside", "a", "virtualenv", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2679-L2689
29,762
Miserlou/Zappa
zappa/cli.py
ZappaCLI.silence
def silence(self): """ Route all stdout to null. """ sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w')
python
def silence(self): """ Route all stdout to null. """ sys.stdout = open(os.devnull, 'w') sys.stderr = open(os.devnull, 'w')
[ "def", "silence", "(", "self", ")", ":", "sys", ".", "stdout", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "sys", ".", "stderr", "=", "open", "(", "os", ".", "devnull", ",", "'w'", ")" ]
Route all stdout to null.
[ "Route", "all", "stdout", "to", "null", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2691-L2697
29,763
Miserlou/Zappa
zappa/cli.py
ZappaCLI.touch_endpoint
def touch_endpoint(self, endpoint_url): """ Test the deployed endpoint with a GET request. """ # Private APIGW endpoints most likely can't be reached by a deployer # unless they're connected to the VPC by VPN. Instead of trying # connect to the service, print a warning a...
python
def touch_endpoint(self, endpoint_url): """ Test the deployed endpoint with a GET request. """ # Private APIGW endpoints most likely can't be reached by a deployer # unless they're connected to the VPC by VPN. Instead of trying # connect to the service, print a warning a...
[ "def", "touch_endpoint", "(", "self", ",", "endpoint_url", ")", ":", "# Private APIGW endpoints most likely can't be reached by a deployer", "# unless they're connected to the VPC by VPN. Instead of trying", "# connect to the service, print a warning and let the user know", "# to check it manu...
Test the deployed endpoint with a GET request.
[ "Test", "the", "deployed", "endpoint", "with", "a", "GET", "request", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2699-L2738
29,764
Miserlou/Zappa
zappa/middleware.py
all_casings
def all_casings(input_string): """ Permute all casings of a given string. A pretty algorithm, via @Amber http://stackoverflow.com/questions/6792803/finding-all-possible-case-permutations-in-python """ if not input_string: yield "" else: first = input_string[:1] if fi...
python
def all_casings(input_string): """ Permute all casings of a given string. A pretty algorithm, via @Amber http://stackoverflow.com/questions/6792803/finding-all-possible-case-permutations-in-python """ if not input_string: yield "" else: first = input_string[:1] if fi...
[ "def", "all_casings", "(", "input_string", ")", ":", "if", "not", "input_string", ":", "yield", "\"\"", "else", ":", "first", "=", "input_string", "[", ":", "1", "]", "if", "first", ".", "lower", "(", ")", "==", "first", ".", "upper", "(", ")", ":", ...
Permute all casings of a given string. A pretty algorithm, via @Amber http://stackoverflow.com/questions/6792803/finding-all-possible-case-permutations-in-python
[ "Permute", "all", "casings", "of", "a", "given", "string", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/middleware.py#L4-L21
29,765
binux/pyspider
pyspider/libs/response.py
get_encoding
def get_encoding(headers, content): """Get encoding from request headers or page head.""" encoding = None content_type = headers.get('content-type') if content_type: _, params = cgi.parse_header(content_type) if 'charset' in params: encoding = params['charset'].strip("'\"") ...
python
def get_encoding(headers, content): """Get encoding from request headers or page head.""" encoding = None content_type = headers.get('content-type') if content_type: _, params = cgi.parse_header(content_type) if 'charset' in params: encoding = params['charset'].strip("'\"") ...
[ "def", "get_encoding", "(", "headers", ",", "content", ")", ":", "encoding", "=", "None", "content_type", "=", "headers", ".", "get", "(", "'content-type'", ")", "if", "content_type", ":", "_", ",", "params", "=", "cgi", ".", "parse_header", "(", "content_...
Get encoding from request headers or page head.
[ "Get", "encoding", "from", "request", "headers", "or", "page", "head", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L211-L234
29,766
binux/pyspider
pyspider/libs/response.py
Response.encoding
def encoding(self): """ encoding of Response.content. if Response.encoding is None, encoding will be guessed by header or content or chardet if available. """ if hasattr(self, '_encoding'): return self._encoding # content is unicode if isinst...
python
def encoding(self): """ encoding of Response.content. if Response.encoding is None, encoding will be guessed by header or content or chardet if available. """ if hasattr(self, '_encoding'): return self._encoding # content is unicode if isinst...
[ "def", "encoding", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_encoding'", ")", ":", "return", "self", ".", "_encoding", "# content is unicode", "if", "isinstance", "(", "self", ".", "content", ",", "six", ".", "text_type", ")", ":", "re...
encoding of Response.content. if Response.encoding is None, encoding will be guessed by header or content or chardet if available.
[ "encoding", "of", "Response", ".", "content", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L61-L86
29,767
binux/pyspider
pyspider/libs/response.py
Response.json
def json(self): """Returns the json-encoded content of the response, if any.""" if hasattr(self, '_json'): return self._json try: self._json = json.loads(self.text or self.content) except ValueError: self._json = None return self._json
python
def json(self): """Returns the json-encoded content of the response, if any.""" if hasattr(self, '_json'): return self._json try: self._json = json.loads(self.text or self.content) except ValueError: self._json = None return self._json
[ "def", "json", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_json'", ")", ":", "return", "self", ".", "_json", "try", ":", "self", ".", "_json", "=", "json", ".", "loads", "(", "self", ".", "text", "or", "self", ".", "content", ")"...
Returns the json-encoded content of the response, if any.
[ "Returns", "the", "json", "-", "encoded", "content", "of", "the", "response", "if", "any", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L129-L137
29,768
binux/pyspider
pyspider/libs/response.py
Response.doc
def doc(self): """Returns a PyQuery object of the response's content""" if hasattr(self, '_doc'): return self._doc elements = self.etree doc = self._doc = PyQuery(elements) doc.make_links_absolute(utils.text(self.url)) return doc
python
def doc(self): """Returns a PyQuery object of the response's content""" if hasattr(self, '_doc'): return self._doc elements = self.etree doc = self._doc = PyQuery(elements) doc.make_links_absolute(utils.text(self.url)) return doc
[ "def", "doc", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_doc'", ")", ":", "return", "self", ".", "_doc", "elements", "=", "self", ".", "etree", "doc", "=", "self", ".", "_doc", "=", "PyQuery", "(", "elements", ")", "doc", ".", "...
Returns a PyQuery object of the response's content
[ "Returns", "a", "PyQuery", "object", "of", "the", "response", "s", "content" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L140-L147
29,769
binux/pyspider
pyspider/libs/response.py
Response.etree
def etree(self): """Returns a lxml object of the response's content that can be selected by xpath""" if not hasattr(self, '_elements'): try: parser = lxml.html.HTMLParser(encoding=self.encoding) self._elements = lxml.html.fromstring(self.content, parser=parser...
python
def etree(self): """Returns a lxml object of the response's content that can be selected by xpath""" if not hasattr(self, '_elements'): try: parser = lxml.html.HTMLParser(encoding=self.encoding) self._elements = lxml.html.fromstring(self.content, parser=parser...
[ "def", "etree", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_elements'", ")", ":", "try", ":", "parser", "=", "lxml", ".", "html", ".", "HTMLParser", "(", "encoding", "=", "self", ".", "encoding", ")", "self", ".", "_elements",...
Returns a lxml object of the response's content that can be selected by xpath
[ "Returns", "a", "lxml", "object", "of", "the", "response", "s", "content", "that", "can", "be", "selected", "by", "xpath" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L150-L163
29,770
binux/pyspider
pyspider/libs/base_handler.py
not_send_status
def not_send_status(func): """ Do not send process status package back to scheduler. It's used by callbacks like on_message, on_result etc... """ @functools.wraps(func) def wrapper(self, response, task): self._extinfo['not_send_status'] = True function = func.__get__(self, self....
python
def not_send_status(func): """ Do not send process status package back to scheduler. It's used by callbacks like on_message, on_result etc... """ @functools.wraps(func) def wrapper(self, response, task): self._extinfo['not_send_status'] = True function = func.__get__(self, self....
[ "def", "not_send_status", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "self", ",", "response", ",", "task", ")", ":", "self", ".", "_extinfo", "[", "'not_send_status'", "]", "=", "True", "function", "...
Do not send process status package back to scheduler. It's used by callbacks like on_message, on_result etc...
[ "Do", "not", "send", "process", "status", "package", "back", "to", "scheduler", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/base_handler.py#L35-L46
29,771
binux/pyspider
pyspider/libs/base_handler.py
config
def config(_config=None, **kwargs): """ A decorator for setting the default kwargs of `BaseHandler.crawl`. Any self.crawl with this callback will use this config. """ if _config is None: _config = {} _config.update(kwargs) def wrapper(func): func._config = _config re...
python
def config(_config=None, **kwargs): """ A decorator for setting the default kwargs of `BaseHandler.crawl`. Any self.crawl with this callback will use this config. """ if _config is None: _config = {} _config.update(kwargs) def wrapper(func): func._config = _config re...
[ "def", "config", "(", "_config", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "_config", "is", "None", ":", "_config", "=", "{", "}", "_config", ".", "update", "(", "kwargs", ")", "def", "wrapper", "(", "func", ")", ":", "func", ".", "_c...
A decorator for setting the default kwargs of `BaseHandler.crawl`. Any self.crawl with this callback will use this config.
[ "A", "decorator", "for", "setting", "the", "default", "kwargs", "of", "BaseHandler", ".", "crawl", ".", "Any", "self", ".", "crawl", "with", "this", "callback", "will", "use", "this", "config", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/base_handler.py#L49-L61
29,772
binux/pyspider
pyspider/libs/base_handler.py
every
def every(minutes=NOTSET, seconds=NOTSET): """ method will been called every minutes or seconds """ def wrapper(func): # mark the function with variable 'is_cronjob=True', the function would be # collected into the list Handler._cron_jobs by meta class func.is_cronjob = True ...
python
def every(minutes=NOTSET, seconds=NOTSET): """ method will been called every minutes or seconds """ def wrapper(func): # mark the function with variable 'is_cronjob=True', the function would be # collected into the list Handler._cron_jobs by meta class func.is_cronjob = True ...
[ "def", "every", "(", "minutes", "=", "NOTSET", ",", "seconds", "=", "NOTSET", ")", ":", "def", "wrapper", "(", "func", ")", ":", "# mark the function with variable 'is_cronjob=True', the function would be", "# collected into the list Handler._cron_jobs by meta class", "func",...
method will been called every minutes or seconds
[ "method", "will", "been", "called", "every", "minutes", "or", "seconds" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/base_handler.py#L68-L97
29,773
binux/pyspider
pyspider/message_queue/rabbitmq.py
catch_error
def catch_error(func): """Catch errors of rabbitmq then reconnect""" import amqp try: import pika.exceptions connect_exceptions = ( pika.exceptions.ConnectionClosed, pika.exceptions.AMQPConnectionError, ) except ImportError: connect_exceptions = ()...
python
def catch_error(func): """Catch errors of rabbitmq then reconnect""" import amqp try: import pika.exceptions connect_exceptions = ( pika.exceptions.ConnectionClosed, pika.exceptions.AMQPConnectionError, ) except ImportError: connect_exceptions = ()...
[ "def", "catch_error", "(", "func", ")", ":", "import", "amqp", "try", ":", "import", "pika", ".", "exceptions", "connect_exceptions", "=", "(", "pika", ".", "exceptions", ".", "ConnectionClosed", ",", "pika", ".", "exceptions", ".", "AMQPConnectionError", ",",...
Catch errors of rabbitmq then reconnect
[ "Catch", "errors", "of", "rabbitmq", "then", "reconnect" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/message_queue/rabbitmq.py#L24-L49
29,774
binux/pyspider
pyspider/scheduler/task_queue.py
TaskQueue.get
def get(self): '''Get a task from queue when bucket available''' if self.bucket.get() < 1: return None now = time.time() self.mutex.acquire() try: task = self.priority_queue.get_nowait() self.bucket.desc() except Queue.Empty: ...
python
def get(self): '''Get a task from queue when bucket available''' if self.bucket.get() < 1: return None now = time.time() self.mutex.acquire() try: task = self.priority_queue.get_nowait() self.bucket.desc() except Queue.Empty: ...
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "bucket", ".", "get", "(", ")", "<", "1", ":", "return", "None", "now", "=", "time", ".", "time", "(", ")", "self", ".", "mutex", ".", "acquire", "(", ")", "try", ":", "task", "=", "self...
Get a task from queue when bucket available
[ "Get", "a", "task", "from", "queue", "when", "bucket", "available" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/task_queue.py#L227-L242
29,775
binux/pyspider
pyspider/scheduler/task_queue.py
TaskQueue.done
def done(self, taskid): '''Mark task done''' if taskid in self.processing: self.mutex.acquire() if taskid in self.processing: del self.processing[taskid] self.mutex.release() return True return False
python
def done(self, taskid): '''Mark task done''' if taskid in self.processing: self.mutex.acquire() if taskid in self.processing: del self.processing[taskid] self.mutex.release() return True return False
[ "def", "done", "(", "self", ",", "taskid", ")", ":", "if", "taskid", "in", "self", ".", "processing", ":", "self", ".", "mutex", ".", "acquire", "(", ")", "if", "taskid", "in", "self", ".", "processing", ":", "del", "self", ".", "processing", "[", ...
Mark task done
[ "Mark", "task", "done" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/task_queue.py#L244-L252
29,776
binux/pyspider
pyspider/scheduler/task_queue.py
TaskQueue.is_processing
def is_processing(self, taskid): ''' return True if taskid is in processing ''' return taskid in self.processing and self.processing[taskid].taskid
python
def is_processing(self, taskid): ''' return True if taskid is in processing ''' return taskid in self.processing and self.processing[taskid].taskid
[ "def", "is_processing", "(", "self", ",", "taskid", ")", ":", "return", "taskid", "in", "self", ".", "processing", "and", "self", ".", "processing", "[", "taskid", "]", ".", "taskid" ]
return True if taskid is in processing
[ "return", "True", "if", "taskid", "is", "in", "processing" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/task_queue.py#L272-L276
29,777
binux/pyspider
pyspider/processor/processor.py
ProcessorResult.logstr
def logstr(self): """handler the log records to formatted string""" result = [] formater = LogFormatter(color=False) for record in self.logs: if isinstance(record, six.string_types): result.append(pretty_unicode(record)) else: if r...
python
def logstr(self): """handler the log records to formatted string""" result = [] formater = LogFormatter(color=False) for record in self.logs: if isinstance(record, six.string_types): result.append(pretty_unicode(record)) else: if r...
[ "def", "logstr", "(", "self", ")", ":", "result", "=", "[", "]", "formater", "=", "LogFormatter", "(", "color", "=", "False", ")", "for", "record", "in", "self", ".", "logs", ":", "if", "isinstance", "(", "record", ",", "six", ".", "string_types", ")...
handler the log records to formatted string
[ "handler", "the", "log", "records", "to", "formatted", "string" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/processor.py#L44-L59
29,778
binux/pyspider
pyspider/message_queue/__init__.py
connect_message_queue
def connect_message_queue(name, url=None, maxsize=0, lazy_limit=True): """ create connection to message queue name: name of message queue rabbitmq: amqp://username:password@host:5672/%2F see https://www.rabbitmq.com/uri-spec.html beanstalk: beanstalk://host:11300/ ...
python
def connect_message_queue(name, url=None, maxsize=0, lazy_limit=True): """ create connection to message queue name: name of message queue rabbitmq: amqp://username:password@host:5672/%2F see https://www.rabbitmq.com/uri-spec.html beanstalk: beanstalk://host:11300/ ...
[ "def", "connect_message_queue", "(", "name", ",", "url", "=", "None", ",", "maxsize", "=", "0", ",", "lazy_limit", "=", "True", ")", ":", "if", "not", "url", ":", "from", "pyspider", ".", "libs", ".", "multiprocessing_queue", "import", "Queue", "return", ...
create connection to message queue name: name of message queue rabbitmq: amqp://username:password@host:5672/%2F see https://www.rabbitmq.com/uri-spec.html beanstalk: beanstalk://host:11300/ redis: redis://host:6379/db redis://host1:port1,host2:port2,...,...
[ "create", "connection", "to", "message", "queue" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/message_queue/__init__.py#L16-L78
29,779
binux/pyspider
pyspider/libs/utils.py
hide_me
def hide_me(tb, g=globals()): """Hide stack traceback of given stack""" base_tb = tb try: while tb and tb.tb_frame.f_globals is not g: tb = tb.tb_next while tb and tb.tb_frame.f_globals is g: tb = tb.tb_next except Exception as e: logging.exception(e) ...
python
def hide_me(tb, g=globals()): """Hide stack traceback of given stack""" base_tb = tb try: while tb and tb.tb_frame.f_globals is not g: tb = tb.tb_next while tb and tb.tb_frame.f_globals is g: tb = tb.tb_next except Exception as e: logging.exception(e) ...
[ "def", "hide_me", "(", "tb", ",", "g", "=", "globals", "(", ")", ")", ":", "base_tb", "=", "tb", "try", ":", "while", "tb", "and", "tb", ".", "tb_frame", ".", "f_globals", "is", "not", "g", ":", "tb", "=", "tb", ".", "tb_next", "while", "tb", "...
Hide stack traceback of given stack
[ "Hide", "stack", "traceback", "of", "given", "stack" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L38-L51
29,780
binux/pyspider
pyspider/libs/utils.py
run_in_subprocess
def run_in_subprocess(func, *args, **kwargs): """Run function in subprocess, return a Process object""" from multiprocessing import Process thread = Process(target=func, args=args, kwargs=kwargs) thread.daemon = True thread.start() return thread
python
def run_in_subprocess(func, *args, **kwargs): """Run function in subprocess, return a Process object""" from multiprocessing import Process thread = Process(target=func, args=args, kwargs=kwargs) thread.daemon = True thread.start() return thread
[ "def", "run_in_subprocess", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "multiprocessing", "import", "Process", "thread", "=", "Process", "(", "target", "=", "func", ",", "args", "=", "args", ",", "kwargs", "=", "kwargs", ...
Run function in subprocess, return a Process object
[ "Run", "function", "in", "subprocess", "return", "a", "Process", "object" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L63-L69
29,781
binux/pyspider
pyspider/libs/utils.py
utf8
def utf8(string): """ Make sure string is utf8 encoded bytes. If parameter is a object, object.__str__ will been called before encode as bytes """ if isinstance(string, six.text_type): return string.encode('utf8') elif isinstance(string, six.binary_type): return string else:...
python
def utf8(string): """ Make sure string is utf8 encoded bytes. If parameter is a object, object.__str__ will been called before encode as bytes """ if isinstance(string, six.text_type): return string.encode('utf8') elif isinstance(string, six.binary_type): return string else:...
[ "def", "utf8", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "six", ".", "text_type", ")", ":", "return", "string", ".", "encode", "(", "'utf8'", ")", "elif", "isinstance", "(", "string", ",", "six", ".", "binary_type", ")", ":", "...
Make sure string is utf8 encoded bytes. If parameter is a object, object.__str__ will been called before encode as bytes
[ "Make", "sure", "string", "is", "utf8", "encoded", "bytes", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L213-L224
29,782
binux/pyspider
pyspider/libs/utils.py
text
def text(string, encoding='utf8'): """ Make sure string is unicode type, decode with given encoding if it's not. If parameter is a object, object.__str__ will been called """ if isinstance(string, six.text_type): return string elif isinstance(string, six.binary_type): return str...
python
def text(string, encoding='utf8'): """ Make sure string is unicode type, decode with given encoding if it's not. If parameter is a object, object.__str__ will been called """ if isinstance(string, six.text_type): return string elif isinstance(string, six.binary_type): return str...
[ "def", "text", "(", "string", ",", "encoding", "=", "'utf8'", ")", ":", "if", "isinstance", "(", "string", ",", "six", ".", "text_type", ")", ":", "return", "string", "elif", "isinstance", "(", "string", ",", "six", ".", "binary_type", ")", ":", "retur...
Make sure string is unicode type, decode with given encoding if it's not. If parameter is a object, object.__str__ will been called
[ "Make", "sure", "string", "is", "unicode", "type", "decode", "with", "given", "encoding", "if", "it", "s", "not", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L227-L238
29,783
binux/pyspider
pyspider/libs/utils.py
pretty_unicode
def pretty_unicode(string): """ Make sure string is unicode, try to decode with utf8, or unicode escaped string if failed. """ if isinstance(string, six.text_type): return string try: return string.decode("utf8") except UnicodeDecodeError: return string.decode('Latin-1')....
python
def pretty_unicode(string): """ Make sure string is unicode, try to decode with utf8, or unicode escaped string if failed. """ if isinstance(string, six.text_type): return string try: return string.decode("utf8") except UnicodeDecodeError: return string.decode('Latin-1')....
[ "def", "pretty_unicode", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "six", ".", "text_type", ")", ":", "return", "string", "try", ":", "return", "string", ".", "decode", "(", "\"utf8\"", ")", "except", "UnicodeDecodeError", ":", "retu...
Make sure string is unicode, try to decode with utf8, or unicode escaped string if failed.
[ "Make", "sure", "string", "is", "unicode", "try", "to", "decode", "with", "utf8", "or", "unicode", "escaped", "string", "if", "failed", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L241-L250
29,784
binux/pyspider
pyspider/libs/utils.py
unicode_string
def unicode_string(string): """ Make sure string is unicode, try to default with utf8, or base64 if failed. can been decode by `decode_unicode_string` """ if isinstance(string, six.text_type): return string try: return string.decode("utf8") except UnicodeDecodeError: ...
python
def unicode_string(string): """ Make sure string is unicode, try to default with utf8, or base64 if failed. can been decode by `decode_unicode_string` """ if isinstance(string, six.text_type): return string try: return string.decode("utf8") except UnicodeDecodeError: ...
[ "def", "unicode_string", "(", "string", ")", ":", "if", "isinstance", "(", "string", ",", "six", ".", "text_type", ")", ":", "return", "string", "try", ":", "return", "string", ".", "decode", "(", "\"utf8\"", ")", "except", "UnicodeDecodeError", ":", "retu...
Make sure string is unicode, try to default with utf8, or base64 if failed. can been decode by `decode_unicode_string`
[ "Make", "sure", "string", "is", "unicode", "try", "to", "default", "with", "utf8", "or", "base64", "if", "failed", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L253-L264
29,785
binux/pyspider
pyspider/libs/utils.py
unicode_dict
def unicode_dict(_dict): """ Make sure keys and values of dict is unicode. """ r = {} for k, v in iteritems(_dict): r[unicode_obj(k)] = unicode_obj(v) return r
python
def unicode_dict(_dict): """ Make sure keys and values of dict is unicode. """ r = {} for k, v in iteritems(_dict): r[unicode_obj(k)] = unicode_obj(v) return r
[ "def", "unicode_dict", "(", "_dict", ")", ":", "r", "=", "{", "}", "for", "k", ",", "v", "in", "iteritems", "(", "_dict", ")", ":", "r", "[", "unicode_obj", "(", "k", ")", "]", "=", "unicode_obj", "(", "v", ")", "return", "r" ]
Make sure keys and values of dict is unicode.
[ "Make", "sure", "keys", "and", "values", "of", "dict", "is", "unicode", "." ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L267-L274
29,786
binux/pyspider
pyspider/libs/utils.py
decode_unicode_string
def decode_unicode_string(string): """ Decode string encoded by `unicode_string` """ if string.startswith('[BASE64-DATA]') and string.endswith('[/BASE64-DATA]'): return base64.b64decode(string[len('[BASE64-DATA]'):-len('[/BASE64-DATA]')]) return string
python
def decode_unicode_string(string): """ Decode string encoded by `unicode_string` """ if string.startswith('[BASE64-DATA]') and string.endswith('[/BASE64-DATA]'): return base64.b64decode(string[len('[BASE64-DATA]'):-len('[/BASE64-DATA]')]) return string
[ "def", "decode_unicode_string", "(", "string", ")", ":", "if", "string", ".", "startswith", "(", "'[BASE64-DATA]'", ")", "and", "string", ".", "endswith", "(", "'[/BASE64-DATA]'", ")", ":", "return", "base64", ".", "b64decode", "(", "string", "[", "len", "("...
Decode string encoded by `unicode_string`
[ "Decode", "string", "encoded", "by", "unicode_string" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L307-L313
29,787
binux/pyspider
pyspider/libs/utils.py
load_object
def load_object(name): """Load object from module""" if "." not in name: raise Exception('load object need module.object') module_name, object_name = name.rsplit('.', 1) if six.PY2: module = __import__(module_name, globals(), locals(), [utf8(object_name)], -1) else: module ...
python
def load_object(name): """Load object from module""" if "." not in name: raise Exception('load object need module.object') module_name, object_name = name.rsplit('.', 1) if six.PY2: module = __import__(module_name, globals(), locals(), [utf8(object_name)], -1) else: module ...
[ "def", "load_object", "(", "name", ")", ":", "if", "\".\"", "not", "in", "name", ":", "raise", "Exception", "(", "'load object need module.object'", ")", "module_name", ",", "object_name", "=", "name", ".", "rsplit", "(", "'.'", ",", "1", ")", "if", "six",...
Load object from module
[ "Load", "object", "from", "module" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L359-L370
29,788
binux/pyspider
pyspider/libs/utils.py
get_python_console
def get_python_console(namespace=None): """ Return a interactive python console instance with caller's stack """ if namespace is None: import inspect frame = inspect.currentframe() caller = frame.f_back if not caller: logging.error("can't find caller who star...
python
def get_python_console(namespace=None): """ Return a interactive python console instance with caller's stack """ if namespace is None: import inspect frame = inspect.currentframe() caller = frame.f_back if not caller: logging.error("can't find caller who star...
[ "def", "get_python_console", "(", "namespace", "=", "None", ")", ":", "if", "namespace", "is", "None", ":", "import", "inspect", "frame", "=", "inspect", ".", "currentframe", "(", ")", "caller", "=", "frame", ".", "f_back", "if", "not", "caller", ":", "l...
Return a interactive python console instance with caller's stack
[ "Return", "a", "interactive", "python", "console", "instance", "with", "caller", "s", "stack" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L373-L415
29,789
binux/pyspider
pyspider/libs/utils.py
python_console
def python_console(namespace=None): """Start a interactive python console with caller's stack""" if namespace is None: import inspect frame = inspect.currentframe() caller = frame.f_back if not caller: logging.error("can't find caller who start this console.") ...
python
def python_console(namespace=None): """Start a interactive python console with caller's stack""" if namespace is None: import inspect frame = inspect.currentframe() caller = frame.f_back if not caller: logging.error("can't find caller who start this console.") ...
[ "def", "python_console", "(", "namespace", "=", "None", ")", ":", "if", "namespace", "is", "None", ":", "import", "inspect", "frame", "=", "inspect", ".", "currentframe", "(", ")", "caller", "=", "frame", ".", "f_back", "if", "not", "caller", ":", "loggi...
Start a interactive python console with caller's stack
[ "Start", "a", "interactive", "python", "console", "with", "caller", "s", "stack" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L418-L431
29,790
binux/pyspider
pyspider/libs/wsgi_xmlrpc.py
WSGIXMLRPCApplication.handler
def handler(self, environ, start_response): """XMLRPC service for windmill browser core to communicate with""" if environ['REQUEST_METHOD'] == 'POST': return self.handle_POST(environ, start_response) else: start_response("400 Bad request", [('Content-Type', 'text/plain')...
python
def handler(self, environ, start_response): """XMLRPC service for windmill browser core to communicate with""" if environ['REQUEST_METHOD'] == 'POST': return self.handle_POST(environ, start_response) else: start_response("400 Bad request", [('Content-Type', 'text/plain')...
[ "def", "handler", "(", "self", ",", "environ", ",", "start_response", ")", ":", "if", "environ", "[", "'REQUEST_METHOD'", "]", "==", "'POST'", ":", "return", "self", ".", "handle_POST", "(", "environ", ",", "start_response", ")", "else", ":", "start_response...
XMLRPC service for windmill browser core to communicate with
[ "XMLRPC", "service", "for", "windmill", "browser", "core", "to", "communicate", "with" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/wsgi_xmlrpc.py#L48-L55
29,791
binux/pyspider
pyspider/database/__init__.py
connect_database
def connect_database(url): """ create database object by url mysql: mysql+type://user:passwd@host:port/database sqlite: # relative path sqlite+type:///path/to/database.db # absolute path sqlite+type:////path/to/database.db # memory database sqlite...
python
def connect_database(url): """ create database object by url mysql: mysql+type://user:passwd@host:port/database sqlite: # relative path sqlite+type:///path/to/database.db # absolute path sqlite+type:////path/to/database.db # memory database sqlite...
[ "def", "connect_database", "(", "url", ")", ":", "db", "=", "_connect_database", "(", "url", ")", "db", ".", "copy", "=", "lambda", ":", "_connect_database", "(", "url", ")", "return", "db" ]
create database object by url mysql: mysql+type://user:passwd@host:port/database sqlite: # relative path sqlite+type:///path/to/database.db # absolute path sqlite+type:////path/to/database.db # memory database sqlite+type:// mongodb: mongodb+t...
[ "create", "database", "object", "by", "url" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/database/__init__.py#L11-L46
29,792
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler._update_projects
def _update_projects(self): '''Check project update''' now = time.time() if ( not self._force_update_project and self._last_update_project + self.UPDATE_PROJECT_INTERVAL > now ): return for project in self.projectdb.check_update(self._l...
python
def _update_projects(self): '''Check project update''' now = time.time() if ( not self._force_update_project and self._last_update_project + self.UPDATE_PROJECT_INTERVAL > now ): return for project in self.projectdb.check_update(self._l...
[ "def", "_update_projects", "(", "self", ")", ":", "now", "=", "time", ".", "time", "(", ")", "if", "(", "not", "self", ".", "_force_update_project", "and", "self", ".", "_last_update_project", "+", "self", ".", "UPDATE_PROJECT_INTERVAL", ">", "now", ")", "...
Check project update
[ "Check", "project", "update" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L206-L218
29,793
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler._update_project
def _update_project(self, project): '''update one project''' if project['name'] not in self.projects: self.projects[project['name']] = Project(self, project) else: self.projects[project['name']].update(project) project = self.projects[project['name']] if...
python
def _update_project(self, project): '''update one project''' if project['name'] not in self.projects: self.projects[project['name']] = Project(self, project) else: self.projects[project['name']].update(project) project = self.projects[project['name']] if...
[ "def", "_update_project", "(", "self", ",", "project", ")", ":", "if", "project", "[", "'name'", "]", "not", "in", "self", ".", "projects", ":", "self", ".", "projects", "[", "project", "[", "'name'", "]", "]", "=", "Project", "(", "self", ",", "proj...
update one project
[ "update", "one", "project" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L222-L259
29,794
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler._load_tasks
def _load_tasks(self, project): '''load tasks from database''' task_queue = project.task_queue for task in self.taskdb.load_tasks( self.taskdb.ACTIVE, project.name, self.scheduler_task_fields ): taskid = task['taskid'] _schedule = task.get('schedu...
python
def _load_tasks(self, project): '''load tasks from database''' task_queue = project.task_queue for task in self.taskdb.load_tasks( self.taskdb.ACTIVE, project.name, self.scheduler_task_fields ): taskid = task['taskid'] _schedule = task.get('schedu...
[ "def", "_load_tasks", "(", "self", ",", "project", ")", ":", "task_queue", "=", "project", ".", "task_queue", "for", "task", "in", "self", ".", "taskdb", ".", "load_tasks", "(", "self", ".", "taskdb", ".", "ACTIVE", ",", "project", ".", "name", ",", "s...
load tasks from database
[ "load", "tasks", "from", "database" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L263-L280
29,795
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler.task_verify
def task_verify(self, task): ''' return False if any of 'taskid', 'project', 'url' is not in task dict or project in not in task_queue ''' for each in ('taskid', 'project', 'url', ): if each not in task or not task[each]: logger.error('...
python
def task_verify(self, task): ''' return False if any of 'taskid', 'project', 'url' is not in task dict or project in not in task_queue ''' for each in ('taskid', 'project', 'url', ): if each not in task or not task[each]: logger.error('...
[ "def", "task_verify", "(", "self", ",", "task", ")", ":", "for", "each", "in", "(", "'taskid'", ",", "'project'", ",", "'url'", ",", ")", ":", "if", "each", "not", "in", "task", "or", "not", "task", "[", "each", "]", ":", "logger", ".", "error", ...
return False if any of 'taskid', 'project', 'url' is not in task dict or project in not in task_queue
[ "return", "False", "if", "any", "of", "taskid", "project", "url", "is", "not", "in", "task", "dict", "or", "project", "in", "not", "in", "task_queue" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L297-L315
29,796
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler.put_task
def put_task(self, task): '''put task to task queue''' _schedule = task.get('schedule', self.default_schedule) self.projects[task['project']].task_queue.put( task['taskid'], priority=_schedule.get('priority', self.default_schedule['priority']), exetime=_schedu...
python
def put_task(self, task): '''put task to task queue''' _schedule = task.get('schedule', self.default_schedule) self.projects[task['project']].task_queue.put( task['taskid'], priority=_schedule.get('priority', self.default_schedule['priority']), exetime=_schedu...
[ "def", "put_task", "(", "self", ",", "task", ")", ":", "_schedule", "=", "task", ".", "get", "(", "'schedule'", ",", "self", ".", "default_schedule", ")", "self", ".", "projects", "[", "task", "[", "'project'", "]", "]", ".", "task_queue", ".", "put", ...
put task to task queue
[ "put", "task", "to", "task", "queue" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L325-L332
29,797
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler.send_task
def send_task(self, task, force=True): ''' dispatch task to fetcher out queue may have size limit to prevent block, a send_buffer is used ''' try: self.out_queue.put_nowait(task) except Queue.Full: if force: self._send_buffer.appen...
python
def send_task(self, task, force=True): ''' dispatch task to fetcher out queue may have size limit to prevent block, a send_buffer is used ''' try: self.out_queue.put_nowait(task) except Queue.Full: if force: self._send_buffer.appen...
[ "def", "send_task", "(", "self", ",", "task", ",", "force", "=", "True", ")", ":", "try", ":", "self", ".", "out_queue", ".", "put_nowait", "(", "task", ")", "except", "Queue", ".", "Full", ":", "if", "force", ":", "self", ".", "_send_buffer", ".", ...
dispatch task to fetcher out queue may have size limit to prevent block, a send_buffer is used
[ "dispatch", "task", "to", "fetcher" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L334-L346
29,798
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler._check_task_done
def _check_task_done(self): '''Check status queue''' cnt = 0 try: while True: task = self.status_queue.get_nowait() # check _on_get_info result here if task.get('taskid') == '_on_get_info' and 'project' in task and 'track' in task: ...
python
def _check_task_done(self): '''Check status queue''' cnt = 0 try: while True: task = self.status_queue.get_nowait() # check _on_get_info result here if task.get('taskid') == '_on_get_info' and 'project' in task and 'track' in task: ...
[ "def", "_check_task_done", "(", "self", ")", ":", "cnt", "=", "0", "try", ":", "while", "True", ":", "task", "=", "self", ".", "status_queue", ".", "get_nowait", "(", ")", "# check _on_get_info result here", "if", "task", ".", "get", "(", "'taskid'", ")", ...
Check status queue
[ "Check", "status", "queue" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L348-L370
29,799
binux/pyspider
pyspider/scheduler/scheduler.py
Scheduler._check_request
def _check_request(self): '''Check new task queue''' # check _postpone_request first todo = [] for task in self._postpone_request: if task['project'] not in self.projects: continue if self.projects[task['project']].task_queue.is_processing(task['ta...
python
def _check_request(self): '''Check new task queue''' # check _postpone_request first todo = [] for task in self._postpone_request: if task['project'] not in self.projects: continue if self.projects[task['project']].task_queue.is_processing(task['ta...
[ "def", "_check_request", "(", "self", ")", ":", "# check _postpone_request first", "todo", "=", "[", "]", "for", "task", "in", "self", ".", "_postpone_request", ":", "if", "task", "[", "'project'", "]", "not", "in", "self", ".", "projects", ":", "continue", ...
Check new task queue
[ "Check", "new", "task", "queue" ]
3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9
https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L374-L417