repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
Bogdanp/dramatiq
dramatiq/watcher.py
setup_file_watcher
def setup_file_watcher(path, use_polling=False): """Sets up a background thread that watches for source changes and automatically sends SIGHUP to the current process whenever a file changes. """ if use_polling: observer_class = watchdog.observers.polling.PollingObserver else: obs...
python
def setup_file_watcher(path, use_polling=False): """Sets up a background thread that watches for source changes and automatically sends SIGHUP to the current process whenever a file changes. """ if use_polling: observer_class = watchdog.observers.polling.PollingObserver else: obs...
[ "def", "setup_file_watcher", "(", "path", ",", "use_polling", "=", "False", ")", ":", "if", "use_polling", ":", "observer_class", "=", "watchdog", ".", "observers", ".", "polling", ".", "PollingObserver", "else", ":", "observer_class", "=", "EVENTED_OBSERVER", "...
Sets up a background thread that watches for source changes and automatically sends SIGHUP to the current process whenever a file changes.
[ "Sets", "up", "a", "background", "thread", "that", "watches", "for", "source", "changes", "and", "automatically", "sends", "SIGHUP", "to", "the", "current", "process", "whenever", "a", "file", "changes", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/watcher.py#L16-L30
train
Bogdanp/dramatiq
dramatiq/brokers/stub.py
StubBroker.declare_queue
def declare_queue(self, queue_name): """Declare a queue. Has no effect if a queue with the given name has already been declared. Parameters: queue_name(str): The name of the new queue. """ if queue_name not in self.queues: self.emit_before("declare_queue",...
python
def declare_queue(self, queue_name): """Declare a queue. Has no effect if a queue with the given name has already been declared. Parameters: queue_name(str): The name of the new queue. """ if queue_name not in self.queues: self.emit_before("declare_queue",...
[ "def", "declare_queue", "(", "self", ",", "queue_name", ")", ":", "if", "queue_name", "not", "in", "self", ".", "queues", ":", "self", ".", "emit_before", "(", "\"declare_queue\"", ",", "queue_name", ")", "self", ".", "queues", "[", "queue_name", "]", "=",...
Declare a queue. Has no effect if a queue with the given name has already been declared. Parameters: queue_name(str): The name of the new queue.
[ "Declare", "a", "queue", ".", "Has", "no", "effect", "if", "a", "queue", "with", "the", "given", "name", "has", "already", "been", "declared", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/brokers/stub.py#L66-L81
train
Bogdanp/dramatiq
dramatiq/brokers/stub.py
StubBroker.flush_all
def flush_all(self): """Drop all messages from all declared queues. """ for queue_name in chain(self.queues, self.delay_queues): self.flush(queue_name)
python
def flush_all(self): """Drop all messages from all declared queues. """ for queue_name in chain(self.queues, self.delay_queues): self.flush(queue_name)
[ "def", "flush_all", "(", "self", ")", ":", "for", "queue_name", "in", "chain", "(", "self", ".", "queues", ",", "self", ".", "delay_queues", ")", ":", "self", ".", "flush", "(", "queue_name", ")" ]
Drop all messages from all declared queues.
[ "Drop", "all", "messages", "from", "all", "declared", "queues", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/brokers/stub.py#L123-L127
train
Bogdanp/dramatiq
dramatiq/composition.py
pipeline.run
def run(self, *, delay=None): """Run this pipeline. Parameters: delay(int): The minimum amount of time, in milliseconds, the pipeline should be delayed by. Returns: pipeline: Itself. """ self.broker.enqueue(self.messages[0], delay=delay) ...
python
def run(self, *, delay=None): """Run this pipeline. Parameters: delay(int): The minimum amount of time, in milliseconds, the pipeline should be delayed by. Returns: pipeline: Itself. """ self.broker.enqueue(self.messages[0], delay=delay) ...
[ "def", "run", "(", "self", ",", "*", ",", "delay", "=", "None", ")", ":", "self", ".", "broker", ".", "enqueue", "(", "self", ".", "messages", "[", "0", "]", ",", "delay", "=", "delay", ")", "return", "self" ]
Run this pipeline. Parameters: delay(int): The minimum amount of time, in milliseconds, the pipeline should be delayed by. Returns: pipeline: Itself.
[ "Run", "this", "pipeline", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L101-L112
train
Bogdanp/dramatiq
dramatiq/composition.py
pipeline.get_result
def get_result(self, *, block=False, timeout=None): """Get the result of this pipeline. Pipeline results are represented by the result of the last message in the chain. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum...
python
def get_result(self, *, block=False, timeout=None): """Get the result of this pipeline. Pipeline results are represented by the result of the last message in the chain. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum...
[ "def", "get_result", "(", "self", ",", "*", ",", "block", "=", "False", ",", "timeout", "=", "None", ")", ":", "return", "self", ".", "messages", "[", "-", "1", "]", ".", "get_result", "(", "block", "=", "block", ",", "timeout", "=", "timeout", ")"...
Get the result of this pipeline. Pipeline results are represented by the result of the last message in the chain. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum amount of time, in ms, to wait for a result when b...
[ "Get", "the", "result", "of", "this", "pipeline", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L114-L132
train
Bogdanp/dramatiq
dramatiq/composition.py
pipeline.get_results
def get_results(self, *, block=False, timeout=None): """Get the results of each job in the pipeline. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum amount of time, in ms, to wait for a result when block is True. Default...
python
def get_results(self, *, block=False, timeout=None): """Get the results of each job in the pipeline. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum amount of time, in ms, to wait for a result when block is True. Default...
[ "def", "get_results", "(", "self", ",", "*", ",", "block", "=", "False", ",", "timeout", "=", "None", ")", ":", "deadline", "=", "None", "if", "timeout", ":", "deadline", "=", "time", ".", "monotonic", "(", ")", "+", "timeout", "/", "1000", "for", ...
Get the results of each job in the pipeline. Parameters: block(bool): Whether or not to block until a result is set. timeout(int): The maximum amount of time, in ms, to wait for a result when block is True. Defaults to 10 seconds. Raises: ResultMissing: When ...
[ "Get", "the", "results", "of", "each", "job", "in", "the", "pipeline", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L134-L157
train
Bogdanp/dramatiq
dramatiq/composition.py
group.run
def run(self, *, delay=None): """Run the actors in this group. Parameters: delay(int): The minimum amount of time, in milliseconds, each message in the group should be delayed by. """ for child in self.children: if isinstance(child, (group, pipeline)): ...
python
def run(self, *, delay=None): """Run the actors in this group. Parameters: delay(int): The minimum amount of time, in milliseconds, each message in the group should be delayed by. """ for child in self.children: if isinstance(child, (group, pipeline)): ...
[ "def", "run", "(", "self", ",", "*", ",", "delay", "=", "None", ")", ":", "for", "child", "in", "self", ".", "children", ":", "if", "isinstance", "(", "child", ",", "(", "group", ",", "pipeline", ")", ")", ":", "child", ".", "run", "(", "delay", ...
Run the actors in this group. Parameters: delay(int): The minimum amount of time, in milliseconds, each message in the group should be delayed by.
[ "Run", "the", "actors", "in", "this", "group", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L220-L233
train
Bogdanp/dramatiq
dramatiq/composition.py
group.get_results
def get_results(self, *, block=False, timeout=None): """Get the results of each job in the group. Parameters: block(bool): Whether or not to block until the results are stored. timeout(int): The maximum amount of time, in milliseconds, to wait for results when block is T...
python
def get_results(self, *, block=False, timeout=None): """Get the results of each job in the group. Parameters: block(bool): Whether or not to block until the results are stored. timeout(int): The maximum amount of time, in milliseconds, to wait for results when block is T...
[ "def", "get_results", "(", "self", ",", "*", ",", "block", "=", "False", ",", "timeout", "=", "None", ")", ":", "deadline", "=", "None", "if", "timeout", ":", "deadline", "=", "time", ".", "monotonic", "(", ")", "+", "timeout", "/", "1000", "for", ...
Get the results of each job in the group. Parameters: block(bool): Whether or not to block until the results are stored. timeout(int): The maximum amount of time, in milliseconds, to wait for results when block is True. Defaults to 10 seconds. Raises: ...
[ "Get", "the", "results", "of", "each", "job", "in", "the", "group", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L235-L262
train
Bogdanp/dramatiq
dramatiq/composition.py
group.wait
def wait(self, *, timeout=None): """Block until all the jobs in the group have finished or until the timeout expires. Parameters: timeout(int): The maximum amount of time, in ms, to wait. Defaults to 10 seconds. """ for _ in self.get_results(block=True, tim...
python
def wait(self, *, timeout=None): """Block until all the jobs in the group have finished or until the timeout expires. Parameters: timeout(int): The maximum amount of time, in ms, to wait. Defaults to 10 seconds. """ for _ in self.get_results(block=True, tim...
[ "def", "wait", "(", "self", ",", "*", ",", "timeout", "=", "None", ")", ":", "for", "_", "in", "self", ".", "get_results", "(", "block", "=", "True", ",", "timeout", "=", "timeout", ")", ":", "# pragma: no cover", "pass" ]
Block until all the jobs in the group have finished or until the timeout expires. Parameters: timeout(int): The maximum amount of time, in ms, to wait. Defaults to 10 seconds.
[ "Block", "until", "all", "the", "jobs", "in", "the", "group", "have", "finished", "or", "until", "the", "timeout", "expires", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/composition.py#L264-L273
train
Bogdanp/dramatiq
dramatiq/actor.py
actor
def actor(fn=None, *, actor_class=Actor, actor_name=None, queue_name="default", priority=0, broker=None, **options): """Declare an actor. Examples: >>> import dramatiq >>> @dramatiq.actor ... def add(x, y): ... print(x + y) ... >>> add Actor(<function add at 0x10...
python
def actor(fn=None, *, actor_class=Actor, actor_name=None, queue_name="default", priority=0, broker=None, **options): """Declare an actor. Examples: >>> import dramatiq >>> @dramatiq.actor ... def add(x, y): ... print(x + y) ... >>> add Actor(<function add at 0x10...
[ "def", "actor", "(", "fn", "=", "None", ",", "*", ",", "actor_class", "=", "Actor", ",", "actor_name", "=", "None", ",", "queue_name", "=", "\"default\"", ",", "priority", "=", "0", ",", "broker", "=", "None", ",", "*", "*", "options", ")", ":", "d...
Declare an actor. Examples: >>> import dramatiq >>> @dramatiq.actor ... def add(x, y): ... print(x + y) ... >>> add Actor(<function add at 0x106c6d488>, queue_name='default', actor_name='add') >>> add(1, 2) 3 >>> add.send(1, 2) Message( ...
[ "Declare", "an", "actor", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/actor.py#L157-L225
train
Bogdanp/dramatiq
dramatiq/actor.py
Actor.message
def message(self, *args, **kwargs): """Build a message. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments ...
python
def message(self, *args, **kwargs): """Build a message. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments ...
[ "def", "message", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "message_with_options", "(", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")" ]
Build a message. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments to send to the actor. Examples: ...
[ "Build", "a", "message", ".", "This", "method", "is", "useful", "if", "you", "want", "to", "compose", "actors", ".", "See", "the", "actor", "composition", "documentation", "for", "details", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/actor.py#L54-L70
train
Bogdanp/dramatiq
dramatiq/actor.py
Actor.message_with_options
def message_with_options(self, *, args=None, kwargs=None, **options): """Build a message with an arbitray set of processing options. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: args(tuple): Positional a...
python
def message_with_options(self, *, args=None, kwargs=None, **options): """Build a message with an arbitray set of processing options. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: args(tuple): Positional a...
[ "def", "message_with_options", "(", "self", ",", "*", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "*", "*", "options", ")", ":", "for", "name", "in", "[", "\"on_failure\"", ",", "\"on_success\"", "]", ":", "callback", "=", "options", "."...
Build a message with an arbitray set of processing options. This method is useful if you want to compose actors. See the actor composition documentation for details. Parameters: args(tuple): Positional arguments that are passed to the actor. kwargs(dict): Keyword arguments ...
[ "Build", "a", "message", "with", "an", "arbitray", "set", "of", "processing", "options", ".", "This", "method", "is", "useful", "if", "you", "want", "to", "compose", "actors", ".", "See", "the", "actor", "composition", "documentation", "for", "details", "." ...
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/actor.py#L72-L99
train
Bogdanp/dramatiq
dramatiq/actor.py
Actor.send
def send(self, *args, **kwargs): """Asynchronously send a message to this actor. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments to send to the actor. Returns: Message: The enqueued message. """ ...
python
def send(self, *args, **kwargs): """Asynchronously send a message to this actor. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments to send to the actor. Returns: Message: The enqueued message. """ ...
[ "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "send_with_options", "(", "args", "=", "args", ",", "kwargs", "=", "kwargs", ")" ]
Asynchronously send a message to this actor. Parameters: *args(tuple): Positional arguments to send to the actor. **kwargs(dict): Keyword arguments to send to the actor. Returns: Message: The enqueued message.
[ "Asynchronously", "send", "a", "message", "to", "this", "actor", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/actor.py#L101-L111
train
Bogdanp/dramatiq
dramatiq/actor.py
Actor.send_with_options
def send_with_options(self, *, args=None, kwargs=None, delay=None, **options): """Asynchronously send a message to this actor, along with an arbitrary set of processing options for the broker and middleware. Parameters: args(tuple): Positional arguments that are passed to the ...
python
def send_with_options(self, *, args=None, kwargs=None, delay=None, **options): """Asynchronously send a message to this actor, along with an arbitrary set of processing options for the broker and middleware. Parameters: args(tuple): Positional arguments that are passed to the ...
[ "def", "send_with_options", "(", "self", ",", "*", ",", "args", "=", "None", ",", "kwargs", "=", "None", ",", "delay", "=", "None", ",", "*", "*", "options", ")", ":", "message", "=", "self", ".", "message_with_options", "(", "args", "=", "args", ","...
Asynchronously send a message to this actor, along with an arbitrary set of processing options for the broker and middleware. Parameters: args(tuple): Positional arguments that are passed to the actor. kwargs(dict): Keyword arguments that are passed to the actor. d...
[ "Asynchronously", "send", "a", "message", "to", "this", "actor", "along", "with", "an", "arbitrary", "set", "of", "processing", "options", "for", "the", "broker", "and", "middleware", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/actor.py#L113-L130
train
Bogdanp/dramatiq
dramatiq/worker.py
Worker.start
def start(self): """Initialize the worker boot sequence and start up all the worker threads. """ self.broker.emit_before("worker_boot", self) worker_middleware = _WorkerMiddleware(self) self.broker.add_middleware(worker_middleware) for _ in range(self.worker_thre...
python
def start(self): """Initialize the worker boot sequence and start up all the worker threads. """ self.broker.emit_before("worker_boot", self) worker_middleware = _WorkerMiddleware(self) self.broker.add_middleware(worker_middleware) for _ in range(self.worker_thre...
[ "def", "start", "(", "self", ")", ":", "self", ".", "broker", ".", "emit_before", "(", "\"worker_boot\"", ",", "self", ")", "worker_middleware", "=", "_WorkerMiddleware", "(", "self", ")", "self", ".", "broker", ".", "add_middleware", "(", "worker_middleware",...
Initialize the worker boot sequence and start up all the worker threads.
[ "Initialize", "the", "worker", "boot", "sequence", "and", "start", "up", "all", "the", "worker", "threads", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L80-L91
train
Bogdanp/dramatiq
dramatiq/worker.py
Worker.pause
def pause(self): """Pauses all the worker threads. """ for child in chain(self.consumers.values(), self.workers): child.pause() for child in chain(self.consumers.values(), self.workers): child.paused_event.wait()
python
def pause(self): """Pauses all the worker threads. """ for child in chain(self.consumers.values(), self.workers): child.pause() for child in chain(self.consumers.values(), self.workers): child.paused_event.wait()
[ "def", "pause", "(", "self", ")", ":", "for", "child", "in", "chain", "(", "self", ".", "consumers", ".", "values", "(", ")", ",", "self", ".", "workers", ")", ":", "child", ".", "pause", "(", ")", "for", "child", "in", "chain", "(", "self", ".",...
Pauses all the worker threads.
[ "Pauses", "all", "the", "worker", "threads", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L93-L100
train
Bogdanp/dramatiq
dramatiq/worker.py
Worker.resume
def resume(self): """Resumes all the worker threads. """ for child in chain(self.consumers.values(), self.workers): child.resume()
python
def resume(self): """Resumes all the worker threads. """ for child in chain(self.consumers.values(), self.workers): child.resume()
[ "def", "resume", "(", "self", ")", ":", "for", "child", "in", "chain", "(", "self", ".", "consumers", ".", "values", "(", ")", ",", "self", ".", "workers", ")", ":", "child", ".", "resume", "(", ")" ]
Resumes all the worker threads.
[ "Resumes", "all", "the", "worker", "threads", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L102-L106
train
Bogdanp/dramatiq
dramatiq/worker.py
Worker.stop
def stop(self, timeout=600000): """Gracefully stop the Worker and all of its consumers and workers. Parameters: timeout(int): The number of milliseconds to wait for everything to shut down. """ self.broker.emit_before("worker_shutdown", self) self.l...
python
def stop(self, timeout=600000): """Gracefully stop the Worker and all of its consumers and workers. Parameters: timeout(int): The number of milliseconds to wait for everything to shut down. """ self.broker.emit_before("worker_shutdown", self) self.l...
[ "def", "stop", "(", "self", ",", "timeout", "=", "600000", ")", ":", "self", ".", "broker", ".", "emit_before", "(", "\"worker_shutdown\"", ",", "self", ")", "self", ".", "logger", ".", "info", "(", "\"Shutting down...\"", ")", "# Stop workers before consumers...
Gracefully stop the Worker and all of its consumers and workers. Parameters: timeout(int): The number of milliseconds to wait for everything to shut down.
[ "Gracefully", "stop", "the", "Worker", "and", "all", "of", "its", "consumers", "and", "workers", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L108-L153
train
Bogdanp/dramatiq
dramatiq/worker.py
Worker.join
def join(self): """Wait for this worker to complete its work in progress. This method is useful when testing code. """ while True: for consumer in self.consumers.values(): consumer.delay_queue.join() self.work_queue.join() # If nothin...
python
def join(self): """Wait for this worker to complete its work in progress. This method is useful when testing code. """ while True: for consumer in self.consumers.values(): consumer.delay_queue.join() self.work_queue.join() # If nothin...
[ "def", "join", "(", "self", ")", ":", "while", "True", ":", "for", "consumer", "in", "self", ".", "consumers", ".", "values", "(", ")", ":", "consumer", ".", "delay_queue", ".", "join", "(", ")", "self", ".", "work_queue", ".", "join", "(", ")", "#...
Wait for this worker to complete its work in progress. This method is useful when testing code.
[ "Wait", "for", "this", "worker", "to", "complete", "its", "work", "in", "progress", ".", "This", "method", "is", "useful", "when", "testing", "code", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L155-L174
train
Bogdanp/dramatiq
dramatiq/worker.py
_ConsumerThread.handle_delayed_messages
def handle_delayed_messages(self): """Enqueue any delayed messages whose eta has passed. """ for eta, message in iter_queue(self.delay_queue): if eta > current_millis(): self.delay_queue.put((eta, message)) self.delay_queue.task_done() ...
python
def handle_delayed_messages(self): """Enqueue any delayed messages whose eta has passed. """ for eta, message in iter_queue(self.delay_queue): if eta > current_millis(): self.delay_queue.put((eta, message)) self.delay_queue.task_done() ...
[ "def", "handle_delayed_messages", "(", "self", ")", ":", "for", "eta", ",", "message", "in", "iter_queue", "(", "self", ".", "delay_queue", ")", ":", "if", "eta", ">", "current_millis", "(", ")", ":", "self", ".", "delay_queue", ".", "put", "(", "(", "...
Enqueue any delayed messages whose eta has passed.
[ "Enqueue", "any", "delayed", "messages", "whose", "eta", "has", "passed", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L285-L300
train
Bogdanp/dramatiq
dramatiq/worker.py
_ConsumerThread.handle_message
def handle_message(self, message): """Handle a message received off of the underlying consumer. If the message has an eta, delay it. Otherwise, put it on the work queue. """ try: if "eta" in message.options: self.logger.debug("Pushing message %r onto ...
python
def handle_message(self, message): """Handle a message received off of the underlying consumer. If the message has an eta, delay it. Otherwise, put it on the work queue. """ try: if "eta" in message.options: self.logger.debug("Pushing message %r onto ...
[ "def", "handle_message", "(", "self", ",", "message", ")", ":", "try", ":", "if", "\"eta\"", "in", "message", ".", "options", ":", "self", ".", "logger", ".", "debug", "(", "\"Pushing message %r onto delay queue.\"", ",", "message", ".", "message_id", ")", "...
Handle a message received off of the underlying consumer. If the message has an eta, delay it. Otherwise, put it on the work queue.
[ "Handle", "a", "message", "received", "off", "of", "the", "underlying", "consumer", ".", "If", "the", "message", "has", "an", "eta", "delay", "it", ".", "Otherwise", "put", "it", "on", "the", "work", "queue", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L302-L323
train
Bogdanp/dramatiq
dramatiq/worker.py
_ConsumerThread.post_process_message
def post_process_message(self, message): """Called by worker threads whenever they're done processing individual messages, signaling that each message is ready to be acked or rejected. """ while True: try: if message.failed: self.lo...
python
def post_process_message(self, message): """Called by worker threads whenever they're done processing individual messages, signaling that each message is ready to be acked or rejected. """ while True: try: if message.failed: self.lo...
[ "def", "post_process_message", "(", "self", ",", "message", ")", ":", "while", "True", ":", "try", ":", "if", "message", ".", "failed", ":", "self", ".", "logger", ".", "debug", "(", "\"Rejecting message %r.\"", ",", "message", ".", "message_id", ")", "sel...
Called by worker threads whenever they're done processing individual messages, signaling that each message is ready to be acked or rejected.
[ "Called", "by", "worker", "threads", "whenever", "they", "re", "done", "processing", "individual", "messages", "signaling", "that", "each", "message", "is", "ready", "to", "be", "acked", "or", "rejected", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L325-L373
train
Bogdanp/dramatiq
dramatiq/worker.py
_ConsumerThread.close
def close(self): """Close this consumer thread and its underlying connection. """ try: if self.consumer: self.requeue_messages(m for _, m in iter_queue(self.delay_queue)) self.consumer.close() except ConnectionError: pass
python
def close(self): """Close this consumer thread and its underlying connection. """ try: if self.consumer: self.requeue_messages(m for _, m in iter_queue(self.delay_queue)) self.consumer.close() except ConnectionError: pass
[ "def", "close", "(", "self", ")", ":", "try", ":", "if", "self", ".", "consumer", ":", "self", ".", "requeue_messages", "(", "m", "for", "_", ",", "m", "in", "iter_queue", "(", "self", ".", "delay_queue", ")", ")", "self", ".", "consumer", ".", "cl...
Close this consumer thread and its underlying connection.
[ "Close", "this", "consumer", "thread", "and", "its", "underlying", "connection", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L403-L411
train
Bogdanp/dramatiq
dramatiq/worker.py
_WorkerThread.process_message
def process_message(self, message): """Process a message pulled off of the work queue then push it back to its associated consumer for post processing. Parameters: message(MessageProxy) """ try: self.logger.debug("Received message %s with id %r.", message, ...
python
def process_message(self, message): """Process a message pulled off of the work queue then push it back to its associated consumer for post processing. Parameters: message(MessageProxy) """ try: self.logger.debug("Received message %s with id %r.", message, ...
[ "def", "process_message", "(", "self", ",", "message", ")", ":", "try", ":", "self", ".", "logger", ".", "debug", "(", "\"Received message %s with id %r.\"", ",", "message", ",", "message", ".", "message_id", ")", "self", ".", "broker", ".", "emit_before", "...
Process a message pulled off of the work queue then push it back to its associated consumer for post processing. Parameters: message(MessageProxy)
[ "Process", "a", "message", "pulled", "off", "of", "the", "work", "queue", "then", "push", "it", "back", "to", "its", "associated", "consumer", "for", "post", "processing", "." ]
a8cc2728478e794952a5a50c3fb19ec455fe91b6
https://github.com/Bogdanp/dramatiq/blob/a8cc2728478e794952a5a50c3fb19ec455fe91b6/dramatiq/worker.py#L456-L497
train
github/octodns
octodns/manager.py
Manager.compare
def compare(self, a, b, zone): ''' Compare zone data between 2 sources. Note: only things supported by both sources will be considered ''' self.log.info('compare: a=%s, b=%s, zone=%s', a, b, zone) try: a = [self.providers[source] for source in a] ...
python
def compare(self, a, b, zone): ''' Compare zone data between 2 sources. Note: only things supported by both sources will be considered ''' self.log.info('compare: a=%s, b=%s, zone=%s', a, b, zone) try: a = [self.providers[source] for source in a] ...
[ "def", "compare", "(", "self", ",", "a", ",", "b", ",", "zone", ")", ":", "self", ".", "log", ".", "info", "(", "'compare: a=%s, b=%s, zone=%s'", ",", "a", ",", "b", ",", "zone", ")", "try", ":", "a", "=", "[", "self", ".", "providers", "[", "sou...
Compare zone data between 2 sources. Note: only things supported by both sources will be considered
[ "Compare", "zone", "data", "between", "2", "sources", "." ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/manager.py#L335-L358
train
github/octodns
octodns/manager.py
Manager.dump
def dump(self, zone, output_dir, lenient, split, source, *sources): ''' Dump zone data from the specified source ''' self.log.info('dump: zone=%s, sources=%s', zone, sources) # We broke out source to force at least one to be passed, add it to any # others we got. ...
python
def dump(self, zone, output_dir, lenient, split, source, *sources): ''' Dump zone data from the specified source ''' self.log.info('dump: zone=%s, sources=%s', zone, sources) # We broke out source to force at least one to be passed, add it to any # others we got. ...
[ "def", "dump", "(", "self", ",", "zone", ",", "output_dir", ",", "lenient", ",", "split", ",", "source", ",", "*", "sources", ")", ":", "self", ".", "log", ".", "info", "(", "'dump: zone=%s, sources=%s'", ",", "zone", ",", "sources", ")", "# We broke out...
Dump zone data from the specified source
[ "Dump", "zone", "data", "from", "the", "specified", "source" ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/manager.py#L360-L387
train
github/octodns
octodns/provider/dyn.py
_CachingDynZone.flush_zone
def flush_zone(cls, zone_name): '''Flushes the zone cache, if there is one''' cls.log.debug('flush_zone: zone_name=%s', zone_name) try: del cls._cache[zone_name] except KeyError: pass
python
def flush_zone(cls, zone_name): '''Flushes the zone cache, if there is one''' cls.log.debug('flush_zone: zone_name=%s', zone_name) try: del cls._cache[zone_name] except KeyError: pass
[ "def", "flush_zone", "(", "cls", ",", "zone_name", ")", ":", "cls", ".", "log", ".", "debug", "(", "'flush_zone: zone_name=%s'", ",", "zone_name", ")", "try", ":", "del", "cls", ".", "_cache", "[", "zone_name", "]", "except", "KeyError", ":", "pass" ]
Flushes the zone cache, if there is one
[ "Flushes", "the", "zone", "cache", "if", "there", "is", "one" ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/dyn.py#L156-L162
train
github/octodns
octodns/provider/azuredns.py
AzureProvider._check_zone
def _check_zone(self, name, create=False): '''Checks whether a zone specified in a source exist in Azure server. Note that Azure zones omit end '.' eg: contoso.com vs contoso.com. Returns the name if it exists. :param name: Name of a zone to checks :type name: ...
python
def _check_zone(self, name, create=False): '''Checks whether a zone specified in a source exist in Azure server. Note that Azure zones omit end '.' eg: contoso.com vs contoso.com. Returns the name if it exists. :param name: Name of a zone to checks :type name: ...
[ "def", "_check_zone", "(", "self", ",", "name", ",", "create", "=", "False", ")", ":", "self", ".", "log", ".", "debug", "(", "'_check_zone: name=%s'", ",", "name", ")", "try", ":", "if", "name", "in", "self", ".", "_azure_zones", ":", "return", "name"...
Checks whether a zone specified in a source exist in Azure server. Note that Azure zones omit end '.' eg: contoso.com vs contoso.com. Returns the name if it exists. :param name: Name of a zone to checks :type name: str :param create: If True, creates the zo...
[ "Checks", "whether", "a", "zone", "specified", "in", "a", "source", "exist", "in", "Azure", "server", "." ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/azuredns.py#L306-L341
train
github/octodns
octodns/provider/azuredns.py
AzureProvider._apply_Create
def _apply_Create(self, change): '''A record from change must be created. :param change: a change object :type change: octodns.record.Change :type return: void ''' ar = _AzureRecord(self._resource_group, change.new) create = self._dns_client.record_...
python
def _apply_Create(self, change): '''A record from change must be created. :param change: a change object :type change: octodns.record.Change :type return: void ''' ar = _AzureRecord(self._resource_group, change.new) create = self._dns_client.record_...
[ "def", "_apply_Create", "(", "self", ",", "change", ")", ":", "ar", "=", "_AzureRecord", "(", "self", ".", "_resource_group", ",", "change", ".", "new", ")", "create", "=", "self", ".", "_dns_client", ".", "record_sets", ".", "create_or_update", "create", ...
A record from change must be created. :param change: a change object :type change: octodns.record.Change :type return: void
[ "A", "record", "from", "change", "must", "be", "created", "." ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/azuredns.py#L450-L467
train
github/octodns
octodns/provider/base.py
BaseProvider.apply
def apply(self, plan): ''' Submits actual planned changes to the provider. Returns the number of changes made ''' if self.apply_disabled: self.log.info('apply: disabled') return 0 self.log.info('apply: making changes') self._apply(plan) ...
python
def apply(self, plan): ''' Submits actual planned changes to the provider. Returns the number of changes made ''' if self.apply_disabled: self.log.info('apply: disabled') return 0 self.log.info('apply: making changes') self._apply(plan) ...
[ "def", "apply", "(", "self", ",", "plan", ")", ":", "if", "self", ".", "apply_disabled", ":", "self", ".", "log", ".", "info", "(", "'apply: disabled'", ")", "return", "0", "self", ".", "log", ".", "info", "(", "'apply: making changes'", ")", "self", "...
Submits actual planned changes to the provider. Returns the number of changes made
[ "Submits", "actual", "planned", "changes", "to", "the", "provider", ".", "Returns", "the", "number", "of", "changes", "made" ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/base.py#L83-L94
train
github/octodns
octodns/provider/ovh.py
OvhProvider._is_valid_dkim
def _is_valid_dkim(self, value): """Check if value is a valid DKIM""" validator_dict = {'h': lambda val: val in ['sha1', 'sha256'], 's': lambda val: val in ['*', 'email'], 't': lambda val: val in ['y', 's'], 'v': lambda val: v...
python
def _is_valid_dkim(self, value): """Check if value is a valid DKIM""" validator_dict = {'h': lambda val: val in ['sha1', 'sha256'], 's': lambda val: val in ['*', 'email'], 't': lambda val: val in ['y', 's'], 'v': lambda val: v...
[ "def", "_is_valid_dkim", "(", "self", ",", "value", ")", ":", "validator_dict", "=", "{", "'h'", ":", "lambda", "val", ":", "val", "in", "[", "'sha1'", ",", "'sha256'", "]", ",", "'s'", ":", "lambda", "val", ":", "val", "in", "[", "'*'", ",", "'ema...
Check if value is a valid DKIM
[ "Check", "if", "value", "is", "a", "valid", "DKIM" ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/ovh.py#L315-L341
train
github/octodns
octodns/provider/googlecloud.py
GoogleCloudProvider._get_gcloud_records
def _get_gcloud_records(self, gcloud_zone, page_token=None): """ Generator function which yields ResourceRecordSet for the managed gcloud zone, until there are no more records to pull. :param gcloud_zone: zone to pull records from :type gcloud_zone: google.cloud.dns.ManagedZ...
python
def _get_gcloud_records(self, gcloud_zone, page_token=None): """ Generator function which yields ResourceRecordSet for the managed gcloud zone, until there are no more records to pull. :param gcloud_zone: zone to pull records from :type gcloud_zone: google.cloud.dns.ManagedZ...
[ "def", "_get_gcloud_records", "(", "self", ",", "gcloud_zone", ",", "page_token", "=", "None", ")", ":", "gcloud_iterator", "=", "gcloud_zone", ".", "list_resource_record_sets", "(", "page_token", "=", "page_token", ")", "for", "gcloud_record", "in", "gcloud_iterato...
Generator function which yields ResourceRecordSet for the managed gcloud zone, until there are no more records to pull. :param gcloud_zone: zone to pull records from :type gcloud_zone: google.cloud.dns.ManagedZone :param page_token: page token for the page to get ...
[ "Generator", "function", "which", "yields", "ResourceRecordSet", "for", "the", "managed", "gcloud", "zone", "until", "there", "are", "no", "more", "records", "to", "pull", "." ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/googlecloud.py#L150-L171
train
github/octodns
octodns/provider/googlecloud.py
GoogleCloudProvider._get_cloud_zones
def _get_cloud_zones(self, page_token=None): """Load all ManagedZones into the self._gcloud_zones dict which is mapped with the dns_name as key. :return: void """ gcloud_zones = self.gcloud_client.list_zones(page_token=page_token) for gcloud_zone in gcloud_zones: ...
python
def _get_cloud_zones(self, page_token=None): """Load all ManagedZones into the self._gcloud_zones dict which is mapped with the dns_name as key. :return: void """ gcloud_zones = self.gcloud_client.list_zones(page_token=page_token) for gcloud_zone in gcloud_zones: ...
[ "def", "_get_cloud_zones", "(", "self", ",", "page_token", "=", "None", ")", ":", "gcloud_zones", "=", "self", ".", "gcloud_client", ".", "list_zones", "(", "page_token", "=", "page_token", ")", "for", "gcloud_zone", "in", "gcloud_zones", ":", "self", ".", "...
Load all ManagedZones into the self._gcloud_zones dict which is mapped with the dns_name as key. :return: void
[ "Load", "all", "ManagedZones", "into", "the", "self", ".", "_gcloud_zones", "dict", "which", "is", "mapped", "with", "the", "dns_name", "as", "key", "." ]
65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6
https://github.com/github/octodns/blob/65ee60491e22e6bb0a2aa08f7069c6ecf6c3fee6/octodns/provider/googlecloud.py#L173-L185
train
nabla-c0d3/sslyze
sslyze/plugins/robot_plugin.py
RobotTlsRecordPayloads.get_client_key_exchange_record
def get_client_key_exchange_record( cls, robot_payload_enum: RobotPmsPaddingPayloadEnum, tls_version: TlsVersionEnum, modulus: int, exponent: int ) -> TlsRsaClientKeyExchangeRecord: """A client key exchange record with a hardcoded pre_master_secret...
python
def get_client_key_exchange_record( cls, robot_payload_enum: RobotPmsPaddingPayloadEnum, tls_version: TlsVersionEnum, modulus: int, exponent: int ) -> TlsRsaClientKeyExchangeRecord: """A client key exchange record with a hardcoded pre_master_secret...
[ "def", "get_client_key_exchange_record", "(", "cls", ",", "robot_payload_enum", ":", "RobotPmsPaddingPayloadEnum", ",", "tls_version", ":", "TlsVersionEnum", ",", "modulus", ":", "int", ",", "exponent", ":", "int", ")", "->", "TlsRsaClientKeyExchangeRecord", ":", "pms...
A client key exchange record with a hardcoded pre_master_secret, and a valid or invalid padding.
[ "A", "client", "key", "exchange", "record", "with", "a", "hardcoded", "pre_master_secret", "and", "a", "valid", "or", "invalid", "padding", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/robot_plugin.py#L71-L90
train
nabla-c0d3/sslyze
sslyze/plugins/robot_plugin.py
RobotTlsRecordPayloads.get_finished_record_bytes
def get_finished_record_bytes(cls, tls_version: TlsVersionEnum) -> bytes: """The Finished TLS record corresponding to the hardcoded PMS used in the Client Key Exchange record. """ # TODO(AD): The ROBOT poc script uses the same Finished record for all possible client hello (default, GCM, ...
python
def get_finished_record_bytes(cls, tls_version: TlsVersionEnum) -> bytes: """The Finished TLS record corresponding to the hardcoded PMS used in the Client Key Exchange record. """ # TODO(AD): The ROBOT poc script uses the same Finished record for all possible client hello (default, GCM, ...
[ "def", "get_finished_record_bytes", "(", "cls", ",", "tls_version", ":", "TlsVersionEnum", ")", "->", "bytes", ":", "# TODO(AD): The ROBOT poc script uses the same Finished record for all possible client hello (default, GCM,", "# etc.); as the Finished record contains a hashes of all previ...
The Finished TLS record corresponding to the hardcoded PMS used in the Client Key Exchange record.
[ "The", "Finished", "TLS", "record", "corresponding", "to", "the", "hardcoded", "PMS", "used", "in", "the", "Client", "Key", "Exchange", "record", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/robot_plugin.py#L109-L116
train
nabla-c0d3/sslyze
sslyze/plugins/robot_plugin.py
RobotServerResponsesAnalyzer.compute_result_enum
def compute_result_enum(self) -> RobotScanResultEnum: """Look at the server's response to each ROBOT payload and return the conclusion of the analysis. """ # Ensure the results were consistent for payload_enum, server_responses in self._payload_responses.items(): # We ran the...
python
def compute_result_enum(self) -> RobotScanResultEnum: """Look at the server's response to each ROBOT payload and return the conclusion of the analysis. """ # Ensure the results were consistent for payload_enum, server_responses in self._payload_responses.items(): # We ran the...
[ "def", "compute_result_enum", "(", "self", ")", "->", "RobotScanResultEnum", ":", "# Ensure the results were consistent", "for", "payload_enum", ",", "server_responses", "in", "self", ".", "_payload_responses", ".", "items", "(", ")", ":", "# We ran the check twice per pa...
Look at the server's response to each ROBOT payload and return the conclusion of the analysis.
[ "Look", "at", "the", "server", "s", "response", "to", "each", "ROBOT", "payload", "and", "return", "the", "conclusion", "of", "the", "analysis", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/robot_plugin.py#L135-L164
train
nabla-c0d3/sslyze
sslyze/plugins/utils/trust_store/trust_store.py
TrustStore.is_extended_validation
def is_extended_validation(self, certificate: Certificate) -> bool: """Is the supplied server certificate EV? """ if not self.ev_oids: raise ValueError('No EV OIDs supplied for {} store - cannot detect EV certificates'.format(self.name)) try: cert_policies_ext = ...
python
def is_extended_validation(self, certificate: Certificate) -> bool: """Is the supplied server certificate EV? """ if not self.ev_oids: raise ValueError('No EV OIDs supplied for {} store - cannot detect EV certificates'.format(self.name)) try: cert_policies_ext = ...
[ "def", "is_extended_validation", "(", "self", ",", "certificate", ":", "Certificate", ")", "->", "bool", ":", "if", "not", "self", ".", "ev_oids", ":", "raise", "ValueError", "(", "'No EV OIDs supplied for {} store - cannot detect EV certificates'", ".", "format", "("...
Is the supplied server certificate EV?
[ "Is", "the", "supplied", "server", "certificate", "EV?" ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/trust_store/trust_store.py#L58-L72
train
nabla-c0d3/sslyze
sslyze/synchronous_scanner.py
SynchronousScanner.run_scan_command
def run_scan_command( self, server_info: ServerConnectivityInfo, scan_command: PluginScanCommand ) -> PluginScanResult: """Run a single scan command against a server; will block until the scan command has been completed. Args: server_info: The server'...
python
def run_scan_command( self, server_info: ServerConnectivityInfo, scan_command: PluginScanCommand ) -> PluginScanResult: """Run a single scan command against a server; will block until the scan command has been completed. Args: server_info: The server'...
[ "def", "run_scan_command", "(", "self", ",", "server_info", ":", "ServerConnectivityInfo", ",", "scan_command", ":", "PluginScanCommand", ")", "->", "PluginScanResult", ":", "plugin_class", "=", "self", ".", "_plugins_repository", ".", "get_plugin_class_for_command", "(...
Run a single scan command against a server; will block until the scan command has been completed. Args: server_info: The server's connectivity information. The test_connectivity_to_server() method must have been called first to ensure that the server is online and accessible. ...
[ "Run", "a", "single", "scan", "command", "against", "a", "server", ";", "will", "block", "until", "the", "scan", "command", "has", "been", "completed", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/synchronous_scanner.py#L32-L50
train
nabla-c0d3/sslyze
sslyze/plugins/utils/trust_store/trust_store_repository.py
TrustStoresRepository.update_default
def update_default(cls) -> 'TrustStoresRepository': """Update the default trust stores used by SSLyze. The latest stores will be downloaded from https://github.com/nabla-c0d3/trust_stores_observatory. """ temp_path = mkdtemp() try: # Download the latest trust stores ...
python
def update_default(cls) -> 'TrustStoresRepository': """Update the default trust stores used by SSLyze. The latest stores will be downloaded from https://github.com/nabla-c0d3/trust_stores_observatory. """ temp_path = mkdtemp() try: # Download the latest trust stores ...
[ "def", "update_default", "(", "cls", ")", "->", "'TrustStoresRepository'", ":", "temp_path", "=", "mkdtemp", "(", ")", "try", ":", "# Download the latest trust stores", "archive_path", "=", "join", "(", "temp_path", ",", "'trust_stores_as_pem.tar.gz'", ")", "urlretrie...
Update the default trust stores used by SSLyze. The latest stores will be downloaded from https://github.com/nabla-c0d3/trust_stores_observatory.
[ "Update", "the", "default", "trust", "stores", "used", "by", "SSLyze", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/trust_store/trust_store_repository.py#L123-L146
train
nabla-c0d3/sslyze
sslyze/plugins/openssl_cipher_suites_plugin.py
OpenSslCipherSuitesPlugin._get_preferred_cipher_suite
def _get_preferred_cipher_suite( cls, server_connectivity_info: ServerConnectivityInfo, ssl_version: OpenSslVersionEnum, accepted_cipher_list: List['AcceptedCipherSuite'] ) -> Optional['AcceptedCipherSuite']: """Try to detect the server's preferred cipher suit...
python
def _get_preferred_cipher_suite( cls, server_connectivity_info: ServerConnectivityInfo, ssl_version: OpenSslVersionEnum, accepted_cipher_list: List['AcceptedCipherSuite'] ) -> Optional['AcceptedCipherSuite']: """Try to detect the server's preferred cipher suit...
[ "def", "_get_preferred_cipher_suite", "(", "cls", ",", "server_connectivity_info", ":", "ServerConnectivityInfo", ",", "ssl_version", ":", "OpenSslVersionEnum", ",", "accepted_cipher_list", ":", "List", "[", "'AcceptedCipherSuite'", "]", ")", "->", "Optional", "[", "'Ac...
Try to detect the server's preferred cipher suite among all cipher suites supported by SSLyze.
[ "Try", "to", "detect", "the", "server", "s", "preferred", "cipher", "suite", "among", "all", "cipher", "suites", "supported", "by", "SSLyze", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/openssl_cipher_suites_plugin.py#L283-L330
train
nabla-c0d3/sslyze
sslyze/plugins/openssl_cipher_suites_plugin.py
CipherSuite.name
def name(self) -> str: """OpenSSL uses a different naming convention than the corresponding RFCs. """ return OPENSSL_TO_RFC_NAMES_MAPPING[self.ssl_version].get(self.openssl_name, self.openssl_name)
python
def name(self) -> str: """OpenSSL uses a different naming convention than the corresponding RFCs. """ return OPENSSL_TO_RFC_NAMES_MAPPING[self.ssl_version].get(self.openssl_name, self.openssl_name)
[ "def", "name", "(", "self", ")", "->", "str", ":", "return", "OPENSSL_TO_RFC_NAMES_MAPPING", "[", "self", ".", "ssl_version", "]", ".", "get", "(", "self", ".", "openssl_name", ",", "self", ".", "openssl_name", ")" ]
OpenSSL uses a different naming convention than the corresponding RFCs.
[ "OpenSSL", "uses", "a", "different", "naming", "convention", "than", "the", "corresponding", "RFCs", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/openssl_cipher_suites_plugin.py#L366-L369
train
nabla-c0d3/sslyze
sslyze/concurrent_scanner.py
ConcurrentScanner.queue_scan_command
def queue_scan_command(self, server_info: ServerConnectivityInfo, scan_command: PluginScanCommand) -> None: """Queue a scan command targeting a specific server. Args: server_info: The server's connectivity information. The test_connectivity_to_server() method must have been ...
python
def queue_scan_command(self, server_info: ServerConnectivityInfo, scan_command: PluginScanCommand) -> None: """Queue a scan command targeting a specific server. Args: server_info: The server's connectivity information. The test_connectivity_to_server() method must have been ...
[ "def", "queue_scan_command", "(", "self", ",", "server_info", ":", "ServerConnectivityInfo", ",", "scan_command", ":", "PluginScanCommand", ")", "->", "None", ":", "# Ensure we have the right processes and queues in place for this hostname", "self", ".", "_check_and_create_proc...
Queue a scan command targeting a specific server. Args: server_info: The server's connectivity information. The test_connectivity_to_server() method must have been called first to ensure that the server is online and accessible. scan_command: The scan command to run agai...
[ "Queue", "a", "scan", "command", "targeting", "a", "specific", "server", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/concurrent_scanner.py#L83-L102
train
nabla-c0d3/sslyze
sslyze/concurrent_scanner.py
ConcurrentScanner.get_results
def get_results(self) -> Iterable[PluginScanResult]: """Return the result of previously queued scan commands; new commands cannot be queued once this is called. Returns: The results of all the scan commands previously queued. Each result will be an instance of the scan correspon...
python
def get_results(self) -> Iterable[PluginScanResult]: """Return the result of previously queued scan commands; new commands cannot be queued once this is called. Returns: The results of all the scan commands previously queued. Each result will be an instance of the scan correspon...
[ "def", "get_results", "(", "self", ")", "->", "Iterable", "[", "PluginScanResult", "]", ":", "# Put a 'None' sentinel in the queue to let the each process know when every task has been completed", "for", "_", "in", "range", "(", "self", ".", "_get_current_processes_nb", "(", ...
Return the result of previously queued scan commands; new commands cannot be queued once this is called. Returns: The results of all the scan commands previously queued. Each result will be an instance of the scan corresponding command's PluginScanResult subclass. If there was an unexpe...
[ "Return", "the", "result", "of", "previously", "queued", "scan", "commands", ";", "new", "commands", "cannot", "be", "queued", "once", "this", "is", "called", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/concurrent_scanner.py#L135-L172
train
nabla-c0d3/sslyze
sslyze/utils/worker_process.py
WorkerProcess.run
def run(self) -> None: """The process will first complete tasks it gets from self.queue_in. Once it gets notified that all the tasks have been completed, it terminates. """ from sslyze.concurrent_scanner import PluginRaisedExceptionScanResult # Start processing task in the prior...
python
def run(self) -> None: """The process will first complete tasks it gets from self.queue_in. Once it gets notified that all the tasks have been completed, it terminates. """ from sslyze.concurrent_scanner import PluginRaisedExceptionScanResult # Start processing task in the prior...
[ "def", "run", "(", "self", ")", "->", "None", ":", "from", "sslyze", ".", "concurrent_scanner", "import", "PluginRaisedExceptionScanResult", "# Start processing task in the priority queue first", "current_queue_in", "=", "self", ".", "priority_queue_in", "while", "True", ...
The process will first complete tasks it gets from self.queue_in. Once it gets notified that all the tasks have been completed, it terminates.
[ "The", "process", "will", "first", "complete", "tasks", "it", "gets", "from", "self", ".", "queue_in", ".", "Once", "it", "gets", "notified", "that", "all", "the", "tasks", "have", "been", "completed", "it", "terminates", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/worker_process.py#L26-L58
train
nabla-c0d3/sslyze
sslyze/utils/connection_helpers.py
ProxyTunnelingConnectionHelper.connect_socket
def connect_socket(self, sock: socket.socket) -> None: """Setup HTTP tunneling with the configured proxy. """ # Setup HTTP tunneling try: sock.connect((self._tunnel_host, self._tunnel_port)) except socket.timeout as e: raise ProxyError(self.ERR_PROXY_OFFLI...
python
def connect_socket(self, sock: socket.socket) -> None: """Setup HTTP tunneling with the configured proxy. """ # Setup HTTP tunneling try: sock.connect((self._tunnel_host, self._tunnel_port)) except socket.timeout as e: raise ProxyError(self.ERR_PROXY_OFFLI...
[ "def", "connect_socket", "(", "self", ",", "sock", ":", "socket", ".", "socket", ")", "->", "None", ":", "# Setup HTTP tunneling", "try", ":", "sock", ".", "connect", "(", "(", "self", ".", "_tunnel_host", ",", "self", ".", "_tunnel_port", ")", ")", "exc...
Setup HTTP tunneling with the configured proxy.
[ "Setup", "HTTP", "tunneling", "with", "the", "configured", "proxy", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/connection_helpers.py#L63-L85
train
nabla-c0d3/sslyze
sslyze/server_connectivity_info.py
ServerConnectivityInfo.get_preconfigured_ssl_connection
def get_preconfigured_ssl_connection( self, override_ssl_version: Optional[OpenSslVersionEnum] = None, ssl_verify_locations: Optional[str] = None, should_use_legacy_openssl: Optional[bool] = None, ) -> SslConnection: """Get an SSLConnection instance with the r...
python
def get_preconfigured_ssl_connection( self, override_ssl_version: Optional[OpenSslVersionEnum] = None, ssl_verify_locations: Optional[str] = None, should_use_legacy_openssl: Optional[bool] = None, ) -> SslConnection: """Get an SSLConnection instance with the r...
[ "def", "get_preconfigured_ssl_connection", "(", "self", ",", "override_ssl_version", ":", "Optional", "[", "OpenSslVersionEnum", "]", "=", "None", ",", "ssl_verify_locations", ":", "Optional", "[", "str", "]", "=", "None", ",", "should_use_legacy_openssl", ":", "Opt...
Get an SSLConnection instance with the right SSL configuration for successfully connecting to the server. Used by all plugins to connect to the server and run scans.
[ "Get", "an", "SSLConnection", "instance", "with", "the", "right", "SSL", "configuration", "for", "successfully", "connecting", "to", "the", "server", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/server_connectivity_info.py#L70-L114
train
nabla-c0d3/sslyze
sslyze/cli/command_line_parser.py
CommandLineParser._add_plugin_options
def _add_plugin_options(self, available_plugins: Set[Type[Plugin]]) -> None: """Recovers the list of command line options implemented by the available plugins and adds them to the command line parser. """ for plugin_class in available_plugins: # Add the current plugin's comma...
python
def _add_plugin_options(self, available_plugins: Set[Type[Plugin]]) -> None: """Recovers the list of command line options implemented by the available plugins and adds them to the command line parser. """ for plugin_class in available_plugins: # Add the current plugin's comma...
[ "def", "_add_plugin_options", "(", "self", ",", "available_plugins", ":", "Set", "[", "Type", "[", "Plugin", "]", "]", ")", "->", "None", ":", "for", "plugin_class", "in", "available_plugins", ":", "# Add the current plugin's commands to the parser", "group", "=", ...
Recovers the list of command line options implemented by the available plugins and adds them to the command line parser.
[ "Recovers", "the", "list", "of", "command", "line", "options", "implemented", "by", "the", "available", "plugins", "and", "adds", "them", "to", "the", "command", "line", "parser", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/cli/command_line_parser.py#L428-L437
train
nabla-c0d3/sslyze
setup.py
get_long_description
def get_long_description(): """Convert the README file into the long description. """ with open(path.join(root_path, 'README.md'), encoding='utf-8') as f: long_description = f.read() return long_description
python
def get_long_description(): """Convert the README file into the long description. """ with open(path.join(root_path, 'README.md'), encoding='utf-8') as f: long_description = f.read() return long_description
[ "def", "get_long_description", "(", ")", ":", "with", "open", "(", "path", ".", "join", "(", "root_path", ",", "'README.md'", ")", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "long_description", "=", "f", ".", "read", "(", ")", "return", "lon...
Convert the README file into the long description.
[ "Convert", "the", "README", "file", "into", "the", "long", "description", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/setup.py#L23-L28
train
nabla-c0d3/sslyze
setup.py
get_include_files
def get_include_files(): """"Get the list of trust stores so they properly packaged when doing a cx_freeze build. """ plugin_data_files = [] trust_stores_pem_path = path.join(root_path, 'sslyze', 'plugins', 'utils', 'trust_store', 'pem_files') for file in listdir(trust_stores_pem_path): file...
python
def get_include_files(): """"Get the list of trust stores so they properly packaged when doing a cx_freeze build. """ plugin_data_files = [] trust_stores_pem_path = path.join(root_path, 'sslyze', 'plugins', 'utils', 'trust_store', 'pem_files') for file in listdir(trust_stores_pem_path): file...
[ "def", "get_include_files", "(", ")", ":", "plugin_data_files", "=", "[", "]", "trust_stores_pem_path", "=", "path", ".", "join", "(", "root_path", ",", "'sslyze'", ",", "'plugins'", ",", "'utils'", ",", "'trust_store'", ",", "'pem_files'", ")", "for", "file",...
Get the list of trust stores so they properly packaged when doing a cx_freeze build.
[ "Get", "the", "list", "of", "trust", "stores", "so", "they", "properly", "packaged", "when", "doing", "a", "cx_freeze", "build", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/setup.py#L31-L41
train
nabla-c0d3/sslyze
sslyze/plugins/utils/certificate_utils.py
CertificateUtils.get_dns_subject_alternative_names
def get_dns_subject_alternative_names(certificate: cryptography.x509.Certificate) -> List[str]: """Retrieve all the DNS entries of the Subject Alternative Name extension. """ subj_alt_names: List[str] = [] try: san_ext = certificate.extensions.get_extension_for_oid(ExtensionO...
python
def get_dns_subject_alternative_names(certificate: cryptography.x509.Certificate) -> List[str]: """Retrieve all the DNS entries of the Subject Alternative Name extension. """ subj_alt_names: List[str] = [] try: san_ext = certificate.extensions.get_extension_for_oid(ExtensionO...
[ "def", "get_dns_subject_alternative_names", "(", "certificate", ":", "cryptography", ".", "x509", ".", "Certificate", ")", "->", "List", "[", "str", "]", ":", "subj_alt_names", ":", "List", "[", "str", "]", "=", "[", "]", "try", ":", "san_ext", "=", "certi...
Retrieve all the DNS entries of the Subject Alternative Name extension.
[ "Retrieve", "all", "the", "DNS", "entries", "of", "the", "Subject", "Alternative", "Name", "extension", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/certificate_utils.py#L24-L33
train
nabla-c0d3/sslyze
sslyze/plugins/utils/certificate_utils.py
CertificateUtils.matches_hostname
def matches_hostname(cls, certificate: cryptography.x509.Certificate, hostname: str) -> None: """Verify that the certificate was issued for the given hostname. Raises: CertificateError: If the certificate was not issued for the supplied hostname. """ # Extract the names from...
python
def matches_hostname(cls, certificate: cryptography.x509.Certificate, hostname: str) -> None: """Verify that the certificate was issued for the given hostname. Raises: CertificateError: If the certificate was not issued for the supplied hostname. """ # Extract the names from...
[ "def", "matches_hostname", "(", "cls", ",", "certificate", ":", "cryptography", ".", "x509", ".", "Certificate", ",", "hostname", ":", "str", ")", "->", "None", ":", "# Extract the names from the certificate to create the properly-formatted dictionary", "certificate_names",...
Verify that the certificate was issued for the given hostname. Raises: CertificateError: If the certificate was not issued for the supplied hostname.
[ "Verify", "that", "the", "certificate", "was", "issued", "for", "the", "given", "hostname", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/certificate_utils.py#L36-L48
train
nabla-c0d3/sslyze
sslyze/plugins/utils/certificate_utils.py
CertificateUtils.get_name_as_short_text
def get_name_as_short_text(cls, name_field: cryptography.x509.Name) -> str: """Convert a name field returned by the cryptography module to a string suitable for displaying it to the user. """ # Name_field is supposed to be a Subject or an Issuer; print the CN if there is one common_names...
python
def get_name_as_short_text(cls, name_field: cryptography.x509.Name) -> str: """Convert a name field returned by the cryptography module to a string suitable for displaying it to the user. """ # Name_field is supposed to be a Subject or an Issuer; print the CN if there is one common_names...
[ "def", "get_name_as_short_text", "(", "cls", ",", "name_field", ":", "cryptography", ".", "x509", ".", "Name", ")", "->", "str", ":", "# Name_field is supposed to be a Subject or an Issuer; print the CN if there is one", "common_names", "=", "cls", ".", "get_common_names", ...
Convert a name field returned by the cryptography module to a string suitable for displaying it to the user.
[ "Convert", "a", "name", "field", "returned", "by", "the", "cryptography", "module", "to", "a", "string", "suitable", "for", "displaying", "it", "to", "the", "user", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/certificate_utils.py#L51-L61
train
nabla-c0d3/sslyze
sslyze/plugins/utils/certificate_utils.py
CertificateUtils.has_ocsp_must_staple_extension
def has_ocsp_must_staple_extension(certificate: cryptography.x509.Certificate) -> bool: """Return True if the certificate has the OCSP Must-Staple extension defined in RFC 6066. """ has_ocsp_must_staple = False try: tls_feature_ext = certificate.extensions.get_extension_for_o...
python
def has_ocsp_must_staple_extension(certificate: cryptography.x509.Certificate) -> bool: """Return True if the certificate has the OCSP Must-Staple extension defined in RFC 6066. """ has_ocsp_must_staple = False try: tls_feature_ext = certificate.extensions.get_extension_for_o...
[ "def", "has_ocsp_must_staple_extension", "(", "certificate", ":", "cryptography", ".", "x509", ".", "Certificate", ")", "->", "bool", ":", "has_ocsp_must_staple", "=", "False", "try", ":", "tls_feature_ext", "=", "certificate", ".", "extensions", ".", "get_extension...
Return True if the certificate has the OCSP Must-Staple extension defined in RFC 6066.
[ "Return", "True", "if", "the", "certificate", "has", "the", "OCSP", "Must", "-", "Staple", "extension", "defined", "in", "RFC", "6066", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/utils/certificate_utils.py#L95-L108
train
nabla-c0d3/sslyze
sslyze/utils/tls_wrapped_protocol_helpers.py
HttpsHelper.send_request
def send_request(self, ssl_client: SslClient) -> str: """Send an HTTP GET to the server and return the HTTP status code. """ try: ssl_client.write(HttpRequestGenerator.get_request(self._hostname)) # Parse the response and print the Location header http_respon...
python
def send_request(self, ssl_client: SslClient) -> str: """Send an HTTP GET to the server and return the HTTP status code. """ try: ssl_client.write(HttpRequestGenerator.get_request(self._hostname)) # Parse the response and print the Location header http_respon...
[ "def", "send_request", "(", "self", ",", "ssl_client", ":", "SslClient", ")", "->", "str", ":", "try", ":", "ssl_client", ".", "write", "(", "HttpRequestGenerator", ".", "get_request", "(", "self", ".", "_hostname", ")", ")", "# Parse the response and print the ...
Send an HTTP GET to the server and return the HTTP status code.
[ "Send", "an", "HTTP", "GET", "to", "the", "server", "and", "return", "the", "HTTP", "status", "code", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/tls_wrapped_protocol_helpers.py#L65-L90
train
nabla-c0d3/sslyze
sslyze/plugins/plugins_repository.py
PluginsRepository.get_plugin_class_for_command
def get_plugin_class_for_command(self, scan_command: PluginScanCommand) -> Type[Plugin]: """Get the class of the plugin implementing the supplied scan command. """ return self._scan_command_classes_to_plugin_classes[scan_command.__class__]
python
def get_plugin_class_for_command(self, scan_command: PluginScanCommand) -> Type[Plugin]: """Get the class of the plugin implementing the supplied scan command. """ return self._scan_command_classes_to_plugin_classes[scan_command.__class__]
[ "def", "get_plugin_class_for_command", "(", "self", ",", "scan_command", ":", "PluginScanCommand", ")", "->", "Type", "[", "Plugin", "]", ":", "return", "self", ".", "_scan_command_classes_to_plugin_classes", "[", "scan_command", ".", "__class__", "]" ]
Get the class of the plugin implementing the supplied scan command.
[ "Get", "the", "class", "of", "the", "plugin", "implementing", "the", "supplied", "scan", "command", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/plugins_repository.py#L44-L47
train
nabla-c0d3/sslyze
sslyze/utils/http_response_parser.py
HttpResponseParser._parse
def _parse(read_method: Callable) -> HTTPResponse: """Trick to standardize the API between sockets and SSLConnection objects. """ response = read_method(4096) while b'HTTP/' not in response or b'\r\n\r\n' not in response: # Parse until the end of the headers respo...
python
def _parse(read_method: Callable) -> HTTPResponse: """Trick to standardize the API between sockets and SSLConnection objects. """ response = read_method(4096) while b'HTTP/' not in response or b'\r\n\r\n' not in response: # Parse until the end of the headers respo...
[ "def", "_parse", "(", "read_method", ":", "Callable", ")", "->", "HTTPResponse", ":", "response", "=", "read_method", "(", "4096", ")", "while", "b'HTTP/'", "not", "in", "response", "or", "b'\\r\\n\\r\\n'", "not", "in", "response", ":", "# Parse until the end of...
Trick to standardize the API between sockets and SSLConnection objects.
[ "Trick", "to", "standardize", "the", "API", "between", "sockets", "and", "SSLConnection", "objects", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/http_response_parser.py#L26-L37
train
nabla-c0d3/sslyze
sslyze/utils/thread_pool.py
_work_function
def _work_function(job_q: Queue, result_q: Queue, error_q: Queue) -> None: """Work function expected to run within threads. """ while True: job = job_q.get() if isinstance(job, _ThreadPoolSentinel): # All the work is done, get out result_q.put(_ThreadPoolSentinel()) ...
python
def _work_function(job_q: Queue, result_q: Queue, error_q: Queue) -> None: """Work function expected to run within threads. """ while True: job = job_q.get() if isinstance(job, _ThreadPoolSentinel): # All the work is done, get out result_q.put(_ThreadPoolSentinel()) ...
[ "def", "_work_function", "(", "job_q", ":", "Queue", ",", "result_q", ":", "Queue", ",", "error_q", ":", "Queue", ")", "->", "None", ":", "while", "True", ":", "job", "=", "job_q", ".", "get", "(", ")", "if", "isinstance", "(", "job", ",", "_ThreadPo...
Work function expected to run within threads.
[ "Work", "function", "expected", "to", "run", "within", "threads", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/thread_pool.py#L93-L115
train
nabla-c0d3/sslyze
sslyze/plugins/session_resumption_plugin.py
SessionResumptionPlugin._resume_with_session_id
def _resume_with_session_id( self, server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum ) -> bool: """Perform one session resumption using Session IDs. """ session1 = self._resume_ssl_session(server_info, ssl_version_to_use) ...
python
def _resume_with_session_id( self, server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum ) -> bool: """Perform one session resumption using Session IDs. """ session1 = self._resume_ssl_session(server_info, ssl_version_to_use) ...
[ "def", "_resume_with_session_id", "(", "self", ",", "server_info", ":", "ServerConnectivityInfo", ",", "ssl_version_to_use", ":", "OpenSslVersionEnum", ")", "->", "bool", ":", "session1", "=", "self", ".", "_resume_ssl_session", "(", "server_info", ",", "ssl_version_t...
Perform one session resumption using Session IDs.
[ "Perform", "one", "session", "resumption", "using", "Session", "IDs", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/session_resumption_plugin.py#L151-L184
train
nabla-c0d3/sslyze
sslyze/plugins/session_resumption_plugin.py
SessionResumptionPlugin._resume_with_session_ticket
def _resume_with_session_ticket( self, server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum, ) -> TslSessionTicketSupportEnum: """Perform one session resumption using TLS Session Tickets. """ # Connect to the server and keep the SSL ...
python
def _resume_with_session_ticket( self, server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum, ) -> TslSessionTicketSupportEnum: """Perform one session resumption using TLS Session Tickets. """ # Connect to the server and keep the SSL ...
[ "def", "_resume_with_session_ticket", "(", "self", ",", "server_info", ":", "ServerConnectivityInfo", ",", "ssl_version_to_use", ":", "OpenSslVersionEnum", ",", ")", "->", "TslSessionTicketSupportEnum", ":", "# Connect to the server and keep the SSL session", "try", ":", "ses...
Perform one session resumption using TLS Session Tickets.
[ "Perform", "one", "session", "resumption", "using", "TLS", "Session", "Tickets", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/session_resumption_plugin.py#L186-L220
train
nabla-c0d3/sslyze
sslyze/plugins/session_resumption_plugin.py
SessionResumptionPlugin._extract_session_id
def _extract_session_id(ssl_session: nassl._nassl.SSL_SESSION) -> str: """Extract the SSL session ID from a SSL session object or raises IndexError if the session ID was not set. """ session_string = ((ssl_session.as_text()).split('Session-ID:'))[1] session_id = (session_string.split('Se...
python
def _extract_session_id(ssl_session: nassl._nassl.SSL_SESSION) -> str: """Extract the SSL session ID from a SSL session object or raises IndexError if the session ID was not set. """ session_string = ((ssl_session.as_text()).split('Session-ID:'))[1] session_id = (session_string.split('Se...
[ "def", "_extract_session_id", "(", "ssl_session", ":", "nassl", ".", "_nassl", ".", "SSL_SESSION", ")", "->", "str", ":", "session_string", "=", "(", "(", "ssl_session", ".", "as_text", "(", ")", ")", ".", "split", "(", "'Session-ID:'", ")", ")", "[", "1...
Extract the SSL session ID from a SSL session object or raises IndexError if the session ID was not set.
[ "Extract", "the", "SSL", "session", "ID", "from", "a", "SSL", "session", "object", "or", "raises", "IndexError", "if", "the", "session", "ID", "was", "not", "set", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/session_resumption_plugin.py#L223-L228
train
nabla-c0d3/sslyze
sslyze/plugins/session_resumption_plugin.py
SessionResumptionPlugin._extract_tls_session_ticket
def _extract_tls_session_ticket(ssl_session: nassl._nassl.SSL_SESSION) -> str: """Extract the TLS session ticket from a SSL session object or raises IndexError if the ticket was not set. """ session_string = ((ssl_session.as_text()).split('TLS session ticket:'))[1] session_tls_ticket = (...
python
def _extract_tls_session_ticket(ssl_session: nassl._nassl.SSL_SESSION) -> str: """Extract the TLS session ticket from a SSL session object or raises IndexError if the ticket was not set. """ session_string = ((ssl_session.as_text()).split('TLS session ticket:'))[1] session_tls_ticket = (...
[ "def", "_extract_tls_session_ticket", "(", "ssl_session", ":", "nassl", ".", "_nassl", ".", "SSL_SESSION", ")", "->", "str", ":", "session_string", "=", "(", "(", "ssl_session", ".", "as_text", "(", ")", ")", ".", "split", "(", "'TLS session ticket:'", ")", ...
Extract the TLS session ticket from a SSL session object or raises IndexError if the ticket was not set.
[ "Extract", "the", "TLS", "session", "ticket", "from", "a", "SSL", "session", "object", "or", "raises", "IndexError", "if", "the", "ticket", "was", "not", "set", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/session_resumption_plugin.py#L231-L236
train
nabla-c0d3/sslyze
sslyze/plugins/session_resumption_plugin.py
SessionResumptionPlugin._resume_ssl_session
def _resume_ssl_session( server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum, ssl_session: Optional[nassl._nassl.SSL_SESSION] = None, should_enable_tls_ticket: bool = False ) -> nassl._nassl.SSL_SESSION: """Connect to the server and ret...
python
def _resume_ssl_session( server_info: ServerConnectivityInfo, ssl_version_to_use: OpenSslVersionEnum, ssl_session: Optional[nassl._nassl.SSL_SESSION] = None, should_enable_tls_ticket: bool = False ) -> nassl._nassl.SSL_SESSION: """Connect to the server and ret...
[ "def", "_resume_ssl_session", "(", "server_info", ":", "ServerConnectivityInfo", ",", "ssl_version_to_use", ":", "OpenSslVersionEnum", ",", "ssl_session", ":", "Optional", "[", "nassl", ".", "_nassl", ".", "SSL_SESSION", "]", "=", "None", ",", "should_enable_tls_ticke...
Connect to the server and returns the session object that was assigned for that connection. If ssl_session is given, tries to resume that session.
[ "Connect", "to", "the", "server", "and", "returns", "the", "session", "object", "that", "was", "assigned", "for", "that", "connection", ".", "If", "ssl_session", "is", "given", "tries", "to", "resume", "that", "session", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/session_resumption_plugin.py#L239-L265
train
nabla-c0d3/sslyze
sslyze/cli/json_output.py
_object_to_json_dict
def _object_to_json_dict(obj: Any) -> Union[bool, int, float, str, Dict[str, Any]]: """Convert an object to a dictionary suitable for the JSON output. """ if isinstance(obj, Enum): # Properly serialize Enums (such as OpenSslVersionEnum) result = obj.name elif isinstance(obj, ObjectIdent...
python
def _object_to_json_dict(obj: Any) -> Union[bool, int, float, str, Dict[str, Any]]: """Convert an object to a dictionary suitable for the JSON output. """ if isinstance(obj, Enum): # Properly serialize Enums (such as OpenSslVersionEnum) result = obj.name elif isinstance(obj, ObjectIdent...
[ "def", "_object_to_json_dict", "(", "obj", ":", "Any", ")", "->", "Union", "[", "bool", ",", "int", ",", "float", ",", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "if", "isinstance", "(", "obj", ",", "Enum", ")", ":", "# Properly ser...
Convert an object to a dictionary suitable for the JSON output.
[ "Convert", "an", "object", "to", "a", "dictionary", "suitable", "for", "the", "JSON", "output", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/cli/json_output.py#L84-L145
train
nabla-c0d3/sslyze
sslyze/plugins/certificate_info_plugin.py
CertificateInfoPlugin._get_and_verify_certificate_chain
def _get_and_verify_certificate_chain( server_info: ServerConnectivityInfo, trust_store: TrustStore ) -> Tuple[List[Certificate], str, Optional[OcspResponse]]: """Connects to the target server and uses the supplied trust store to validate the server's certificate. Returns the...
python
def _get_and_verify_certificate_chain( server_info: ServerConnectivityInfo, trust_store: TrustStore ) -> Tuple[List[Certificate], str, Optional[OcspResponse]]: """Connects to the target server and uses the supplied trust store to validate the server's certificate. Returns the...
[ "def", "_get_and_verify_certificate_chain", "(", "server_info", ":", "ServerConnectivityInfo", ",", "trust_store", ":", "TrustStore", ")", "->", "Tuple", "[", "List", "[", "Certificate", "]", ",", "str", ",", "Optional", "[", "OcspResponse", "]", "]", ":", "ssl_...
Connects to the target server and uses the supplied trust store to validate the server's certificate. Returns the server's certificate and OCSP response.
[ "Connects", "to", "the", "target", "server", "and", "uses", "the", "supplied", "trust", "store", "to", "validate", "the", "server", "s", "certificate", ".", "Returns", "the", "server", "s", "certificate", "and", "OCSP", "response", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/certificate_info_plugin.py#L171-L202
train
nabla-c0d3/sslyze
sslyze/plugins/plugin_base.py
PluginScanCommand.get_description
def get_description(cls) -> str: """The description is expected to be the command class' docstring. """ if cls.__doc__ is None: raise ValueError('No docstring found for {}'.format(cls.__name__)) return cls.__doc__.strip()
python
def get_description(cls) -> str: """The description is expected to be the command class' docstring. """ if cls.__doc__ is None: raise ValueError('No docstring found for {}'.format(cls.__name__)) return cls.__doc__.strip()
[ "def", "get_description", "(", "cls", ")", "->", "str", ":", "if", "cls", ".", "__doc__", "is", "None", ":", "raise", "ValueError", "(", "'No docstring found for {}'", ".", "format", "(", "cls", ".", "__name__", ")", ")", "return", "cls", ".", "__doc__", ...
The description is expected to be the command class' docstring.
[ "The", "description", "is", "expected", "to", "be", "the", "command", "class", "docstring", "." ]
0fb3ae668453d7ecf616d0755f237ca7be9f62fa
https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/plugins/plugin_base.py#L30-L35
train
kennethreitz/inbox.py
inbox.py
Inbox.serve
def serve(self, port=None, address=None): """Serves the SMTP server on the given port and address.""" port = port or self.port address = address or self.address log.info('Starting SMTP server at {0}:{1}'.format(address, port)) server = InboxServer(self.collator, (address, port)...
python
def serve(self, port=None, address=None): """Serves the SMTP server on the given port and address.""" port = port or self.port address = address or self.address log.info('Starting SMTP server at {0}:{1}'.format(address, port)) server = InboxServer(self.collator, (address, port)...
[ "def", "serve", "(", "self", ",", "port", "=", "None", ",", "address", "=", "None", ")", ":", "port", "=", "port", "or", "self", ".", "port", "address", "=", "address", "or", "self", ".", "address", "log", ".", "info", "(", "'Starting SMTP server at {0...
Serves the SMTP server on the given port and address.
[ "Serves", "the", "SMTP", "server", "on", "the", "given", "port", "and", "address", "." ]
493f8d9834a41ac9012f13da5693697efdcb1826
https://github.com/kennethreitz/inbox.py/blob/493f8d9834a41ac9012f13da5693697efdcb1826/inbox.py#L41-L53
train
kennethreitz/inbox.py
inbox.py
Inbox.dispatch
def dispatch(self): """Command-line dispatch.""" parser = argparse.ArgumentParser(description='Run an Inbox server.') parser.add_argument('addr', metavar='addr', type=str, help='addr to bind to') parser.add_argument('port', metavar='port', type=int, help='port to bind to') args...
python
def dispatch(self): """Command-line dispatch.""" parser = argparse.ArgumentParser(description='Run an Inbox server.') parser.add_argument('addr', metavar='addr', type=str, help='addr to bind to') parser.add_argument('port', metavar='port', type=int, help='port to bind to') args...
[ "def", "dispatch", "(", "self", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Run an Inbox server.'", ")", "parser", ".", "add_argument", "(", "'addr'", ",", "metavar", "=", "'addr'", ",", "type", "=", "str", ",", "...
Command-line dispatch.
[ "Command", "-", "line", "dispatch", "." ]
493f8d9834a41ac9012f13da5693697efdcb1826
https://github.com/kennethreitz/inbox.py/blob/493f8d9834a41ac9012f13da5693697efdcb1826/inbox.py#L55-L64
train
securestate/termineter
lib/c1219/data.py
format_ltime
def format_ltime(endianess, tm_format, data): """ Return data formatted into a human readable time stamp. :param str endianess: The endianess to use when packing values ('>' or '<') :param int tm_format: The format that the data is packed in, this typically corresponds with the value in the GEN_CONFIG_TBL (tabl...
python
def format_ltime(endianess, tm_format, data): """ Return data formatted into a human readable time stamp. :param str endianess: The endianess to use when packing values ('>' or '<') :param int tm_format: The format that the data is packed in, this typically corresponds with the value in the GEN_CONFIG_TBL (tabl...
[ "def", "format_ltime", "(", "endianess", ",", "tm_format", ",", "data", ")", ":", "if", "tm_format", "==", "0", ":", "return", "''", "elif", "tm_format", "==", "1", "or", "tm_format", "==", "2", ":", "# I can't find solid documentation on the BCD data-type", "y"...
Return data formatted into a human readable time stamp. :param str endianess: The endianess to use when packing values ('>' or '<') :param int tm_format: The format that the data is packed in, this typically corresponds with the value in the GEN_CONFIG_TBL (table #0) (1 <= tm_format <= 4) :param bytes data: The ...
[ "Return", "data", "formatted", "into", "a", "human", "readable", "time", "stamp", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1219/data.py#L40-L80
train
securestate/termineter
lib/c1219/data.py
get_history_entry_record
def get_history_entry_record(endianess, hist_date_time_flag, tm_format, event_number_flag, hist_seq_nbr_flag, data): """ Return data formatted into a log entry. :param str endianess: The endianess to use when packing values ('>' or '<') :param bool hist_date_time_flag: Whether or not a time stamp is included. :pa...
python
def get_history_entry_record(endianess, hist_date_time_flag, tm_format, event_number_flag, hist_seq_nbr_flag, data): """ Return data formatted into a log entry. :param str endianess: The endianess to use when packing values ('>' or '<') :param bool hist_date_time_flag: Whether or not a time stamp is included. :pa...
[ "def", "get_history_entry_record", "(", "endianess", ",", "hist_date_time_flag", ",", "tm_format", ",", "event_number_flag", ",", "hist_seq_nbr_flag", ",", "data", ")", ":", "rcd", "=", "{", "}", "if", "hist_date_time_flag", ":", "tmstmp", "=", "format_ltime", "("...
Return data formatted into a log entry. :param str endianess: The endianess to use when packing values ('>' or '<') :param bool hist_date_time_flag: Whether or not a time stamp is included. :param int tm_format: The format that the data is packed in, this typically corresponds with the value in the GEN_CONFIG_TB...
[ "Return", "data", "formatted", "into", "a", "log", "entry", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1219/data.py#L82-L111
train
securestate/termineter
lib/c1219/data.py
get_table_idbb_field
def get_table_idbb_field(endianess, data): """ Return data from a packed TABLE_IDB_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg) """ bfld = struct...
python
def get_table_idbb_field(endianess, data): """ Return data from a packed TABLE_IDB_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg) """ bfld = struct...
[ "def", "get_table_idbb_field", "(", "endianess", ",", "data", ")", ":", "bfld", "=", "struct", ".", "unpack", "(", "endianess", "+", "'H'", ",", "data", "[", ":", "2", "]", ")", "[", "0", "]", "proc_nbr", "=", "bfld", "&", "0x7ff", "std_vs_mfg", "=",...
Return data from a packed TABLE_IDB_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg)
[ "Return", "data", "from", "a", "packed", "TABLE_IDB_BFLD", "bit", "-", "field", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1219/data.py#L113-L126
train
securestate/termineter
lib/c1219/data.py
get_table_idcb_field
def get_table_idcb_field(endianess, data): """ Return data from a packed TABLE_IDC_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg, proc_flag, flag1, f...
python
def get_table_idcb_field(endianess, data): """ Return data from a packed TABLE_IDC_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg, proc_flag, flag1, f...
[ "def", "get_table_idcb_field", "(", "endianess", ",", "data", ")", ":", "bfld", "=", "struct", ".", "unpack", "(", "endianess", "+", "'H'", ",", "data", "[", ":", "2", "]", ")", "[", "0", "]", "proc_nbr", "=", "bfld", "&", "2047", "std_vs_mfg", "=", ...
Return data from a packed TABLE_IDC_BFLD bit-field. :param str endianess: The endianess to use when packing values ('>' or '<') :param str data: The packed and machine-formatted data to parse :rtype: tuple :return: Tuple of (proc_nbr, std_vs_mfg, proc_flag, flag1, flag2, flag3)
[ "Return", "data", "from", "a", "packed", "TABLE_IDC_BFLD", "bit", "-", "field", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1219/data.py#L128-L144
train
securestate/termineter
lib/termineter/utilities.py
unique
def unique(seq, idfunc=None): """ Unique a list or tuple and preserve the order @type idfunc: Function or None @param idfunc: If idfunc is provided it will be called during the comparison process. """ if idfunc is None: idfunc = lambda x: x preserved_type = type(seq) seen = {} result = [] for item in seq:...
python
def unique(seq, idfunc=None): """ Unique a list or tuple and preserve the order @type idfunc: Function or None @param idfunc: If idfunc is provided it will be called during the comparison process. """ if idfunc is None: idfunc = lambda x: x preserved_type = type(seq) seen = {} result = [] for item in seq:...
[ "def", "unique", "(", "seq", ",", "idfunc", "=", "None", ")", ":", "if", "idfunc", "is", "None", ":", "idfunc", "=", "lambda", "x", ":", "x", "preserved_type", "=", "type", "(", "seq", ")", "seen", "=", "{", "}", "result", "=", "[", "]", "for", ...
Unique a list or tuple and preserve the order @type idfunc: Function or None @param idfunc: If idfunc is provided it will be called during the comparison process.
[ "Unique", "a", "list", "or", "tuple", "and", "preserve", "the", "order" ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/utilities.py#L63-L82
train
securestate/termineter
lib/termineter/interface.py
InteractiveInterpreter.do_ipy
def do_ipy(self, args): """Start an interactive Python interpreter""" import c1218.data import c1219.data from c1219.access.general import C1219GeneralAccess from c1219.access.security import C1219SecurityAccess from c1219.access.log import C1219LogAccess from c1219.access.telephone import C1219TelephoneA...
python
def do_ipy(self, args): """Start an interactive Python interpreter""" import c1218.data import c1219.data from c1219.access.general import C1219GeneralAccess from c1219.access.security import C1219SecurityAccess from c1219.access.log import C1219LogAccess from c1219.access.telephone import C1219TelephoneA...
[ "def", "do_ipy", "(", "self", ",", "args", ")", ":", "import", "c1218", ".", "data", "import", "c1219", ".", "data", "from", "c1219", ".", "access", ".", "general", "import", "C1219GeneralAccess", "from", "c1219", ".", "access", ".", "security", "import", ...
Start an interactive Python interpreter
[ "Start", "an", "interactive", "Python", "interpreter" ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/interface.py#L308-L355
train
securestate/termineter
lib/termineter/interface.py
InteractiveInterpreter.do_reload
def do_reload(self, args): """Reload a module in to the framework""" if args.module is not None: if args.module not in self.frmwk.modules: self.print_error('Invalid Module Selected.') return module = self.frmwk.modules[args.module] elif self.frmwk.current_module: module = self.frmwk.current_modul...
python
def do_reload(self, args): """Reload a module in to the framework""" if args.module is not None: if args.module not in self.frmwk.modules: self.print_error('Invalid Module Selected.') return module = self.frmwk.modules[args.module] elif self.frmwk.current_module: module = self.frmwk.current_modul...
[ "def", "do_reload", "(", "self", ",", "args", ")", ":", "if", "args", ".", "module", "is", "not", "None", ":", "if", "args", ".", "module", "not", "in", "self", ".", "frmwk", ".", "modules", ":", "self", ".", "print_error", "(", "'Invalid Module Select...
Reload a module in to the framework
[ "Reload", "a", "module", "in", "to", "the", "framework" ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/interface.py#L428-L440
train
securestate/termineter
lib/c1218/connection.py
ConnectionBase.send
def send(self, data): """ This sends a raw C12.18 frame and waits checks for an ACK response. In the event that a NACK is received, this function will attempt to resend the frame up to 3 times. :param data: the data to be transmitted :type data: str, :py:class:`~c1218.data.C1218Packet` """ if not isins...
python
def send(self, data): """ This sends a raw C12.18 frame and waits checks for an ACK response. In the event that a NACK is received, this function will attempt to resend the frame up to 3 times. :param data: the data to be transmitted :type data: str, :py:class:`~c1218.data.C1218Packet` """ if not isins...
[ "def", "send", "(", "self", ",", "data", ")", ":", "if", "not", "isinstance", "(", "data", ",", "C1218Packet", ")", ":", "data", "=", "C1218Packet", "(", "data", ")", "if", "self", ".", "toggle_control", ":", "# bit wise, fuck yeah", "if", "self", ".", ...
This sends a raw C12.18 frame and waits checks for an ACK response. In the event that a NACK is received, this function will attempt to resend the frame up to 3 times. :param data: the data to be transmitted :type data: str, :py:class:`~c1218.data.C1218Packet`
[ "This", "sends", "a", "raw", "C12", ".", "18", "frame", "and", "waits", "checks", "for", "an", "ACK", "response", ".", "In", "the", "event", "that", "a", "NACK", "is", "received", "this", "function", "will", "attempt", "to", "resend", "the", "frame", "...
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L120-L157
train
securestate/termineter
lib/c1218/connection.py
ConnectionBase.recv
def recv(self, full_frame=False): """ Receive a C1218Packet, the payload data is returned. :param bool full_frame: If set to True, the entire C1218 frame is returned instead of just the payload. """ payloadbuffer = b'' tries = 3 while tries: tmpbuffer = self.serial_h.read(1) if tmpbuffer != b'\...
python
def recv(self, full_frame=False): """ Receive a C1218Packet, the payload data is returned. :param bool full_frame: If set to True, the entire C1218 frame is returned instead of just the payload. """ payloadbuffer = b'' tries = 3 while tries: tmpbuffer = self.serial_h.read(1) if tmpbuffer != b'\...
[ "def", "recv", "(", "self", ",", "full_frame", "=", "False", ")", ":", "payloadbuffer", "=", "b''", "tries", "=", "3", "while", "tries", ":", "tmpbuffer", "=", "self", ".", "serial_h", ".", "read", "(", "1", ")", "if", "tmpbuffer", "!=", "b'\\xee'", ...
Receive a C1218Packet, the payload data is returned. :param bool full_frame: If set to True, the entire C1218 frame is returned instead of just the payload.
[ "Receive", "a", "C1218Packet", "the", "payload", "data", "is", "returned", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L159-L198
train
securestate/termineter
lib/c1218/connection.py
ConnectionBase.read
def read(self, size): """ Read raw data from the serial connection. This function is not meant to be called directly. :param int size: The number of bytes to read from the serial connection. """ data = self.serial_h.read(size) self.logger.debug('read data, length: ' + str(len(data)) + ' data: ' + binasci...
python
def read(self, size): """ Read raw data from the serial connection. This function is not meant to be called directly. :param int size: The number of bytes to read from the serial connection. """ data = self.serial_h.read(size) self.logger.debug('read data, length: ' + str(len(data)) + ' data: ' + binasci...
[ "def", "read", "(", "self", ",", "size", ")", ":", "data", "=", "self", ".", "serial_h", ".", "read", "(", "size", ")", "self", ".", "logger", ".", "debug", "(", "'read data, length: '", "+", "str", "(", "len", "(", "data", ")", ")", "+", "' data: ...
Read raw data from the serial connection. This function is not meant to be called directly. :param int size: The number of bytes to read from the serial connection.
[ "Read", "raw", "data", "from", "the", "serial", "connection", ".", "This", "function", "is", "not", "meant", "to", "be", "called", "directly", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L210-L222
train
securestate/termineter
lib/c1218/connection.py
ConnectionBase.close
def close(self): """ Send a terminate request and then disconnect from the serial device. """ if self._initialized: self.stop() self.logged_in = False return self.serial_h.close()
python
def close(self): """ Send a terminate request and then disconnect from the serial device. """ if self._initialized: self.stop() self.logged_in = False return self.serial_h.close()
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_initialized", ":", "self", ".", "stop", "(", ")", "self", ".", "logged_in", "=", "False", "return", "self", ".", "serial_h", ".", "close", "(", ")" ]
Send a terminate request and then disconnect from the serial device.
[ "Send", "a", "terminate", "request", "and", "then", "disconnect", "from", "the", "serial", "device", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L224-L231
train
securestate/termineter
lib/c1218/connection.py
Connection.start
def start(self): """ Send an identity request and then a negotiation request. """ self.serial_h.flushOutput() self.serial_h.flushInput() self.send(C1218IdentRequest()) data = self.recv() if data[0] != 0x00: self.logger.error('received incorrect response to identification service request') return F...
python
def start(self): """ Send an identity request and then a negotiation request. """ self.serial_h.flushOutput() self.serial_h.flushInput() self.send(C1218IdentRequest()) data = self.recv() if data[0] != 0x00: self.logger.error('received incorrect response to identification service request') return F...
[ "def", "start", "(", "self", ")", ":", "self", ".", "serial_h", ".", "flushOutput", "(", ")", "self", ".", "serial_h", ".", "flushInput", "(", ")", "self", ".", "send", "(", "C1218IdentRequest", "(", ")", ")", "data", "=", "self", ".", "recv", "(", ...
Send an identity request and then a negotiation request.
[ "Send", "an", "identity", "request", "and", "then", "a", "negotiation", "request", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L278-L297
train
securestate/termineter
lib/c1218/connection.py
Connection.stop
def stop(self, force=False): """ Send a terminate request. :param bool force: ignore the remote devices response """ if self._initialized: self.send(C1218TerminateRequest()) data = self.recv() if data == b'\x00' or force: self._initialized = False self._toggle_bit = False return True r...
python
def stop(self, force=False): """ Send a terminate request. :param bool force: ignore the remote devices response """ if self._initialized: self.send(C1218TerminateRequest()) data = self.recv() if data == b'\x00' or force: self._initialized = False self._toggle_bit = False return True r...
[ "def", "stop", "(", "self", ",", "force", "=", "False", ")", ":", "if", "self", ".", "_initialized", ":", "self", ".", "send", "(", "C1218TerminateRequest", "(", ")", ")", "data", "=", "self", ".", "recv", "(", ")", "if", "data", "==", "b'\\x00'", ...
Send a terminate request. :param bool force: ignore the remote devices response
[ "Send", "a", "terminate", "request", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L299-L312
train
securestate/termineter
lib/c1218/connection.py
Connection.login
def login(self, username='0000', userid=0, password=None): """ Log into the connected device. :param str username: the username to log in with (len(username) <= 10) :param int userid: the userid to log in with (0x0000 <= userid <= 0xffff) :param str password: password to log in with (len(password) <= 20) :...
python
def login(self, username='0000', userid=0, password=None): """ Log into the connected device. :param str username: the username to log in with (len(username) <= 10) :param int userid: the userid to log in with (0x0000 <= userid <= 0xffff) :param str password: password to log in with (len(password) <= 20) :...
[ "def", "login", "(", "self", ",", "username", "=", "'0000'", ",", "userid", "=", "0", ",", "password", "=", "None", ")", ":", "if", "password", "and", "len", "(", "password", ")", ">", "20", ":", "self", ".", "logger", ".", "error", "(", "'password...
Log into the connected device. :param str username: the username to log in with (len(username) <= 10) :param int userid: the userid to log in with (0x0000 <= userid <= 0xffff) :param str password: password to log in with (len(password) <= 20) :rtype: bool
[ "Log", "into", "the", "connected", "device", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L314-L341
train
securestate/termineter
lib/c1218/connection.py
Connection.logoff
def logoff(self): """ Send a logoff request. :rtype: bool """ self.send(C1218LogoffRequest()) data = self.recv() if data == b'\x00': self._initialized = False return True return False
python
def logoff(self): """ Send a logoff request. :rtype: bool """ self.send(C1218LogoffRequest()) data = self.recv() if data == b'\x00': self._initialized = False return True return False
[ "def", "logoff", "(", "self", ")", ":", "self", ".", "send", "(", "C1218LogoffRequest", "(", ")", ")", "data", "=", "self", ".", "recv", "(", ")", "if", "data", "==", "b'\\x00'", ":", "self", ".", "_initialized", "=", "False", "return", "True", "retu...
Send a logoff request. :rtype: bool
[ "Send", "a", "logoff", "request", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L343-L354
train
securestate/termineter
lib/c1218/connection.py
Connection.get_table_data
def get_table_data(self, tableid, octetcount=None, offset=None): """ Read data from a table. If successful, all of the data from the requested table will be returned. :param int tableid: The table number to read from (0x0000 <= tableid <= 0xffff) :param int octetcount: Limit the amount of data read, only wor...
python
def get_table_data(self, tableid, octetcount=None, offset=None): """ Read data from a table. If successful, all of the data from the requested table will be returned. :param int tableid: The table number to read from (0x0000 <= tableid <= 0xffff) :param int octetcount: Limit the amount of data read, only wor...
[ "def", "get_table_data", "(", "self", ",", "tableid", ",", "octetcount", "=", "None", ",", "offset", "=", "None", ")", ":", "if", "self", ".", "caching_enabled", "and", "tableid", "in", "self", ".", "_cacheable_tables", "and", "tableid", "in", "self", ".",...
Read data from a table. If successful, all of the data from the requested table will be returned. :param int tableid: The table number to read from (0x0000 <= tableid <= 0xffff) :param int octetcount: Limit the amount of data read, only works if the meter supports this type of reading. :param int offset: T...
[ "Read", "data", "from", "a", "table", ".", "If", "successful", "all", "of", "the", "data", "from", "the", "requested", "table", "will", "be", "returned", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L356-L396
train
securestate/termineter
lib/c1218/connection.py
Connection.set_table_data
def set_table_data(self, tableid, data, offset=None): """ Write data to a table. :param int tableid: The table number to write to (0x0000 <= tableid <= 0xffff) :param str data: The data to write into the table. :param int offset: The offset at which to start to write the data (0x000000 <= octetcount <= 0xfff...
python
def set_table_data(self, tableid, data, offset=None): """ Write data to a table. :param int tableid: The table number to write to (0x0000 <= tableid <= 0xffff) :param str data: The data to write into the table. :param int offset: The offset at which to start to write the data (0x000000 <= octetcount <= 0xfff...
[ "def", "set_table_data", "(", "self", ",", "tableid", ",", "data", ",", "offset", "=", "None", ")", ":", "self", ".", "send", "(", "C1218WriteRequest", "(", "tableid", ",", "data", ",", "offset", ")", ")", "data", "=", "self", ".", "recv", "(", ")", ...
Write data to a table. :param int tableid: The table number to write to (0x0000 <= tableid <= 0xffff) :param str data: The data to write into the table. :param int offset: The offset at which to start to write the data (0x000000 <= octetcount <= 0xffffff).
[ "Write", "data", "to", "a", "table", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L398-L413
train
securestate/termineter
lib/c1218/connection.py
Connection.run_procedure
def run_procedure(self, process_number, std_vs_mfg, params=''): """ Initiate a C1219 procedure, the request is written to table 7 and the response is read from table 8. :param int process_number: The numeric procedure identifier (0 <= process_number <= 2047). :param bool std_vs_mfg: Whether the procedure is ...
python
def run_procedure(self, process_number, std_vs_mfg, params=''): """ Initiate a C1219 procedure, the request is written to table 7 and the response is read from table 8. :param int process_number: The numeric procedure identifier (0 <= process_number <= 2047). :param bool std_vs_mfg: Whether the procedure is ...
[ "def", "run_procedure", "(", "self", ",", "process_number", ",", "std_vs_mfg", ",", "params", "=", "''", ")", ":", "seqnum", "=", "random", ".", "randint", "(", "2", ",", "254", ")", "self", ".", "logger", ".", "info", "(", "'starting procedure: '", "+",...
Initiate a C1219 procedure, the request is written to table 7 and the response is read from table 8. :param int process_number: The numeric procedure identifier (0 <= process_number <= 2047). :param bool std_vs_mfg: Whether the procedure is manufacturer specified or not. True is manufacturer specified. :pa...
[ "Initiate", "a", "C1219", "procedure", "the", "request", "is", "written", "to", "table", "7", "and", "the", "response", "is", "read", "from", "table", "8", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/c1218/connection.py#L415-L437
train
securestate/termineter
lib/termineter/options.py
Options.add_string
def add_string(self, name, help, required=True, default=None): """ Add a new option with a type of String. :param str name: The name of the option, how it will be referenced. :param str help: The string returned as help to describe how the option is used. :param bool required: Whether to require that this op...
python
def add_string(self, name, help, required=True, default=None): """ Add a new option with a type of String. :param str name: The name of the option, how it will be referenced. :param str help: The string returned as help to describe how the option is used. :param bool required: Whether to require that this op...
[ "def", "add_string", "(", "self", ",", "name", ",", "help", ",", "required", "=", "True", ",", "default", "=", "None", ")", ":", "self", ".", "_options", "[", "name", "]", "=", "Option", "(", "name", ",", "'str'", ",", "help", ",", "required", ",",...
Add a new option with a type of String. :param str name: The name of the option, how it will be referenced. :param str help: The string returned as help to describe how the option is used. :param bool required: Whether to require that this option be set or not. :param str default: The default value for this op...
[ "Add", "a", "new", "option", "with", "a", "type", "of", "String", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/options.py#L80-L89
train
securestate/termineter
lib/termineter/options.py
Options.set_option_value
def set_option_value(self, name, value): """ Set an option's value. :param str name: The name of the option to set the value for. :param str value: The value to set the option to, it will be converted from a string. :return: The previous value for the specified option. """ option = self.get_option(name) ...
python
def set_option_value(self, name, value): """ Set an option's value. :param str name: The name of the option to set the value for. :param str value: The value to set the option to, it will be converted from a string. :return: The previous value for the specified option. """ option = self.get_option(name) ...
[ "def", "set_option_value", "(", "self", ",", "name", ",", "value", ")", ":", "option", "=", "self", ".", "get_option", "(", "name", ")", "old_value", "=", "option", ".", "value", "if", "option", ".", "type", "in", "(", "'str'", ",", "'rfile'", ")", "...
Set an option's value. :param str name: The name of the option to set the value for. :param str value: The value to set the option to, it will be converted from a string. :return: The previous value for the specified option.
[ "Set", "an", "option", "s", "value", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/options.py#L153-L191
train
securestate/termineter
lib/termineter/options.py
Options.get_missing_options
def get_missing_options(self): """ Get a list of options that are required, but with default values of None. """ return [option.name for option in self._options.values() if option.required and option.value is None]
python
def get_missing_options(self): """ Get a list of options that are required, but with default values of None. """ return [option.name for option in self._options.values() if option.required and option.value is None]
[ "def", "get_missing_options", "(", "self", ")", ":", "return", "[", "option", ".", "name", "for", "option", "in", "self", ".", "_options", ".", "values", "(", ")", "if", "option", ".", "required", "and", "option", ".", "value", "is", "None", "]" ]
Get a list of options that are required, but with default values of None.
[ "Get", "a", "list", "of", "options", "that", "are", "required", "but", "with", "default", "values", "of", "None", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/options.py#L193-L198
train
securestate/termineter
lib/termineter/__init__.py
get_revision
def get_revision(): """ Retrieve the current git revision identifier. If the git binary can not be found or the repository information is unavailable, None will be returned. :return: The git revision tag if it's available. :rtype: str """ git_bin = smoke_zephyr.utilities.which('git') if not git_bin: return N...
python
def get_revision(): """ Retrieve the current git revision identifier. If the git binary can not be found or the repository information is unavailable, None will be returned. :return: The git revision tag if it's available. :rtype: str """ git_bin = smoke_zephyr.utilities.which('git') if not git_bin: return N...
[ "def", "get_revision", "(", ")", ":", "git_bin", "=", "smoke_zephyr", ".", "utilities", ".", "which", "(", "'git'", ")", "if", "not", "git_bin", ":", "return", "None", "proc_h", "=", "subprocess", ".", "Popen", "(", "(", "git_bin", ",", "'rev-parse'", ",...
Retrieve the current git revision identifier. If the git binary can not be found or the repository information is unavailable, None will be returned. :return: The git revision tag if it's available. :rtype: str
[ "Retrieve", "the", "current", "git", "revision", "identifier", ".", "If", "the", "git", "binary", "can", "not", "be", "found", "or", "the", "repository", "information", "is", "unavailable", "None", "will", "be", "returned", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/__init__.py#L42-L64
train
securestate/termineter
lib/termineter/core.py
Framework.reload_module
def reload_module(self, module_path=None): """ Reloads a module into the framework. If module_path is not specified, then the current_module variable is used. Returns True on success, False on error. @type module_path: String @param module_path: The name of the module to reload """ if module_path is ...
python
def reload_module(self, module_path=None): """ Reloads a module into the framework. If module_path is not specified, then the current_module variable is used. Returns True on success, False on error. @type module_path: String @param module_path: The name of the module to reload """ if module_path is ...
[ "def", "reload_module", "(", "self", ",", "module_path", "=", "None", ")", ":", "if", "module_path", "is", "None", ":", "if", "self", ".", "current_module", "is", "not", "None", ":", "module_path", "=", "self", ".", "current_module", ".", "name", "else", ...
Reloads a module into the framework. If module_path is not specified, then the current_module variable is used. Returns True on success, False on error. @type module_path: String @param module_path: The name of the module to reload
[ "Reloads", "a", "module", "into", "the", "framework", ".", "If", "module_path", "is", "not", "specified", "then", "the", "current_module", "variable", "is", "used", ".", "Returns", "True", "on", "success", "False", "on", "error", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L168-L204
train
securestate/termineter
lib/termineter/core.py
Framework.serial_disconnect
def serial_disconnect(self): """ Closes the serial connection to the meter and disconnects from the device. """ if self._serial_connected: try: self.serial_connection.close() except c1218.errors.C1218IOError as error: self.logger.error('caught C1218IOError: ' + str(error)) except serial.seria...
python
def serial_disconnect(self): """ Closes the serial connection to the meter and disconnects from the device. """ if self._serial_connected: try: self.serial_connection.close() except c1218.errors.C1218IOError as error: self.logger.error('caught C1218IOError: ' + str(error)) except serial.seria...
[ "def", "serial_disconnect", "(", "self", ")", ":", "if", "self", ".", "_serial_connected", ":", "try", ":", "self", ".", "serial_connection", ".", "close", "(", ")", "except", "c1218", ".", "errors", ".", "C1218IOError", "as", "error", ":", "self", ".", ...
Closes the serial connection to the meter and disconnects from the device.
[ "Closes", "the", "serial", "connection", "to", "the", "meter", "and", "disconnects", "from", "the", "device", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L324-L338
train
securestate/termineter
lib/termineter/core.py
Framework.serial_get
def serial_get(self): """ Create the serial connection from the framework settings and return it, setting the framework instance in the process. """ frmwk_c1218_settings = { 'nbrpkts': self.advanced_options['C1218_MAX_PACKETS'], 'pktsize': self.advanced_options['C1218_PACKET_SIZE'] } frmwk_serial_s...
python
def serial_get(self): """ Create the serial connection from the framework settings and return it, setting the framework instance in the process. """ frmwk_c1218_settings = { 'nbrpkts': self.advanced_options['C1218_MAX_PACKETS'], 'pktsize': self.advanced_options['C1218_PACKET_SIZE'] } frmwk_serial_s...
[ "def", "serial_get", "(", "self", ")", ":", "frmwk_c1218_settings", "=", "{", "'nbrpkts'", ":", "self", ".", "advanced_options", "[", "'C1218_MAX_PACKETS'", "]", ",", "'pktsize'", ":", "self", ".", "advanced_options", "[", "'C1218_PACKET_SIZE'", "]", "}", "frmwk...
Create the serial connection from the framework settings and return it, setting the framework instance in the process.
[ "Create", "the", "serial", "connection", "from", "the", "framework", "settings", "and", "return", "it", "setting", "the", "framework", "instance", "in", "the", "process", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L340-L361
train
securestate/termineter
lib/termineter/core.py
Framework.serial_connect
def serial_connect(self): """ Connect to the serial device. """ self.serial_get() try: self.serial_connection.start() except c1218.errors.C1218IOError as error: self.logger.error('serial connection has been opened but the meter is unresponsive') raise error self._serial_connected = True return ...
python
def serial_connect(self): """ Connect to the serial device. """ self.serial_get() try: self.serial_connection.start() except c1218.errors.C1218IOError as error: self.logger.error('serial connection has been opened but the meter is unresponsive') raise error self._serial_connected = True return ...
[ "def", "serial_connect", "(", "self", ")", ":", "self", ".", "serial_get", "(", ")", "try", ":", "self", ".", "serial_connection", ".", "start", "(", ")", "except", "c1218", ".", "errors", ".", "C1218IOError", "as", "error", ":", "self", ".", "logger", ...
Connect to the serial device.
[ "Connect", "to", "the", "serial", "device", "." ]
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L363-L374
train
securestate/termineter
lib/termineter/core.py
Framework.serial_login
def serial_login(self): """ Attempt to log into the meter over the C12.18 protocol. Returns True on success, False on a failure. This can be called by modules in order to login with a username and password configured within the framework instance. """ if not self._serial_connected: raise termineter.errors....
python
def serial_login(self): """ Attempt to log into the meter over the C12.18 protocol. Returns True on success, False on a failure. This can be called by modules in order to login with a username and password configured within the framework instance. """ if not self._serial_connected: raise termineter.errors....
[ "def", "serial_login", "(", "self", ")", ":", "if", "not", "self", ".", "_serial_connected", ":", "raise", "termineter", ".", "errors", ".", "FrameworkRuntimeError", "(", "'the serial interface is disconnected'", ")", "username", "=", "self", ".", "options", "[", ...
Attempt to log into the meter over the C12.18 protocol. Returns True on success, False on a failure. This can be called by modules in order to login with a username and password configured within the framework instance.
[ "Attempt", "to", "log", "into", "the", "meter", "over", "the", "C12", ".", "18", "protocol", ".", "Returns", "True", "on", "success", "False", "on", "a", "failure", ".", "This", "can", "be", "called", "by", "modules", "in", "order", "to", "login", "wit...
d657d25d97c7739e650b951c396404e857e56625
https://github.com/securestate/termineter/blob/d657d25d97c7739e650b951c396404e857e56625/lib/termineter/core.py#L376-L405
train
MasoniteFramework/masonite
databases/seeds/user_table_seeder.py
UserTableSeeder.run
def run(self): """ Run the database seeds. """ self.factory.register(User, self.users_factory) self.factory(User, 50).create()
python
def run(self): """ Run the database seeds. """ self.factory.register(User, self.users_factory) self.factory(User, 50).create()
[ "def", "run", "(", "self", ")", ":", "self", ".", "factory", ".", "register", "(", "User", ",", "self", ".", "users_factory", ")", "self", ".", "factory", "(", "User", ",", "50", ")", ".", "create", "(", ")" ]
Run the database seeds.
[ "Run", "the", "database", "seeds", "." ]
c9bcca8f59169934c2accd8cecb2b996bb5e1a0d
https://github.com/MasoniteFramework/masonite/blob/c9bcca8f59169934c2accd8cecb2b996bb5e1a0d/databases/seeds/user_table_seeder.py#L18-L24
train
MasoniteFramework/masonite
bootstrap/start.py
app
def app(environ, start_response): """The WSGI Application Server. Arguments: environ {dict} -- The WSGI environ dictionary start_response {WSGI callable} Returns: WSGI Response """ from wsgi import container """Add Environ To Service Container Add the environ to th...
python
def app(environ, start_response): """The WSGI Application Server. Arguments: environ {dict} -- The WSGI environ dictionary start_response {WSGI callable} Returns: WSGI Response """ from wsgi import container """Add Environ To Service Container Add the environ to th...
[ "def", "app", "(", "environ", ",", "start_response", ")", ":", "from", "wsgi", "import", "container", "\"\"\"Add Environ To Service Container\n Add the environ to the service container. The environ is generated by the\n the WSGI server above and used by a service provider to manipulate...
The WSGI Application Server. Arguments: environ {dict} -- The WSGI environ dictionary start_response {WSGI callable} Returns: WSGI Response
[ "The", "WSGI", "Application", "Server", "." ]
c9bcca8f59169934c2accd8cecb2b996bb5e1a0d
https://github.com/MasoniteFramework/masonite/blob/c9bcca8f59169934c2accd8cecb2b996bb5e1a0d/bootstrap/start.py#L12-L57
train
MasoniteFramework/masonite
databases/migrations/2018_01_09_043202_create_users_table.py
CreateUsersTable.up
def up(self): """Run the migrations.""" with self.schema.create('users') as table: table.increments('id') table.string('name') table.string('email').unique() table.string('password') table.string('remember_token').nullable() table.t...
python
def up(self): """Run the migrations.""" with self.schema.create('users') as table: table.increments('id') table.string('name') table.string('email').unique() table.string('password') table.string('remember_token').nullable() table.t...
[ "def", "up", "(", "self", ")", ":", "with", "self", ".", "schema", ".", "create", "(", "'users'", ")", "as", "table", ":", "table", ".", "increments", "(", "'id'", ")", "table", ".", "string", "(", "'name'", ")", "table", ".", "string", "(", "'emai...
Run the migrations.
[ "Run", "the", "migrations", "." ]
c9bcca8f59169934c2accd8cecb2b996bb5e1a0d
https://github.com/MasoniteFramework/masonite/blob/c9bcca8f59169934c2accd8cecb2b996bb5e1a0d/databases/migrations/2018_01_09_043202_create_users_table.py#L6-L15
train
MasoniteFramework/masonite
app/http/middleware/VerifyEmailMiddleware.py
VerifyEmailMiddleware.before
def before(self): """Run This Middleware Before The Route Executes.""" user = self.request.user() if user and user.verified_at is None: self.request.redirect('/email/verify')
python
def before(self): """Run This Middleware Before The Route Executes.""" user = self.request.user() if user and user.verified_at is None: self.request.redirect('/email/verify')
[ "def", "before", "(", "self", ")", ":", "user", "=", "self", ".", "request", ".", "user", "(", ")", "if", "user", "and", "user", ".", "verified_at", "is", "None", ":", "self", ".", "request", ".", "redirect", "(", "'/email/verify'", ")" ]
Run This Middleware Before The Route Executes.
[ "Run", "This", "Middleware", "Before", "The", "Route", "Executes", "." ]
c9bcca8f59169934c2accd8cecb2b996bb5e1a0d
https://github.com/MasoniteFramework/masonite/blob/c9bcca8f59169934c2accd8cecb2b996bb5e1a0d/app/http/middleware/VerifyEmailMiddleware.py#L17-L22
train
MasoniteFramework/masonite
app/http/controllers/WelcomeController.py
WelcomeController.show
def show(self, view: View, request: Request): """Show the welcome page. Arguments: view {masonite.view.View} -- The Masonite view class. Application {config.application} -- The application config module. Returns: masonite.view.View -- The Masonite view class...
python
def show(self, view: View, request: Request): """Show the welcome page. Arguments: view {masonite.view.View} -- The Masonite view class. Application {config.application} -- The application config module. Returns: masonite.view.View -- The Masonite view class...
[ "def", "show", "(", "self", ",", "view", ":", "View", ",", "request", ":", "Request", ")", ":", "return", "view", ".", "render", "(", "'welcome'", ",", "{", "'app'", ":", "request", ".", "app", "(", ")", ".", "make", "(", "'Application'", ")", "}",...
Show the welcome page. Arguments: view {masonite.view.View} -- The Masonite view class. Application {config.application} -- The application config module. Returns: masonite.view.View -- The Masonite view class.
[ "Show", "the", "welcome", "page", "." ]
c9bcca8f59169934c2accd8cecb2b996bb5e1a0d
https://github.com/MasoniteFramework/masonite/blob/c9bcca8f59169934c2accd8cecb2b996bb5e1a0d/app/http/controllers/WelcomeController.py#L10-L22
train
pybluez/pybluez
bluetooth/btcommon.py
is_valid_address
def is_valid_address (s): """ returns True if address is a valid Bluetooth address valid address are always strings of the form XX:XX:XX:XX:XX:XX where X is a hexadecimal character. For example, 01:23:45:67:89:AB is a valid address, but IN:VA:LI:DA:DD:RE is not """ try: ...
python
def is_valid_address (s): """ returns True if address is a valid Bluetooth address valid address are always strings of the form XX:XX:XX:XX:XX:XX where X is a hexadecimal character. For example, 01:23:45:67:89:AB is a valid address, but IN:VA:LI:DA:DD:RE is not """ try: ...
[ "def", "is_valid_address", "(", "s", ")", ":", "try", ":", "pairs", "=", "s", ".", "split", "(", "\":\"", ")", "if", "len", "(", "pairs", ")", "!=", "6", ":", "return", "False", "if", "not", "all", "(", "0", "<=", "int", "(", "b", ",", "16", ...
returns True if address is a valid Bluetooth address valid address are always strings of the form XX:XX:XX:XX:XX:XX where X is a hexadecimal character. For example, 01:23:45:67:89:AB is a valid address, but IN:VA:LI:DA:DD:RE is not
[ "returns", "True", "if", "address", "is", "a", "valid", "Bluetooth", "address" ]
e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9
https://github.com/pybluez/pybluez/blob/e0dc4093dcbaa3ecb3fa24f8ccf22bbfe6b57fc9/bluetooth/btcommon.py#L182-L197
train