repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train | Undeploy an existing lambda function. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Update any cognito triggers that are present in the user pool. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Schedules the function to execute. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Unschedule CloudWatch based events. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Invoke a remote function. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.format_invoke_command | def format_invoke_command(self, string):
"""
Formats correctly the string output from the invoke() method,
replacing line breaks and tabs when necessary.
"""
string = string.replace('\\n', '\n')
formated_response = ''
for line in string.splitlines():
... | python | def format_invoke_command(self, string):
"""
Formats correctly the string output from the invoke() method,
replacing line breaks and tabs when necessary.
"""
string = string.replace('\\n', '\n')
formated_response = ''
for line in string.splitlines():
... | [
"def",
"format_invoke_command",
"(",
"self",
",",
"string",
")",
":",
"string",
"=",
"string",
".",
"replace",
"(",
"'\\\\n'",
",",
"'\\n'",
")",
"formated_response",
"=",
"''",
"for",
"line",
"in",
"string",
".",
"splitlines",
"(",
")",
":",
"if",
"line... | Formats correctly the string output from the invoke() method,
replacing line breaks and tabs when necessary. | [
"Formats",
"correctly",
"the",
"string",
"output",
"from",
"the",
"invoke",
"()",
"method",
"replacing",
"line",
"breaks",
"and",
"tabs",
"when",
"necessary",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1302-L1319 | train | Formats correctly the string output from the invoke method. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Return a colorized version of the invoke command string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.status | def status(self, return_json=False):
"""
Describe the status of the current deployment.
"""
def tabular_print(title, value):
"""
Convenience function for priting formatted table items.
"""
click.echo('%-*s%s' % (32, click.style("\t" + titl... | python | def status(self, return_json=False):
"""
Describe the status of the current deployment.
"""
def tabular_print(title, value):
"""
Convenience function for priting formatted table items.
"""
click.echo('%-*s%s' % (32, click.style("\t" + titl... | [
"def",
"status",
"(",
"self",
",",
"return_json",
"=",
"False",
")",
":",
"def",
"tabular_print",
"(",
"title",
",",
"value",
")",
":",
"\"\"\"\n Convenience function for priting formatted table items.\n \"\"\"",
"click",
".",
"echo",
"(",
"'%-*s%s... | Describe the status of the current deployment. | [
"Describe",
"the",
"status",
"of",
"the",
"current",
"deployment",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1389-L1519 | train | Get the status of the current deployment. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Check that the environment contains only strings | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.init | def init(self, settings_file="zappa_settings.json"):
"""
Initialize a new Zappa project by creating a new zappa_settings.json in a guided process.
This should probably be broken up into few separate componants once it's stable.
Testing these inputs requires monkeypatching with mock, whi... | python | def init(self, settings_file="zappa_settings.json"):
"""
Initialize a new Zappa project by creating a new zappa_settings.json in a guided process.
This should probably be broken up into few separate componants once it's stable.
Testing these inputs requires monkeypatching with mock, whi... | [
"def",
"init",
"(",
"self",
",",
"settings_file",
"=",
"\"zappa_settings.json\"",
")",
":",
"# Make sure we're in a venv.",
"self",
".",
"check_venv",
"(",
")",
"# Ensure that we don't already have a zappa_settings file.",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
... | Initialize a new Zappa project by creating a new zappa_settings.json in a guided process.
This should probably be broken up into few separate componants once it's stable.
Testing these inputs requires monkeypatching with mock, which isn't pretty. | [
"Initialize",
"a",
"new",
"Zappa",
"project",
"by",
"creating",
"a",
"new",
"zappa_settings",
".",
"json",
"in",
"a",
"guided",
"process",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1550-L1797 | train | Initialize a new Zappa project by creating a new Zappa_settings. json in a guided process. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.certify | def certify(self, no_confirm=True, manual=False):
"""
Register or update a domain certificate for this env.
"""
if not self.domain:
raise ClickException("Can't certify a domain without " + click.style("domain", fg="red", bold=True) + " configured!")
if not no_confir... | python | def certify(self, no_confirm=True, manual=False):
"""
Register or update a domain certificate for this env.
"""
if not self.domain:
raise ClickException("Can't certify a domain without " + click.style("domain", fg="red", bold=True) + " configured!")
if not no_confir... | [
"def",
"certify",
"(",
"self",
",",
"no_confirm",
"=",
"True",
",",
"manual",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"domain",
":",
"raise",
"ClickException",
"(",
"\"Can't certify a domain without \"",
"+",
"click",
".",
"style",
"(",
"\"domain\"... | Register or update a domain certificate for this env. | [
"Register",
"or",
"update",
"a",
"domain",
"certificate",
"for",
"this",
"env",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1799-L1919 | train | Certify a domain certificate for this application. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Spawn a debug shell. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Allows the execution of custom code between creation of the zip file and deployment to AWS. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Check if there s a new Zappa version available. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.load_settings | def load_settings(self, settings_file=None, session=None):
"""
Load the local zappa_settings file.
An existing boto session can be supplied, though this is likely for testing purposes.
Returns the loaded Zappa object.
"""
# Ensure we're passed a valid settings file.
... | python | def load_settings(self, settings_file=None, session=None):
"""
Load the local zappa_settings file.
An existing boto session can be supplied, though this is likely for testing purposes.
Returns the loaded Zappa object.
"""
# Ensure we're passed a valid settings file.
... | [
"def",
"load_settings",
"(",
"self",
",",
"settings_file",
"=",
"None",
",",
"session",
"=",
"None",
")",
":",
"# Ensure we're passed a valid settings file.",
"if",
"not",
"settings_file",
":",
"settings_file",
"=",
"self",
".",
"get_json_or_yaml_settings",
"(",
")"... | Load the local zappa_settings file.
An existing boto session can be supplied, though this is likely for testing purposes.
Returns the loaded Zappa object. | [
"Load",
"the",
"local",
"zappa_settings",
"file",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1996-L2133 | train | Load the local Zappa settings file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.get_json_or_yaml_settings | def get_json_or_yaml_settings(self, settings_name="zappa_settings"):
"""
Return zappa_settings path as JSON or YAML (or TOML), as appropriate.
"""
zs_json = settings_name + ".json"
zs_yml = settings_name + ".yml"
zs_yaml = settings_name + ".yaml"
zs_toml = setting... | python | def get_json_or_yaml_settings(self, settings_name="zappa_settings"):
"""
Return zappa_settings path as JSON or YAML (or TOML), as appropriate.
"""
zs_json = settings_name + ".json"
zs_yml = settings_name + ".yml"
zs_yaml = settings_name + ".yaml"
zs_toml = setting... | [
"def",
"get_json_or_yaml_settings",
"(",
"self",
",",
"settings_name",
"=",
"\"zappa_settings\"",
")",
":",
"zs_json",
"=",
"settings_name",
"+",
"\".json\"",
"zs_yml",
"=",
"settings_name",
"+",
"\".yml\"",
"zs_yaml",
"=",
"settings_name",
"+",
"\".yaml\"",
"zs_tom... | Return zappa_settings path as JSON or YAML (or TOML), as appropriate. | [
"Return",
"zappa_settings",
"path",
"as",
"JSON",
"or",
"YAML",
"(",
"or",
"TOML",
")",
"as",
"appropriate",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2135-L2161 | train | Return the path to the zappa_settings file as JSON or YAML as appropriate. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Load our settings file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.create_package | def create_package(self, output=None):
"""
Ensure that the package can be properly configured,
and then create it.
"""
# Create the Lambda zip package (includes project and virtualenvironment)
# Also define the path the handler file so it can be copied to the zip
... | python | def create_package(self, output=None):
"""
Ensure that the package can be properly configured,
and then create it.
"""
# Create the Lambda zip package (includes project and virtualenvironment)
# Also define the path the handler file so it can be copied to the zip
... | [
"def",
"create_package",
"(",
"self",
",",
"output",
"=",
"None",
")",
":",
"# Create the Lambda zip package (includes project and virtualenvironment)",
"# Also define the path the handler file so it can be copied to the zip",
"# root for Lambda.",
"current_file",
"=",
"os",
".",
"... | Ensure that the package can be properly configured,
and then create it. | [
"Ensure",
"that",
"the",
"package",
"can",
"be",
"properly",
"configured",
"and",
"then",
"create",
"it",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2193-L2441 | train | Create the Lambda package and the handler file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.remove_local_zip | def remove_local_zip(self):
"""
Remove our local zip file.
"""
if self.stage_config.get('delete_local_zip', True):
try:
if os.path.isfile(self.zip_path):
os.remove(self.zip_path)
if self.handler_path and os.path.isfile(self... | python | def remove_local_zip(self):
"""
Remove our local zip file.
"""
if self.stage_config.get('delete_local_zip', True):
try:
if os.path.isfile(self.zip_path):
os.remove(self.zip_path)
if self.handler_path and os.path.isfile(self... | [
"def",
"remove_local_zip",
"(",
"self",
")",
":",
"if",
"self",
".",
"stage_config",
".",
"get",
"(",
"'delete_local_zip'",
",",
"True",
")",
":",
"try",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"zip_path",
")",
":",
"os",
".",
... | Remove our local zip file. | [
"Remove",
"our",
"local",
"zip",
"file",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2443-L2455 | train | Remove our local zip file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.remove_uploaded_zip | def remove_uploaded_zip(self):
"""
Remove the local and S3 zip file after uploading and updating.
"""
# Remove the uploaded zip from S3, because it is now registered..
if self.stage_config.get('delete_s3_zip', True):
self.zappa.remove_from_s3(self.zip_path, self.s3_b... | python | def remove_uploaded_zip(self):
"""
Remove the local and S3 zip file after uploading and updating.
"""
# Remove the uploaded zip from S3, because it is now registered..
if self.stage_config.get('delete_s3_zip', True):
self.zappa.remove_from_s3(self.zip_path, self.s3_b... | [
"def",
"remove_uploaded_zip",
"(",
"self",
")",
":",
"# Remove the uploaded zip from S3, because it is now registered..",
"if",
"self",
".",
"stage_config",
".",
"get",
"(",
"'delete_s3_zip'",
",",
"True",
")",
":",
"self",
".",
"zappa",
".",
"remove_from_s3",
"(",
... | Remove the local and S3 zip file after uploading and updating. | [
"Remove",
"the",
"local",
"and",
"S3",
"zip",
"file",
"after",
"uploading",
"and",
"updating",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2457-L2467 | train | Remove the uploaded zip file from S3 if it is already registered. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Miserlou/Zappa | zappa/cli.py | ZappaCLI.on_exit | def on_exit(self):
"""
Cleanup after the command finishes.
Always called: SystemExit, KeyboardInterrupt and any other Exception that occurs.
"""
if self.zip_path:
# Only try to remove uploaded zip if we're running a command that has loaded credentials
if s... | python | def on_exit(self):
"""
Cleanup after the command finishes.
Always called: SystemExit, KeyboardInterrupt and any other Exception that occurs.
"""
if self.zip_path:
# Only try to remove uploaded zip if we're running a command that has loaded credentials
if s... | [
"def",
"on_exit",
"(",
"self",
")",
":",
"if",
"self",
".",
"zip_path",
":",
"# Only try to remove uploaded zip if we're running a command that has loaded credentials",
"if",
"self",
".",
"load_credentials",
":",
"self",
".",
"remove_uploaded_zip",
"(",
")",
"self",
"."... | Cleanup after the command finishes.
Always called: SystemExit, KeyboardInterrupt and any other Exception that occurs. | [
"Cleanup",
"after",
"the",
"command",
"finishes",
".",
"Always",
"called",
":",
"SystemExit",
"KeyboardInterrupt",
"and",
"any",
"other",
"Exception",
"that",
"occurs",
"."
] | 3ccf7490a8d8b8fa74a61ee39bf44234f3567739 | https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2469-L2479 | train | Cleanup after the command finishes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Print the logs to the console. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Determines if a log entry is an HTTP - formatted log string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Return a colorized version of a log entry. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Parse and execute the prebuild script from the zappa_settings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Print a warning if this could
collide with a Zappa core package module. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Ensure we re inside a virtualenv. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Route all stdout to null. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Test the deployed endpoint with a GET request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Permute all casings of a given string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/database/sqlite/taskdb.py | TaskDB.status_count | def status_count(self, project):
'''
return a dict
'''
result = dict()
if project not in self.projects:
self._list_project()
if project not in self.projects:
return result
tablename = self._tablename(project)
for status, count in se... | python | def status_count(self, project):
'''
return a dict
'''
result = dict()
if project not in self.projects:
self._list_project()
if project not in self.projects:
return result
tablename = self._tablename(project)
for status, count in se... | [
"def",
"status_count",
"(",
"self",
",",
"project",
")",
":",
"result",
"=",
"dict",
"(",
")",
"if",
"project",
"not",
"in",
"self",
".",
"projects",
":",
"self",
".",
"_list_project",
"(",
")",
"if",
"project",
"not",
"in",
"self",
".",
"projects",
... | return a dict | [
"return",
"a",
"dict"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/database/sqlite/taskdb.py#L85-L98 | train | get the number of times a specific project has been created | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Get encoding from request headers or page head. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Returns the encoding of the response. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/response.py | Response.text | def text(self):
"""
Content of the response, in unicode.
if Response.encoding is None and chardet module is available, encoding
will be guessed.
"""
if hasattr(self, '_text') and self._text:
return self._text
if not self.content:
return u'... | python | def text(self):
"""
Content of the response, in unicode.
if Response.encoding is None and chardet module is available, encoding
will be guessed.
"""
if hasattr(self, '_text') and self._text:
return self._text
if not self.content:
return u'... | [
"def",
"text",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'_text'",
")",
"and",
"self",
".",
"_text",
":",
"return",
"self",
".",
"_text",
"if",
"not",
"self",
".",
"content",
":",
"return",
"u''",
"if",
"isinstance",
"(",
"self",
"... | Content of the response, in unicode.
if Response.encoding is None and chardet module is available, encoding
will be guessed. | [
"Content",
"of",
"the",
"response",
"in",
"unicode",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L98-L126 | train | Return the content of the response in unicode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Returns the json - encoded content of the response if any. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Returns a PyQuery object of the response s content | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Returns a lxml. etree. _ElementTree object of the response s content that can be selected by xpath | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/response.py | Response.raise_for_status | def raise_for_status(self, allow_redirects=True):
"""Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""
if self.status_code == 304:
return
elif self.error:
if self.traceback:
six.reraise(Exception, Exception(self.error), Traceback.... | python | def raise_for_status(self, allow_redirects=True):
"""Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred."""
if self.status_code == 304:
return
elif self.error:
if self.traceback:
six.reraise(Exception, Exception(self.error), Traceback.... | [
"def",
"raise_for_status",
"(",
"self",
",",
"allow_redirects",
"=",
"True",
")",
":",
"if",
"self",
".",
"status_code",
"==",
"304",
":",
"return",
"elif",
"self",
".",
"error",
":",
"if",
"self",
".",
"traceback",
":",
"six",
".",
"reraise",
"(",
"Ex... | Raises stored :class:`HTTPError` or :class:`URLError`, if one occurred. | [
"Raises",
"stored",
":",
"class",
":",
"HTTPError",
"or",
":",
"class",
":",
"URLError",
"if",
"one",
"occurred",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/response.py#L165-L184 | train | Raises HTTPError or URLError if one occurred. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Decorator to mark a task as not sending status to scheduler. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | A decorator for setting the default kwargs of BaseHandler. crawl. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Decorator for cronjob functions | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Catch errors of rabbitmq then reconnect | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/message_queue/rabbitmq.py | PikaQueue.reconnect | def reconnect(self):
"""Reconnect to rabbitmq server"""
import pika
import pika.exceptions
self.connection = pika.BlockingConnection(pika.URLParameters(self.amqp_url))
self.channel = self.connection.channel()
try:
self.channel.queue_declare(self.name)
... | python | def reconnect(self):
"""Reconnect to rabbitmq server"""
import pika
import pika.exceptions
self.connection = pika.BlockingConnection(pika.URLParameters(self.amqp_url))
self.channel = self.connection.channel()
try:
self.channel.queue_declare(self.name)
... | [
"def",
"reconnect",
"(",
"self",
")",
":",
"import",
"pika",
"import",
"pika",
".",
"exceptions",
"self",
".",
"connection",
"=",
"pika",
".",
"BlockingConnection",
"(",
"pika",
".",
"URLParameters",
"(",
"self",
".",
"amqp_url",
")",
")",
"self",
".",
"... | Reconnect to rabbitmq server | [
"Reconnect",
"to",
"rabbitmq",
"server"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/message_queue/rabbitmq.py#L91-L102 | train | Reconnect to rabbitmq server | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/message_queue/rabbitmq.py | AmqpQueue.reconnect | def reconnect(self):
"""Reconnect to rabbitmq server"""
parsed = urlparse.urlparse(self.amqp_url)
port = parsed.port or 5672
self.connection = amqp.Connection(host="%s:%s" % (parsed.hostname, port),
userid=parsed.username or 'guest',
... | python | def reconnect(self):
"""Reconnect to rabbitmq server"""
parsed = urlparse.urlparse(self.amqp_url)
port = parsed.port or 5672
self.connection = amqp.Connection(host="%s:%s" % (parsed.hostname, port),
userid=parsed.username or 'guest',
... | [
"def",
"reconnect",
"(",
"self",
")",
":",
"parsed",
"=",
"urlparse",
".",
"urlparse",
"(",
"self",
".",
"amqp_url",
")",
"port",
"=",
"parsed",
".",
"port",
"or",
"5672",
"self",
".",
"connection",
"=",
"amqp",
".",
"Connection",
"(",
"host",
"=",
"... | Reconnect to rabbitmq server | [
"Reconnect",
"to",
"rabbitmq",
"server"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/message_queue/rabbitmq.py#L224-L237 | train | Reconnect to rabbitmq server | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/task_queue.py | TaskQueue.put | def put(self, taskid, priority=0, exetime=0):
"""
Put a task into task queue
when use heap sort, if we put tasks(with the same priority and exetime=0) into queue,
the queue is not a strict FIFO queue, but more like a FILO stack.
It is very possible that when there are co... | python | def put(self, taskid, priority=0, exetime=0):
"""
Put a task into task queue
when use heap sort, if we put tasks(with the same priority and exetime=0) into queue,
the queue is not a strict FIFO queue, but more like a FILO stack.
It is very possible that when there are co... | [
"def",
"put",
"(",
"self",
",",
"taskid",
",",
"priority",
"=",
"0",
",",
"exetime",
"=",
"0",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"task",
"=",
"InQueueTask",
"(",
"taskid",
",",
"priority",
",",
"exetime",
")",
"self",
".",
"mut... | Put a task into task queue
when use heap sort, if we put tasks(with the same priority and exetime=0) into queue,
the queue is not a strict FIFO queue, but more like a FILO stack.
It is very possible that when there are continuous big flow, the speed of select is
slower than req... | [
"Put",
"a",
"task",
"into",
"task",
"queue",
"when",
"use",
"heap",
"sort",
"if",
"we",
"put",
"tasks",
"(",
"with",
"the",
"same",
"priority",
"and",
"exetime",
"=",
"0",
")",
"into",
"queue",
"the",
"queue",
"is",
"not",
"a",
"strict",
"FIFO",
"que... | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/task_queue.py#L190-L225 | train | Put a task into the priority queue and time queue. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Get a task from queue when bucket available | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Mark task done | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Returns True if taskid is in processing or False if taskid is not in processing
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | handler the log records to formatted string | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/processor.py | Processor.on_task | def on_task(self, task, response):
'''Deal one task'''
start_time = time.time()
response = rebuild_response(response)
try:
assert 'taskid' in task, 'need taskid in task'
project = task['project']
updatetime = task.get('project_updatetime', None)
... | python | def on_task(self, task, response):
'''Deal one task'''
start_time = time.time()
response = rebuild_response(response)
try:
assert 'taskid' in task, 'need taskid in task'
project = task['project']
updatetime = task.get('project_updatetime', None)
... | [
"def",
"on_task",
"(",
"self",
",",
"task",
",",
"response",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"response",
"=",
"rebuild_response",
"(",
"response",
")",
"try",
":",
"assert",
"'taskid'",
"in",
"task",
",",
"'need taskid in task'"... | Deal one task | [
"Deal",
"one",
"task"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/processor.py#L102-L203 | train | Deal one task | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/processor.py | Processor.run | def run(self):
'''Run loop'''
logger.info("processor starting...")
while not self._quit:
try:
task, response = self.inqueue.get(timeout=1)
self.on_task(task, response)
self._exceptions = 0
except Queue.Empty as e:
... | python | def run(self):
'''Run loop'''
logger.info("processor starting...")
while not self._quit:
try:
task, response = self.inqueue.get(timeout=1)
self.on_task(task, response)
self._exceptions = 0
except Queue.Empty as e:
... | [
"def",
"run",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"processor starting...\"",
")",
"while",
"not",
"self",
".",
"_quit",
":",
"try",
":",
"task",
",",
"response",
"=",
"self",
".",
"inqueue",
".",
"get",
"(",
"timeout",
"=",
"1",
")",... | Run loop | [
"Run",
"loop"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/processor.py#L209-L229 | train | Run the loop of the processor. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | create a connection to a message queue | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Hide stack traceback of given stack | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Run function in subprocess return a Process object | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/utils.py | format_date | def format_date(date, gmt_offset=0, relative=True, shorter=False, full_format=False):
"""Formats the given date (which should be GMT).
By default, we return a relative time (e.g., "2 minutes ago"). You
can return an absolute date string with ``relative=False``.
You can force a full format date ("July ... | python | def format_date(date, gmt_offset=0, relative=True, shorter=False, full_format=False):
"""Formats the given date (which should be GMT).
By default, we return a relative time (e.g., "2 minutes ago"). You
can return an absolute date string with ``relative=False``.
You can force a full format date ("July ... | [
"def",
"format_date",
"(",
"date",
",",
"gmt_offset",
"=",
"0",
",",
"relative",
"=",
"True",
",",
"shorter",
"=",
"False",
",",
"full_format",
"=",
"False",
")",
":",
"if",
"not",
"date",
":",
"return",
"'-'",
"if",
"isinstance",
"(",
"date",
",",
"... | Formats the given date (which should be GMT).
By default, we return a relative time (e.g., "2 minutes ago"). You
can return an absolute date string with ``relative=False``.
You can force a full format date ("July 10, 1980") with
``full_format=True``.
This method is primarily intended for dates in... | [
"Formats",
"the",
"given",
"date",
"(",
"which",
"should",
"be",
"GMT",
")",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L72-L130 | train | Formats the given date in a tornado - internal format. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Make sure string is utf8 encoded bytes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Make sure string is unicode type decode with given encoding if it s not. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Make sure string is unicode try to decode with utf8 escaped string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Make sure string is unicode try to default with base64 | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Make sure keys and values of dict are unicode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/utils.py | unicode_obj | def unicode_obj(obj):
"""
Make sure keys and values of dict/list/tuple is unicode. bytes will encode in base64.
Can been decode by `decode_unicode_obj`
"""
if isinstance(obj, dict):
return unicode_dict(obj)
elif isinstance(obj, (list, tuple)):
return unicode_list(obj)
elif i... | python | def unicode_obj(obj):
"""
Make sure keys and values of dict/list/tuple is unicode. bytes will encode in base64.
Can been decode by `decode_unicode_obj`
"""
if isinstance(obj, dict):
return unicode_dict(obj)
elif isinstance(obj, (list, tuple)):
return unicode_list(obj)
elif i... | [
"def",
"unicode_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"return",
"unicode_dict",
"(",
"obj",
")",
"elif",
"isinstance",
"(",
"obj",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"unicode_list",
"... | Make sure keys and values of dict/list/tuple is unicode. bytes will encode in base64.
Can been decode by `decode_unicode_obj` | [
"Make",
"sure",
"keys",
"and",
"values",
"of",
"dict",
"/",
"list",
"/",
"tuple",
"is",
"unicode",
".",
"bytes",
"will",
"encode",
"in",
"base64",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L284-L304 | train | Convert obj into unicode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Decode string encoded by unicode_string | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/utils.py | decode_unicode_obj | def decode_unicode_obj(obj):
"""
Decode unicoded dict/list/tuple encoded by `unicode_obj`
"""
if isinstance(obj, dict):
r = {}
for k, v in iteritems(obj):
r[decode_unicode_string(k)] = decode_unicode_obj(v)
return r
elif isinstance(obj, six.string_types):
... | python | def decode_unicode_obj(obj):
"""
Decode unicoded dict/list/tuple encoded by `unicode_obj`
"""
if isinstance(obj, dict):
r = {}
for k, v in iteritems(obj):
r[decode_unicode_string(k)] = decode_unicode_obj(v)
return r
elif isinstance(obj, six.string_types):
... | [
"def",
"decode_unicode_obj",
"(",
"obj",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"dict",
")",
":",
"r",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"obj",
")",
":",
"r",
"[",
"decode_unicode_string",
"(",
"k",
")",
"]",
"=... | Decode unicoded dict/list/tuple encoded by `unicode_obj` | [
"Decode",
"unicoded",
"dict",
"/",
"list",
"/",
"tuple",
"encoded",
"by",
"unicode_obj"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/utils.py#L316-L330 | train | Decode unicoded dict list tuple encoded by unicode_obj | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Load object from module | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Return an interactive python console instance with caller s stack
AttributeNames. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Start a interactive python console with caller s stack | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | XMLRPC service for windmill browser core to communicate with | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/libs/wsgi_xmlrpc.py | WSGIXMLRPCApplication.handle_POST | def handle_POST(self, environ, start_response):
"""Handles the HTTP POST request.
Attempts to interpret all HTTP POST requests as XML-RPC calls,
which are forwarded to the server's _dispatch method for handling.
Most code taken from SimpleXMLRPCServer with modifications for wsgi and my... | python | def handle_POST(self, environ, start_response):
"""Handles the HTTP POST request.
Attempts to interpret all HTTP POST requests as XML-RPC calls,
which are forwarded to the server's _dispatch method for handling.
Most code taken from SimpleXMLRPCServer with modifications for wsgi and my... | [
"def",
"handle_POST",
"(",
"self",
",",
"environ",
",",
"start_response",
")",
":",
"try",
":",
"# Get arguments by reading body of request.",
"# We read this in chunks to avoid straining",
"# socket.read(); around the 10 or 15Mb mark, some platforms",
"# begin to have problems (bug #7... | Handles the HTTP POST request.
Attempts to interpret all HTTP POST requests as XML-RPC calls,
which are forwarded to the server's _dispatch method for handling.
Most code taken from SimpleXMLRPCServer with modifications for wsgi and my custom dispatcher. | [
"Handles",
"the",
"HTTP",
"POST",
"request",
"."
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/libs/wsgi_xmlrpc.py#L57-L92 | train | Handles the HTTP POST request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | create database object by url | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Check project update | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | update one project by creating or updating it with the project information | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | load tasks from database | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Verify that a task is valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | put task to task queue | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | dispatch task to fetcher
out queue and append it to the send_buffer | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Check status queue for tasks that are done and check if they are still valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
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 | train | Check new task queue and check if new task is valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler._check_cronjob | def _check_cronjob(self):
"""Check projects cronjob tick, return True when a new tick is sended"""
now = time.time()
self._last_tick = int(self._last_tick)
if now - self._last_tick < 1:
return False
self._last_tick += 1
for project in itervalues(self.projects)... | python | def _check_cronjob(self):
"""Check projects cronjob tick, return True when a new tick is sended"""
now = time.time()
self._last_tick = int(self._last_tick)
if now - self._last_tick < 1:
return False
self._last_tick += 1
for project in itervalues(self.projects)... | [
"def",
"_check_cronjob",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_last_tick",
"=",
"int",
"(",
"self",
".",
"_last_tick",
")",
"if",
"now",
"-",
"self",
".",
"_last_tick",
"<",
"1",
":",
"return",
"False",
"s... | Check projects cronjob tick, return True when a new tick is sended | [
"Check",
"projects",
"cronjob",
"tick",
"return",
"True",
"when",
"a",
"new",
"tick",
"is",
"sended"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L419-L449 | train | Check projects cronjob tick return True when a new tick is sended | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler._check_select | def _check_select(self):
'''Select task to fetch & process'''
while self._send_buffer:
_task = self._send_buffer.pop()
try:
# use force=False here to prevent automatic send_buffer append and get exception
self.send_task(_task, False)
ex... | python | def _check_select(self):
'''Select task to fetch & process'''
while self._send_buffer:
_task = self._send_buffer.pop()
try:
# use force=False here to prevent automatic send_buffer append and get exception
self.send_task(_task, False)
ex... | [
"def",
"_check_select",
"(",
"self",
")",
":",
"while",
"self",
".",
"_send_buffer",
":",
"_task",
"=",
"self",
".",
"_send_buffer",
".",
"pop",
"(",
")",
"try",
":",
"# use force=False here to prevent automatic send_buffer append and get exception",
"self",
".",
"s... | Select task to fetch & process | [
"Select",
"task",
"to",
"fetch",
"&",
"process"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L463-L566 | train | Select task to fetch & process | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler._dump_cnt | def _dump_cnt(self):
'''Dump counters to file'''
self._cnt['1h'].dump(os.path.join(self.data_path, 'scheduler.1h'))
self._cnt['1d'].dump(os.path.join(self.data_path, 'scheduler.1d'))
self._cnt['all'].dump(os.path.join(self.data_path, 'scheduler.all')) | python | def _dump_cnt(self):
'''Dump counters to file'''
self._cnt['1h'].dump(os.path.join(self.data_path, 'scheduler.1h'))
self._cnt['1d'].dump(os.path.join(self.data_path, 'scheduler.1d'))
self._cnt['all'].dump(os.path.join(self.data_path, 'scheduler.all')) | [
"def",
"_dump_cnt",
"(",
"self",
")",
":",
"self",
".",
"_cnt",
"[",
"'1h'",
"]",
".",
"dump",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"data_path",
",",
"'scheduler.1h'",
")",
")",
"self",
".",
"_cnt",
"[",
"'1d'",
"]",
".",
"dump"... | Dump counters to file | [
"Dump",
"counters",
"to",
"file"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L616-L620 | train | Dump counters to file | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler._try_dump_cnt | def _try_dump_cnt(self):
'''Dump counters every 60 seconds'''
now = time.time()
if now - self._last_dump_cnt > 60:
self._last_dump_cnt = now
self._dump_cnt()
self._print_counter_log() | python | def _try_dump_cnt(self):
'''Dump counters every 60 seconds'''
now = time.time()
if now - self._last_dump_cnt > 60:
self._last_dump_cnt = now
self._dump_cnt()
self._print_counter_log() | [
"def",
"_try_dump_cnt",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"if",
"now",
"-",
"self",
".",
"_last_dump_cnt",
">",
"60",
":",
"self",
".",
"_last_dump_cnt",
"=",
"now",
"self",
".",
"_dump_cnt",
"(",
")",
"self",
".",
"... | Dump counters every 60 seconds | [
"Dump",
"counters",
"every",
"60",
"seconds"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L622-L628 | train | Dump counters every 60 seconds | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler._check_delete | def _check_delete(self):
'''Check project delete'''
now = time.time()
for project in list(itervalues(self.projects)):
if project.db_status != 'STOP':
continue
if now - project.updatetime < self.DELETE_TIME:
continue
if 'delete' ... | python | def _check_delete(self):
'''Check project delete'''
now = time.time()
for project in list(itervalues(self.projects)):
if project.db_status != 'STOP':
continue
if now - project.updatetime < self.DELETE_TIME:
continue
if 'delete' ... | [
"def",
"_check_delete",
"(",
"self",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"for",
"project",
"in",
"list",
"(",
"itervalues",
"(",
"self",
".",
"projects",
")",
")",
":",
"if",
"project",
".",
"db_status",
"!=",
"'STOP'",
":",
"continu... | Check project delete | [
"Check",
"project",
"delete"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L630-L648 | train | Check if project delete is still in progress. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.quit | def quit(self):
'''Set quit signal'''
self._quit = True
# stop xmlrpc server
if hasattr(self, 'xmlrpc_server'):
self.xmlrpc_ioloop.add_callback(self.xmlrpc_server.stop)
self.xmlrpc_ioloop.add_callback(self.xmlrpc_ioloop.stop) | python | def quit(self):
'''Set quit signal'''
self._quit = True
# stop xmlrpc server
if hasattr(self, 'xmlrpc_server'):
self.xmlrpc_ioloop.add_callback(self.xmlrpc_server.stop)
self.xmlrpc_ioloop.add_callback(self.xmlrpc_ioloop.stop) | [
"def",
"quit",
"(",
"self",
")",
":",
"self",
".",
"_quit",
"=",
"True",
"# stop xmlrpc server",
"if",
"hasattr",
"(",
"self",
",",
"'xmlrpc_server'",
")",
":",
"self",
".",
"xmlrpc_ioloop",
".",
"add_callback",
"(",
"self",
".",
"xmlrpc_server",
".",
"sto... | Set quit signal | [
"Set",
"quit",
"signal"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L653-L659 | train | Stop xmlrpc server and xmlrpc ioloop | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.run_once | def run_once(self):
'''comsume queues and feed tasks to fetcher, once'''
self._update_projects()
self._check_task_done()
self._check_request()
while self._check_cronjob():
pass
self._check_select()
self._check_delete()
self._try_dump_cnt() | python | def run_once(self):
'''comsume queues and feed tasks to fetcher, once'''
self._update_projects()
self._check_task_done()
self._check_request()
while self._check_cronjob():
pass
self._check_select()
self._check_delete()
self._try_dump_cnt() | [
"def",
"run_once",
"(",
"self",
")",
":",
"self",
".",
"_update_projects",
"(",
")",
"self",
".",
"_check_task_done",
"(",
")",
"self",
".",
"_check_request",
"(",
")",
"while",
"self",
".",
"_check_cronjob",
"(",
")",
":",
"pass",
"self",
".",
"_check_s... | comsume queues and feed tasks to fetcher, once | [
"comsume",
"queues",
"and",
"feed",
"tasks",
"to",
"fetcher",
"once"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L661-L671 | train | run tasks to fetcher once | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.run | def run(self):
'''Start scheduler loop'''
logger.info("scheduler starting...")
while not self._quit:
try:
time.sleep(self.LOOP_INTERVAL)
self.run_once()
self._exceptions = 0
except KeyboardInterrupt:
break
... | python | def run(self):
'''Start scheduler loop'''
logger.info("scheduler starting...")
while not self._quit:
try:
time.sleep(self.LOOP_INTERVAL)
self.run_once()
self._exceptions = 0
except KeyboardInterrupt:
break
... | [
"def",
"run",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"scheduler starting...\"",
")",
"while",
"not",
"self",
".",
"_quit",
":",
"try",
":",
"time",
".",
"sleep",
"(",
"self",
".",
"LOOP_INTERVAL",
")",
"self",
".",
"run_once",
"(",
")",
... | Start scheduler loop | [
"Start",
"scheduler",
"loop"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L673-L692 | train | Start scheduler loop | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.xmlrpc_run | def xmlrpc_run(self, port=23333, bind='127.0.0.1', logRequests=False):
'''Start xmlrpc interface'''
from pyspider.libs.wsgi_xmlrpc import WSGIXMLRPCApplication
application = WSGIXMLRPCApplication()
application.register_function(self.quit, '_quit')
application.register_function(... | python | def xmlrpc_run(self, port=23333, bind='127.0.0.1', logRequests=False):
'''Start xmlrpc interface'''
from pyspider.libs.wsgi_xmlrpc import WSGIXMLRPCApplication
application = WSGIXMLRPCApplication()
application.register_function(self.quit, '_quit')
application.register_function(... | [
"def",
"xmlrpc_run",
"(",
"self",
",",
"port",
"=",
"23333",
",",
"bind",
"=",
"'127.0.0.1'",
",",
"logRequests",
"=",
"False",
")",
":",
"from",
"pyspider",
".",
"libs",
".",
"wsgi_xmlrpc",
"import",
"WSGIXMLRPCApplication",
"application",
"=",
"WSGIXMLRPCApp... | Start xmlrpc interface | [
"Start",
"xmlrpc",
"interface"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L705-L811 | train | Start xmlrpc interface. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_new_request | def on_new_request(self, task):
'''Called when a new request is arrived'''
task['status'] = self.taskdb.ACTIVE
self.insert_task(task)
self.put_task(task)
project = task['project']
self._cnt['5m'].event((project, 'pending'), +1)
self._cnt['1h'].event((project, 'pe... | python | def on_new_request(self, task):
'''Called when a new request is arrived'''
task['status'] = self.taskdb.ACTIVE
self.insert_task(task)
self.put_task(task)
project = task['project']
self._cnt['5m'].event((project, 'pending'), +1)
self._cnt['1h'].event((project, 'pe... | [
"def",
"on_new_request",
"(",
"self",
",",
"task",
")",
":",
"task",
"[",
"'status'",
"]",
"=",
"self",
".",
"taskdb",
".",
"ACTIVE",
"self",
".",
"insert_task",
"(",
"task",
")",
"self",
".",
"put_task",
"(",
"task",
")",
"project",
"=",
"task",
"["... | Called when a new request is arrived | [
"Called",
"when",
"a",
"new",
"request",
"is",
"arrived"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L825-L837 | train | Called when a new request arrived | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_old_request | def on_old_request(self, task, old_task):
'''Called when a crawled task is arrived'''
now = time.time()
_schedule = task.get('schedule', self.default_schedule)
old_schedule = old_task.get('schedule', {})
if _schedule.get('force_update') and self.projects[task['project']].task_q... | python | def on_old_request(self, task, old_task):
'''Called when a crawled task is arrived'''
now = time.time()
_schedule = task.get('schedule', self.default_schedule)
old_schedule = old_task.get('schedule', {})
if _schedule.get('force_update') and self.projects[task['project']].task_q... | [
"def",
"on_old_request",
"(",
"self",
",",
"task",
",",
"old_task",
")",
":",
"now",
"=",
"time",
".",
"time",
"(",
")",
"_schedule",
"=",
"task",
".",
"get",
"(",
"'schedule'",
",",
"self",
".",
"default_schedule",
")",
"old_schedule",
"=",
"old_task",
... | Called when a crawled task is arrived | [
"Called",
"when",
"a",
"crawled",
"task",
"is",
"arrived"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L839-L887 | train | Called when a task is arrived | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_task_status | def on_task_status(self, task):
'''Called when a status pack is arrived'''
try:
procesok = task['track']['process']['ok']
if not self.projects[task['project']].task_queue.done(task['taskid']):
logging.error('not processing pack: %(project)s:%(taskid)s %(url)s', ta... | python | def on_task_status(self, task):
'''Called when a status pack is arrived'''
try:
procesok = task['track']['process']['ok']
if not self.projects[task['project']].task_queue.done(task['taskid']):
logging.error('not processing pack: %(project)s:%(taskid)s %(url)s', ta... | [
"def",
"on_task_status",
"(",
"self",
",",
"task",
")",
":",
"try",
":",
"procesok",
"=",
"task",
"[",
"'track'",
"]",
"[",
"'process'",
"]",
"[",
"'ok'",
"]",
"if",
"not",
"self",
".",
"projects",
"[",
"task",
"[",
"'project'",
"]",
"]",
".",
"tas... | Called when a status pack is arrived | [
"Called",
"when",
"a",
"status",
"pack",
"is",
"arrived"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L889-L912 | train | Called when a status pack is arrived | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_task_done | def on_task_done(self, task):
'''Called when a task is done and success, called by `on_task_status`'''
task['status'] = self.taskdb.SUCCESS
task['lastcrawltime'] = time.time()
if 'schedule' in task:
if task['schedule'].get('auto_recrawl') and 'age' in task['schedule']:
... | python | def on_task_done(self, task):
'''Called when a task is done and success, called by `on_task_status`'''
task['status'] = self.taskdb.SUCCESS
task['lastcrawltime'] = time.time()
if 'schedule' in task:
if task['schedule'].get('auto_recrawl') and 'age' in task['schedule']:
... | [
"def",
"on_task_done",
"(",
"self",
",",
"task",
")",
":",
"task",
"[",
"'status'",
"]",
"=",
"self",
".",
"taskdb",
".",
"SUCCESS",
"task",
"[",
"'lastcrawltime'",
"]",
"=",
"time",
".",
"time",
"(",
")",
"if",
"'schedule'",
"in",
"task",
":",
"if",... | Called when a task is done and success, called by `on_task_status` | [
"Called",
"when",
"a",
"task",
"is",
"done",
"and",
"success",
"called",
"by",
"on_task_status"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L914-L935 | train | Called when a task is done and success | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_task_failed | def on_task_failed(self, task):
'''Called when a task is failed, called by `on_task_status`'''
if 'schedule' not in task:
old_task = self.taskdb.get_task(task['project'], task['taskid'], fields=['schedule'])
if old_task is None:
logging.error('unknown status pack... | python | def on_task_failed(self, task):
'''Called when a task is failed, called by `on_task_status`'''
if 'schedule' not in task:
old_task = self.taskdb.get_task(task['project'], task['taskid'], fields=['schedule'])
if old_task is None:
logging.error('unknown status pack... | [
"def",
"on_task_failed",
"(",
"self",
",",
"task",
")",
":",
"if",
"'schedule'",
"not",
"in",
"task",
":",
"old_task",
"=",
"self",
".",
"taskdb",
".",
"get_task",
"(",
"task",
"[",
"'project'",
"]",
",",
"task",
"[",
"'taskid'",
"]",
",",
"fields",
... | Called when a task is failed, called by `on_task_status` | [
"Called",
"when",
"a",
"task",
"is",
"failed",
"called",
"by",
"on_task_status"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L937-L988 | train | Called when a task is failed | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | Scheduler.on_select_task | def on_select_task(self, task):
'''Called when a task is selected to fetch & process'''
# inject informations about project
logger.info('select %(project)s:%(taskid)s %(url)s', task)
project_info = self.projects.get(task['project'])
assert project_info, 'no such project'
... | python | def on_select_task(self, task):
'''Called when a task is selected to fetch & process'''
# inject informations about project
logger.info('select %(project)s:%(taskid)s %(url)s', task)
project_info = self.projects.get(task['project'])
assert project_info, 'no such project'
... | [
"def",
"on_select_task",
"(",
"self",
",",
"task",
")",
":",
"# inject informations about project",
"logger",
".",
"info",
"(",
"'select %(project)s:%(taskid)s %(url)s'",
",",
"task",
")",
"project_info",
"=",
"self",
".",
"projects",
".",
"get",
"(",
"task",
"[",... | Called when a task is selected to fetch & process | [
"Called",
"when",
"a",
"task",
"is",
"selected",
"to",
"fetch",
"&",
"process"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L990-L1008 | train | Called when a task is selected to fetch & process | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | OneScheduler._check_select | def _check_select(self):
"""
interactive mode of select tasks
"""
if not self.interactive:
return super(OneScheduler, self)._check_select()
# waiting for running tasks
if self.running_task > 0:
return
is_crawled = []
def run(proj... | python | def _check_select(self):
"""
interactive mode of select tasks
"""
if not self.interactive:
return super(OneScheduler, self)._check_select()
# waiting for running tasks
if self.running_task > 0:
return
is_crawled = []
def run(proj... | [
"def",
"_check_select",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"interactive",
":",
"return",
"super",
"(",
"OneScheduler",
",",
"self",
")",
".",
"_check_select",
"(",
")",
"# waiting for running tasks",
"if",
"self",
".",
"running_task",
">",
"0",... | interactive mode of select tasks | [
"interactive",
"mode",
"of",
"select",
"tasks"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L1022-L1104 | train | check if select tasks are in interactive mode | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/scheduler/scheduler.py | OneScheduler.on_task_status | def on_task_status(self, task):
"""Ignore not processing error in interactive mode"""
if not self.interactive:
super(OneScheduler, self).on_task_status(task)
try:
procesok = task['track']['process']['ok']
except KeyError as e:
logger.error("Bad status... | python | def on_task_status(self, task):
"""Ignore not processing error in interactive mode"""
if not self.interactive:
super(OneScheduler, self).on_task_status(task)
try:
procesok = task['track']['process']['ok']
except KeyError as e:
logger.error("Bad status... | [
"def",
"on_task_status",
"(",
"self",
",",
"task",
")",
":",
"if",
"not",
"self",
".",
"interactive",
":",
"super",
"(",
"OneScheduler",
",",
"self",
")",
".",
"on_task_status",
"(",
"task",
")",
"try",
":",
"procesok",
"=",
"task",
"[",
"'track'",
"]"... | Ignore not processing error in interactive mode | [
"Ignore",
"not",
"processing",
"error",
"in",
"interactive",
"mode"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/scheduler/scheduler.py#L1112-L1134 | train | Called when a task is completed or failed. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager.build_module | def build_module(project, env=None):
'''Build project script as module'''
from pyspider.libs import base_handler
assert 'name' in project, 'need name of project'
assert 'script' in project, 'need script of project'
if env is None:
env = {}
# fix for old non-p... | python | def build_module(project, env=None):
'''Build project script as module'''
from pyspider.libs import base_handler
assert 'name' in project, 'need name of project'
assert 'script' in project, 'need script of project'
if env is None:
env = {}
# fix for old non-p... | [
"def",
"build_module",
"(",
"project",
",",
"env",
"=",
"None",
")",
":",
"from",
"pyspider",
".",
"libs",
"import",
"base_handler",
"assert",
"'name'",
"in",
"project",
",",
"'need name of project'",
"assert",
"'script'",
"in",
"project",
",",
"'need script of ... | Build project script as module | [
"Build",
"project",
"script",
"as",
"module"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L32-L87 | train | Build project script as module | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager._need_update | def _need_update(self, project_name, updatetime=None, md5sum=None):
'''Check if project_name need update'''
if project_name not in self.projects:
return True
elif md5sum and md5sum != self.projects[project_name]['info'].get('md5sum'):
return True
elif updatetime a... | python | def _need_update(self, project_name, updatetime=None, md5sum=None):
'''Check if project_name need update'''
if project_name not in self.projects:
return True
elif md5sum and md5sum != self.projects[project_name]['info'].get('md5sum'):
return True
elif updatetime a... | [
"def",
"_need_update",
"(",
"self",
",",
"project_name",
",",
"updatetime",
"=",
"None",
",",
"md5sum",
"=",
"None",
")",
":",
"if",
"project_name",
"not",
"in",
"self",
".",
"projects",
":",
"return",
"True",
"elif",
"md5sum",
"and",
"md5sum",
"!=",
"se... | Check if project_name need update | [
"Check",
"if",
"project_name",
"need",
"update"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L96-L106 | train | Check if project_name need update | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager._check_projects | def _check_projects(self):
'''Check projects by last update time'''
for project in self.projectdb.check_update(self.last_check_projects,
['name', 'updatetime']):
if project['name'] not in self.projects:
continue
i... | python | def _check_projects(self):
'''Check projects by last update time'''
for project in self.projectdb.check_update(self.last_check_projects,
['name', 'updatetime']):
if project['name'] not in self.projects:
continue
i... | [
"def",
"_check_projects",
"(",
"self",
")",
":",
"for",
"project",
"in",
"self",
".",
"projectdb",
".",
"check_update",
"(",
"self",
".",
"last_check_projects",
",",
"[",
"'name'",
",",
"'updatetime'",
"]",
")",
":",
"if",
"project",
"[",
"'name'",
"]",
... | Check projects by last update time | [
"Check",
"projects",
"by",
"last",
"update",
"time"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L108-L116 | train | Check projects by last update time | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager._update_project | def _update_project(self, project_name):
'''Update one project from database'''
project = self.projectdb.get(project_name)
if not project:
return None
return self._load_project(project) | python | def _update_project(self, project_name):
'''Update one project from database'''
project = self.projectdb.get(project_name)
if not project:
return None
return self._load_project(project) | [
"def",
"_update_project",
"(",
"self",
",",
"project_name",
")",
":",
"project",
"=",
"self",
".",
"projectdb",
".",
"get",
"(",
"project_name",
")",
"if",
"not",
"project",
":",
"return",
"None",
"return",
"self",
".",
"_load_project",
"(",
"project",
")"... | Update one project from database | [
"Update",
"one",
"project",
"from",
"database"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L118-L123 | train | Update one project from database | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager._load_project | def _load_project(self, project):
'''Load project into self.projects from project info dict'''
try:
project['md5sum'] = utils.md5string(project['script'])
ret = self.build_module(project, self.env)
self.projects[project['name']] = ret
except Exception as e:
... | python | def _load_project(self, project):
'''Load project into self.projects from project info dict'''
try:
project['md5sum'] = utils.md5string(project['script'])
ret = self.build_module(project, self.env)
self.projects[project['name']] = ret
except Exception as e:
... | [
"def",
"_load_project",
"(",
"self",
",",
"project",
")",
":",
"try",
":",
"project",
"[",
"'md5sum'",
"]",
"=",
"utils",
".",
"md5string",
"(",
"project",
"[",
"'script'",
"]",
")",
"ret",
"=",
"self",
".",
"build_module",
"(",
"project",
",",
"self",... | Load project into self.projects from project info dict | [
"Load",
"project",
"into",
"self",
".",
"projects",
"from",
"project",
"info",
"dict"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L125-L146 | train | Load project into self. projects from project info dict | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
binux/pyspider | pyspider/processor/project_module.py | ProjectManager.get | def get(self, project_name, updatetime=None, md5sum=None):
'''get project data object, return None if not exists'''
if time.time() - self.last_check_projects > self.CHECK_PROJECTS_INTERVAL:
self._check_projects()
if self._need_update(project_name, updatetime, md5sum):
sel... | python | def get(self, project_name, updatetime=None, md5sum=None):
'''get project data object, return None if not exists'''
if time.time() - self.last_check_projects > self.CHECK_PROJECTS_INTERVAL:
self._check_projects()
if self._need_update(project_name, updatetime, md5sum):
sel... | [
"def",
"get",
"(",
"self",
",",
"project_name",
",",
"updatetime",
"=",
"None",
",",
"md5sum",
"=",
"None",
")",
":",
"if",
"time",
".",
"time",
"(",
")",
"-",
"self",
".",
"last_check_projects",
">",
"self",
".",
"CHECK_PROJECTS_INTERVAL",
":",
"self",
... | get project data object, return None if not exists | [
"get",
"project",
"data",
"object",
"return",
"None",
"if",
"not",
"exists"
] | 3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9 | https://github.com/binux/pyspider/blob/3fccfabe2b057b7a56d4a4c79dc0dd6cd2239fe9/pyspider/processor/project_module.py#L148-L154 | train | get project data object return None if not exists | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.