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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
napalm-automation/napalm-logs | napalm_logs/device.py | NapalmLogsDeviceProc._publish | def _publish(self, obj):
'''
Publish the OC object.
'''
bin_obj = umsgpack.packb(obj)
self.pub.send(bin_obj) | python | def _publish(self, obj):
'''
Publish the OC object.
'''
bin_obj = umsgpack.packb(obj)
self.pub.send(bin_obj) | [
"def",
"_publish",
"(",
"self",
",",
"obj",
")",
":",
"bin_obj",
"=",
"umsgpack",
".",
"packb",
"(",
"obj",
")",
"self",
".",
"pub",
".",
"send",
"(",
"bin_obj",
")"
] | Publish the OC object. | [
"Publish",
"the",
"OC",
"object",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L202-L207 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc._handshake | def _handshake(self, conn, addr):
'''
Ensures that the client receives the AES key.
'''
# waiting for the magic request message
msg = conn.recv(len(MAGIC_REQ))
log.debug('Received message %s from %s', msg, addr)
if msg != MAGIC_REQ:
log.warning('%s is ... | python | def _handshake(self, conn, addr):
'''
Ensures that the client receives the AES key.
'''
# waiting for the magic request message
msg = conn.recv(len(MAGIC_REQ))
log.debug('Received message %s from %s', msg, addr)
if msg != MAGIC_REQ:
log.warning('%s is ... | [
"def",
"_handshake",
"(",
"self",
",",
"conn",
",",
"addr",
")",
":",
"msg",
"=",
"conn",
".",
"recv",
"(",
"len",
"(",
"MAGIC_REQ",
")",
")",
"log",
".",
"debug",
"(",
"'Received message %s from %s'",
",",
"msg",
",",
"addr",
")",
"if",
"msg",
"!=",... | Ensures that the client receives the AES key. | [
"Ensures",
"that",
"the",
"client",
"receives",
"the",
"AES",
"key",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L79-L104 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc.keep_alive | def keep_alive(self, conn):
'''
Maintains auth sessions
'''
while self.__up:
msg = conn.recv(len(AUTH_KEEP_ALIVE))
if msg != AUTH_KEEP_ALIVE:
log.error('Received something other than %s', AUTH_KEEP_ALIVE)
conn.close()
... | python | def keep_alive(self, conn):
'''
Maintains auth sessions
'''
while self.__up:
msg = conn.recv(len(AUTH_KEEP_ALIVE))
if msg != AUTH_KEEP_ALIVE:
log.error('Received something other than %s', AUTH_KEEP_ALIVE)
conn.close()
... | [
"def",
"keep_alive",
"(",
"self",
",",
"conn",
")",
":",
"while",
"self",
".",
"__up",
":",
"msg",
"=",
"conn",
".",
"recv",
"(",
"len",
"(",
"AUTH_KEEP_ALIVE",
")",
")",
"if",
"msg",
"!=",
"AUTH_KEEP_ALIVE",
":",
"log",
".",
"error",
"(",
"'Received... | Maintains auth sessions | [
"Maintains",
"auth",
"sessions"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L106-L121 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc.verify_cert | def verify_cert(self):
'''
Checks that the provided cert and key are valid and usable
'''
log.debug('Verifying the %s certificate, keyfile: %s',
self.certificate, self.keyfile)
try:
ssl.create_default_context().load_cert_chain(self.certificate, keyfi... | python | def verify_cert(self):
'''
Checks that the provided cert and key are valid and usable
'''
log.debug('Verifying the %s certificate, keyfile: %s',
self.certificate, self.keyfile)
try:
ssl.create_default_context().load_cert_chain(self.certificate, keyfi... | [
"def",
"verify_cert",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Verifying the %s certificate, keyfile: %s'",
",",
"self",
".",
"certificate",
",",
"self",
".",
"keyfile",
")",
"try",
":",
"ssl",
".",
"create_default_context",
"(",
")",
".",
"load_cert... | Checks that the provided cert and key are valid and usable | [
"Checks",
"that",
"the",
"provided",
"cert",
"and",
"key",
"are",
"valid",
"and",
"usable"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L123-L138 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc._create_skt | def _create_skt(self):
'''
Create the authentication socket.
'''
log.debug('Creating the auth socket')
if ':' in self.auth_address:
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
self.socket = socket.socket(socket.AF_INET, s... | python | def _create_skt(self):
'''
Create the authentication socket.
'''
log.debug('Creating the auth socket')
if ':' in self.auth_address:
self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
self.socket = socket.socket(socket.AF_INET, s... | [
"def",
"_create_skt",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Creating the auth socket'",
")",
"if",
"':'",
"in",
"self",
".",
"auth_address",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET6",
",",
"sock... | Create the authentication socket. | [
"Create",
"the",
"authentication",
"socket",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L140-L154 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc.start | def start(self):
'''
Listen to auth requests and send the AES key.
Each client connection starts a new thread.
'''
# Start suicide polling thread
log.debug('Starting the auth process')
self.verify_cert()
self._create_skt()
log.debug('The auth proce... | python | def start(self):
'''
Listen to auth requests and send the AES key.
Each client connection starts a new thread.
'''
# Start suicide polling thread
log.debug('Starting the auth process')
self.verify_cert()
self._create_skt()
log.debug('The auth proce... | [
"def",
"start",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Starting the auth process'",
")",
"self",
".",
"verify_cert",
"(",
")",
"self",
".",
"_create_skt",
"(",
")",
"log",
".",
"debug",
"(",
"'The auth process can receive at most %d parallel connection... | Listen to auth requests and send the AES key.
Each client connection starts a new thread. | [
"Listen",
"to",
"auth",
"requests",
"and",
"send",
"the",
"AES",
"key",
".",
"Each",
"client",
"connection",
"starts",
"a",
"new",
"thread",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L156-L192 | train |
napalm-automation/napalm-logs | napalm_logs/auth.py | NapalmLogsAuthProc.stop | def stop(self):
'''
Stop the auth proc.
'''
log.info('Stopping auth process')
self.__up = False
self.socket.close() | python | def stop(self):
'''
Stop the auth proc.
'''
log.info('Stopping auth process')
self.__up = False
self.socket.close() | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Stopping auth process'",
")",
"self",
".",
"__up",
"=",
"False",
"self",
".",
"socket",
".",
"close",
"(",
")"
] | Stop the auth proc. | [
"Stop",
"the",
"auth",
"proc",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L194-L200 | train |
napalm-automation/napalm-logs | napalm_logs/listener/kafka.py | KafkaListener.start | def start(self):
'''
Startup the kafka consumer.
'''
log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s',
self.bootstrap_servers,
self.group_id)
try:
self.consumer = kafka.KafkaConsumer(bootstrap_s... | python | def start(self):
'''
Startup the kafka consumer.
'''
log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s',
self.bootstrap_servers,
self.group_id)
try:
self.consumer = kafka.KafkaConsumer(bootstrap_s... | [
"def",
"start",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Creating the consumer using the bootstrap servers: %s and the group ID: %s'",
",",
"self",
".",
"bootstrap_servers",
",",
"self",
".",
"group_id",
")",
"try",
":",
"self",
".",
"consumer",
"=",
"ka... | Startup the kafka consumer. | [
"Startup",
"the",
"kafka",
"consumer",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/kafka.py#L41-L55 | train |
napalm-automation/napalm-logs | napalm_logs/listener/kafka.py | KafkaListener.stop | def stop(self):
'''
Shutdown kafka consumer.
'''
log.info('Stopping te kafka listener class')
self.consumer.unsubscribe()
self.consumer.close() | python | def stop(self):
'''
Shutdown kafka consumer.
'''
log.info('Stopping te kafka listener class')
self.consumer.unsubscribe()
self.consumer.close() | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Stopping te kafka listener class'",
")",
"self",
".",
"consumer",
".",
"unsubscribe",
"(",
")",
"self",
".",
"consumer",
".",
"close",
"(",
")"
] | Shutdown kafka consumer. | [
"Shutdown",
"kafka",
"consumer",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/kafka.py#L76-L82 | train |
napalm-automation/napalm-logs | napalm_logs/transport/__init__.py | get_transport | def get_transport(name):
'''
Return the transport class.
'''
try:
log.debug('Using %s as transport', name)
return TRANSPORT_LOOKUP[name]
except KeyError:
msg = 'Transport {} is not available. Are the dependencies installed?'.format(name)
log.error(msg, exc_info=True)
... | python | def get_transport(name):
'''
Return the transport class.
'''
try:
log.debug('Using %s as transport', name)
return TRANSPORT_LOOKUP[name]
except KeyError:
msg = 'Transport {} is not available. Are the dependencies installed?'.format(name)
log.error(msg, exc_info=True)
... | [
"def",
"get_transport",
"(",
"name",
")",
":",
"try",
":",
"log",
".",
"debug",
"(",
"'Using %s as transport'",
",",
"name",
")",
"return",
"TRANSPORT_LOOKUP",
"[",
"name",
"]",
"except",
"KeyError",
":",
"msg",
"=",
"'Transport {} is not available. Are the depend... | Return the transport class. | [
"Return",
"the",
"transport",
"class",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/transport/__init__.py#L50-L60 | train |
napalm-automation/napalm-logs | napalm_logs/listener/zeromq.py | ZMQListener.start | def start(self):
'''
Startup the zmq consumer.
'''
zmq_uri = '{protocol}://{address}:{port}'.format(
protocol=self.protocol,
address=self.address,
port=self.port
) if self.port else\
... | python | def start(self):
'''
Startup the zmq consumer.
'''
zmq_uri = '{protocol}://{address}:{port}'.format(
protocol=self.protocol,
address=self.address,
port=self.port
) if self.port else\
... | [
"def",
"start",
"(",
"self",
")",
":",
"zmq_uri",
"=",
"'{protocol}://{address}:{port}'",
".",
"format",
"(",
"protocol",
"=",
"self",
".",
"protocol",
",",
"address",
"=",
"self",
".",
"address",
",",
"port",
"=",
"self",
".",
"port",
")",
"if",
"self",... | Startup the zmq consumer. | [
"Startup",
"the",
"zmq",
"consumer",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L45-L82 | train |
napalm-automation/napalm-logs | napalm_logs/listener/zeromq.py | ZMQListener.receive | def receive(self):
'''
Return the message received.
..note::
In ZMQ we are unable to get the address where we got the message from.
'''
try:
msg = self.sub.recv()
except zmq.Again as error:
log.error('Unable to receive messages: %s', e... | python | def receive(self):
'''
Return the message received.
..note::
In ZMQ we are unable to get the address where we got the message from.
'''
try:
msg = self.sub.recv()
except zmq.Again as error:
log.error('Unable to receive messages: %s', e... | [
"def",
"receive",
"(",
"self",
")",
":",
"try",
":",
"msg",
"=",
"self",
".",
"sub",
".",
"recv",
"(",
")",
"except",
"zmq",
".",
"Again",
"as",
"error",
":",
"log",
".",
"error",
"(",
"'Unable to receive messages: %s'",
",",
"error",
",",
"exc_info",
... | Return the message received.
..note::
In ZMQ we are unable to get the address where we got the message from. | [
"Return",
"the",
"message",
"received",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L84-L97 | train |
napalm-automation/napalm-logs | napalm_logs/listener/zeromq.py | ZMQListener.stop | def stop(self):
'''
Shutdown zmq listener.
'''
log.info('Stopping the zmq listener class')
self.sub.close()
self.ctx.term() | python | def stop(self):
'''
Shutdown zmq listener.
'''
log.info('Stopping the zmq listener class')
self.sub.close()
self.ctx.term() | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Stopping the zmq listener class'",
")",
"self",
".",
"sub",
".",
"close",
"(",
")",
"self",
".",
"ctx",
".",
"term",
"(",
")"
] | Shutdown zmq listener. | [
"Shutdown",
"zmq",
"listener",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L99-L105 | train |
napalm-automation/napalm-logs | napalm_logs/listener/udp.py | UDPListener.start | def start(self):
'''
Create the UDP listener socket.
'''
if ':' in self.address:
self.skt = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
else:
self.skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
if self.reuse_port:
self.skt... | python | def start(self):
'''
Create the UDP listener socket.
'''
if ':' in self.address:
self.skt = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
else:
self.skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
if self.reuse_port:
self.skt... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"':'",
"in",
"self",
".",
"address",
":",
"self",
".",
"skt",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET6",
",",
"socket",
".",
"SOCK_DGRAM",
")",
"else",
":",
"self",
".",
"skt",
"=",
... | Create the UDP listener socket. | [
"Create",
"the",
"UDP",
"listener",
"socket",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/udp.py#L43-L62 | train |
napalm-automation/napalm-logs | napalm_logs/proc.py | NapalmLogsProc._suicide_when_without_parent | def _suicide_when_without_parent(self, parent_pid):
'''
Kill this process when the parent died.
'''
while True:
time.sleep(5)
try:
# Check pid alive
os.kill(parent_pid, 0)
except OSError:
# Forcibly exit
... | python | def _suicide_when_without_parent(self, parent_pid):
'''
Kill this process when the parent died.
'''
while True:
time.sleep(5)
try:
# Check pid alive
os.kill(parent_pid, 0)
except OSError:
# Forcibly exit
... | [
"def",
"_suicide_when_without_parent",
"(",
"self",
",",
"parent_pid",
")",
":",
"while",
"True",
":",
"time",
".",
"sleep",
"(",
"5",
")",
"try",
":",
"os",
".",
"kill",
"(",
"parent_pid",
",",
"0",
")",
"except",
"OSError",
":",
"self",
".",
"stop",
... | Kill this process when the parent died. | [
"Kill",
"this",
"process",
"when",
"the",
"parent",
"died",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/proc.py#L20-L34 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._setup_buffer | def _setup_buffer(self):
'''
Setup the buffer subsystem.
'''
if not self._buffer_cfg or not isinstance(self._buffer_cfg, dict):
return
buffer_name = list(self._buffer_cfg.keys())[0]
buffer_class = napalm_logs.buffer.get_interface(buffer_name)
log.debug... | python | def _setup_buffer(self):
'''
Setup the buffer subsystem.
'''
if not self._buffer_cfg or not isinstance(self._buffer_cfg, dict):
return
buffer_name = list(self._buffer_cfg.keys())[0]
buffer_class = napalm_logs.buffer.get_interface(buffer_name)
log.debug... | [
"def",
"_setup_buffer",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_buffer_cfg",
"or",
"not",
"isinstance",
"(",
"self",
".",
"_buffer_cfg",
",",
"dict",
")",
":",
"return",
"buffer_name",
"=",
"list",
"(",
"self",
".",
"_buffer_cfg",
".",
"keys",... | Setup the buffer subsystem. | [
"Setup",
"the",
"buffer",
"subsystem",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L134-L145 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._setup_metrics | def _setup_metrics(self):
"""
Start metric exposition
"""
path = os.environ.get("prometheus_multiproc_dir")
if not os.path.exists(self.metrics_dir):
try:
log.info("Creating metrics directory")
os.makedirs(self.metrics_dir)
e... | python | def _setup_metrics(self):
"""
Start metric exposition
"""
path = os.environ.get("prometheus_multiproc_dir")
if not os.path.exists(self.metrics_dir):
try:
log.info("Creating metrics directory")
os.makedirs(self.metrics_dir)
e... | [
"def",
"_setup_metrics",
"(",
"self",
")",
":",
"path",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"\"prometheus_multiproc_dir\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"metrics_dir",
")",
":",
"try",
":",
"log",
".",
... | Start metric exposition | [
"Start",
"metric",
"exposition"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L147-L177 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._setup_log | def _setup_log(self):
'''
Setup the log object.
'''
logging_level = CONFIG.LOGGING_LEVEL.get(self.log_level.lower())
logging.basicConfig(format=self.log_format,
level=logging_level) | python | def _setup_log(self):
'''
Setup the log object.
'''
logging_level = CONFIG.LOGGING_LEVEL.get(self.log_level.lower())
logging.basicConfig(format=self.log_format,
level=logging_level) | [
"def",
"_setup_log",
"(",
"self",
")",
":",
"logging_level",
"=",
"CONFIG",
".",
"LOGGING_LEVEL",
".",
"get",
"(",
"self",
".",
"log_level",
".",
"lower",
"(",
")",
")",
"logging",
".",
"basicConfig",
"(",
"format",
"=",
"self",
".",
"log_format",
",",
... | Setup the log object. | [
"Setup",
"the",
"log",
"object",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L179-L185 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._whitelist_blacklist | def _whitelist_blacklist(self, os_name):
'''
Determines if the OS should be ignored,
depending on the whitelist-blacklist logic
configured by the user.
'''
return napalm_logs.ext.check_whitelist_blacklist(os_name,
w... | python | def _whitelist_blacklist(self, os_name):
'''
Determines if the OS should be ignored,
depending on the whitelist-blacklist logic
configured by the user.
'''
return napalm_logs.ext.check_whitelist_blacklist(os_name,
w... | [
"def",
"_whitelist_blacklist",
"(",
"self",
",",
"os_name",
")",
":",
"return",
"napalm_logs",
".",
"ext",
".",
"check_whitelist_blacklist",
"(",
"os_name",
",",
"whitelist",
"=",
"self",
".",
"device_whitelist",
",",
"blacklist",
"=",
"self",
".",
"device_black... | Determines if the OS should be ignored,
depending on the whitelist-blacklist logic
configured by the user. | [
"Determines",
"if",
"the",
"OS",
"should",
"be",
"ignored",
"depending",
"on",
"the",
"whitelist",
"-",
"blacklist",
"logic",
"configured",
"by",
"the",
"user",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L223-L231 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._extract_yaml_docstring | def _extract_yaml_docstring(stream):
'''
Extract the comments at the top of the YAML file,
from the stream handler.
Return the extracted comment as string.
'''
comment_lines = []
lines = stream.read().splitlines()
for line in lines:
line_strip ... | python | def _extract_yaml_docstring(stream):
'''
Extract the comments at the top of the YAML file,
from the stream handler.
Return the extracted comment as string.
'''
comment_lines = []
lines = stream.read().splitlines()
for line in lines:
line_strip ... | [
"def",
"_extract_yaml_docstring",
"(",
"stream",
")",
":",
"comment_lines",
"=",
"[",
"]",
"lines",
"=",
"stream",
".",
"read",
"(",
")",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"lines",
":",
"line_strip",
"=",
"line",
".",
"strip",
"(",
")",... | Extract the comments at the top of the YAML file,
from the stream handler.
Return the extracted comment as string. | [
"Extract",
"the",
"comments",
"at",
"the",
"top",
"of",
"the",
"YAML",
"file",
"from",
"the",
"stream",
"handler",
".",
"Return",
"the",
"extracted",
"comment",
"as",
"string",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L234-L252 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._verify_config_dict | def _verify_config_dict(self, valid, config, dev_os, key_path=None):
'''
Verify if the config dict is valid.
'''
if not key_path:
key_path = []
for key, value in valid.items():
self._verify_config_key(key, value, valid, config, dev_os, key_path) | python | def _verify_config_dict(self, valid, config, dev_os, key_path=None):
'''
Verify if the config dict is valid.
'''
if not key_path:
key_path = []
for key, value in valid.items():
self._verify_config_key(key, value, valid, config, dev_os, key_path) | [
"def",
"_verify_config_dict",
"(",
"self",
",",
"valid",
",",
"config",
",",
"dev_os",
",",
"key_path",
"=",
"None",
")",
":",
"if",
"not",
"key_path",
":",
"key_path",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"valid",
".",
"items",
"(",
")",... | Verify if the config dict is valid. | [
"Verify",
"if",
"the",
"config",
"dict",
"is",
"valid",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L461-L468 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._verify_config | def _verify_config(self):
'''
Verify that the config is correct
'''
if not self.config_dict:
self._raise_config_exception('No config found')
# Check for device conifg, if there isn't anything then just log, do not raise an exception
for dev_os, dev_config in s... | python | def _verify_config(self):
'''
Verify that the config is correct
'''
if not self.config_dict:
self._raise_config_exception('No config found')
# Check for device conifg, if there isn't anything then just log, do not raise an exception
for dev_os, dev_config in s... | [
"def",
"_verify_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config_dict",
":",
"self",
".",
"_raise_config_exception",
"(",
"'No config found'",
")",
"for",
"dev_os",
",",
"dev_config",
"in",
"self",
".",
"config_dict",
".",
"items",
"(",
")",... | Verify that the config is correct | [
"Verify",
"that",
"the",
"config",
"is",
"correct"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L470-L483 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._build_config | def _build_config(self):
'''
Build the config of the napalm syslog parser.
'''
if not self.config_dict:
if not self.config_path:
# No custom config path requested
# Read the native config files
self.config_path = os.path.join(
... | python | def _build_config(self):
'''
Build the config of the napalm syslog parser.
'''
if not self.config_dict:
if not self.config_path:
# No custom config path requested
# Read the native config files
self.config_path = os.path.join(
... | [
"def",
"_build_config",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"config_dict",
":",
"if",
"not",
"self",
".",
"config_path",
":",
"self",
".",
"config_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
... | Build the config of the napalm syslog parser. | [
"Build",
"the",
"config",
"of",
"the",
"napalm",
"syslog",
"parser",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L485-L507 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._start_auth_proc | def _start_auth_proc(self):
'''
Start the authenticator process.
'''
log.debug('Computing the signing key hex')
verify_key = self.__signing_key.verify_key
sgn_verify_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder)
log.debug('Starting the authenticator su... | python | def _start_auth_proc(self):
'''
Start the authenticator process.
'''
log.debug('Computing the signing key hex')
verify_key = self.__signing_key.verify_key
sgn_verify_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder)
log.debug('Starting the authenticator su... | [
"def",
"_start_auth_proc",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Computing the signing key hex'",
")",
"verify_key",
"=",
"self",
".",
"__signing_key",
".",
"verify_key",
"sgn_verify_hex",
"=",
"verify_key",
".",
"encode",
"(",
"encoder",
"=",
"nacl... | Start the authenticator process. | [
"Start",
"the",
"authenticator",
"process",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L509-L527 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._start_lst_proc | def _start_lst_proc(self,
listener_type,
listener_opts):
'''
Start the listener process.
'''
log.debug('Starting the listener process for %s', listener_type)
listener = NapalmLogsListenerProc(self.opts,
... | python | def _start_lst_proc(self,
listener_type,
listener_opts):
'''
Start the listener process.
'''
log.debug('Starting the listener process for %s', listener_type)
listener = NapalmLogsListenerProc(self.opts,
... | [
"def",
"_start_lst_proc",
"(",
"self",
",",
"listener_type",
",",
"listener_opts",
")",
":",
"log",
".",
"debug",
"(",
"'Starting the listener process for %s'",
",",
"listener_type",
")",
"listener",
"=",
"NapalmLogsListenerProc",
"(",
"self",
".",
"opts",
",",
"s... | Start the listener process. | [
"Start",
"the",
"listener",
"process",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L529-L545 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._start_srv_proc | def _start_srv_proc(self,
started_os_proc):
'''
Start the server process.
'''
log.debug('Starting the server process')
server = NapalmLogsServerProc(self.opts,
self.config_dict,
st... | python | def _start_srv_proc(self,
started_os_proc):
'''
Start the server process.
'''
log.debug('Starting the server process')
server = NapalmLogsServerProc(self.opts,
self.config_dict,
st... | [
"def",
"_start_srv_proc",
"(",
"self",
",",
"started_os_proc",
")",
":",
"log",
".",
"debug",
"(",
"'Starting the server process'",
")",
"server",
"=",
"NapalmLogsServerProc",
"(",
"self",
".",
"opts",
",",
"self",
".",
"config_dict",
",",
"started_os_proc",
","... | Start the server process. | [
"Start",
"the",
"server",
"process",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L547-L561 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._start_pub_proc | def _start_pub_proc(self,
publisher_type,
publisher_opts,
pub_id):
'''
Start the publisher process.
'''
log.debug('Starting the publisher process for %s', publisher_type)
publisher = NapalmLogsPublisherProc(s... | python | def _start_pub_proc(self,
publisher_type,
publisher_opts,
pub_id):
'''
Start the publisher process.
'''
log.debug('Starting the publisher process for %s', publisher_type)
publisher = NapalmLogsPublisherProc(s... | [
"def",
"_start_pub_proc",
"(",
"self",
",",
"publisher_type",
",",
"publisher_opts",
",",
"pub_id",
")",
":",
"log",
".",
"debug",
"(",
"'Starting the publisher process for %s'",
",",
"publisher_type",
")",
"publisher",
"=",
"NapalmLogsPublisherProc",
"(",
"self",
"... | Start the publisher process. | [
"Start",
"the",
"publisher",
"process",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L573-L595 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._start_dev_proc | def _start_dev_proc(self,
device_os,
device_config):
'''
Start the device worker process.
'''
log.info('Starting the child process for %s', device_os)
dos = NapalmLogsDeviceProc(device_os,
self.opt... | python | def _start_dev_proc(self,
device_os,
device_config):
'''
Start the device worker process.
'''
log.info('Starting the child process for %s', device_os)
dos = NapalmLogsDeviceProc(device_os,
self.opt... | [
"def",
"_start_dev_proc",
"(",
"self",
",",
"device_os",
",",
"device_config",
")",
":",
"log",
".",
"info",
"(",
"'Starting the child process for %s'",
",",
"device_os",
")",
"dos",
"=",
"NapalmLogsDeviceProc",
"(",
"device_os",
",",
"self",
".",
"opts",
",",
... | Start the device worker process. | [
"Start",
"the",
"device",
"worker",
"process",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L597-L611 | train |
napalm-automation/napalm-logs | napalm_logs/base.py | NapalmLogs._check_children | def _check_children(self):
'''
Check all of the child processes are still running
'''
while self.up:
time.sleep(1)
for process in self._processes:
if process.is_alive() is True:
continue
log.debug('%s is dead. St... | python | def _check_children(self):
'''
Check all of the child processes are still running
'''
while self.up:
time.sleep(1)
for process in self._processes:
if process.is_alive() is True:
continue
log.debug('%s is dead. St... | [
"def",
"_check_children",
"(",
"self",
")",
":",
"while",
"self",
".",
"up",
":",
"time",
".",
"sleep",
"(",
"1",
")",
"for",
"process",
"in",
"self",
".",
"_processes",
":",
"if",
"process",
".",
"is_alive",
"(",
")",
"is",
"True",
":",
"continue",
... | Check all of the child processes are still running | [
"Check",
"all",
"of",
"the",
"child",
"processes",
"are",
"still",
"running"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L664-L674 | train |
napalm-automation/napalm-logs | napalm_logs/pub_proxy.py | NapalmLogsPublisherProxy._setup_ipc | def _setup_ipc(self):
'''
Setup the IPC PUB and SUB sockets for the proxy.
'''
log.debug('Setting up the internal IPC proxy')
self.ctx = zmq.Context()
# Frontend
self.sub = self.ctx.socket(zmq.SUB)
self.sub.bind(PUB_PX_IPC_URL)
self.sub.setsockopt(... | python | def _setup_ipc(self):
'''
Setup the IPC PUB and SUB sockets for the proxy.
'''
log.debug('Setting up the internal IPC proxy')
self.ctx = zmq.Context()
# Frontend
self.sub = self.ctx.socket(zmq.SUB)
self.sub.bind(PUB_PX_IPC_URL)
self.sub.setsockopt(... | [
"def",
"_setup_ipc",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Setting up the internal IPC proxy'",
")",
"self",
".",
"ctx",
"=",
"zmq",
".",
"Context",
"(",
")",
"self",
".",
"sub",
"=",
"self",
".",
"ctx",
".",
"socket",
"(",
"zmq",
".",
"... | Setup the IPC PUB and SUB sockets for the proxy. | [
"Setup",
"the",
"IPC",
"PUB",
"and",
"SUB",
"sockets",
"for",
"the",
"proxy",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/pub_proxy.py#L38-L64 | train |
napalm-automation/napalm-logs | napalm_logs/publisher.py | NapalmLogsPublisherProc._setup_ipc | def _setup_ipc(self):
'''
Subscribe to the pub IPC
and publish the messages
on the right transport.
'''
self.ctx = zmq.Context()
log.debug('Setting up the %s publisher subscriber #%d', self._transport_type, self.pub_id)
self.sub = self.ctx.socket(zmq.SUB)
... | python | def _setup_ipc(self):
'''
Subscribe to the pub IPC
and publish the messages
on the right transport.
'''
self.ctx = zmq.Context()
log.debug('Setting up the %s publisher subscriber #%d', self._transport_type, self.pub_id)
self.sub = self.ctx.socket(zmq.SUB)
... | [
"def",
"_setup_ipc",
"(",
"self",
")",
":",
"self",
".",
"ctx",
"=",
"zmq",
".",
"Context",
"(",
")",
"log",
".",
"debug",
"(",
"'Setting up the %s publisher subscriber #%d'",
",",
"self",
".",
"_transport_type",
",",
"self",
".",
"pub_id",
")",
"self",
".... | Subscribe to the pub IPC
and publish the messages
on the right transport. | [
"Subscribe",
"to",
"the",
"pub",
"IPC",
"and",
"publish",
"the",
"messages",
"on",
"the",
"right",
"transport",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/publisher.py#L71-L87 | train |
napalm-automation/napalm-logs | napalm_logs/publisher.py | NapalmLogsPublisherProc._prepare | def _prepare(self, serialized_obj):
'''
Prepare the object to be sent over the untrusted channel.
'''
# generating a nonce
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
# encrypting using the nonce
encrypted = self.__safe.encrypt(serialized_obj, nonc... | python | def _prepare(self, serialized_obj):
'''
Prepare the object to be sent over the untrusted channel.
'''
# generating a nonce
nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE)
# encrypting using the nonce
encrypted = self.__safe.encrypt(serialized_obj, nonc... | [
"def",
"_prepare",
"(",
"self",
",",
"serialized_obj",
")",
":",
"nonce",
"=",
"nacl",
".",
"utils",
".",
"random",
"(",
"nacl",
".",
"secret",
".",
"SecretBox",
".",
"NONCE_SIZE",
")",
"encrypted",
"=",
"self",
".",
"__safe",
".",
"encrypt",
"(",
"ser... | Prepare the object to be sent over the untrusted channel. | [
"Prepare",
"the",
"object",
"to",
"be",
"sent",
"over",
"the",
"untrusted",
"channel",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/publisher.py#L110-L120 | train |
napalm-automation/napalm-logs | napalm_logs/listener/__init__.py | get_listener | def get_listener(name):
'''
Return the listener class.
'''
try:
log.debug('Using %s as listener', name)
return LISTENER_LOOKUP[name]
except KeyError:
msg = 'Listener {} is not available. Are the dependencies installed?'.format(name)
log.error(msg, exc_info=True)
... | python | def get_listener(name):
'''
Return the listener class.
'''
try:
log.debug('Using %s as listener', name)
return LISTENER_LOOKUP[name]
except KeyError:
msg = 'Listener {} is not available. Are the dependencies installed?'.format(name)
log.error(msg, exc_info=True)
... | [
"def",
"get_listener",
"(",
"name",
")",
":",
"try",
":",
"log",
".",
"debug",
"(",
"'Using %s as listener'",
",",
"name",
")",
"return",
"LISTENER_LOOKUP",
"[",
"name",
"]",
"except",
"KeyError",
":",
"msg",
"=",
"'Listener {} is not available. Are the dependenci... | Return the listener class. | [
"Return",
"the",
"listener",
"class",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/__init__.py#L41-L51 | train |
napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | ClientAuth._start_keep_alive | def _start_keep_alive(self):
'''
Start the keep alive thread as a daemon
'''
keep_alive_thread = threading.Thread(target=self.keep_alive)
keep_alive_thread.daemon = True
keep_alive_thread.start() | python | def _start_keep_alive(self):
'''
Start the keep alive thread as a daemon
'''
keep_alive_thread = threading.Thread(target=self.keep_alive)
keep_alive_thread.daemon = True
keep_alive_thread.start() | [
"def",
"_start_keep_alive",
"(",
"self",
")",
":",
"keep_alive_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"keep_alive",
")",
"keep_alive_thread",
".",
"daemon",
"=",
"True",
"keep_alive_thread",
".",
"start",
"(",
")"
] | Start the keep alive thread as a daemon | [
"Start",
"the",
"keep",
"alive",
"thread",
"as",
"a",
"daemon"
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L61-L67 | train |
napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | ClientAuth.keep_alive | def keep_alive(self):
'''
Send a keep alive request periodically to make sure that the server
is still alive. If not then try to reconnect.
'''
self.ssl_skt.settimeout(defaults.AUTH_KEEP_ALIVE_INTERVAL)
while self.__up:
try:
log.debug('Sending ... | python | def keep_alive(self):
'''
Send a keep alive request periodically to make sure that the server
is still alive. If not then try to reconnect.
'''
self.ssl_skt.settimeout(defaults.AUTH_KEEP_ALIVE_INTERVAL)
while self.__up:
try:
log.debug('Sending ... | [
"def",
"keep_alive",
"(",
"self",
")",
":",
"self",
".",
"ssl_skt",
".",
"settimeout",
"(",
"defaults",
".",
"AUTH_KEEP_ALIVE_INTERVAL",
")",
"while",
"self",
".",
"__up",
":",
"try",
":",
"log",
".",
"debug",
"(",
"'Sending keep-alive message to the server'",
... | Send a keep alive request periodically to make sure that the server
is still alive. If not then try to reconnect. | [
"Send",
"a",
"keep",
"alive",
"request",
"periodically",
"to",
"make",
"sure",
"that",
"the",
"server",
"is",
"still",
"alive",
".",
"If",
"not",
"then",
"try",
"to",
"reconnect",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L69-L92 | train |
napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | ClientAuth.reconnect | def reconnect(self):
'''
Try to reconnect and re-authenticate with the server.
'''
log.debug('Closing the SSH socket.')
try:
self.ssl_skt.close()
except socket.error:
log.error('The socket seems to be closed already.')
log.debug('Re-opening... | python | def reconnect(self):
'''
Try to reconnect and re-authenticate with the server.
'''
log.debug('Closing the SSH socket.')
try:
self.ssl_skt.close()
except socket.error:
log.error('The socket seems to be closed already.')
log.debug('Re-opening... | [
"def",
"reconnect",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Closing the SSH socket.'",
")",
"try",
":",
"self",
".",
"ssl_skt",
".",
"close",
"(",
")",
"except",
"socket",
".",
"error",
":",
"log",
".",
"error",
"(",
"'The socket seems to be clo... | Try to reconnect and re-authenticate with the server. | [
"Try",
"to",
"reconnect",
"and",
"re",
"-",
"authenticate",
"with",
"the",
"server",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L94-L104 | train |
napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | ClientAuth.authenticate | def authenticate(self):
'''
Authenticate the client and return the private
and signature keys.
Establish a connection through a secured socket,
then do the handshake using the napalm-logs
auth algorithm.
'''
log.debug('Authenticate to %s:%d, using the cer... | python | def authenticate(self):
'''
Authenticate the client and return the private
and signature keys.
Establish a connection through a secured socket,
then do the handshake using the napalm-logs
auth algorithm.
'''
log.debug('Authenticate to %s:%d, using the cer... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Authenticate to %s:%d, using the certificate %s'",
",",
"self",
".",
"address",
",",
"self",
".",
"port",
",",
"self",
".",
"certificate",
")",
"if",
"':'",
"in",
"self",
".",
"address... | Authenticate the client and return the private
and signature keys.
Establish a connection through a secured socket,
then do the handshake using the napalm-logs
auth algorithm. | [
"Authenticate",
"the",
"client",
"and",
"return",
"the",
"private",
"and",
"signature",
"keys",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L106-L150 | train |
napalm-automation/napalm-logs | napalm_logs/utils/__init__.py | ClientAuth.decrypt | def decrypt(self, binary):
'''
Decrypt and unpack the original OpenConfig object,
serialized using MessagePack.
Raise BadSignatureException when the signature
was forged or corrupted.
'''
try:
encrypted = self.verify_key.verify(binary)
except B... | python | def decrypt(self, binary):
'''
Decrypt and unpack the original OpenConfig object,
serialized using MessagePack.
Raise BadSignatureException when the signature
was forged or corrupted.
'''
try:
encrypted = self.verify_key.verify(binary)
except B... | [
"def",
"decrypt",
"(",
"self",
",",
"binary",
")",
":",
"try",
":",
"encrypted",
"=",
"self",
".",
"verify_key",
".",
"verify",
"(",
"binary",
")",
"except",
"BadSignatureError",
":",
"log",
".",
"error",
"(",
"'Signature was forged or corrupt'",
",",
"exc_i... | Decrypt and unpack the original OpenConfig object,
serialized using MessagePack.
Raise BadSignatureException when the signature
was forged or corrupted. | [
"Decrypt",
"and",
"unpack",
"the",
"original",
"OpenConfig",
"object",
"serialized",
"using",
"MessagePack",
".",
"Raise",
"BadSignatureException",
"when",
"the",
"signature",
"was",
"forged",
"or",
"corrupted",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L152-L169 | train |
napalm-automation/napalm-logs | napalm_logs/listener/tcp.py | TCPListener._client_connection | def _client_connection(self, conn, addr):
'''
Handle the connecition with one client.
'''
log.debug('Established connection with %s:%d', addr[0], addr[1])
conn.settimeout(self.socket_timeout)
try:
while self.__up:
msg = conn.recv(self.buffer_si... | python | def _client_connection(self, conn, addr):
'''
Handle the connecition with one client.
'''
log.debug('Established connection with %s:%d', addr[0], addr[1])
conn.settimeout(self.socket_timeout)
try:
while self.__up:
msg = conn.recv(self.buffer_si... | [
"def",
"_client_connection",
"(",
"self",
",",
"conn",
",",
"addr",
")",
":",
"log",
".",
"debug",
"(",
"'Established connection with %s:%d'",
",",
"addr",
"[",
"0",
"]",
",",
"addr",
"[",
"1",
"]",
")",
"conn",
".",
"settimeout",
"(",
"self",
".",
"so... | Handle the connecition with one client. | [
"Handle",
"the",
"connecition",
"with",
"one",
"client",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L53-L75 | train |
napalm-automation/napalm-logs | napalm_logs/listener/tcp.py | TCPListener._serve_clients | def _serve_clients(self):
'''
Accept cients and serve, one separate thread per client.
'''
self.__up = True
while self.__up:
log.debug('Waiting for a client to connect')
try:
conn, addr = self.skt.accept()
log.debug('Receive... | python | def _serve_clients(self):
'''
Accept cients and serve, one separate thread per client.
'''
self.__up = True
while self.__up:
log.debug('Waiting for a client to connect')
try:
conn, addr = self.skt.accept()
log.debug('Receive... | [
"def",
"_serve_clients",
"(",
"self",
")",
":",
"self",
".",
"__up",
"=",
"True",
"while",
"self",
".",
"__up",
":",
"log",
".",
"debug",
"(",
"'Waiting for a client to connect'",
")",
"try",
":",
"conn",
",",
"addr",
"=",
"self",
".",
"skt",
".",
"acc... | Accept cients and serve, one separate thread per client. | [
"Accept",
"cients",
"and",
"serve",
"one",
"separate",
"thread",
"per",
"client",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L77-L94 | train |
napalm-automation/napalm-logs | napalm_logs/listener/tcp.py | TCPListener.start | def start(self):
'''
Start listening for messages.
'''
log.debug('Creating the TCP server')
if ':' in self.address:
self.skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
... | python | def start(self):
'''
Start listening for messages.
'''
log.debug('Creating the TCP server')
if ':' in self.address:
self.skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
else:
self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
... | [
"def",
"start",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Creating the TCP server'",
")",
"if",
"':'",
"in",
"self",
".",
"address",
":",
"self",
".",
"skt",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET6",
",",
"socket",
".",
"... | Start listening for messages. | [
"Start",
"listening",
"for",
"messages",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L96-L120 | train |
napalm-automation/napalm-logs | napalm_logs/listener/tcp.py | TCPListener.receive | def receive(self):
'''
Return one message dequeued from the listen buffer.
'''
while self.buffer.empty() and self.__up:
# This sequence is skipped when the buffer is not empty.
sleep_ms = random.randint(0, 1000)
# log.debug('The message queue is empty,... | python | def receive(self):
'''
Return one message dequeued from the listen buffer.
'''
while self.buffer.empty() and self.__up:
# This sequence is skipped when the buffer is not empty.
sleep_ms = random.randint(0, 1000)
# log.debug('The message queue is empty,... | [
"def",
"receive",
"(",
"self",
")",
":",
"while",
"self",
".",
"buffer",
".",
"empty",
"(",
")",
"and",
"self",
".",
"__up",
":",
"sleep_ms",
"=",
"random",
".",
"randint",
"(",
"0",
",",
"1000",
")",
"time",
".",
"sleep",
"(",
"sleep_ms",
"/",
"... | Return one message dequeued from the listen buffer. | [
"Return",
"one",
"message",
"dequeued",
"from",
"the",
"listen",
"buffer",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L122-L134 | train |
napalm-automation/napalm-logs | napalm_logs/listener/tcp.py | TCPListener.stop | def stop(self):
'''
Closing the socket.
'''
log.info('Stopping the TCP listener')
self.__up = False
try:
self.skt.shutdown(socket.SHUT_RDWR)
except socket.error:
log.error('The following error may not be critical:', exc_info=True)
s... | python | def stop(self):
'''
Closing the socket.
'''
log.info('Stopping the TCP listener')
self.__up = False
try:
self.skt.shutdown(socket.SHUT_RDWR)
except socket.error:
log.error('The following error may not be critical:', exc_info=True)
s... | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Stopping the TCP listener'",
")",
"self",
".",
"__up",
"=",
"False",
"try",
":",
"self",
".",
"skt",
".",
"shutdown",
"(",
"socket",
".",
"SHUT_RDWR",
")",
"except",
"socket",
".",
"error... | Closing the socket. | [
"Closing",
"the",
"socket",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L136-L146 | train |
napalm-automation/napalm-logs | napalm_logs/listener_proc.py | NapalmLogsListenerProc._setup_ipc | def _setup_ipc(self):
'''
Setup the listener ICP pusher.
'''
log.debug('Setting up the listener IPC pusher')
self.ctx = zmq.Context()
self.pub = self.ctx.socket(zmq.PUSH)
self.pub.connect(LST_IPC_URL)
log.debug('Setting HWM for the listener: %d', self.opts... | python | def _setup_ipc(self):
'''
Setup the listener ICP pusher.
'''
log.debug('Setting up the listener IPC pusher')
self.ctx = zmq.Context()
self.pub = self.ctx.socket(zmq.PUSH)
self.pub.connect(LST_IPC_URL)
log.debug('Setting HWM for the listener: %d', self.opts... | [
"def",
"_setup_ipc",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"'Setting up the listener IPC pusher'",
")",
"self",
".",
"ctx",
"=",
"zmq",
".",
"Context",
"(",
")",
"self",
".",
"pub",
"=",
"self",
".",
"ctx",
".",
"socket",
"(",
"zmq",
".",
... | Setup the listener ICP pusher. | [
"Setup",
"the",
"listener",
"ICP",
"pusher",
"."
] | 4b89100a6e4f994aa004f3ea42a06dc803a7ccb0 | https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener_proc.py#L62-L76 | train |
poppy-project/pypot | pypot/utils/stoppablethread.py | make_update_loop | def make_update_loop(thread, update_func):
""" Makes a run loop which calls an update function at a predefined frequency. """
while not thread.should_stop():
if thread.should_pause():
thread.wait_to_resume()
start = time.time()
if hasattr(thread, '_updated'):
thr... | python | def make_update_loop(thread, update_func):
""" Makes a run loop which calls an update function at a predefined frequency. """
while not thread.should_stop():
if thread.should_pause():
thread.wait_to_resume()
start = time.time()
if hasattr(thread, '_updated'):
thr... | [
"def",
"make_update_loop",
"(",
"thread",
",",
"update_func",
")",
":",
"while",
"not",
"thread",
".",
"should_stop",
"(",
")",
":",
"if",
"thread",
".",
"should_pause",
"(",
")",
":",
"thread",
".",
"wait_to_resume",
"(",
")",
"start",
"=",
"time",
".",... | Makes a run loop which calls an update function at a predefined frequency. | [
"Makes",
"a",
"run",
"loop",
"which",
"calls",
"an",
"update",
"function",
"at",
"a",
"predefined",
"frequency",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L166-L183 | train |
poppy-project/pypot | pypot/utils/stoppablethread.py | StoppableThread.start | def start(self):
""" Start the run method as a new thread.
It will first stop the thread if it is already running.
"""
if self.running:
self.stop()
self._thread = threading.Thread(target=self._wrapped_target)
self._thread.daemon = True
self._thread.... | python | def start(self):
""" Start the run method as a new thread.
It will first stop the thread if it is already running.
"""
if self.running:
self.stop()
self._thread = threading.Thread(target=self._wrapped_target)
self._thread.daemon = True
self._thread.... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"running",
":",
"self",
".",
"stop",
"(",
")",
"self",
".",
"_thread",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"self",
".",
"_wrapped_target",
")",
"self",
".",
"_thread",
".",
... | Start the run method as a new thread.
It will first stop the thread if it is already running. | [
"Start",
"the",
"run",
"method",
"as",
"a",
"new",
"thread",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L33-L44 | train |
poppy-project/pypot | pypot/utils/stoppablethread.py | StoppableThread.wait_to_start | def wait_to_start(self, allow_failure=False):
""" Wait for the thread to actually starts. """
self._started.wait()
if self._crashed and not allow_failure:
self._thread.join()
raise RuntimeError('Setup failed, see {} Traceback'
'for details.... | python | def wait_to_start(self, allow_failure=False):
""" Wait for the thread to actually starts. """
self._started.wait()
if self._crashed and not allow_failure:
self._thread.join()
raise RuntimeError('Setup failed, see {} Traceback'
'for details.... | [
"def",
"wait_to_start",
"(",
"self",
",",
"allow_failure",
"=",
"False",
")",
":",
"self",
".",
"_started",
".",
"wait",
"(",
")",
"if",
"self",
".",
"_crashed",
"and",
"not",
"allow_failure",
":",
"self",
".",
"_thread",
".",
"join",
"(",
")",
"raise"... | Wait for the thread to actually starts. | [
"Wait",
"for",
"the",
"thread",
"to",
"actually",
"starts",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L82-L89 | train |
poppy-project/pypot | pypot/vrep/__init__.py | from_vrep | def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None,
tracked_objects=[], tracked_collisions=[],
id=None, shared_vrep_io=None):
""" Create a robot from a V-REP instance.
:param config: robot configuration (either the path to the json or directly the dictionary)
... | python | def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None,
tracked_objects=[], tracked_collisions=[],
id=None, shared_vrep_io=None):
""" Create a robot from a V-REP instance.
:param config: robot configuration (either the path to the json or directly the dictionary)
... | [
"def",
"from_vrep",
"(",
"config",
",",
"vrep_host",
"=",
"'127.0.0.1'",
",",
"vrep_port",
"=",
"19997",
",",
"scene",
"=",
"None",
",",
"tracked_objects",
"=",
"[",
"]",
",",
"tracked_collisions",
"=",
"[",
"]",
",",
"id",
"=",
"None",
",",
"shared_vrep... | Create a robot from a V-REP instance.
:param config: robot configuration (either the path to the json or directly the dictionary)
:type config: str or dict
:param str vrep_host: host of the V-REP server
:param int vrep_port: port of the V-REP server
:param str scene: path to the V-REP scene to load... | [
"Create",
"a",
"robot",
"from",
"a",
"V",
"-",
"REP",
"instance",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/__init__.py#L52-L176 | train |
poppy-project/pypot | pypot/dynamixel/io/io.py | DxlIO.set_wheel_mode | def set_wheel_mode(self, ids):
""" Sets the specified motors to wheel mode. """
self.set_control_mode(dict(zip(ids, itertools.repeat('wheel')))) | python | def set_wheel_mode(self, ids):
""" Sets the specified motors to wheel mode. """
self.set_control_mode(dict(zip(ids, itertools.repeat('wheel')))) | [
"def",
"set_wheel_mode",
"(",
"self",
",",
"ids",
")",
":",
"self",
".",
"set_control_mode",
"(",
"dict",
"(",
"zip",
"(",
"ids",
",",
"itertools",
".",
"repeat",
"(",
"'wheel'",
")",
")",
")",
")"
] | Sets the specified motors to wheel mode. | [
"Sets",
"the",
"specified",
"motors",
"to",
"wheel",
"mode",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L30-L32 | train |
poppy-project/pypot | pypot/dynamixel/io/io.py | DxlIO.set_joint_mode | def set_joint_mode(self, ids):
""" Sets the specified motors to joint mode. """
self.set_control_mode(dict(zip(ids, itertools.repeat('joint')))) | python | def set_joint_mode(self, ids):
""" Sets the specified motors to joint mode. """
self.set_control_mode(dict(zip(ids, itertools.repeat('joint')))) | [
"def",
"set_joint_mode",
"(",
"self",
",",
"ids",
")",
":",
"self",
".",
"set_control_mode",
"(",
"dict",
"(",
"zip",
"(",
"ids",
",",
"itertools",
".",
"repeat",
"(",
"'joint'",
")",
")",
")",
")"
] | Sets the specified motors to joint mode. | [
"Sets",
"the",
"specified",
"motors",
"to",
"joint",
"mode",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L34-L36 | train |
poppy-project/pypot | pypot/dynamixel/io/io.py | DxlIO.set_angle_limit | def set_angle_limit(self, limit_for_id, **kwargs):
""" Sets the angle limit to the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
if 'wheel' in self.get_control_mode(limit_for_id.keys()):
raise ValueError('can not change the angle limit o... | python | def set_angle_limit(self, limit_for_id, **kwargs):
""" Sets the angle limit to the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
if 'wheel' in self.get_control_mode(limit_for_id.keys()):
raise ValueError('can not change the angle limit o... | [
"def",
"set_angle_limit",
"(",
"self",
",",
"limit_for_id",
",",
"**",
"kwargs",
")",
":",
"convert",
"=",
"kwargs",
"[",
"'convert'",
"]",
"if",
"'convert'",
"in",
"kwargs",
"else",
"self",
".",
"_convert",
"if",
"'wheel'",
"in",
"self",
".",
"get_control... | Sets the angle limit to the specified motors. | [
"Sets",
"the",
"angle",
"limit",
"to",
"the",
"specified",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L55-L65 | train |
poppy-project/pypot | pypot/robot/robot.py | Robot.close | def close(self):
""" Cleans the robot by stopping synchronization and all controllers."""
self.stop_sync()
[c.io.close() for c in self._controllers if c.io is not None] | python | def close(self):
""" Cleans the robot by stopping synchronization and all controllers."""
self.stop_sync()
[c.io.close() for c in self._controllers if c.io is not None] | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"stop_sync",
"(",
")",
"[",
"c",
".",
"io",
".",
"close",
"(",
")",
"for",
"c",
"in",
"self",
".",
"_controllers",
"if",
"c",
".",
"io",
"is",
"not",
"None",
"]"
] | Cleans the robot by stopping synchronization and all controllers. | [
"Cleans",
"the",
"robot",
"by",
"stopping",
"synchronization",
"and",
"all",
"controllers",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L51-L54 | train |
poppy-project/pypot | pypot/robot/robot.py | Robot.goto_position | def goto_position(self, position_for_motors, duration, control=None, wait=False):
""" Moves a subset of the motors to a position within a specific duration.
:param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...}
:param float duration: durat... | python | def goto_position(self, position_for_motors, duration, control=None, wait=False):
""" Moves a subset of the motors to a position within a specific duration.
:param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...}
:param float duration: durat... | [
"def",
"goto_position",
"(",
"self",
",",
"position_for_motors",
",",
"duration",
",",
"control",
"=",
"None",
",",
"wait",
"=",
"False",
")",
":",
"for",
"i",
",",
"(",
"motor_name",
",",
"position",
")",
"in",
"enumerate",
"(",
"position_for_motors",
"."... | Moves a subset of the motors to a position within a specific duration.
:param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...}
:param float duration: duration of the move
:param str control: control type ('dummy', 'minjerk')
... | [
"Moves",
"a",
"subset",
"of",
"the",
"motors",
"to",
"a",
"position",
"within",
"a",
"specific",
"duration",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L126-L141 | train |
poppy-project/pypot | pypot/robot/robot.py | Robot.power_up | def power_up(self):
""" Changes all settings to guarantee the motors will be used at their maximum power. """
for m in self.motors:
m.compliant = False
m.moving_speed = 0
m.torque_limit = 100.0 | python | def power_up(self):
""" Changes all settings to guarantee the motors will be used at their maximum power. """
for m in self.motors:
m.compliant = False
m.moving_speed = 0
m.torque_limit = 100.0 | [
"def",
"power_up",
"(",
"self",
")",
":",
"for",
"m",
"in",
"self",
".",
"motors",
":",
"m",
".",
"compliant",
"=",
"False",
"m",
".",
"moving_speed",
"=",
"0",
"m",
".",
"torque_limit",
"=",
"100.0"
] | Changes all settings to guarantee the motors will be used at their maximum power. | [
"Changes",
"all",
"settings",
"to",
"guarantee",
"the",
"motors",
"will",
"be",
"used",
"at",
"their",
"maximum",
"power",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L143-L148 | train |
poppy-project/pypot | pypot/robot/robot.py | Robot.to_config | def to_config(self):
""" Generates the config for the current robot.
.. note:: The generated config should be used as a basis and must probably be modified.
"""
from ..dynamixel.controller import DxlController
dxl_controllers = [c for c in self._controllers
... | python | def to_config(self):
""" Generates the config for the current robot.
.. note:: The generated config should be used as a basis and must probably be modified.
"""
from ..dynamixel.controller import DxlController
dxl_controllers = [c for c in self._controllers
... | [
"def",
"to_config",
"(",
"self",
")",
":",
"from",
".",
".",
"dynamixel",
".",
"controller",
"import",
"DxlController",
"dxl_controllers",
"=",
"[",
"c",
"for",
"c",
"in",
"self",
".",
"_controllers",
"if",
"isinstance",
"(",
"c",
",",
"DxlController",
")"... | Generates the config for the current robot.
.. note:: The generated config should be used as a basis and must probably be modified. | [
"Generates",
"the",
"config",
"for",
"the",
"current",
"robot",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L150-L187 | train |
poppy-project/pypot | pypot/vrep/controller.py | VrepController.update | def update(self):
""" Synchronization update loop.
At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep.
"""
# Read all the angle limits
h, _, l, _ = self.io.call_remote_api('simxGetObjectGroupData',
... | python | def update(self):
""" Synchronization update loop.
At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep.
"""
# Read all the angle limits
h, _, l, _ = self.io.call_remote_api('simxGetObjectGroupData',
... | [
"def",
"update",
"(",
"self",
")",
":",
"h",
",",
"_",
",",
"l",
",",
"_",
"=",
"self",
".",
"io",
".",
"call_remote_api",
"(",
"'simxGetObjectGroupData'",
",",
"remote_api",
".",
"sim_object_joint_type",
",",
"16",
",",
"streaming",
"=",
"True",
")",
... | Synchronization update loop.
At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep. | [
"Synchronization",
"update",
"loop",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L41-L82 | train |
poppy-project/pypot | pypot/vrep/controller.py | VrepObjectTracker.update | def update(self):
""" Updates the position and orientation of the tracked objects. """
for s in self.sensors:
s.position = self.io.get_object_position(object_name=s.name)
s.orientation = self.io.get_object_orientation(object_name=s.name) | python | def update(self):
""" Updates the position and orientation of the tracked objects. """
for s in self.sensors:
s.position = self.io.get_object_position(object_name=s.name)
s.orientation = self.io.get_object_orientation(object_name=s.name) | [
"def",
"update",
"(",
"self",
")",
":",
"for",
"s",
"in",
"self",
".",
"sensors",
":",
"s",
".",
"position",
"=",
"self",
".",
"io",
".",
"get_object_position",
"(",
"object_name",
"=",
"s",
".",
"name",
")",
"s",
".",
"orientation",
"=",
"self",
"... | Updates the position and orientation of the tracked objects. | [
"Updates",
"the",
"position",
"and",
"orientation",
"of",
"the",
"tracked",
"objects",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L149-L153 | train |
poppy-project/pypot | pypot/vrep/controller.py | VrepCollisionTracker.update | def update(self):
""" Update the state of the collision detectors. """
for s in self.sensors:
s.colliding = self.io.get_collision_state(collision_name=s.name) | python | def update(self):
""" Update the state of the collision detectors. """
for s in self.sensors:
s.colliding = self.io.get_collision_state(collision_name=s.name) | [
"def",
"update",
"(",
"self",
")",
":",
"for",
"s",
"in",
"self",
".",
"sensors",
":",
"s",
".",
"colliding",
"=",
"self",
".",
"io",
".",
"get_collision_state",
"(",
"collision_name",
"=",
"s",
".",
"name",
")"
] | Update the state of the collision detectors. | [
"Update",
"the",
"state",
"of",
"the",
"collision",
"detectors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L180-L184 | train |
poppy-project/pypot | pypot/kinematics.py | Link.get_transformation_matrix | def get_transformation_matrix(self, theta):
""" Computes the homogeneous transformation matrix for this link. """
ct = numpy.cos(theta + self.theta)
st = numpy.sin(theta + self.theta)
ca = numpy.cos(self.alpha)
sa = numpy.sin(self.alpha)
return numpy.matrix(((ct, -st * c... | python | def get_transformation_matrix(self, theta):
""" Computes the homogeneous transformation matrix for this link. """
ct = numpy.cos(theta + self.theta)
st = numpy.sin(theta + self.theta)
ca = numpy.cos(self.alpha)
sa = numpy.sin(self.alpha)
return numpy.matrix(((ct, -st * c... | [
"def",
"get_transformation_matrix",
"(",
"self",
",",
"theta",
")",
":",
"ct",
"=",
"numpy",
".",
"cos",
"(",
"theta",
"+",
"self",
".",
"theta",
")",
"st",
"=",
"numpy",
".",
"sin",
"(",
"theta",
"+",
"self",
".",
"theta",
")",
"ca",
"=",
"numpy",... | Computes the homogeneous transformation matrix for this link. | [
"Computes",
"the",
"homogeneous",
"transformation",
"matrix",
"for",
"this",
"link",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L27-L37 | train |
poppy-project/pypot | pypot/kinematics.py | Chain.forward_kinematics | def forward_kinematics(self, q):
""" Computes the homogeneous transformation matrix of the end effector of the chain.
:param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n)
"""
q = numpy.array(q).flatten()
if len(q) != len(self.links):
raise V... | python | def forward_kinematics(self, q):
""" Computes the homogeneous transformation matrix of the end effector of the chain.
:param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n)
"""
q = numpy.array(q).flatten()
if len(q) != len(self.links):
raise V... | [
"def",
"forward_kinematics",
"(",
"self",
",",
"q",
")",
":",
"q",
"=",
"numpy",
".",
"array",
"(",
"q",
")",
".",
"flatten",
"(",
")",
"if",
"len",
"(",
"q",
")",
"!=",
"len",
"(",
"self",
".",
"links",
")",
":",
"raise",
"ValueError",
"(",
"'... | Computes the homogeneous transformation matrix of the end effector of the chain.
:param vector q: vector of the joint angles (theta 1, theta 2, ..., theta n) | [
"Computes",
"the",
"homogeneous",
"transformation",
"matrix",
"of",
"the",
"end",
"effector",
"of",
"the",
"chain",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L51-L73 | train |
poppy-project/pypot | pypot/kinematics.py | Chain.inverse_kinematics | def inverse_kinematics(self, end_effector_transformation,
q=None,
max_iter=1000, tolerance=0.05,
mask=numpy.ones(6),
use_pinv=False):
""" Computes the joint angles corresponding to the end effector transf... | python | def inverse_kinematics(self, end_effector_transformation,
q=None,
max_iter=1000, tolerance=0.05,
mask=numpy.ones(6),
use_pinv=False):
""" Computes the joint angles corresponding to the end effector transf... | [
"def",
"inverse_kinematics",
"(",
"self",
",",
"end_effector_transformation",
",",
"q",
"=",
"None",
",",
"max_iter",
"=",
"1000",
",",
"tolerance",
"=",
"0.05",
",",
"mask",
"=",
"numpy",
".",
"ones",
"(",
"6",
")",
",",
"use_pinv",
"=",
"False",
")",
... | Computes the joint angles corresponding to the end effector transformation.
:param end_effector_transformation: the end effector homogeneous transformation matrix
:param vector q: initial estimate of the joint angles
:param int max_iter: maximum number of iteration
:param float toleranc... | [
"Computes",
"the",
"joint",
"angles",
"corresponding",
"to",
"the",
"end",
"effector",
"transformation",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/kinematics.py#L75-L122 | train |
poppy-project/pypot | pypot/dynamixel/__init__.py | _get_available_ports | def _get_available_ports():
""" Tries to find the available serial ports on your system. """
if platform.system() == 'Darwin':
return glob.glob('/dev/tty.usb*')
elif platform.system() == 'Linux':
return glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyAMA*')
e... | python | def _get_available_ports():
""" Tries to find the available serial ports on your system. """
if platform.system() == 'Darwin':
return glob.glob('/dev/tty.usb*')
elif platform.system() == 'Linux':
return glob.glob('/dev/ttyACM*') + glob.glob('/dev/ttyUSB*') + glob.glob('/dev/ttyAMA*')
e... | [
"def",
"_get_available_ports",
"(",
")",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Darwin'",
":",
"return",
"glob",
".",
"glob",
"(",
"'/dev/tty.usb*'",
")",
"elif",
"platform",
".",
"system",
"(",
")",
"==",
"'Linux'",
":",
"return",
"glob... | Tries to find the available serial ports on your system. | [
"Tries",
"to",
"find",
"the",
"available",
"serial",
"ports",
"on",
"your",
"system",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L20-L46 | train |
poppy-project/pypot | pypot/dynamixel/__init__.py | find_port | def find_port(ids, strict=True):
""" Find the port with the specified attached motor ids.
:param list ids: list of motor ids to find
:param bool strict: specify if all ids should be find (when set to False, only half motor must be found)
.. warning:: If two (or more) ports are attached to ... | python | def find_port(ids, strict=True):
""" Find the port with the specified attached motor ids.
:param list ids: list of motor ids to find
:param bool strict: specify if all ids should be find (when set to False, only half motor must be found)
.. warning:: If two (or more) ports are attached to ... | [
"def",
"find_port",
"(",
"ids",
",",
"strict",
"=",
"True",
")",
":",
"ids_founds",
"=",
"[",
"]",
"for",
"port",
"in",
"get_available_ports",
"(",
")",
":",
"for",
"DxlIOCls",
"in",
"(",
"DxlIO",
",",
"Dxl320IO",
")",
":",
"try",
":",
"with",
"DxlIO... | Find the port with the specified attached motor ids.
:param list ids: list of motor ids to find
:param bool strict: specify if all ids should be find (when set to False, only half motor must be found)
.. warning:: If two (or more) ports are attached to the same list of motor ids the first matc... | [
"Find",
"the",
"port",
"with",
"the",
"specified",
"attached",
"motor",
"ids",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/__init__.py#L74-L106 | train |
poppy-project/pypot | pypot/sensor/depth/sonar.py | Sonar._filter | def _filter(self, data):
""" Apply a filter to reduce noisy data.
Return the median value of a heap of data.
"""
filtered_data = []
for queue, data in zip(self._raw_data_queues, data):
queue.append(data)
filtered_data.append(numpy.median(queue))
... | python | def _filter(self, data):
""" Apply a filter to reduce noisy data.
Return the median value of a heap of data.
"""
filtered_data = []
for queue, data in zip(self._raw_data_queues, data):
queue.append(data)
filtered_data.append(numpy.median(queue))
... | [
"def",
"_filter",
"(",
"self",
",",
"data",
")",
":",
"filtered_data",
"=",
"[",
"]",
"for",
"queue",
",",
"data",
"in",
"zip",
"(",
"self",
".",
"_raw_data_queues",
",",
"data",
")",
":",
"queue",
".",
"append",
"(",
"data",
")",
"filtered_data",
".... | Apply a filter to reduce noisy data.
Return the median value of a heap of data. | [
"Apply",
"a",
"filter",
"to",
"reduce",
"noisy",
"data",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/sensor/depth/sonar.py#L87-L98 | train |
poppy-project/pypot | pypot/dynamixel/syncloop.py | MetaDxlController.setup | def setup(self):
""" Starts all the synchronization loops. """
[c.start() for c in self.controllers]
[c.wait_to_start() for c in self.controllers] | python | def setup(self):
""" Starts all the synchronization loops. """
[c.start() for c in self.controllers]
[c.wait_to_start() for c in self.controllers] | [
"def",
"setup",
"(",
"self",
")",
":",
"[",
"c",
".",
"start",
"(",
")",
"for",
"c",
"in",
"self",
".",
"controllers",
"]",
"[",
"c",
".",
"wait_to_start",
"(",
")",
"for",
"c",
"in",
"self",
".",
"controllers",
"]"
] | Starts all the synchronization loops. | [
"Starts",
"all",
"the",
"synchronization",
"loops",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/syncloop.py#L20-L23 | train |
poppy-project/pypot | pypot/creatures/ik.py | IKChain.from_poppy_creature | def from_poppy_creature(cls, poppy, motors, passiv, tip,
reversed_motors=[]):
""" Creates an kinematic chain from motors of a Poppy Creature.
:param poppy: PoppyCreature used
:param list motors: list of all motors that composed the kinematic chain
... | python | def from_poppy_creature(cls, poppy, motors, passiv, tip,
reversed_motors=[]):
""" Creates an kinematic chain from motors of a Poppy Creature.
:param poppy: PoppyCreature used
:param list motors: list of all motors that composed the kinematic chain
... | [
"def",
"from_poppy_creature",
"(",
"cls",
",",
"poppy",
",",
"motors",
",",
"passiv",
",",
"tip",
",",
"reversed_motors",
"=",
"[",
"]",
")",
":",
"chain_elements",
"=",
"get_chain_from_joints",
"(",
"poppy",
".",
"urdf_file",
",",
"[",
"m",
".",
"name",
... | Creates an kinematic chain from motors of a Poppy Creature.
:param poppy: PoppyCreature used
:param list motors: list of all motors that composed the kinematic chain
:param list passiv: list of motors which are passiv in the chain (they will not move)
:param list tip: [x... | [
"Creates",
"an",
"kinematic",
"chain",
"from",
"motors",
"of",
"a",
"Poppy",
"Creature",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L14-L48 | train |
poppy-project/pypot | pypot/creatures/ik.py | IKChain.goto | def goto(self, position, duration, wait=False, accurate=False):
""" Goes to a given cartesian position.
:param list position: [x, y, z] representing the target position (in meters)
:param float duration: move duration
:param bool wait: whether to wait for the end of the move... | python | def goto(self, position, duration, wait=False, accurate=False):
""" Goes to a given cartesian position.
:param list position: [x, y, z] representing the target position (in meters)
:param float duration: move duration
:param bool wait: whether to wait for the end of the move... | [
"def",
"goto",
"(",
"self",
",",
"position",
",",
"duration",
",",
"wait",
"=",
"False",
",",
"accurate",
"=",
"False",
")",
":",
"if",
"len",
"(",
"position",
")",
"!=",
"3",
":",
"raise",
"ValueError",
"(",
"'Position should be a list [x, y, z]!'",
")",
... | Goes to a given cartesian position.
:param list position: [x, y, z] representing the target position (in meters)
:param float duration: move duration
:param bool wait: whether to wait for the end of the move
:param bool accurate: trade-off between accurate solution and c... | [
"Goes",
"to",
"a",
"given",
"cartesian",
"position",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L61-L75 | train |
poppy-project/pypot | pypot/creatures/ik.py | IKChain._goto | def _goto(self, pose, duration, wait, accurate):
""" Goes to a given cartesian pose.
:param matrix pose: homogeneous matrix representing the target position
:param float duration: move duration
:param bool wait: whether to wait for the end of the move
:param bool... | python | def _goto(self, pose, duration, wait, accurate):
""" Goes to a given cartesian pose.
:param matrix pose: homogeneous matrix representing the target position
:param float duration: move duration
:param bool wait: whether to wait for the end of the move
:param bool... | [
"def",
"_goto",
"(",
"self",
",",
"pose",
",",
"duration",
",",
"wait",
",",
"accurate",
")",
":",
"kwargs",
"=",
"{",
"}",
"if",
"not",
"accurate",
":",
"kwargs",
"[",
"'max_iter'",
"]",
"=",
"3",
"q0",
"=",
"self",
".",
"convert_to_ik_angles",
"(",... | Goes to a given cartesian pose.
:param matrix pose: homogeneous matrix representing the target position
:param float duration: move duration
:param bool wait: whether to wait for the end of the move
:param bool accurate: trade-off between accurate solution and computatio... | [
"Goes",
"to",
"a",
"given",
"cartesian",
"pose",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L77-L99 | train |
poppy-project/pypot | pypot/creatures/ik.py | IKChain.convert_to_ik_angles | def convert_to_ik_angles(self, joints):
""" Convert from poppy representation to IKPY internal representation. """
if len(joints) != len(self.motors):
raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors)))
raw_joints = [(j + m.offset) * (1 if m.dir... | python | def convert_to_ik_angles(self, joints):
""" Convert from poppy representation to IKPY internal representation. """
if len(joints) != len(self.motors):
raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors)))
raw_joints = [(j + m.offset) * (1 if m.dir... | [
"def",
"convert_to_ik_angles",
"(",
"self",
",",
"joints",
")",
":",
"if",
"len",
"(",
"joints",
")",
"!=",
"len",
"(",
"self",
".",
"motors",
")",
":",
"raise",
"ValueError",
"(",
"'Incompatible data, len(joints) should be {}!'",
".",
"format",
"(",
"len",
... | Convert from poppy representation to IKPY internal representation. | [
"Convert",
"from",
"poppy",
"representation",
"to",
"IKPY",
"internal",
"representation",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L101-L111 | train |
poppy-project/pypot | pypot/creatures/ik.py | IKChain.convert_from_ik_angles | def convert_from_ik_angles(self, joints):
""" Convert from IKPY internal representation to poppy representation. """
if len(joints) != len(self.motors) + 2:
raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors) + 2))
joints = [rad2deg(j) for j in jo... | python | def convert_from_ik_angles(self, joints):
""" Convert from IKPY internal representation to poppy representation. """
if len(joints) != len(self.motors) + 2:
raise ValueError('Incompatible data, len(joints) should be {}!'.format(len(self.motors) + 2))
joints = [rad2deg(j) for j in jo... | [
"def",
"convert_from_ik_angles",
"(",
"self",
",",
"joints",
")",
":",
"if",
"len",
"(",
"joints",
")",
"!=",
"len",
"(",
"self",
".",
"motors",
")",
"+",
"2",
":",
"raise",
"ValueError",
"(",
"'Incompatible data, len(joints) should be {}!'",
".",
"format",
... | Convert from IKPY internal representation to poppy representation. | [
"Convert",
"from",
"IKPY",
"internal",
"representation",
"to",
"poppy",
"representation",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/creatures/ik.py#L113-L122 | train |
poppy-project/pypot | pypot/dynamixel/io/io_320.py | Dxl320IO.factory_reset | def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False):
""" Reset all motors on the bus to their factory default settings. """
mode = (0x02 if except_baudrate_and_ids else
0x01 if except_ids else 0xFF)
for id in ids:
try:
self.... | python | def factory_reset(self, ids, except_ids=False, except_baudrate_and_ids=False):
""" Reset all motors on the bus to their factory default settings. """
mode = (0x02 if except_baudrate_and_ids else
0x01 if except_ids else 0xFF)
for id in ids:
try:
self.... | [
"def",
"factory_reset",
"(",
"self",
",",
"ids",
",",
"except_ids",
"=",
"False",
",",
"except_baudrate_and_ids",
"=",
"False",
")",
":",
"mode",
"=",
"(",
"0x02",
"if",
"except_baudrate_and_ids",
"else",
"0x01",
"if",
"except_ids",
"else",
"0xFF",
")",
"for... | Reset all motors on the bus to their factory default settings. | [
"Reset",
"all",
"motors",
"on",
"the",
"bus",
"to",
"their",
"factory",
"default",
"settings",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io_320.py#L32-L43 | train |
poppy-project/pypot | pypot/primitive/primitive.py | Primitive.stop | def stop(self, wait=True):
""" Requests the primitive to stop. """
logger.info("Primitive %s stopped.", self)
StoppableThread.stop(self, wait) | python | def stop(self, wait=True):
""" Requests the primitive to stop. """
logger.info("Primitive %s stopped.", self)
StoppableThread.stop(self, wait) | [
"def",
"stop",
"(",
"self",
",",
"wait",
"=",
"True",
")",
":",
"logger",
".",
"info",
"(",
"\"Primitive %s stopped.\"",
",",
"self",
")",
"StoppableThread",
".",
"stop",
"(",
"self",
",",
"wait",
")"
] | Requests the primitive to stop. | [
"Requests",
"the",
"primitive",
"to",
"stop",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L126-L129 | train |
poppy-project/pypot | pypot/primitive/primitive.py | LoopPrimitive.recent_update_frequencies | def recent_update_frequencies(self):
""" Returns the 10 most recent update frequencies.
The given frequencies are computed as short-term frequencies!
The 0th element of the list corresponds to the most recent frequency.
"""
return list(reversed([(1.0 / p) for p in numpy.diff(sel... | python | def recent_update_frequencies(self):
""" Returns the 10 most recent update frequencies.
The given frequencies are computed as short-term frequencies!
The 0th element of the list corresponds to the most recent frequency.
"""
return list(reversed([(1.0 / p) for p in numpy.diff(sel... | [
"def",
"recent_update_frequencies",
"(",
"self",
")",
":",
"return",
"list",
"(",
"reversed",
"(",
"[",
"(",
"1.0",
"/",
"p",
")",
"for",
"p",
"in",
"numpy",
".",
"diff",
"(",
"self",
".",
"_recent_updates",
")",
"]",
")",
")"
] | Returns the 10 most recent update frequencies.
The given frequencies are computed as short-term frequencies!
The 0th element of the list corresponds to the most recent frequency. | [
"Returns",
"the",
"10",
"most",
"recent",
"update",
"frequencies",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L174-L180 | train |
poppy-project/pypot | pypot/primitive/primitive.py | MockupMotor.goto_position | def goto_position(self, position, duration, control=None, wait=False):
""" Automatically sets the goal position and the moving speed to reach the desired position within the duration. """
if control is None:
control = self.goto_behavior
if control == 'minjerk':
goto_min... | python | def goto_position(self, position, duration, control=None, wait=False):
""" Automatically sets the goal position and the moving speed to reach the desired position within the duration. """
if control is None:
control = self.goto_behavior
if control == 'minjerk':
goto_min... | [
"def",
"goto_position",
"(",
"self",
",",
"position",
",",
"duration",
",",
"control",
"=",
"None",
",",
"wait",
"=",
"False",
")",
":",
"if",
"control",
"is",
"None",
":",
"control",
"=",
"self",
".",
"goto_behavior",
"if",
"control",
"==",
"'minjerk'",... | Automatically sets the goal position and the moving speed to reach the desired position within the duration. | [
"Automatically",
"sets",
"the",
"goal",
"position",
"and",
"the",
"moving",
"speed",
"to",
"reach",
"the",
"desired",
"position",
"within",
"the",
"duration",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/primitive.py#L257-L277 | train |
poppy-project/pypot | pypot/primitive/move.py | MoveRecorder.add_tracked_motors | def add_tracked_motors(self, tracked_motors):
"""Add new motors to the recording"""
new_mockup_motors = map(self.get_mockup_motor, tracked_motors)
self.tracked_motors = list(set(self.tracked_motors + new_mockup_motors)) | python | def add_tracked_motors(self, tracked_motors):
"""Add new motors to the recording"""
new_mockup_motors = map(self.get_mockup_motor, tracked_motors)
self.tracked_motors = list(set(self.tracked_motors + new_mockup_motors)) | [
"def",
"add_tracked_motors",
"(",
"self",
",",
"tracked_motors",
")",
":",
"new_mockup_motors",
"=",
"map",
"(",
"self",
".",
"get_mockup_motor",
",",
"tracked_motors",
")",
"self",
".",
"tracked_motors",
"=",
"list",
"(",
"set",
"(",
"self",
".",
"tracked_mot... | Add new motors to the recording | [
"Add",
"new",
"motors",
"to",
"the",
"recording"
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/move.py#L137-L140 | train |
poppy-project/pypot | pypot/primitive/manager.py | PrimitiveManager.update | def update(self):
""" Combined at a predefined frequency the request orders and affect them to the real motors. """
with self.syncing:
for m in self._motors:
to_set = defaultdict(list)
for p in self._prim:
for key, val in getattr(p.robot, ... | python | def update(self):
""" Combined at a predefined frequency the request orders and affect them to the real motors. """
with self.syncing:
for m in self._motors:
to_set = defaultdict(list)
for p in self._prim:
for key, val in getattr(p.robot, ... | [
"def",
"update",
"(",
"self",
")",
":",
"with",
"self",
".",
"syncing",
":",
"for",
"m",
"in",
"self",
".",
"_motors",
":",
"to_set",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"p",
"in",
"self",
".",
"_prim",
":",
"for",
"key",
",",
"val",
"in... | Combined at a predefined frequency the request orders and affect them to the real motors. | [
"Combined",
"at",
"a",
"predefined",
"frequency",
"the",
"request",
"orders",
"and",
"affect",
"them",
"to",
"the",
"real",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/manager.py#L51-L74 | train |
poppy-project/pypot | pypot/primitive/manager.py | PrimitiveManager.stop | def stop(self):
""" Stop the primitive manager. """
for p in self.primitives[:]:
p.stop()
StoppableLoopThread.stop(self) | python | def stop(self):
""" Stop the primitive manager. """
for p in self.primitives[:]:
p.stop()
StoppableLoopThread.stop(self) | [
"def",
"stop",
"(",
"self",
")",
":",
"for",
"p",
"in",
"self",
".",
"primitives",
"[",
":",
"]",
":",
"p",
".",
"stop",
"(",
")",
"StoppableLoopThread",
".",
"stop",
"(",
"self",
")"
] | Stop the primitive manager. | [
"Stop",
"the",
"primitive",
"manager",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/primitive/manager.py#L76-L81 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.load_scene | def load_scene(self, scene_path, start=False):
""" Loads a scene on the V-REP server.
:param str scene_path: path to a V-REP scene file
:param bool start: whether to directly start the simulation after loading the scene
.. note:: It is assumed that the scene file is always available on... | python | def load_scene(self, scene_path, start=False):
""" Loads a scene on the V-REP server.
:param str scene_path: path to a V-REP scene file
:param bool start: whether to directly start the simulation after loading the scene
.. note:: It is assumed that the scene file is always available on... | [
"def",
"load_scene",
"(",
"self",
",",
"scene_path",
",",
"start",
"=",
"False",
")",
":",
"self",
".",
"stop_simulation",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"scene_path",
")",
":",
"raise",
"IOError",
"(",
"\"No such file or d... | Loads a scene on the V-REP server.
:param str scene_path: path to a V-REP scene file
:param bool start: whether to directly start the simulation after loading the scene
.. note:: It is assumed that the scene file is always available on the server side. | [
"Loads",
"a",
"scene",
"on",
"the",
"V",
"-",
"REP",
"server",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L91-L108 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.get_motor_position | def get_motor_position(self, motor_name):
""" Gets the motor current position. """
return self.call_remote_api('simxGetJointPosition',
self.get_object_handle(motor_name),
streaming=True) | python | def get_motor_position(self, motor_name):
""" Gets the motor current position. """
return self.call_remote_api('simxGetJointPosition',
self.get_object_handle(motor_name),
streaming=True) | [
"def",
"get_motor_position",
"(",
"self",
",",
"motor_name",
")",
":",
"return",
"self",
".",
"call_remote_api",
"(",
"'simxGetJointPosition'",
",",
"self",
".",
"get_object_handle",
"(",
"motor_name",
")",
",",
"streaming",
"=",
"True",
")"
] | Gets the motor current position. | [
"Gets",
"the",
"motor",
"current",
"position",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L143-L147 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.set_motor_position | def set_motor_position(self, motor_name, position):
""" Sets the motor target position. """
self.call_remote_api('simxSetJointTargetPosition',
self.get_object_handle(motor_name),
position,
sending=True) | python | def set_motor_position(self, motor_name, position):
""" Sets the motor target position. """
self.call_remote_api('simxSetJointTargetPosition',
self.get_object_handle(motor_name),
position,
sending=True) | [
"def",
"set_motor_position",
"(",
"self",
",",
"motor_name",
",",
"position",
")",
":",
"self",
".",
"call_remote_api",
"(",
"'simxSetJointTargetPosition'",
",",
"self",
".",
"get_object_handle",
"(",
"motor_name",
")",
",",
"position",
",",
"sending",
"=",
"Tru... | Sets the motor target position. | [
"Sets",
"the",
"motor",
"target",
"position",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L149-L154 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.set_motor_force | def set_motor_force(self, motor_name, force):
""" Sets the maximum force or torque that a joint can exert. """
self.call_remote_api('simxSetJointForce',
self.get_object_handle(motor_name),
force,
sending=True) | python | def set_motor_force(self, motor_name, force):
""" Sets the maximum force or torque that a joint can exert. """
self.call_remote_api('simxSetJointForce',
self.get_object_handle(motor_name),
force,
sending=True) | [
"def",
"set_motor_force",
"(",
"self",
",",
"motor_name",
",",
"force",
")",
":",
"self",
".",
"call_remote_api",
"(",
"'simxSetJointForce'",
",",
"self",
".",
"get_object_handle",
"(",
"motor_name",
")",
",",
"force",
",",
"sending",
"=",
"True",
")"
] | Sets the maximum force or torque that a joint can exert. | [
"Sets",
"the",
"maximum",
"force",
"or",
"torque",
"that",
"a",
"joint",
"can",
"exert",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L162-L167 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.get_object_position | def get_object_position(self, object_name, relative_to_object=None):
""" Gets the object position. """
h = self.get_object_handle(object_name)
relative_handle = (-1 if relative_to_object is None
else self.get_object_handle(relative_to_object))
return self.call... | python | def get_object_position(self, object_name, relative_to_object=None):
""" Gets the object position. """
h = self.get_object_handle(object_name)
relative_handle = (-1 if relative_to_object is None
else self.get_object_handle(relative_to_object))
return self.call... | [
"def",
"get_object_position",
"(",
"self",
",",
"object_name",
",",
"relative_to_object",
"=",
"None",
")",
":",
"h",
"=",
"self",
".",
"get_object_handle",
"(",
"object_name",
")",
"relative_handle",
"=",
"(",
"-",
"1",
"if",
"relative_to_object",
"is",
"None... | Gets the object position. | [
"Gets",
"the",
"object",
"position",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L169-L177 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.set_object_position | def set_object_position(self, object_name, position=[0, 0, 0]):
""" Sets the object position. """
h = self.get_object_handle(object_name)
return self.call_remote_api('simxSetObjectPosition',
h, -1, position,
sending=True) | python | def set_object_position(self, object_name, position=[0, 0, 0]):
""" Sets the object position. """
h = self.get_object_handle(object_name)
return self.call_remote_api('simxSetObjectPosition',
h, -1, position,
sending=True) | [
"def",
"set_object_position",
"(",
"self",
",",
"object_name",
",",
"position",
"=",
"[",
"0",
",",
"0",
",",
"0",
"]",
")",
":",
"h",
"=",
"self",
".",
"get_object_handle",
"(",
"object_name",
")",
"return",
"self",
".",
"call_remote_api",
"(",
"'simxSe... | Sets the object position. | [
"Sets",
"the",
"object",
"position",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L179-L185 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.get_object_handle | def get_object_handle(self, obj):
""" Gets the vrep object handle. """
if obj not in self._object_handles:
self._object_handles[obj] = self._get_object_handle(obj=obj)
return self._object_handles[obj] | python | def get_object_handle(self, obj):
""" Gets the vrep object handle. """
if obj not in self._object_handles:
self._object_handles[obj] = self._get_object_handle(obj=obj)
return self._object_handles[obj] | [
"def",
"get_object_handle",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
"not",
"in",
"self",
".",
"_object_handles",
":",
"self",
".",
"_object_handles",
"[",
"obj",
"]",
"=",
"self",
".",
"_get_object_handle",
"(",
"obj",
"=",
"obj",
")",
"return",
... | Gets the vrep object handle. | [
"Gets",
"the",
"vrep",
"object",
"handle",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L200-L205 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.get_collision_state | def get_collision_state(self, collision_name):
""" Gets the collision state. """
return self.call_remote_api('simxReadCollision',
self.get_collision_handle(collision_name),
streaming=True) | python | def get_collision_state(self, collision_name):
""" Gets the collision state. """
return self.call_remote_api('simxReadCollision',
self.get_collision_handle(collision_name),
streaming=True) | [
"def",
"get_collision_state",
"(",
"self",
",",
"collision_name",
")",
":",
"return",
"self",
".",
"call_remote_api",
"(",
"'simxReadCollision'",
",",
"self",
".",
"get_collision_handle",
"(",
"collision_name",
")",
",",
"streaming",
"=",
"True",
")"
] | Gets the collision state. | [
"Gets",
"the",
"collision",
"state",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L207-L211 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.get_collision_handle | def get_collision_handle(self, collision):
""" Gets a vrep collisions handle. """
if collision not in self._object_handles:
h = self._get_collision_handle(collision)
self._object_handles[collision] = h
return self._object_handles[collision] | python | def get_collision_handle(self, collision):
""" Gets a vrep collisions handle. """
if collision not in self._object_handles:
h = self._get_collision_handle(collision)
self._object_handles[collision] = h
return self._object_handles[collision] | [
"def",
"get_collision_handle",
"(",
"self",
",",
"collision",
")",
":",
"if",
"collision",
"not",
"in",
"self",
".",
"_object_handles",
":",
"h",
"=",
"self",
".",
"_get_collision_handle",
"(",
"collision",
")",
"self",
".",
"_object_handles",
"[",
"collision"... | Gets a vrep collisions handle. | [
"Gets",
"a",
"vrep",
"collisions",
"handle",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L216-L222 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.change_object_name | def change_object_name(self, old_name, new_name):
""" Change object name """
h = self._get_object_handle(old_name)
if old_name in self._object_handles:
self._object_handles.pop(old_name)
lua_code = "simSetObjectName({}, '{}')".format(h, new_name)
self._inject_lua_code... | python | def change_object_name(self, old_name, new_name):
""" Change object name """
h = self._get_object_handle(old_name)
if old_name in self._object_handles:
self._object_handles.pop(old_name)
lua_code = "simSetObjectName({}, '{}')".format(h, new_name)
self._inject_lua_code... | [
"def",
"change_object_name",
"(",
"self",
",",
"old_name",
",",
"new_name",
")",
":",
"h",
"=",
"self",
".",
"_get_object_handle",
"(",
"old_name",
")",
"if",
"old_name",
"in",
"self",
".",
"_object_handles",
":",
"self",
".",
"_object_handles",
".",
"pop",
... | Change object name | [
"Change",
"object",
"name"
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L255-L261 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO._create_pure_shape | def _create_pure_shape(self, primitive_type, options, sizes, mass, precision):
""" Create Pure Shape """
lua_code = "simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})".format(
primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1])
self._inje... | python | def _create_pure_shape(self, primitive_type, options, sizes, mass, precision):
""" Create Pure Shape """
lua_code = "simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})".format(
primitive_type, options, sizes[0], sizes[1], sizes[2], mass, precision[0], precision[1])
self._inje... | [
"def",
"_create_pure_shape",
"(",
"self",
",",
"primitive_type",
",",
"options",
",",
"sizes",
",",
"mass",
",",
"precision",
")",
":",
"lua_code",
"=",
"\"simCreatePureShape({}, {}, {{{}, {}, {}}}, {}, {{{}, {}}})\"",
".",
"format",
"(",
"primitive_type",
",",
"optio... | Create Pure Shape | [
"Create",
"Pure",
"Shape"
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L263-L267 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO._inject_lua_code | def _inject_lua_code(self, lua_code):
""" Sends raw lua code and evaluate it wihtout any checking! """
msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code.encode())
self.call_remote_api('simxWriteStringStream', 'my_lua_code', msg) | python | def _inject_lua_code(self, lua_code):
""" Sends raw lua code and evaluate it wihtout any checking! """
msg = (ctypes.c_ubyte * len(lua_code)).from_buffer_copy(lua_code.encode())
self.call_remote_api('simxWriteStringStream', 'my_lua_code', msg) | [
"def",
"_inject_lua_code",
"(",
"self",
",",
"lua_code",
")",
":",
"msg",
"=",
"(",
"ctypes",
".",
"c_ubyte",
"*",
"len",
"(",
"lua_code",
")",
")",
".",
"from_buffer_copy",
"(",
"lua_code",
".",
"encode",
"(",
")",
")",
"self",
".",
"call_remote_api",
... | Sends raw lua code and evaluate it wihtout any checking! | [
"Sends",
"raw",
"lua",
"code",
"and",
"evaluate",
"it",
"wihtout",
"any",
"checking!"
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L269-L272 | train |
poppy-project/pypot | pypot/vrep/io.py | VrepIO.call_remote_api | def call_remote_api(self, func_name, *args, **kwargs):
""" Calls any remote API func in a thread_safe way.
:param str func_name: name of the remote API func to call
:param args: args to pass to the remote API call
:param kwargs: args to pass to the remote API call
.. note:: You... | python | def call_remote_api(self, func_name, *args, **kwargs):
""" Calls any remote API func in a thread_safe way.
:param str func_name: name of the remote API func to call
:param args: args to pass to the remote API call
:param kwargs: args to pass to the remote API call
.. note:: You... | [
"def",
"call_remote_api",
"(",
"self",
",",
"func_name",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"f",
"=",
"getattr",
"(",
"remote_api",
",",
"func_name",
")",
"mode",
"=",
"self",
".",
"_extract_mode",
"(",
"kwargs",
")",
"kwargs",
"[",
"'ope... | Calls any remote API func in a thread_safe way.
:param str func_name: name of the remote API func to call
:param args: args to pass to the remote API call
:param kwargs: args to pass to the remote API call
.. note:: You can add an extra keyword to specify if you want to use the streami... | [
"Calls",
"any",
"remote",
"API",
"func",
"in",
"a",
"thread_safe",
"way",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/io.py#L274-L361 | train |
poppy-project/pypot | pypot/server/httpserver.py | HTTPRobotServer.run | def run(self, **kwargs):
""" Start the tornado server, run forever"""
try:
loop = IOLoop()
app = self.make_app()
app.listen(self.port)
loop.start()
except socket.error as serr:
# Re raise the socket error if not "[Errno 98] Address al... | python | def run(self, **kwargs):
""" Start the tornado server, run forever"""
try:
loop = IOLoop()
app = self.make_app()
app.listen(self.port)
loop.start()
except socket.error as serr:
# Re raise the socket error if not "[Errno 98] Address al... | [
"def",
"run",
"(",
"self",
",",
"**",
"kwargs",
")",
":",
"try",
":",
"loop",
"=",
"IOLoop",
"(",
")",
"app",
"=",
"self",
".",
"make_app",
"(",
")",
"app",
".",
"listen",
"(",
"self",
".",
"port",
")",
"loop",
".",
"start",
"(",
")",
"except",... | Start the tornado server, run forever | [
"Start",
"the",
"tornado",
"server",
"run",
"forever"
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/server/httpserver.py#L253-L267 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.close | def close(self, _force_lock=False):
""" Closes the serial communication if opened. """
if not self.closed:
with self.__force_lock(_force_lock) or self._serial_lock:
self._serial.close()
self.__used_ports.remove(self.port)
logger.info("Closing port... | python | def close(self, _force_lock=False):
""" Closes the serial communication if opened. """
if not self.closed:
with self.__force_lock(_force_lock) or self._serial_lock:
self._serial.close()
self.__used_ports.remove(self.port)
logger.info("Closing port... | [
"def",
"close",
"(",
"self",
",",
"_force_lock",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"closed",
":",
"with",
"self",
".",
"__force_lock",
"(",
"_force_lock",
")",
"or",
"self",
".",
"_serial_lock",
":",
"self",
".",
"_serial",
".",
"close"... | Closes the serial communication if opened. | [
"Closes",
"the",
"serial",
"communication",
"if",
"opened",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L145-L155 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.ping | def ping(self, id):
""" Pings the motor with the specified id.
.. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast.
"""
pp = self._protocol.DxlPingPacket(id)
try:
self._send_packet(pp, error_handler=None)
retu... | python | def ping(self, id):
""" Pings the motor with the specified id.
.. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast.
"""
pp = self._protocol.DxlPingPacket(id)
try:
self._send_packet(pp, error_handler=None)
retu... | [
"def",
"ping",
"(",
"self",
",",
"id",
")",
":",
"pp",
"=",
"self",
".",
"_protocol",
".",
"DxlPingPacket",
"(",
"id",
")",
"try",
":",
"self",
".",
"_send_packet",
"(",
"pp",
",",
"error_handler",
"=",
"None",
")",
"return",
"True",
"except",
"DxlTi... | Pings the motor with the specified id.
.. note:: The motor id should always be included in [0, 253]. 254 is used for broadcast. | [
"Pings",
"the",
"motor",
"with",
"the",
"specified",
"id",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L205-L217 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.scan | def scan(self, ids=range(254)):
""" Pings all ids within the specified list, by default it finds all the motors connected to the bus. """
return [id for id in ids if self.ping(id)] | python | def scan(self, ids=range(254)):
""" Pings all ids within the specified list, by default it finds all the motors connected to the bus. """
return [id for id in ids if self.ping(id)] | [
"def",
"scan",
"(",
"self",
",",
"ids",
"=",
"range",
"(",
"254",
")",
")",
":",
"return",
"[",
"id",
"for",
"id",
"in",
"ids",
"if",
"self",
".",
"ping",
"(",
"id",
")",
"]"
] | Pings all ids within the specified list, by default it finds all the motors connected to the bus. | [
"Pings",
"all",
"ids",
"within",
"the",
"specified",
"list",
"by",
"default",
"it",
"finds",
"all",
"the",
"motors",
"connected",
"to",
"the",
"bus",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L219-L221 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.get_model | def get_model(self, ids):
""" Gets the model for the specified motors. """
to_get_ids = [i for i in ids if i not in self._known_models]
models = [dxl_to_model(m) for m in self._get_model(to_get_ids, convert=False)]
self._known_models.update(zip(to_get_ids, models))
return tuple(... | python | def get_model(self, ids):
""" Gets the model for the specified motors. """
to_get_ids = [i for i in ids if i not in self._known_models]
models = [dxl_to_model(m) for m in self._get_model(to_get_ids, convert=False)]
self._known_models.update(zip(to_get_ids, models))
return tuple(... | [
"def",
"get_model",
"(",
"self",
",",
"ids",
")",
":",
"to_get_ids",
"=",
"[",
"i",
"for",
"i",
"in",
"ids",
"if",
"i",
"not",
"in",
"self",
".",
"_known_models",
"]",
"models",
"=",
"[",
"dxl_to_model",
"(",
"m",
")",
"for",
"m",
"in",
"self",
"... | Gets the model for the specified motors. | [
"Gets",
"the",
"model",
"for",
"the",
"specified",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L225-L231 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.change_baudrate | def change_baudrate(self, baudrate_for_ids):
""" Changes the baudrate of the specified motors. """
self._change_baudrate(baudrate_for_ids)
for motor_id in baudrate_for_ids:
if motor_id in self._known_models:
del self._known_models[motor_id]
if motor_id in... | python | def change_baudrate(self, baudrate_for_ids):
""" Changes the baudrate of the specified motors. """
self._change_baudrate(baudrate_for_ids)
for motor_id in baudrate_for_ids:
if motor_id in self._known_models:
del self._known_models[motor_id]
if motor_id in... | [
"def",
"change_baudrate",
"(",
"self",
",",
"baudrate_for_ids",
")",
":",
"self",
".",
"_change_baudrate",
"(",
"baudrate_for_ids",
")",
"for",
"motor_id",
"in",
"baudrate_for_ids",
":",
"if",
"motor_id",
"in",
"self",
".",
"_known_models",
":",
"del",
"self",
... | Changes the baudrate of the specified motors. | [
"Changes",
"the",
"baudrate",
"of",
"the",
"specified",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L252-L260 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.get_status_return_level | def get_status_return_level(self, ids, **kwargs):
""" Gets the status level for the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
srl = []
for id in ids:
try:
srl.extend(self._get_status_return_level((id, ),
... | python | def get_status_return_level(self, ids, **kwargs):
""" Gets the status level for the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
srl = []
for id in ids:
try:
srl.extend(self._get_status_return_level((id, ),
... | [
"def",
"get_status_return_level",
"(",
"self",
",",
"ids",
",",
"**",
"kwargs",
")",
":",
"convert",
"=",
"kwargs",
"[",
"'convert'",
"]",
"if",
"'convert'",
"in",
"kwargs",
"else",
"self",
".",
"_convert",
"srl",
"=",
"[",
"]",
"for",
"id",
"in",
"ids... | Gets the status level for the specified motors. | [
"Gets",
"the",
"status",
"level",
"for",
"the",
"specified",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L262-L280 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.set_status_return_level | def set_status_return_level(self, srl_for_id, **kwargs):
""" Sets status return level to the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
if convert:
srl_for_id = dict(zip(srl_for_id.keys(),
[('never', '... | python | def set_status_return_level(self, srl_for_id, **kwargs):
""" Sets status return level to the specified motors. """
convert = kwargs['convert'] if 'convert' in kwargs else self._convert
if convert:
srl_for_id = dict(zip(srl_for_id.keys(),
[('never', '... | [
"def",
"set_status_return_level",
"(",
"self",
",",
"srl_for_id",
",",
"**",
"kwargs",
")",
":",
"convert",
"=",
"kwargs",
"[",
"'convert'",
"]",
"if",
"'convert'",
"in",
"kwargs",
"else",
"self",
".",
"_convert",
"if",
"convert",
":",
"srl_for_id",
"=",
"... | Sets status return level to the specified motors. | [
"Sets",
"status",
"return",
"level",
"to",
"the",
"specified",
"motors",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L282-L288 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.switch_led_on | def switch_led_on(self, ids):
""" Switches on the LED of the motors with the specified ids. """
self._set_LED(dict(zip(ids, itertools.repeat(True)))) | python | def switch_led_on(self, ids):
""" Switches on the LED of the motors with the specified ids. """
self._set_LED(dict(zip(ids, itertools.repeat(True)))) | [
"def",
"switch_led_on",
"(",
"self",
",",
"ids",
")",
":",
"self",
".",
"_set_LED",
"(",
"dict",
"(",
"zip",
"(",
"ids",
",",
"itertools",
".",
"repeat",
"(",
"True",
")",
")",
")",
")"
] | Switches on the LED of the motors with the specified ids. | [
"Switches",
"on",
"the",
"LED",
"of",
"the",
"motors",
"with",
"the",
"specified",
"ids",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L290-L292 | train |
poppy-project/pypot | pypot/dynamixel/io/abstract_io.py | AbstractDxlIO.switch_led_off | def switch_led_off(self, ids):
""" Switches off the LED of the motors with the specified ids. """
self._set_LED(dict(zip(ids, itertools.repeat(False)))) | python | def switch_led_off(self, ids):
""" Switches off the LED of the motors with the specified ids. """
self._set_LED(dict(zip(ids, itertools.repeat(False)))) | [
"def",
"switch_led_off",
"(",
"self",
",",
"ids",
")",
":",
"self",
".",
"_set_LED",
"(",
"dict",
"(",
"zip",
"(",
"ids",
",",
"itertools",
".",
"repeat",
"(",
"False",
")",
")",
")",
")"
] | Switches off the LED of the motors with the specified ids. | [
"Switches",
"off",
"the",
"LED",
"of",
"the",
"motors",
"with",
"the",
"specified",
"ids",
"."
] | d9c6551bbc87d45d9d1f0bc15e35b616d0002afd | https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/abstract_io.py#L294-L296 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.