repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
Miserlou/Zappa
zappa/letsencrypt.py
sign_certificate
def sign_certificate(): """ Get the new certificate. Returns the signed bytes. """ LOGGER.info("Signing certificate...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-outform', 'DER' ] devnull = open(os.devnull, 'wb') csr_der = ...
python
def sign_certificate(): """ Get the new certificate. Returns the signed bytes. """ LOGGER.info("Signing certificate...") cmd = [ 'openssl', 'req', '-in', os.path.join(gettempdir(), 'domain.csr'), '-outform', 'DER' ] devnull = open(os.devnull, 'wb') csr_der = ...
[ "def", "sign_certificate", "(", ")", ":", "LOGGER", ".", "info", "(", "\"Signing certificate...\"", ")", "cmd", "=", "[", "'openssl'", ",", "'req'", ",", "'-in'", ",", "os", ".", "path", ".", "join", "(", "gettempdir", "(", ")", ",", "'domain.csr'", ")",...
Get the new certificate. Returns the signed bytes.
[ "Get", "the", "new", "certificate", ".", "Returns", "the", "signed", "bytes", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L317-L339
train
Miserlou/Zappa
zappa/letsencrypt.py
encode_certificate
def encode_certificate(result): """ Encode cert bytes to PEM encoded cert file. """ cert_body = """-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n""".format( "\n".join(textwrap.wrap(base64.b64encode(result).decode('utf8'), 64))) signed_crt = open("{}/signed.crt".format(gettempd...
python
def encode_certificate(result): """ Encode cert bytes to PEM encoded cert file. """ cert_body = """-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n""".format( "\n".join(textwrap.wrap(base64.b64encode(result).decode('utf8'), 64))) signed_crt = open("{}/signed.crt".format(gettempd...
[ "def", "encode_certificate", "(", "result", ")", ":", "cert_body", "=", "\"\"\"-----BEGIN CERTIFICATE-----\\n{0}\\n-----END CERTIFICATE-----\\n\"\"\"", ".", "format", "(", "\"\\n\"", ".", "join", "(", "textwrap", ".", "wrap", "(", "base64", ".", "b64encode", "(", "res...
Encode cert bytes to PEM encoded cert file.
[ "Encode", "cert", "bytes", "to", "PEM", "encoded", "cert", "file", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L342-L352
train
Miserlou/Zappa
zappa/letsencrypt.py
_send_signed_request
def _send_signed_request(url, payload): """ Helper function to make signed requests to Boulder """ payload64 = _b64(json.dumps(payload).encode('utf8')) out = parse_account_key() header = get_boulder_header(out) protected = copy.deepcopy(header) protected["nonce"] = urlopen(DEFAULT_CA +...
python
def _send_signed_request(url, payload): """ Helper function to make signed requests to Boulder """ payload64 = _b64(json.dumps(payload).encode('utf8')) out = parse_account_key() header = get_boulder_header(out) protected = copy.deepcopy(header) protected["nonce"] = urlopen(DEFAULT_CA +...
[ "def", "_send_signed_request", "(", "url", ",", "payload", ")", ":", "payload64", "=", "_b64", "(", "json", ".", "dumps", "(", "payload", ")", ".", "encode", "(", "'utf8'", ")", ")", "out", "=", "parse_account_key", "(", ")", "header", "=", "get_boulder_...
Helper function to make signed requests to Boulder
[ "Helper", "function", "to", "make", "signed", "requests", "to", "Boulder" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/letsencrypt.py#L366-L398
train
Miserlou/Zappa
zappa/cli.py
shamelessly_promote
def shamelessly_promote(): """ Shamelessly promote our little community. """ click.echo("Need " + click.style("help", fg='green', bold=True) + "? Found a " + click.style("bug", fg='green', bold=True) + "? Let us " + click.style("know", fg='green', bold=True) + "! :D") ...
python
def shamelessly_promote(): """ Shamelessly promote our little community. """ click.echo("Need " + click.style("help", fg='green', bold=True) + "? Found a " + click.style("bug", fg='green', bold=True) + "? Let us " + click.style("know", fg='green', bold=True) + "! :D") ...
[ "def", "shamelessly_promote", "(", ")", ":", "click", ".", "echo", "(", "\"Need \"", "+", "click", ".", "style", "(", "\"help\"", ",", "fg", "=", "'green'", ",", "bold", "=", "True", ")", "+", "\"? Found a \"", "+", "click", ".", "style", "(", "\"bug\"...
Shamelessly promote our little community.
[ "Shamelessly", "promote", "our", "little", "community", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2744-L2757
train
Miserlou/Zappa
zappa/cli.py
handle
def handle(): # pragma: no cover """ Main program execution handler. """ try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: # pragma: no cover cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: # pragma: no cover cli.on_exit() ...
python
def handle(): # pragma: no cover """ Main program execution handler. """ try: cli = ZappaCLI() sys.exit(cli.handle()) except SystemExit as e: # pragma: no cover cli.on_exit() sys.exit(e.code) except KeyboardInterrupt: # pragma: no cover cli.on_exit() ...
[ "def", "handle", "(", ")", ":", "# pragma: no cover", "try", ":", "cli", "=", "ZappaCLI", "(", ")", "sys", ".", "exit", "(", "cli", ".", "handle", "(", ")", ")", "except", "SystemExit", "as", "e", ":", "# pragma: no cover", "cli", ".", "on_exit", "(", ...
Main program execution handler.
[ "Main", "program", "execution", "handler", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L2772-L2797
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.stage_config
def stage_config(self): """ A shortcut property for settings of a stage. """ def get_stage_setting(stage, extended_stages=None): if extended_stages is None: extended_stages = [] if stage in extended_stages: raise RuntimeError(stag...
python
def stage_config(self): """ A shortcut property for settings of a stage. """ def get_stage_setting(stage, extended_stages=None): if extended_stages is None: extended_stages = [] if stage in extended_stages: raise RuntimeError(stag...
[ "def", "stage_config", "(", "self", ")", ":", "def", "get_stage_setting", "(", "stage", ",", "extended_stages", "=", "None", ")", ":", "if", "extended_stages", "is", "None", ":", "extended_stages", "=", "[", "]", "if", "stage", "in", "extended_stages", ":", ...
A shortcut property for settings of a stage.
[ "A", "shortcut", "property", "for", "settings", "of", "a", "stage", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L127-L161
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.override_stage_config_setting
def override_stage_config_setting(self, key, val): """ Forcefully override a setting set by zappa_settings (for the current stage only) :param key: settings key :param val: value """ self._stage_config_overrides = getattr(self, '_stage_config_overrides', {}) self....
python
def override_stage_config_setting(self, key, val): """ Forcefully override a setting set by zappa_settings (for the current stage only) :param key: settings key :param val: value """ self._stage_config_overrides = getattr(self, '_stage_config_overrides', {}) self....
[ "def", "override_stage_config_setting", "(", "self", ",", "key", ",", "val", ")", ":", "self", ".", "_stage_config_overrides", "=", "getattr", "(", "self", ",", "'_stage_config_overrides'", ",", "{", "}", ")", "self", ".", "_stage_config_overrides", ".", "setdef...
Forcefully override a setting set by zappa_settings (for the current stage only) :param key: settings key :param val: value
[ "Forcefully", "override", "a", "setting", "set", "by", "zappa_settings", "(", "for", "the", "current", "stage", "only", ")", ":", "param", "key", ":", "settings", "key", ":", "param", "val", ":", "value" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L171-L178
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.handle
def handle(self, argv=None): """ Main function. Parses command, load settings and dispatches accordingly. """ desc = ('Zappa - Deploy Python applications to AWS Lambda' ' and API Gateway.\n') parser = argparse.ArgumentParser(description=desc) pa...
python
def handle(self, argv=None): """ Main function. Parses command, load settings and dispatches accordingly. """ desc = ('Zappa - Deploy Python applications to AWS Lambda' ' and API Gateway.\n') parser = argparse.ArgumentParser(description=desc) pa...
[ "def", "handle", "(", "self", ",", "argv", "=", "None", ")", ":", "desc", "=", "(", "'Zappa - Deploy Python applications to AWS Lambda'", "' and API Gateway.\\n'", ")", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "desc", ")", "parser...
Main function. Parses command, load settings and dispatches accordingly.
[ "Main", "function", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L180-L513
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.dispatch_command
def dispatch_command(self, command, stage): """ Given a command to execute and stage, execute that command. """ self.api_stage = stage if command not in ['status', 'manage']: if not self.vargs.get('json', None): click.echo("Calling " + click....
python
def dispatch_command(self, command, stage): """ Given a command to execute and stage, execute that command. """ self.api_stage = stage if command not in ['status', 'manage']: if not self.vargs.get('json', None): click.echo("Calling " + click....
[ "def", "dispatch_command", "(", "self", ",", "command", ",", "stage", ")", ":", "self", ".", "api_stage", "=", "stage", "if", "command", "not", "in", "[", "'status'", ",", "'manage'", "]", ":", "if", "not", "self", ".", "vargs", ".", "get", "(", "'js...
Given a command to execute and stage, execute that command.
[ "Given", "a", "command", "to", "execute", "and", "stage", "execute", "that", "command", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L515-L620
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.package
def package(self, output=None): """ Only build the package """ # Make sure we're in a venv. self.check_venv() # force not to delete the local zip self.override_stage_config_setting('delete_local_zip', False) # Execute the prebuild script if self.p...
python
def package(self, output=None): """ Only build the package """ # Make sure we're in a venv. self.check_venv() # force not to delete the local zip self.override_stage_config_setting('delete_local_zip', False) # Execute the prebuild script if self.p...
[ "def", "package", "(", "self", ",", "output", "=", "None", ")", ":", "# Make sure we're in a venv.", "self", ".", "check_venv", "(", ")", "# force not to delete the local zip", "self", ".", "override_stage_config_setting", "(", "'delete_local_zip'", ",", "False", ")",...
Only build the package
[ "Only", "build", "the", "package" ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L626-L642
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.template
def template(self, lambda_arn, role_arn, output=None, json=False): """ Only build the template file. """ if not lambda_arn: raise ClickException("Lambda ARN is required to template.") if not role_arn: raise ClickException("Role ARN is required to templat...
python
def template(self, lambda_arn, role_arn, output=None, json=False): """ Only build the template file. """ if not lambda_arn: raise ClickException("Lambda ARN is required to template.") if not role_arn: raise ClickException("Role ARN is required to templat...
[ "def", "template", "(", "self", ",", "lambda_arn", ",", "role_arn", ",", "output", "=", "None", ",", "json", "=", "False", ")", ":", "if", "not", "lambda_arn", ":", "raise", "ClickException", "(", "\"Lambda ARN is required to template.\"", ")", "if", "not", ...
Only build the template file.
[ "Only", "build", "the", "template", "file", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L644-L681
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.deploy
def deploy(self, source_zip=None): """ Package your project, upload it to S3, register the Lambda function and create the API Gateway routes. """ if not source_zip: # Make sure we're in a venv. self.check_venv() # Execute the prebuild script...
python
def deploy(self, source_zip=None): """ Package your project, upload it to S3, register the Lambda function and create the API Gateway routes. """ if not source_zip: # Make sure we're in a venv. self.check_venv() # Execute the prebuild script...
[ "def", "deploy", "(", "self", ",", "source_zip", "=", "None", ")", ":", "if", "not", "source_zip", ":", "# Make sure we're in a venv.", "self", ".", "check_venv", "(", ")", "# Execute the prebuild script", "if", "self", ".", "prebuild_script", ":", "self", ".", ...
Package your project, upload it to S3, register the Lambda function and create the API Gateway routes.
[ "Package", "your", "project", "upload", "it", "to", "S3", "register", "the", "Lambda", "function", "and", "create", "the", "API", "Gateway", "routes", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L683-L854
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.update
def update(self, source_zip=None, no_upload=False): """ Repackage and update the function code. """ if not source_zip: # Make sure we're in a venv. self.check_venv() # Execute the prebuild script if self.prebuild_script: s...
python
def update(self, source_zip=None, no_upload=False): """ Repackage and update the function code. """ if not source_zip: # Make sure we're in a venv. self.check_venv() # Execute the prebuild script if self.prebuild_script: s...
[ "def", "update", "(", "self", ",", "source_zip", "=", "None", ",", "no_upload", "=", "False", ")", ":", "if", "not", "source_zip", ":", "# Make sure we're in a venv.", "self", ".", "check_venv", "(", ")", "# Execute the prebuild script", "if", "self", ".", "pr...
Repackage and update the function code.
[ "Repackage", "and", "update", "the", "function", "code", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L856-L1055
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.rollback
def rollback(self, revision): """ Rollsback the currently deploy lambda code to a previous revision. """ print("Rolling back..") self.zappa.rollback_lambda_function_version( self.lambda_name, versions_back=revision) print("Done!")
python
def rollback(self, revision): """ Rollsback the currently deploy lambda code to a previous revision. """ print("Rolling back..") self.zappa.rollback_lambda_function_version( self.lambda_name, versions_back=revision) print("Done!")
[ "def", "rollback", "(", "self", ",", "revision", ")", ":", "print", "(", "\"Rolling back..\"", ")", "self", ".", "zappa", ".", "rollback_lambda_function_version", "(", "self", ".", "lambda_name", ",", "versions_back", "=", "revision", ")", "print", "(", "\"Don...
Rollsback the currently deploy lambda code to a previous revision.
[ "Rollsback", "the", "currently", "deploy", "lambda", "code", "to", "a", "previous", "revision", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1057-L1066
train
Miserlou/Zappa
zappa/cli.py
ZappaCLI.tail
def tail(self, since, filter_pattern, limit=10000, keep_open=True, colorize=True, http=False, non_http=False, force_colorize=False): """ Tail this function's logs. if keep_open, do so repeatedly, printing any new logs """ try: since_stamp = string_to_timestamp(since...
python
def tail(self, since, filter_pattern, limit=10000, keep_open=True, colorize=True, http=False, non_http=False, force_colorize=False): """ Tail this function's logs. if keep_open, do so repeatedly, printing any new logs """ try: since_stamp = string_to_timestamp(since...
[ "def", "tail", "(", "self", ",", "since", ",", "filter_pattern", ",", "limit", "=", "10000", ",", "keep_open", "=", "True", ",", "colorize", "=", "True", ",", "http", "=", "False", ",", "non_http", "=", "False", ",", "force_colorize", "=", "False", ")"...
Tail this function's logs. if keep_open, do so repeatedly, printing any new logs
[ "Tail", "this", "function", "s", "logs", "." ]
3ccf7490a8d8b8fa74a61ee39bf44234f3567739
https://github.com/Miserlou/Zappa/blob/3ccf7490a8d8b8fa74a61ee39bf44234f3567739/zappa/cli.py#L1068-L1100
train
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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