partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Honeypot.check_time | Make sure our Honeypot time is consistent, and not too far off
from the actual time. | beeswarm/drones/honeypot/honeypot.py | def check_time(self):
""" Make sure our Honeypot time is consistent, and not too far off
from the actual time. """
poll = self.config['timecheck']['poll']
ntp_poll = self.config['timecheck']['ntp_pool']
while True:
clnt = ntplib.NTPClient()
try:
... | def check_time(self):
""" Make sure our Honeypot time is consistent, and not too far off
from the actual time. """
poll = self.config['timecheck']['poll']
ntp_poll = self.config['timecheck']['ntp_pool']
while True:
clnt = ntplib.NTPClient()
try:
... | [
"Make",
"sure",
"our",
"Honeypot",
"time",
"is",
"consistent",
"and",
"not",
"too",
"far",
"off",
"from",
"the",
"actual",
"time",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L111-L129 | [
"def",
"check_time",
"(",
"self",
")",
":",
"poll",
"=",
"self",
".",
"config",
"[",
"'timecheck'",
"]",
"[",
"'poll'",
"]",
"ntp_poll",
"=",
"self",
".",
"config",
"[",
"'timecheck'",
"]",
"[",
"'ntp_pool'",
"]",
"while",
"True",
":",
"clnt",
"=",
"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Honeypot.start | Starts services. | beeswarm/drones/honeypot/honeypot.py | def start(self):
""" Starts services. """
# protocol handlers
for c in handlerbase.HandlerBase.__subclasses__():
cap_name = c.__name__.lower()
if cap_name in self.config['capabilities']:
port = self.config['capabilities'][cap_name]['port']
... | def start(self):
""" Starts services. """
# protocol handlers
for c in handlerbase.HandlerBase.__subclasses__():
cap_name = c.__name__.lower()
if cap_name in self.config['capabilities']:
port = self.config['capabilities'][cap_name]['port']
... | [
"Starts",
"services",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L131-L167 | [
"def",
"start",
"(",
"self",
")",
":",
"# protocol handlers",
"for",
"c",
"in",
"handlerbase",
".",
"HandlerBase",
".",
"__subclasses__",
"(",
")",
":",
"cap_name",
"=",
"c",
".",
"__name__",
".",
"lower",
"(",
")",
"if",
"cap_name",
"in",
"self",
".",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Honeypot.stop | Stops services | beeswarm/drones/honeypot/honeypot.py | def stop(self):
"""Stops services"""
for s in self._servers:
s.stop()
for g in self._server_greenlets:
g.kill()
logger.info('All workers stopped.') | def stop(self):
"""Stops services"""
for s in self._servers:
s.stop()
for g in self._server_greenlets:
g.kill()
logger.info('All workers stopped.') | [
"Stops",
"services"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L169-L178 | [
"def",
"stop",
"(",
"self",
")",
":",
"for",
"s",
"in",
"self",
".",
"_servers",
":",
"s",
".",
"stop",
"(",
")",
"for",
"g",
"in",
"self",
".",
"_server_greenlets",
":",
"g",
".",
"kill",
"(",
")",
"logger",
".",
"info",
"(",
"'All workers stopped... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Honeypot.prepare_environment | Performs a few maintenance tasks before the Honeypot is run. Copies the data directory,
and the config file to the cwd. The config file copied here is overwritten if
the __init__ method is called with a configuration URL.
:param work_dir: The directory to copy files to. | beeswarm/drones/honeypot/honeypot.py | def prepare_environment(work_dir):
"""
Performs a few maintenance tasks before the Honeypot is run. Copies the data directory,
and the config file to the cwd. The config file copied here is overwritten if
the __init__ method is called with a configuration URL.
:param... | def prepare_environment(work_dir):
"""
Performs a few maintenance tasks before the Honeypot is run. Copies the data directory,
and the config file to the cwd. The config file copied here is overwritten if
the __init__ method is called with a configuration URL.
:param... | [
"Performs",
"a",
"few",
"maintenance",
"tasks",
"before",
"the",
"Honeypot",
"is",
"run",
".",
"Copies",
"the",
"data",
"directory",
"and",
"the",
"config",
"file",
"to",
"the",
"cwd",
".",
"The",
"config",
"file",
"copied",
"here",
"is",
"overwritten",
"i... | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L181-L193 | [
"def",
"prepare_environment",
"(",
"work_dir",
")",
":",
"package_directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"beeswarm",
".",
"__file__",
")",
")",
"logger",
".",
"info",
"(",
"'Copying data files to work... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Http.start | Launches a new HTTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/http.py | def start(self):
"""
Launches a new HTTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new HTTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"HTTP",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/http.py#L49-L91 | [
"def",
"start",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Http._get_links | Parses the response text and returns all the links in it.
:param response: The Response object. | beeswarm/drones/client/baits/http.py | def _get_links(self, response):
"""
Parses the response text and returns all the links in it.
:param response: The Response object.
"""
html_text = response.text.encode('utf-8')
doc = document_fromstring(html_text)
links = []
for e in doc.cssselect('a... | def _get_links(self, response):
"""
Parses the response text and returns all the links in it.
:param response: The Response object.
"""
html_text = response.text.encode('utf-8')
doc = document_fromstring(html_text)
links = []
for e in doc.cssselect('a... | [
"Parses",
"the",
"response",
"text",
"and",
"returns",
"all",
"the",
"links",
"in",
"it",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/http.py#L100-L110 | [
"def",
"_get_links",
"(",
"self",
",",
"response",
")",
":",
"html_text",
"=",
"response",
".",
"text",
".",
"encode",
"(",
"'utf-8'",
")",
"doc",
"=",
"document_fromstring",
"(",
"html_text",
")",
"links",
"=",
"[",
"]",
"for",
"e",
"in",
"doc",
".",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | bootstrap | Bootstraps localhost configurations for a Beeswarm server and a honeypot.
:param server_workdir: Output directory for the server configuration file.
:param drone_workdir: Output directory for the drone configuration file. | beeswarm/shared/misc/local_bootstrapper.py | def bootstrap(server_workdir, drone_workdir):
"""Bootstraps localhost configurations for a Beeswarm server and a honeypot.
:param server_workdir: Output directory for the server configuration file.
:param drone_workdir: Output directory for the drone configuration file.
"""
root_logger = logging.ge... | def bootstrap(server_workdir, drone_workdir):
"""Bootstraps localhost configurations for a Beeswarm server and a honeypot.
:param server_workdir: Output directory for the server configuration file.
:param drone_workdir: Output directory for the drone configuration file.
"""
root_logger = logging.ge... | [
"Bootstraps",
"localhost",
"configurations",
"for",
"a",
"Beeswarm",
"server",
"and",
"a",
"honeypot",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/misc/local_bootstrapper.py#L39-L120 | [
"def",
"bootstrap",
"(",
"server_workdir",
",",
"drone_workdir",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"root_logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"formatter",
"=",
"logging",
".",
"Formatter",
"(",
"'%(a... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | database_exists | Check if a database exists.
:param url: A SQLAlchemy engine URL.
Performs backend-specific testing to quickly determine if a database
exists on the server. ::
database_exists('postgres://postgres@localhost/name') #=> False
create_database('postgres://postgres@localhost/name')
dat... | beeswarm/shared/helpers.py | def database_exists(url):
"""Check if a database exists.
:param url: A SQLAlchemy engine URL.
Performs backend-specific testing to quickly determine if a database
exists on the server. ::
database_exists('postgres://postgres@localhost/name') #=> False
create_database('postgres://post... | def database_exists(url):
"""Check if a database exists.
:param url: A SQLAlchemy engine URL.
Performs backend-specific testing to quickly determine if a database
exists on the server. ::
database_exists('postgres://postgres@localhost/name') #=> False
create_database('postgres://post... | [
"Check",
"if",
"a",
"database",
"exists",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/helpers.py#L246-L297 | [
"def",
"database_exists",
"(",
"url",
")",
":",
"url",
"=",
"copy",
"(",
"make_url",
"(",
"url",
")",
")",
"database",
"=",
"url",
".",
"database",
"if",
"url",
".",
"drivername",
".",
"startswith",
"(",
"'postgresql'",
")",
":",
"url",
".",
"database"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Server.message_proxy | drone_data_inboud is for data comming from drones
drone_data_outbound is for commands to the drones, topic must either be a drone ID or all for sending
a broadcast message to all drones | beeswarm/server/server.py | def message_proxy(self, work_dir):
"""
drone_data_inboud is for data comming from drones
drone_data_outbound is for commands to the drones, topic must either be a drone ID or all for sending
a broadcast message to all drones
"""
public_keys_dir = os.... | def message_proxy(self, work_dir):
"""
drone_data_inboud is for data comming from drones
drone_data_outbound is for commands to the drones, topic must either be a drone ID or all for sending
a broadcast message to all drones
"""
public_keys_dir = os.... | [
"drone_data_inboud",
"is",
"for",
"data",
"comming",
"from",
"drones",
"drone_data_outbound",
"is",
"for",
"commands",
"to",
"the",
"drones",
"topic",
"must",
"either",
"be",
"a",
"drone",
"ID",
"or",
"all",
"for",
"sending",
"a",
"broadcast",
"message",
"to",... | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L113-L176 | [
"def",
"message_proxy",
"(",
"self",
",",
"work_dir",
")",
":",
"public_keys_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_dir",
",",
"'certificates'",
",",
"'public_keys'",
")",
"secret_keys_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"work_di... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Server.start | Starts the BeeSwarm server. | beeswarm/server/server.py | def start(self):
"""
Starts the BeeSwarm server.
"""
self.started = True
if self.app:
web_port = self.config['network']['web_port']
logger.info('Starting server listening on port {0}'.format(web_port))
key_file = os.path.join(self.work_dir,... | def start(self):
"""
Starts the BeeSwarm server.
"""
self.started = True
if self.app:
web_port = self.config['network']['web_port']
logger.info('Starting server listening on port {0}'.format(web_port))
key_file = os.path.join(self.work_dir,... | [
"Starts",
"the",
"BeeSwarm",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L178-L194 | [
"def",
"start",
"(",
"self",
")",
":",
"self",
".",
"started",
"=",
"True",
"if",
"self",
".",
"app",
":",
"web_port",
"=",
"self",
".",
"config",
"[",
"'network'",
"]",
"[",
"'web_port'",
"]",
"logger",
".",
"info",
"(",
"'Starting server listening on p... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Server.get_config | Loads the configuration from the JSON file, and returns it.
:param configfile: Path to the configuration file | beeswarm/server/server.py | def get_config(self, configfile):
"""
Loads the configuration from the JSON file, and returns it.
:param configfile: Path to the configuration file
"""
with open(configfile) as config_file:
config = json.load(config_file)
return config | def get_config(self, configfile):
"""
Loads the configuration from the JSON file, and returns it.
:param configfile: Path to the configuration file
"""
with open(configfile) as config_file:
config = json.load(config_file)
return config | [
"Loads",
"the",
"configuration",
"from",
"the",
"JSON",
"file",
"and",
"returns",
"it",
".",
":",
"param",
"configfile",
":",
"Path",
"to",
"the",
"configuration",
"file"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L207-L214 | [
"def",
"get_config",
"(",
"self",
",",
"configfile",
")",
":",
"with",
"open",
"(",
"configfile",
")",
"as",
"config_file",
":",
"config",
"=",
"json",
".",
"load",
"(",
"config_file",
")",
"return",
"config"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | BaitDispatcher.time_in_range | Return true if current time is in the active range | beeswarm/drones/client/models/dispatcher.py | def time_in_range(self):
"""Return true if current time is in the active range"""
curr = datetime.datetime.now().time()
if self.start_time <= self.end_time:
return self.start_time <= curr <= self.end_time
else:
return self.start_time <= curr or curr <= self.end_ti... | def time_in_range(self):
"""Return true if current time is in the active range"""
curr = datetime.datetime.now().time()
if self.start_time <= self.end_time:
return self.start_time <= curr <= self.end_time
else:
return self.start_time <= curr or curr <= self.end_ti... | [
"Return",
"true",
"if",
"current",
"time",
"is",
"in",
"the",
"active",
"range"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/models/dispatcher.py#L101-L107 | [
"def",
"time_in_range",
"(",
"self",
")",
":",
"curr",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
".",
"time",
"(",
")",
"if",
"self",
".",
"start_time",
"<=",
"self",
".",
"end_time",
":",
"return",
"self",
".",
"start_time",
"<=",
"cur... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Vnc.start | Launches a new Telnet client session on the server taken from the `self.options` dict.
This session always fails.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/vnc.py | def start(self):
"""
Launches a new Telnet client session on the server taken from the `self.options` dict.
This session always fails.
:param my_ip: IP of this Client itself
"""
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new Telnet client session on the server taken from the `self.options` dict.
This session always fails.
:param my_ip: IP of this Client itself
"""
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"Telnet",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
".",
"This",
"session",
"always",
"fails",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/vnc.py#L37-L92 | [
"def",
"start",
"(",
"self",
")",
":",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",
"self",
".",
"options",
"[",
"'port'",
"]",
"honeypot_id",
"=",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | ClientBase.create_session | Creates a new session.
:param server_host: IP address of the server
:param server_port: Server port
:return: A new `BaitSession` object. | beeswarm/drones/client/baits/clientbase.py | def create_session(self, server_host, server_port, honeypot_id):
"""
Creates a new session.
:param server_host: IP address of the server
:param server_port: Server port
:return: A new `BaitSession` object.
"""
protocol = self.__class__.__name__.lower()
... | def create_session(self, server_host, server_port, honeypot_id):
"""
Creates a new session.
:param server_host: IP address of the server
:param server_port: Server port
:return: A new `BaitSession` object.
"""
protocol = self.__class__.__name__.lower()
... | [
"Creates",
"a",
"new",
"session",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/clientbase.py#L31-L42 | [
"def",
"create_session",
"(",
"self",
",",
"server_host",
",",
"server_port",
",",
"honeypot_id",
")",
":",
"protocol",
"=",
"self",
".",
"__class__",
".",
"__name__",
".",
"lower",
"(",
")",
"session",
"=",
"BaitSession",
"(",
"protocol",
",",
"server_host"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.start | Launches a new FTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/ftp.py | def start(self):
"""
Launches a new FTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new FTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"FTP",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L64-L116 | [
"def",
"start",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.sense | Launches a few "sensing" commands such as 'ls', or 'pwd'
and updates the current bait state. | beeswarm/drones/client/baits/ftp.py | def sense(self):
"""
Launches a few "sensing" commands such as 'ls', or 'pwd'
and updates the current bait state.
"""
cmd_name = random.choice(self.senses)
command = getattr(self, cmd_name)
self.state['last_command'] = cmd_name
command() | def sense(self):
"""
Launches a few "sensing" commands such as 'ls', or 'pwd'
and updates the current bait state.
"""
cmd_name = random.choice(self.senses)
command = getattr(self, cmd_name)
self.state['last_command'] = cmd_name
command() | [
"Launches",
"a",
"few",
"sensing",
"commands",
"such",
"as",
"ls",
"or",
"pwd",
"and",
"updates",
"the",
"current",
"bait",
"state",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L118-L126 | [
"def",
"sense",
"(",
"self",
")",
":",
"cmd_name",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"senses",
")",
"command",
"=",
"getattr",
"(",
"self",
",",
"cmd_name",
")",
"self",
".",
"state",
"[",
"'last_command'",
"]",
"=",
"cmd_name",
"command"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.decide | Decides the next command to be launched based on the current state.
:return: Tuple containing the next command name, and it's parameters. | beeswarm/drones/client/baits/ftp.py | def decide(self):
"""
Decides the next command to be launched based on the current state.
:return: Tuple containing the next command name, and it's parameters.
"""
next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
param = ''
if n... | def decide(self):
"""
Decides the next command to be launched based on the current state.
:return: Tuple containing the next command name, and it's parameters.
"""
next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
param = ''
if n... | [
"Decides",
"the",
"next",
"command",
"to",
"be",
"launched",
"based",
"on",
"the",
"current",
"state",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L128-L140 | [
"def",
"decide",
"(",
"self",
")",
":",
"next_command_name",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"COMMAND_MAP",
"[",
"self",
".",
"state",
"[",
"'last_command'",
"]",
"]",
")",
"param",
"=",
"''",
"if",
"next_command_name",
"==",
"'retrieve'",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.act | Run the command with the parameters.
:param cmd_name: The name of command to run
:param param: Params for the command | beeswarm/drones/client/baits/ftp.py | def act(self, cmd_name, param):
"""
Run the command with the parameters.
:param cmd_name: The name of command to run
:param param: Params for the command
"""
command = getattr(self, cmd_name)
if param:
command(param)
else:
comm... | def act(self, cmd_name, param):
"""
Run the command with the parameters.
:param cmd_name: The name of command to run
:param param: Params for the command
"""
command = getattr(self, cmd_name)
if param:
command(param)
else:
comm... | [
"Run",
"the",
"command",
"with",
"the",
"parameters",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L142-L153 | [
"def",
"act",
"(",
"self",
",",
"cmd_name",
",",
"param",
")",
":",
"command",
"=",
"getattr",
"(",
"self",
",",
"cmd_name",
")",
"if",
"param",
":",
"command",
"(",
"param",
")",
"else",
":",
"command",
"(",
")"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.list | Run the FTP LIST command, and update the state. | beeswarm/drones/client/baits/ftp.py | def list(self):
"""
Run the FTP LIST command, and update the state.
"""
logger.debug('Sending FTP list command.')
self.state['file_list'] = []
self.state['dir_list'] = []
self.client.retrlines('LIST', self._process_list) | def list(self):
"""
Run the FTP LIST command, and update the state.
"""
logger.debug('Sending FTP list command.')
self.state['file_list'] = []
self.state['dir_list'] = []
self.client.retrlines('LIST', self._process_list) | [
"Run",
"the",
"FTP",
"LIST",
"command",
"and",
"update",
"the",
"state",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L155-L162 | [
"def",
"list",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"'Sending FTP list command.'",
")",
"self",
".",
"state",
"[",
"'file_list'",
"]",
"=",
"[",
"]",
"self",
".",
"state",
"[",
"'dir_list'",
"]",
"=",
"[",
"]",
"self",
".",
"client",
"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.retrieve | Run the FTP RETR command, and download the file
:param filename: Name of the file to download | beeswarm/drones/client/baits/ftp.py | def retrieve(self, filename):
"""
Run the FTP RETR command, and download the file
:param filename: Name of the file to download
"""
logger.debug('Sending FTP retr command. Filename: {}'.format(filename))
self.client.retrbinary('RETR {}'.format(filename), self._save_f... | def retrieve(self, filename):
"""
Run the FTP RETR command, and download the file
:param filename: Name of the file to download
"""
logger.debug('Sending FTP retr command. Filename: {}'.format(filename))
self.client.retrbinary('RETR {}'.format(filename), self._save_f... | [
"Run",
"the",
"FTP",
"RETR",
"command",
"and",
"download",
"the",
"file"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L164-L171 | [
"def",
"retrieve",
"(",
"self",
",",
"filename",
")",
":",
"logger",
".",
"debug",
"(",
"'Sending FTP retr command. Filename: {}'",
".",
"format",
"(",
"filename",
")",
")",
"self",
".",
"client",
".",
"retrbinary",
"(",
"'RETR {}'",
".",
"format",
"(",
"fil... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp.cwd | Send the FTP CWD command
:param newdir: Directory to change to | beeswarm/drones/client/baits/ftp.py | def cwd(self, newdir):
"""
Send the FTP CWD command
:param newdir: Directory to change to
"""
logger.debug('Sending FTP cwd command. New Workding Directory: {}'.format(newdir))
self.client.cwd(newdir)
self.state['current_dir'] = self.client.pwd() | def cwd(self, newdir):
"""
Send the FTP CWD command
:param newdir: Directory to change to
"""
logger.debug('Sending FTP cwd command. New Workding Directory: {}'.format(newdir))
self.client.cwd(newdir)
self.state['current_dir'] = self.client.pwd() | [
"Send",
"the",
"FTP",
"CWD",
"command"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L180-L188 | [
"def",
"cwd",
"(",
"self",
",",
"newdir",
")",
":",
"logger",
".",
"debug",
"(",
"'Sending FTP cwd command. New Workding Directory: {}'",
".",
"format",
"(",
"newdir",
")",
")",
"self",
".",
"client",
".",
"cwd",
"(",
"newdir",
")",
"self",
".",
"state",
"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ftp._process_list | Processes a line of 'ls -l' output, and updates state accordingly.
:param list_line: Line to process | beeswarm/drones/client/baits/ftp.py | def _process_list(self, list_line):
# -rw-r--r-- 1 ftp ftp 68 May 09 19:37 testftp.txt
"""
Processes a line of 'ls -l' output, and updates state accordingly.
:param list_line: Line to process
"""
res = list_line.split(' ', 8)
if res[0].startswith('-'):
... | def _process_list(self, list_line):
# -rw-r--r-- 1 ftp ftp 68 May 09 19:37 testftp.txt
"""
Processes a line of 'ls -l' output, and updates state accordingly.
:param list_line: Line to process
"""
res = list_line.split(' ', 8)
if res[0].startswith('-'):
... | [
"Processes",
"a",
"line",
"of",
"ls",
"-",
"l",
"output",
"and",
"updates",
"state",
"accordingly",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L206-L217 | [
"def",
"_process_list",
"(",
"self",
",",
"list_line",
")",
":",
"# -rw-r--r-- 1 ftp ftp 68\t May 09 19:37 testftp.txt",
"res",
"=",
"list_line",
".",
"split",
"(",
"' '",
",",
"8",
")",
"if",
"res",
"[",
"0",
"]",
".",
"startswith",
"(",
"'-'",
")",
":",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | validate_time_range | Makes sure the form data is in 'hh:mm - hh:mm' format and the start time is less than end time. | beeswarm/server/webapp/forms.py | def validate_time_range(form, field):
""" Makes sure the form data is in 'hh:mm - hh:mm' format and the start time is less than end time."""
string = field.data
try:
begin, end = string.split('-')
begin = begin.strip()
end = end.strip()
begin_hours, begin_min = begin.split(... | def validate_time_range(form, field):
""" Makes sure the form data is in 'hh:mm - hh:mm' format and the start time is less than end time."""
string = field.data
try:
begin, end = string.split('-')
begin = begin.strip()
end = end.strip()
begin_hours, begin_min = begin.split(... | [
"Makes",
"sure",
"the",
"form",
"data",
"is",
"in",
"hh",
":",
"mm",
"-",
"hh",
":",
"mm",
"format",
"and",
"the",
"start",
"time",
"is",
"less",
"than",
"end",
"time",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/webapp/forms.py#L6-L24 | [
"def",
"validate_time_range",
"(",
"form",
",",
"field",
")",
":",
"string",
"=",
"field",
".",
"data",
"try",
":",
"begin",
",",
"end",
"=",
"string",
".",
"split",
"(",
"'-'",
")",
"begin",
"=",
"begin",
".",
"strip",
"(",
")",
"end",
"=",
"end",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Client.start | Starts sending client bait to the configured Honeypot. | beeswarm/drones/client/client.py | def start(self):
"""
Starts sending client bait to the configured Honeypot.
"""
logger.info('Starting client.')
self.dispatcher_greenlets = []
for _, entry in self.config['baits'].items():
for b in clientbase.ClientBase.__subclasses__():
... | def start(self):
"""
Starts sending client bait to the configured Honeypot.
"""
logger.info('Starting client.')
self.dispatcher_greenlets = []
for _, entry in self.config['baits'].items():
for b in clientbase.ClientBase.__subclasses__():
... | [
"Starts",
"sending",
"client",
"bait",
"to",
"the",
"configured",
"Honeypot",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/client.py#L58-L78 | [
"def",
"start",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Starting client.'",
")",
"self",
".",
"dispatcher_greenlets",
"=",
"[",
"]",
"for",
"_",
",",
"entry",
"in",
"self",
".",
"config",
"[",
"'baits'",
"]",
".",
"items",
"(",
")",
":",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Pop3s.start | Launches a new POP3 client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/pop3s.py | def start(self):
"""
Launches a new POP3 client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new POP3 client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"POP3",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/pop3s.py#L30-L75 | [
"def",
"start",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | DatabaseActor.get_matching_session | Tries to match a session with it's counterpart. For bait session it will try to match it with honeypot sessions
and the other way around.
:param session: session object which will be used as base for query.
:param timediff: +/- allowed time difference between a session and a potential matching ... | beeswarm/server/db/database_actor.py | def get_matching_session(self, session, db_session, timediff=5):
"""
Tries to match a session with it's counterpart. For bait session it will try to match it with honeypot sessions
and the other way around.
:param session: session object which will be used as base for query.
:pa... | def get_matching_session(self, session, db_session, timediff=5):
"""
Tries to match a session with it's counterpart. For bait session it will try to match it with honeypot sessions
and the other way around.
:param session: session object which will be used as base for query.
:pa... | [
"Tries",
"to",
"match",
"a",
"session",
"with",
"it",
"s",
"counterpart",
".",
"For",
"bait",
"session",
"it",
"will",
"try",
"to",
"match",
"it",
"with",
"honeypot",
"sessions",
"and",
"the",
"other",
"way",
"around",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/db/database_actor.py#L354-L393 | [
"def",
"get_matching_session",
"(",
"self",
",",
"session",
",",
"db_session",
",",
"timediff",
"=",
"5",
")",
":",
"db_session",
"=",
"db_session",
"min_datetime",
"=",
"session",
".",
"timestamp",
"-",
"timedelta",
"(",
"seconds",
"=",
"timediff",
")",
"ma... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | DatabaseActor._classify_malicious_sessions | Will classify all unclassified sessions as malicious activity.
:param delay_seconds: no sessions newer than (now - delay_seconds) will be processed. | beeswarm/server/db/database_actor.py | def _classify_malicious_sessions(self):
"""
Will classify all unclassified sessions as malicious activity.
:param delay_seconds: no sessions newer than (now - delay_seconds) will be processed.
"""
min_datetime = datetime.utcnow() - timedelta(seconds=self.delay_seconds)
... | def _classify_malicious_sessions(self):
"""
Will classify all unclassified sessions as malicious activity.
:param delay_seconds: no sessions newer than (now - delay_seconds) will be processed.
"""
min_datetime = datetime.utcnow() - timedelta(seconds=self.delay_seconds)
... | [
"Will",
"classify",
"all",
"unclassified",
"sessions",
"as",
"malicious",
"activity",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/db/database_actor.py#L414-L474 | [
"def",
"_classify_malicious_sessions",
"(",
"self",
")",
":",
"min_datetime",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"-",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"delay_seconds",
")",
"db_session",
"=",
"database_setup",
".",
"get_session",
"(",
")",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ssh.start | Launches a new SSH client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/ssh.py | def start(self):
"""
Launches a new SSH client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new SSH client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"SSH",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L51-L90 | [
"def",
"start",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ssh.send_command | Send a command to the remote SSH server.
:param cmd: The command to send | beeswarm/drones/client/baits/ssh.py | def send_command(self, cmd):
"""
Send a command to the remote SSH server.
:param cmd: The command to send
"""
logger.debug('Sending {0} command.'.format(cmd))
self.comm_chan.sendall(cmd + '\n') | def send_command(self, cmd):
"""
Send a command to the remote SSH server.
:param cmd: The command to send
"""
logger.debug('Sending {0} command.'.format(cmd))
self.comm_chan.sendall(cmd + '\n') | [
"Send",
"a",
"command",
"to",
"the",
"remote",
"SSH",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L92-L99 | [
"def",
"send_command",
"(",
"self",
",",
"cmd",
")",
":",
"logger",
".",
"debug",
"(",
"'Sending {0} command.'",
".",
"format",
"(",
"cmd",
")",
")",
"self",
".",
"comm_chan",
".",
"sendall",
"(",
"cmd",
"+",
"'\\n'",
")"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ssh.get_response | Get the response from the server. *This may not return the full response*
:return: Response data | beeswarm/drones/client/baits/ssh.py | def get_response(self):
"""
Get the response from the server. *This may not return the full response*
:return: Response data
"""
while not self.comm_chan.recv_ready():
time.sleep(0.5)
return self.comm_chan.recv(2048) | def get_response(self):
"""
Get the response from the server. *This may not return the full response*
:return: Response data
"""
while not self.comm_chan.recv_ready():
time.sleep(0.5)
return self.comm_chan.recv(2048) | [
"Get",
"the",
"response",
"from",
"the",
"server",
".",
"*",
"This",
"may",
"not",
"return",
"the",
"full",
"response",
"*"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L101-L109 | [
"def",
"get_response",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"comm_chan",
".",
"recv_ready",
"(",
")",
":",
"time",
".",
"sleep",
"(",
"0.5",
")",
"return",
"self",
".",
"comm_chan",
".",
"recv",
"(",
"2048",
")"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Ssh.connect_login | Try to login to the Remote SSH Server.
:return: Response text on successful login
:raise: `AuthenticationFailed` on unsuccessful login | beeswarm/drones/client/baits/ssh.py | def connect_login(self):
"""
Try to login to the Remote SSH Server.
:return: Response text on successful login
:raise: `AuthenticationFailed` on unsuccessful login
"""
self.client.connect(self.options['server'], self.options['port'], self.options['username'],
... | def connect_login(self):
"""
Try to login to the Remote SSH Server.
:return: Response text on successful login
:raise: `AuthenticationFailed` on unsuccessful login
"""
self.client.connect(self.options['server'], self.options['port'], self.options['username'],
... | [
"Try",
"to",
"login",
"to",
"the",
"Remote",
"SSH",
"Server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L111-L127 | [
"def",
"connect_login",
"(",
"self",
")",
":",
"self",
".",
"client",
".",
"connect",
"(",
"self",
".",
"options",
"[",
"'server'",
"]",
",",
"self",
".",
"options",
"[",
"'port'",
"]",
",",
"self",
".",
"options",
"[",
"'username'",
"]",
",",
"self"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | list2dict | Transforms a list of 2 element tuples to a dictionary | beeswarm/drones/honeypot/helpers/common.py | def list2dict(list_of_options):
"""Transforms a list of 2 element tuples to a dictionary"""
d = {}
for key, value in list_of_options:
d[key] = value
return d | def list2dict(list_of_options):
"""Transforms a list of 2 element tuples to a dictionary"""
d = {}
for key, value in list_of_options:
d[key] = value
return d | [
"Transforms",
"a",
"list",
"of",
"2",
"element",
"tuples",
"to",
"a",
"dictionary"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/helpers/common.py#L10-L15 | [
"def",
"list2dict",
"(",
"list_of_options",
")",
":",
"d",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"list_of_options",
":",
"d",
"[",
"key",
"]",
"=",
"value",
"return",
"d"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | path_to_ls | Converts an absolute path to an entry resembling the output of
the ls command on most UNIX systems. | beeswarm/drones/honeypot/helpers/common.py | def path_to_ls(fn):
""" Converts an absolute path to an entry resembling the output of
the ls command on most UNIX systems."""
st = os.stat(fn)
full_mode = 'rwxrwxrwx'
mode = ''
file_time = ''
d = ''
for i in range(9):
# Incrementally builds up the 9 character string, using c... | def path_to_ls(fn):
""" Converts an absolute path to an entry resembling the output of
the ls command on most UNIX systems."""
st = os.stat(fn)
full_mode = 'rwxrwxrwx'
mode = ''
file_time = ''
d = ''
for i in range(9):
# Incrementally builds up the 9 character string, using c... | [
"Converts",
"an",
"absolute",
"path",
"to",
"an",
"entry",
"resembling",
"the",
"output",
"of",
"the",
"ls",
"command",
"on",
"most",
"UNIX",
"systems",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/helpers/common.py#L27-L42 | [
"def",
"path_to_ls",
"(",
"fn",
")",
":",
"st",
"=",
"os",
".",
"stat",
"(",
"fn",
")",
"full_mode",
"=",
"'rwxrwxrwx'",
"mode",
"=",
"''",
"file_time",
"=",
"''",
"d",
"=",
"''",
"for",
"i",
"in",
"range",
"(",
"9",
")",
":",
"# Incrementally buil... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Drone.start | Starts services. | beeswarm/drones/drone.py | def start(self):
""" Starts services. """
cert_path = os.path.join(self.work_dir, 'certificates')
public_keys_dir = os.path.join(cert_path, 'public_keys')
private_keys_dir = os.path.join(cert_path, 'private_keys')
client_secret_file = os.path.join(private_keys_dir, "client.key")... | def start(self):
""" Starts services. """
cert_path = os.path.join(self.work_dir, 'certificates')
public_keys_dir = os.path.join(cert_path, 'public_keys')
private_keys_dir = os.path.join(cert_path, 'private_keys')
client_secret_file = os.path.join(private_keys_dir, "client.key")... | [
"Starts",
"services",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L85-L104 | [
"def",
"start",
"(",
"self",
")",
":",
"cert_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"work_dir",
",",
"'certificates'",
")",
"public_keys_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"cert_path",
",",
"'public_keys'",
")",
"pri... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Drone._start_drone | Restarts the drone | beeswarm/drones/drone.py | def _start_drone(self):
"""
Restarts the drone
"""
with open(self.config_file, 'r') as config_file:
self.config = json.load(config_file, object_hook=asciify)
mode = None
if self.config['general']['mode'] == '' or self.config['general']['mode'] is None:
... | def _start_drone(self):
"""
Restarts the drone
"""
with open(self.config_file, 'r') as config_file:
self.config = json.load(config_file, object_hook=asciify)
mode = None
if self.config['general']['mode'] == '' or self.config['general']['mode'] is None:
... | [
"Restarts",
"the",
"drone"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L106-L126 | [
"def",
"_start_drone",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"config_file",
",",
"'r'",
")",
"as",
"config_file",
":",
"self",
".",
"config",
"=",
"json",
".",
"load",
"(",
"config_file",
",",
"object_hook",
"=",
"asciify",
")",
"mod... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Drone.stop | Stops services | beeswarm/drones/drone.py | def stop(self):
"""Stops services"""
logging.debug('Stopping drone, hang on.')
if self.drone is not None:
self.drone_greenlet.unlink(self.on_exception)
self.drone.stop()
self.drone_greenlet.kill()
self.drone = None
# just some time for the ... | def stop(self):
"""Stops services"""
logging.debug('Stopping drone, hang on.')
if self.drone is not None:
self.drone_greenlet.unlink(self.on_exception)
self.drone.stop()
self.drone_greenlet.kill()
self.drone = None
# just some time for the ... | [
"Stops",
"services"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L128-L139 | [
"def",
"stop",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"'Stopping drone, hang on.'",
")",
"if",
"self",
".",
"drone",
"is",
"not",
"None",
":",
"self",
".",
"drone_greenlet",
".",
"unlink",
"(",
"self",
".",
"on_exception",
")",
"self",
".",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Smtp.start | Launches a new SMTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/smtp.py | def start(self):
"""
Launches a new SMTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new SMTP client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
username = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"SMTP",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L51-L103 | [
"def",
"start",
"(",
"self",
")",
":",
"username",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Smtp.get_one_mail | Choose and return a random email from the mail archive.
:return: Tuple containing From Address, To Address and the mail body. | beeswarm/drones/client/baits/smtp.py | def get_one_mail(self):
"""
Choose and return a random email from the mail archive.
:return: Tuple containing From Address, To Address and the mail body.
"""
while True:
mail_key = random.choice(self.mailbox.keys())
mail = self.mailbox[mail_key]
... | def get_one_mail(self):
"""
Choose and return a random email from the mail archive.
:return: Tuple containing From Address, To Address and the mail body.
"""
while True:
mail_key = random.choice(self.mailbox.keys())
mail = self.mailbox[mail_key]
... | [
"Choose",
"and",
"return",
"a",
"random",
"email",
"from",
"the",
"mail",
"archive",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L105-L120 | [
"def",
"get_one_mail",
"(",
"self",
")",
":",
"while",
"True",
":",
"mail_key",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"mailbox",
".",
"keys",
"(",
")",
")",
"mail",
"=",
"self",
".",
"mailbox",
"[",
"mail_key",
"]",
"from_addr",
"=",
"mail"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Smtp.connect | Connect to the SMTP server. | beeswarm/drones/client/baits/smtp.py | def connect(self):
"""
Connect to the SMTP server.
"""
# TODO: local_hostname should be configurable
self.client = smtplib.SMTP(self.options['server'], self.options['port'],
local_hostname='local.domain', timeout=15) | def connect(self):
"""
Connect to the SMTP server.
"""
# TODO: local_hostname should be configurable
self.client = smtplib.SMTP(self.options['server'], self.options['port'],
local_hostname='local.domain', timeout=15) | [
"Connect",
"to",
"the",
"SMTP",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L122-L128 | [
"def",
"connect",
"(",
"self",
")",
":",
"# TODO: local_hostname should be configurable",
"self",
".",
"client",
"=",
"smtplib",
".",
"SMTP",
"(",
"self",
".",
"options",
"[",
"'server'",
"]",
",",
"self",
".",
"options",
"[",
"'port'",
"]",
",",
"local_host... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Commands.handle | The actual service to which the user has connected. | beeswarm/drones/honeypot/capabilities/shared/shell.py | def handle(self):
"The actual service to which the user has connected."
if not self.authentication_ok():
return
if self.DOECHO:
self.writeline(self.WELCOME)
self.session_start()
while self.RUNSHELL:
read_line = self.readline(prompt=self.PROMPT)... | def handle(self):
"The actual service to which the user has connected."
if not self.authentication_ok():
return
if self.DOECHO:
self.writeline(self.WELCOME)
self.session_start()
while self.RUNSHELL:
read_line = self.readline(prompt=self.PROMPT)... | [
"The",
"actual",
"service",
"to",
"which",
"the",
"user",
"has",
"connected",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/capabilities/shared/shell.py#L244-L273 | [
"def",
"handle",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"authentication_ok",
"(",
")",
":",
"return",
"if",
"self",
".",
"DOECHO",
":",
"self",
".",
"writeline",
"(",
"self",
".",
"WELCOME",
")",
"self",
".",
"session_start",
"(",
")",
"whi... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | _asciify_list | Ascii-fies list values | beeswarm/shared/asciify.py | def _asciify_list(data):
""" Ascii-fies list values """
ret = []
for item in data:
if isinstance(item, unicode):
item = _remove_accents(item)
item = item.encode('utf-8')
elif isinstance(item, list):
item = _asciify_list(item)
elif isinstance(item, ... | def _asciify_list(data):
""" Ascii-fies list values """
ret = []
for item in data:
if isinstance(item, unicode):
item = _remove_accents(item)
item = item.encode('utf-8')
elif isinstance(item, list):
item = _asciify_list(item)
elif isinstance(item, ... | [
"Ascii",
"-",
"fies",
"list",
"values"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/asciify.py#L15-L27 | [
"def",
"_asciify_list",
"(",
"data",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
":",
"if",
"isinstance",
"(",
"item",
",",
"unicode",
")",
":",
"item",
"=",
"_remove_accents",
"(",
"item",
")",
"item",
"=",
"item",
".",
"encode",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | _asciify_dict | Ascii-fies dict keys and values | beeswarm/shared/asciify.py | def _asciify_dict(data):
""" Ascii-fies dict keys and values """
ret = {}
for key, value in data.iteritems():
if isinstance(key, unicode):
key = _remove_accents(key)
key = key.encode('utf-8')
# # note new if
if isinstance(value, unicode):
value... | def _asciify_dict(data):
""" Ascii-fies dict keys and values """
ret = {}
for key, value in data.iteritems():
if isinstance(key, unicode):
key = _remove_accents(key)
key = key.encode('utf-8')
# # note new if
if isinstance(value, unicode):
value... | [
"Ascii",
"-",
"fies",
"dict",
"keys",
"and",
"values"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/asciify.py#L30-L46 | [
"def",
"_asciify_dict",
"(",
"data",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"data",
".",
"iteritems",
"(",
")",
":",
"if",
"isinstance",
"(",
"key",
",",
"unicode",
")",
":",
"key",
"=",
"_remove_accents",
"(",
"key",
")"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | BaitTelnetClient.write_human | Emulates human typing speed | beeswarm/drones/client/baits/telnet.py | def write_human(self, buffer_):
""" Emulates human typing speed """
if self.IAC in buffer_:
buffer_ = buffer_.replace(self.IAC, self.IAC + self.IAC)
self.msg("send %r", buffer_)
for char in buffer_:
delta = random.gauss(80, 20)
self.sock.sendall(char)... | def write_human(self, buffer_):
""" Emulates human typing speed """
if self.IAC in buffer_:
buffer_ = buffer_.replace(self.IAC, self.IAC + self.IAC)
self.msg("send %r", buffer_)
for char in buffer_:
delta = random.gauss(80, 20)
self.sock.sendall(char)... | [
"Emulates",
"human",
"typing",
"speed"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L40-L49 | [
"def",
"write_human",
"(",
"self",
",",
"buffer_",
")",
":",
"if",
"self",
".",
"IAC",
"in",
"buffer_",
":",
"buffer_",
"=",
"buffer_",
".",
"replace",
"(",
"self",
".",
"IAC",
",",
"self",
".",
"IAC",
"+",
"self",
".",
"IAC",
")",
"self",
".",
"... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Telnet.start | Launches a new Telnet client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself | beeswarm/drones/client/baits/telnet.py | def start(self):
"""
Launches a new Telnet client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
login = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | def start(self):
"""
Launches a new Telnet client session on the server taken from the `self.options` dict.
:param my_ip: IP of this Client itself
"""
login = self.options['username']
password = self.options['password']
server_host = self.options['server']
... | [
"Launches",
"a",
"new",
"Telnet",
"client",
"session",
"on",
"the",
"server",
"taken",
"from",
"the",
"self",
".",
"options",
"dict",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L75-L122 | [
"def",
"start",
"(",
"self",
")",
":",
"login",
"=",
"self",
".",
"options",
"[",
"'username'",
"]",
"password",
"=",
"self",
".",
"options",
"[",
"'password'",
"]",
"server_host",
"=",
"self",
".",
"options",
"[",
"'server'",
"]",
"server_port",
"=",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Telnet.connect | Open a new telnet session on the remote server. | beeswarm/drones/client/baits/telnet.py | def connect(self):
"""
Open a new telnet session on the remote server.
"""
self.client = BaitTelnetClient(self.options['server'], self.options['port'])
self.client.set_option_negotiation_callback(self.process_options) | def connect(self):
"""
Open a new telnet session on the remote server.
"""
self.client = BaitTelnetClient(self.options['server'], self.options['port'])
self.client.set_option_negotiation_callback(self.process_options) | [
"Open",
"a",
"new",
"telnet",
"session",
"on",
"the",
"remote",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L124-L129 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"client",
"=",
"BaitTelnetClient",
"(",
"self",
".",
"options",
"[",
"'server'",
"]",
",",
"self",
".",
"options",
"[",
"'port'",
"]",
")",
"self",
".",
"client",
".",
"set_option_negotiation_callback",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Telnet.login | Login to the remote telnet server.
:param login: Username to use for logging in
:param password: Password to use for logging in
:raise: `InvalidLogin` on failed login | beeswarm/drones/client/baits/telnet.py | def login(self, login, password):
"""
Login to the remote telnet server.
:param login: Username to use for logging in
:param password: Password to use for logging in
:raise: `InvalidLogin` on failed login
"""
self.client.read_until('Username: ')
self.... | def login(self, login, password):
"""
Login to the remote telnet server.
:param login: Username to use for logging in
:param password: Password to use for logging in
:raise: `InvalidLogin` on failed login
"""
self.client.read_until('Username: ')
self.... | [
"Login",
"to",
"the",
"remote",
"telnet",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L131-L145 | [
"def",
"login",
"(",
"self",
",",
"login",
",",
"password",
")",
":",
"self",
".",
"client",
".",
"read_until",
"(",
"'Username: '",
")",
"self",
".",
"client",
".",
"write",
"(",
"login",
"+",
"'\\r\\n'",
")",
"self",
".",
"client",
".",
"read_until",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Telnet.logout | Logout from the remote server. | beeswarm/drones/client/baits/telnet.py | def logout(self):
"""
Logout from the remote server.
"""
self.client.write('exit\r\n')
self.client.read_all()
self.client.close() | def logout(self):
"""
Logout from the remote server.
"""
self.client.write('exit\r\n')
self.client.read_all()
self.client.close() | [
"Logout",
"from",
"the",
"remote",
"server",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L147-L153 | [
"def",
"logout",
"(",
"self",
")",
":",
"self",
".",
"client",
".",
"write",
"(",
"'exit\\r\\n'",
")",
"self",
".",
"client",
".",
"read_all",
"(",
")",
"self",
".",
"client",
".",
"close",
"(",
")"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | BaseSession.add_auth_attempt | :param username:
:param password:
:param auth_type: possible values:
plain: plaintext username/password
:return: | beeswarm/shared/models/base_session.py | def add_auth_attempt(self, auth_type, successful, **kwargs):
"""
:param username:
:param password:
:param auth_type: possible values:
plain: plaintext username/password
:return:
"""
entry = {'timestamp': datetime.utcnow(),
... | def add_auth_attempt(self, auth_type, successful, **kwargs):
"""
:param username:
:param password:
:param auth_type: possible values:
plain: plaintext username/password
:return:
"""
entry = {'timestamp': datetime.utcnow(),
... | [
":",
"param",
"username",
":",
":",
"param",
"password",
":",
":",
"param",
"auth_type",
":",
"possible",
"values",
":",
"plain",
":",
"plaintext",
"username",
"/",
"password",
":",
"return",
":"
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/models/base_session.py#L54-L76 | [
"def",
"add_auth_attempt",
"(",
"self",
",",
"auth_type",
",",
"successful",
",",
"*",
"*",
"kwargs",
")",
":",
"entry",
"=",
"{",
"'timestamp'",
":",
"datetime",
".",
"utcnow",
"(",
")",
",",
"'auth'",
":",
"auth_type",
",",
"'id'",
":",
"uuid",
".",
... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Commands.sense | Launch a command in the 'senses' List, and update the current state. | beeswarm/drones/client/baits/shared/shell.py | def sense(self):
""" Launch a command in the 'senses' List, and update the current state."""
cmd_name = random.choice(self.senses)
param = ''
if cmd_name == 'ls':
if random.randint(0, 1):
param = '-l'
elif cmd_name == 'uname':
# Choose opt... | def sense(self):
""" Launch a command in the 'senses' List, and update the current state."""
cmd_name = random.choice(self.senses)
param = ''
if cmd_name == 'ls':
if random.randint(0, 1):
param = '-l'
elif cmd_name == 'uname':
# Choose opt... | [
"Launch",
"a",
"command",
"in",
"the",
"senses",
"List",
"and",
"update",
"the",
"current",
"state",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L102-L117 | [
"def",
"sense",
"(",
"self",
")",
":",
"cmd_name",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"senses",
")",
"param",
"=",
"''",
"if",
"cmd_name",
"==",
"'ls'",
":",
"if",
"random",
".",
"randint",
"(",
"0",
",",
"1",
")",
":",
"param",
"=",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Commands.decide | Choose the next command to execute, and its parameters, based on the current
state. | beeswarm/drones/client/baits/shared/shell.py | def decide(self):
""" Choose the next command to execute, and its parameters, based on the current
state.
"""
next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
param = ''
if next_command_name == 'cd':
try:
par... | def decide(self):
""" Choose the next command to execute, and its parameters, based on the current
state.
"""
next_command_name = random.choice(self.COMMAND_MAP[self.state['last_command']])
param = ''
if next_command_name == 'cd':
try:
par... | [
"Choose",
"the",
"next",
"command",
"to",
"execute",
"and",
"its",
"parameters",
"based",
"on",
"the",
"current",
"state",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L119-L164 | [
"def",
"decide",
"(",
"self",
")",
":",
"next_command_name",
"=",
"random",
".",
"choice",
"(",
"self",
".",
"COMMAND_MAP",
"[",
"self",
".",
"state",
"[",
"'last_command'",
"]",
"]",
")",
"param",
"=",
"''",
"if",
"next_command_name",
"==",
"'cd'",
":",... | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | Commands.act | Run the specified command with its parameters. | beeswarm/drones/client/baits/shared/shell.py | def act(self, cmd_name, params=None):
""" Run the specified command with its parameters."""
command = getattr(self, cmd_name)
if params:
command(params)
else:
command() | def act(self, cmd_name, params=None):
""" Run the specified command with its parameters."""
command = getattr(self, cmd_name)
if params:
command(params)
else:
command() | [
"Run",
"the",
"specified",
"command",
"with",
"its",
"parameters",
"."
] | honeynet/beeswarm | python | https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L166-L173 | [
"def",
"act",
"(",
"self",
",",
"cmd_name",
",",
"params",
"=",
"None",
")",
":",
"command",
"=",
"getattr",
"(",
"self",
",",
"cmd_name",
")",
"if",
"params",
":",
"command",
"(",
"params",
")",
"else",
":",
"command",
"(",
")"
] | db51ea0bc29f631c3e3b5312b479ac9d5e31079a |
train | JSONFormatter.json_record | Prepares a JSON payload which will be logged.
Override this method to change JSON log format.
:param message: Log message, e.g., `logger.info(msg='Sign up')`.
:param extra: Dictionary that was passed as `extra` param
`logger.info('Sign up', extra={'referral_code': '52d6ce'})`.
... | json_log_formatter/__init__.py | def json_record(self, message, extra, record):
"""Prepares a JSON payload which will be logged.
Override this method to change JSON log format.
:param message: Log message, e.g., `logger.info(msg='Sign up')`.
:param extra: Dictionary that was passed as `extra` param
`logger... | def json_record(self, message, extra, record):
"""Prepares a JSON payload which will be logged.
Override this method to change JSON log format.
:param message: Log message, e.g., `logger.info(msg='Sign up')`.
:param extra: Dictionary that was passed as `extra` param
`logger... | [
"Prepares",
"a",
"JSON",
"payload",
"which",
"will",
"be",
"logged",
"."
] | marselester/json-log-formatter | python | https://github.com/marselester/json-log-formatter/blob/2db6d5bf025486b0fb690d85e320d01dba614c0c/json_log_formatter/__init__.py#L94-L113 | [
"def",
"json_record",
"(",
"self",
",",
"message",
",",
"extra",
",",
"record",
")",
":",
"extra",
"[",
"'message'",
"]",
"=",
"message",
"if",
"'time'",
"not",
"in",
"extra",
":",
"extra",
"[",
"'time'",
"]",
"=",
"datetime",
".",
"utcnow",
"(",
")"... | 2db6d5bf025486b0fb690d85e320d01dba614c0c |
train | JSONFormatter.mutate_json_record | Override it to convert fields of `json_record` to needed types.
Default implementation converts `datetime` to string in ISO8601 format. | json_log_formatter/__init__.py | def mutate_json_record(self, json_record):
"""Override it to convert fields of `json_record` to needed types.
Default implementation converts `datetime` to string in ISO8601 format.
"""
for attr_name in json_record:
attr = json_record[attr_name]
if isinstance(at... | def mutate_json_record(self, json_record):
"""Override it to convert fields of `json_record` to needed types.
Default implementation converts `datetime` to string in ISO8601 format.
"""
for attr_name in json_record:
attr = json_record[attr_name]
if isinstance(at... | [
"Override",
"it",
"to",
"convert",
"fields",
"of",
"json_record",
"to",
"needed",
"types",
"."
] | marselester/json-log-formatter | python | https://github.com/marselester/json-log-formatter/blob/2db6d5bf025486b0fb690d85e320d01dba614c0c/json_log_formatter/__init__.py#L115-L125 | [
"def",
"mutate_json_record",
"(",
"self",
",",
"json_record",
")",
":",
"for",
"attr_name",
"in",
"json_record",
":",
"attr",
"=",
"json_record",
"[",
"attr_name",
"]",
"if",
"isinstance",
"(",
"attr",
",",
"datetime",
")",
":",
"json_record",
"[",
"attr_nam... | 2db6d5bf025486b0fb690d85e320d01dba614c0c |
train | GerritStream.stop | Stop the thread. | pygerrit/stream.py | def stop(self):
""" Stop the thread. """
self._stop.set()
if self._channel is not None:
self._channel.close() | def stop(self):
""" Stop the thread. """
self._stop.set()
if self._channel is not None:
self._channel.close() | [
"Stop",
"the",
"thread",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/stream.py#L46-L50 | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_stop",
".",
"set",
"(",
")",
"if",
"self",
".",
"_channel",
"is",
"not",
"None",
":",
"self",
".",
"_channel",
".",
"close",
"(",
")"
] | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritStream.run | Listen to the stream and send events to the client. | pygerrit/stream.py | def run(self):
""" Listen to the stream and send events to the client. """
channel = self._ssh_client.get_transport().open_session()
self._channel = channel
channel.exec_command("gerrit stream-events")
stdout = channel.makefile()
stderr = channel.makefile_stderr()
... | def run(self):
""" Listen to the stream and send events to the client. """
channel = self._ssh_client.get_transport().open_session()
self._channel = channel
channel.exec_command("gerrit stream-events")
stdout = channel.makefile()
stderr = channel.makefile_stderr()
... | [
"Listen",
"to",
"the",
"stream",
"and",
"send",
"events",
"to",
"the",
"client",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/stream.py#L56-L77 | [
"def",
"run",
"(",
"self",
")",
":",
"channel",
"=",
"self",
".",
"_ssh_client",
".",
"get_transport",
"(",
")",
".",
"open_session",
"(",
")",
"self",
".",
"_channel",
"=",
"channel",
"channel",
".",
"exec_command",
"(",
"\"gerrit stream-events\"",
")",
"... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.run_command | Run a command.
:arg str command: The command to run.
:Return: The result as a string.
:Raises: `ValueError` if `command` is not a string. | pygerrit/client.py | def run_command(self, command):
""" Run a command.
:arg str command: The command to run.
:Return: The result as a string.
:Raises: `ValueError` if `command` is not a string.
"""
if not isinstance(command, basestring):
raise ValueError("command must be a st... | def run_command(self, command):
""" Run a command.
:arg str command: The command to run.
:Return: The result as a string.
:Raises: `ValueError` if `command` is not a string.
"""
if not isinstance(command, basestring):
raise ValueError("command must be a st... | [
"Run",
"a",
"command",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L79-L91 | [
"def",
"run_command",
"(",
"self",
",",
"command",
")",
":",
"if",
"not",
"isinstance",
"(",
"command",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"command must be a string\"",
")",
"return",
"self",
".",
"_ssh_client",
".",
"run_gerrit_command",... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.query | Run a query.
:arg str term: The query term to run.
:Returns: A list of results as :class:`pygerrit.models.Change` objects.
:Raises: `ValueError` if `term` is not a string. | pygerrit/client.py | def query(self, term):
""" Run a query.
:arg str term: The query term to run.
:Returns: A list of results as :class:`pygerrit.models.Change` objects.
:Raises: `ValueError` if `term` is not a string.
"""
results = []
command = ["query", "--current-patch-set", "... | def query(self, term):
""" Run a query.
:arg str term: The query term to run.
:Returns: A list of results as :class:`pygerrit.models.Change` objects.
:Raises: `ValueError` if `term` is not a string.
"""
results = []
command = ["query", "--current-patch-set", "... | [
"Run",
"a",
"query",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L93-L129 | [
"def",
"query",
"(",
"self",
",",
"term",
")",
":",
"results",
"=",
"[",
"]",
"command",
"=",
"[",
"\"query\"",
",",
"\"--current-patch-set\"",
",",
"\"--all-approvals\"",
",",
"\"--format JSON\"",
",",
"\"--commit-message\"",
"]",
"if",
"not",
"isinstance",
"... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.start_event_stream | Start streaming events from `gerrit stream-events`. | pygerrit/client.py | def start_event_stream(self):
""" Start streaming events from `gerrit stream-events`. """
if not self._stream:
self._stream = GerritStream(self, ssh_client=self._ssh_client)
self._stream.start() | def start_event_stream(self):
""" Start streaming events from `gerrit stream-events`. """
if not self._stream:
self._stream = GerritStream(self, ssh_client=self._ssh_client)
self._stream.start() | [
"Start",
"streaming",
"events",
"from",
"gerrit",
"stream",
"-",
"events",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L131-L135 | [
"def",
"start_event_stream",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_stream",
":",
"self",
".",
"_stream",
"=",
"GerritStream",
"(",
"self",
",",
"ssh_client",
"=",
"self",
".",
"_ssh_client",
")",
"self",
".",
"_stream",
".",
"start",
"(",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.stop_event_stream | Stop streaming events from `gerrit stream-events`. | pygerrit/client.py | def stop_event_stream(self):
""" Stop streaming events from `gerrit stream-events`."""
if self._stream:
self._stream.stop()
self._stream.join()
self._stream = None
with self._events.mutex:
self._events.queue.clear() | def stop_event_stream(self):
""" Stop streaming events from `gerrit stream-events`."""
if self._stream:
self._stream.stop()
self._stream.join()
self._stream = None
with self._events.mutex:
self._events.queue.clear() | [
"Stop",
"streaming",
"events",
"from",
"gerrit",
"stream",
"-",
"events",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L137-L144 | [
"def",
"stop_event_stream",
"(",
"self",
")",
":",
"if",
"self",
".",
"_stream",
":",
"self",
".",
"_stream",
".",
"stop",
"(",
")",
"self",
".",
"_stream",
".",
"join",
"(",
")",
"self",
".",
"_stream",
"=",
"None",
"with",
"self",
".",
"_events",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.get_event | Get the next event from the queue.
:arg boolean block: Set to True to block if no event is available.
:arg seconds timeout: Timeout to wait if no event is available.
:Returns: The next event as a :class:`pygerrit.events.GerritEvent`
instance, or `None` if:
- `block` is... | pygerrit/client.py | def get_event(self, block=True, timeout=None):
""" Get the next event from the queue.
:arg boolean block: Set to True to block if no event is available.
:arg seconds timeout: Timeout to wait if no event is available.
:Returns: The next event as a :class:`pygerrit.events.GerritEvent`
... | def get_event(self, block=True, timeout=None):
""" Get the next event from the queue.
:arg boolean block: Set to True to block if no event is available.
:arg seconds timeout: Timeout to wait if no event is available.
:Returns: The next event as a :class:`pygerrit.events.GerritEvent`
... | [
"Get",
"the",
"next",
"event",
"from",
"the",
"queue",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L146-L162 | [
"def",
"get_event",
"(",
"self",
",",
"block",
"=",
"True",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"return",
"self",
".",
"_events",
".",
"get",
"(",
"block",
",",
"timeout",
")",
"except",
"Empty",
":",
"return",
"None"
] | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritClient.put_event | Create event from `data` and add it to the queue.
:arg json data: The JSON data from which to create the event.
:Raises: :class:`pygerrit.error.GerritError` if the queue is full, or
the factory could not create the event. | pygerrit/client.py | def put_event(self, data):
""" Create event from `data` and add it to the queue.
:arg json data: The JSON data from which to create the event.
:Raises: :class:`pygerrit.error.GerritError` if the queue is full, or
the factory could not create the event.
"""
try:
... | def put_event(self, data):
""" Create event from `data` and add it to the queue.
:arg json data: The JSON data from which to create the event.
:Raises: :class:`pygerrit.error.GerritError` if the queue is full, or
the factory could not create the event.
"""
try:
... | [
"Create",
"event",
"from",
"data",
"and",
"add",
"it",
"to",
"the",
"queue",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L164-L177 | [
"def",
"put_event",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"event",
"=",
"self",
".",
"_factory",
".",
"create",
"(",
"data",
")",
"self",
".",
"_events",
".",
"put",
"(",
"event",
")",
"except",
"Full",
":",
"raise",
"GerritError",
"(",
"... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | _extract_version | Extract the version from `version_string` using `pattern`.
Return the version as a string, with leading/trailing whitespace
stripped. | pygerrit/ssh.py | def _extract_version(version_string, pattern):
""" Extract the version from `version_string` using `pattern`.
Return the version as a string, with leading/trailing whitespace
stripped.
"""
if version_string:
match = pattern.match(version_string.strip())
if match:
return... | def _extract_version(version_string, pattern):
""" Extract the version from `version_string` using `pattern`.
Return the version as a string, with leading/trailing whitespace
stripped.
"""
if version_string:
match = pattern.match(version_string.strip())
if match:
return... | [
"Extract",
"the",
"version",
"from",
"version_string",
"using",
"pattern",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L36-L47 | [
"def",
"_extract_version",
"(",
"version_string",
",",
"pattern",
")",
":",
"if",
"version_string",
":",
"match",
"=",
"pattern",
".",
"match",
"(",
"version_string",
".",
"strip",
"(",
")",
")",
"if",
"match",
":",
"return",
"match",
".",
"group",
"(",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritSSHClient._configure | Configure the ssh parameters from the config file. | pygerrit/ssh.py | def _configure(self):
""" Configure the ssh parameters from the config file. """
configfile = expanduser("~/.ssh/config")
if not isfile(configfile):
raise GerritError("ssh config file '%s' does not exist" %
configfile)
config = SSHConfig()
... | def _configure(self):
""" Configure the ssh parameters from the config file. """
configfile = expanduser("~/.ssh/config")
if not isfile(configfile):
raise GerritError("ssh config file '%s' does not exist" %
configfile)
config = SSHConfig()
... | [
"Configure",
"the",
"ssh",
"parameters",
"from",
"the",
"config",
"file",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L84-L111 | [
"def",
"_configure",
"(",
"self",
")",
":",
"configfile",
"=",
"expanduser",
"(",
"\"~/.ssh/config\"",
")",
"if",
"not",
"isfile",
"(",
"configfile",
")",
":",
"raise",
"GerritError",
"(",
"\"ssh config file '%s' does not exist\"",
"%",
"configfile",
")",
"config"... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritSSHClient._do_connect | Connect to the remote. | pygerrit/ssh.py | def _do_connect(self):
""" Connect to the remote. """
self.load_system_host_keys()
if self.username is None or self.port is None:
self._configure()
try:
self.connect(hostname=self.hostname,
port=self.port,
username... | def _do_connect(self):
""" Connect to the remote. """
self.load_system_host_keys()
if self.username is None or self.port is None:
self._configure()
try:
self.connect(hostname=self.hostname,
port=self.port,
username... | [
"Connect",
"to",
"the",
"remote",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L113-L132 | [
"def",
"_do_connect",
"(",
"self",
")",
":",
"self",
".",
"load_system_host_keys",
"(",
")",
"if",
"self",
".",
"username",
"is",
"None",
"or",
"self",
".",
"port",
"is",
"None",
":",
"self",
".",
"_configure",
"(",
")",
"try",
":",
"self",
".",
"con... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritSSHClient._connect | Connect to the remote if not already connected. | pygerrit/ssh.py | def _connect(self):
""" Connect to the remote if not already connected. """
if not self.connected.is_set():
try:
self.lock.acquire()
# Another thread may have connected while we were
# waiting to acquire the lock
if not self.con... | def _connect(self):
""" Connect to the remote if not already connected. """
if not self.connected.is_set():
try:
self.lock.acquire()
# Another thread may have connected while we were
# waiting to acquire the lock
if not self.con... | [
"Connect",
"to",
"the",
"remote",
"if",
"not",
"already",
"connected",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L134-L149 | [
"def",
"_connect",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"connected",
".",
"is_set",
"(",
")",
":",
"try",
":",
"self",
".",
"lock",
".",
"acquire",
"(",
")",
"# Another thread may have connected while we were",
"# waiting to acquire the lock",
"if",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritSSHClient.get_remote_version | Return the version of the remote Gerrit server. | pygerrit/ssh.py | def get_remote_version(self):
""" Return the version of the remote Gerrit server. """
if self.remote_version is None:
result = self.run_gerrit_command("version")
version_string = result.stdout.read()
pattern = re.compile(r'^gerrit version (.*)$')
self.remo... | def get_remote_version(self):
""" Return the version of the remote Gerrit server. """
if self.remote_version is None:
result = self.run_gerrit_command("version")
version_string = result.stdout.read()
pattern = re.compile(r'^gerrit version (.*)$')
self.remo... | [
"Return",
"the",
"version",
"of",
"the",
"remote",
"Gerrit",
"server",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L151-L158 | [
"def",
"get_remote_version",
"(",
"self",
")",
":",
"if",
"self",
".",
"remote_version",
"is",
"None",
":",
"result",
"=",
"self",
".",
"run_gerrit_command",
"(",
"\"version\"",
")",
"version_string",
"=",
"result",
".",
"stdout",
".",
"read",
"(",
")",
"p... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritSSHClient.run_gerrit_command | Run the given command.
Make sure we're connected to the remote server, and run `command`.
Return the results as a `GerritSSHCommandResult`.
Raise `ValueError` if `command` is not a string, or `GerritError` if
command execution fails. | pygerrit/ssh.py | def run_gerrit_command(self, command):
""" Run the given command.
Make sure we're connected to the remote server, and run `command`.
Return the results as a `GerritSSHCommandResult`.
Raise `ValueError` if `command` is not a string, or `GerritError` if
command execution fails.
... | def run_gerrit_command(self, command):
""" Run the given command.
Make sure we're connected to the remote server, and run `command`.
Return the results as a `GerritSSHCommandResult`.
Raise `ValueError` if `command` is not a string, or `GerritError` if
command execution fails.
... | [
"Run",
"the",
"given",
"command",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L165-L194 | [
"def",
"run_gerrit_command",
"(",
"self",
",",
"command",
")",
":",
"if",
"not",
"isinstance",
"(",
"command",
",",
"basestring",
")",
":",
"raise",
"ValueError",
"(",
"\"command must be a string\"",
")",
"gerrit_command",
"=",
"\"gerrit \"",
"+",
"command",
"# ... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritEventFactory.register | Decorator to register the event identified by `name`.
Return the decorated class.
Raise GerritError if the event is already registered. | pygerrit/events.py | def register(cls, name):
""" Decorator to register the event identified by `name`.
Return the decorated class.
Raise GerritError if the event is already registered.
"""
def decorate(klazz):
""" Decorator. """
if name in cls._events:
rai... | def register(cls, name):
""" Decorator to register the event identified by `name`.
Return the decorated class.
Raise GerritError if the event is already registered.
"""
def decorate(klazz):
""" Decorator. """
if name in cls._events:
rai... | [
"Decorator",
"to",
"register",
"the",
"event",
"identified",
"by",
"name",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L40-L56 | [
"def",
"register",
"(",
"cls",
",",
"name",
")",
":",
"def",
"decorate",
"(",
"klazz",
")",
":",
"\"\"\" Decorator. \"\"\"",
"if",
"name",
"in",
"cls",
".",
"_events",
":",
"raise",
"GerritError",
"(",
"\"Duplicate event: %s\"",
"%",
"name",
")",
"cls",
".... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritEventFactory.create | Create a new event instance.
Return an instance of the `GerritEvent` subclass after converting
`data` to json.
Raise GerritError if json parsed from `data` does not contain a `type`
key. | pygerrit/events.py | def create(cls, data):
""" Create a new event instance.
Return an instance of the `GerritEvent` subclass after converting
`data` to json.
Raise GerritError if json parsed from `data` does not contain a `type`
key.
"""
try:
json_data = json.loads(dat... | def create(cls, data):
""" Create a new event instance.
Return an instance of the `GerritEvent` subclass after converting
`data` to json.
Raise GerritError if json parsed from `data` does not contain a `type`
key.
"""
try:
json_data = json.loads(dat... | [
"Create",
"a",
"new",
"event",
"instance",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L59-L85 | [
"def",
"create",
"(",
"cls",
",",
"data",
")",
":",
"try",
":",
"json_data",
"=",
"json",
".",
"loads",
"(",
"data",
")",
"except",
"ValueError",
"as",
"err",
":",
"logging",
".",
"debug",
"(",
"\"Failed to load json data: %s: [%s]\"",
",",
"str",
"(",
"... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | _decode_response | Strip off Gerrit's magic prefix and decode a response.
:returns:
Decoded JSON content as a dict, or raw text if content could not be
decoded as JSON.
:raises:
requests.HTTPError if the response contains an HTTP error status code. | pygerrit/rest/__init__.py | def _decode_response(response):
""" Strip off Gerrit's magic prefix and decode a response.
:returns:
Decoded JSON content as a dict, or raw text if content could not be
decoded as JSON.
:raises:
requests.HTTPError if the response contains an HTTP error status code.
"""
con... | def _decode_response(response):
""" Strip off Gerrit's magic prefix and decode a response.
:returns:
Decoded JSON content as a dict, or raw text if content could not be
decoded as JSON.
:raises:
requests.HTTPError if the response contains an HTTP error status code.
"""
con... | [
"Strip",
"off",
"Gerrit",
"s",
"magic",
"prefix",
"and",
"decode",
"a",
"response",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L33-L53 | [
"def",
"_decode_response",
"(",
"response",
")",
":",
"content",
"=",
"response",
".",
"content",
".",
"strip",
"(",
")",
"logging",
".",
"debug",
"(",
"content",
"[",
":",
"512",
"]",
")",
"response",
".",
"raise_for_status",
"(",
")",
"if",
"content",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritRestAPI.put | Send HTTP PUT to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error. | pygerrit/rest/__init__.py | def put(self, endpoint, **kwargs):
""" Send HTTP PUT to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
kwargs.update(self.kwargs.co... | def put(self, endpoint, **kwargs):
""" Send HTTP PUT to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
kwargs.update(self.kwargs.co... | [
"Send",
"HTTP",
"PUT",
"to",
"the",
"endpoint",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L121-L138 | [
"def",
"put",
"(",
"self",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"self",
".",
"kwargs",
".",
"copy",
"(",
")",
")",
"if",
"\"data\"",
"in",
"kwargs",
":",
"kwargs",
"[",
"\"headers\"",
"]",
".",
"update",... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritRestAPI.delete | Send HTTP DELETE to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error. | pygerrit/rest/__init__.py | def delete(self, endpoint, **kwargs):
""" Send HTTP DELETE to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
kwargs.update(self.kwa... | def delete(self, endpoint, **kwargs):
""" Send HTTP DELETE to the endpoint.
:arg str endpoint: The endpoint to send to.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error.
"""
kwargs.update(self.kwa... | [
"Send",
"HTTP",
"DELETE",
"to",
"the",
"endpoint",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L159-L173 | [
"def",
"delete",
"(",
"self",
",",
"endpoint",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"update",
"(",
"self",
".",
"kwargs",
".",
"copy",
"(",
")",
")",
"response",
"=",
"requests",
".",
"delete",
"(",
"self",
".",
"make_url",
"(",
"endpo... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritRestAPI.review | Submit a review.
:arg str change_id: The change ID.
:arg str revision: The revision.
:arg str review: The review details as a :class:`GerritReview`.
:returns:
JSON decoded result.
:raises:
requests.RequestException on timeout or connection error. | pygerrit/rest/__init__.py | def review(self, change_id, revision, review):
""" Submit a review.
:arg str change_id: The change ID.
:arg str revision: The revision.
:arg str review: The review details as a :class:`GerritReview`.
:returns:
JSON decoded result.
:raises:
reque... | def review(self, change_id, revision, review):
""" Submit a review.
:arg str change_id: The change ID.
:arg str revision: The revision.
:arg str review: The review details as a :class:`GerritReview`.
:returns:
JSON decoded result.
:raises:
reque... | [
"Submit",
"a",
"review",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L175-L191 | [
"def",
"review",
"(",
"self",
",",
"change_id",
",",
"revision",
",",
"review",
")",
":",
"endpoint",
"=",
"\"changes/%s/revisions/%s/review\"",
"%",
"(",
"change_id",
",",
"revision",
")",
"self",
".",
"post",
"(",
"endpoint",
",",
"data",
"=",
"str",
"("... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | GerritReview.add_comments | Add inline comments.
:arg dict comments: Comments to add.
Usage::
add_comments([{'filename': 'Makefile',
'line': 10,
'message': 'inline message'}])
add_comments([{'filename': 'Makefile',
'range':... | pygerrit/rest/__init__.py | def add_comments(self, comments):
""" Add inline comments.
:arg dict comments: Comments to add.
Usage::
add_comments([{'filename': 'Makefile',
'line': 10,
'message': 'inline message'}])
add_comments([{'filename': '... | def add_comments(self, comments):
""" Add inline comments.
:arg dict comments: Comments to add.
Usage::
add_comments([{'filename': 'Makefile',
'line': 10,
'message': 'inline message'}])
add_comments([{'filename': '... | [
"Add",
"inline",
"comments",
"."
] | sonyxperiadev/pygerrit | python | https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L241-L278 | [
"def",
"add_comments",
"(",
"self",
",",
"comments",
")",
":",
"for",
"comment",
"in",
"comments",
":",
"if",
"'filename'",
"and",
"'message'",
"in",
"comment",
".",
"keys",
"(",
")",
":",
"msg",
"=",
"{",
"}",
"if",
"'range'",
"in",
"comment",
".",
... | 756300120b0f4f4af19e0f985566d82bc80b4359 |
train | _SiriDBProtocol.connection_made | override asyncio.Protocol | siridb/connector/lib/protocol.py | def connection_made(self, transport):
'''
override asyncio.Protocol
'''
self._connected = True
self.transport = transport
self.remote_ip, self.port = transport.get_extra_info('peername')[:2]
logging.debug(
'Connection made (address: {} port: {})'
... | def connection_made(self, transport):
'''
override asyncio.Protocol
'''
self._connected = True
self.transport = transport
self.remote_ip, self.port = transport.get_extra_info('peername')[:2]
logging.debug(
'Connection made (address: {} port: {})'
... | [
"override",
"asyncio",
".",
"Protocol"
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L85-L106 | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"_connected",
"=",
"True",
"self",
".",
"transport",
"=",
"transport",
"self",
".",
"remote_ip",
",",
"self",
".",
"port",
"=",
"transport",
".",
"get_extra_info",
"(",
"'peern... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | _SiriDBProtocol.connection_lost | override asyncio.Protocol | siridb/connector/lib/protocol.py | def connection_lost(self, exc):
'''
override asyncio.Protocol
'''
self._connected = False
logging.debug(
'Connection lost (address: {} port: {})'
.format(self.remote_ip, self.port))
for pid, (future, task) in self._requests.items():
t... | def connection_lost(self, exc):
'''
override asyncio.Protocol
'''
self._connected = False
logging.debug(
'Connection lost (address: {} port: {})'
.format(self.remote_ip, self.port))
for pid, (future, task) in self._requests.items():
t... | [
"override",
"asyncio",
".",
"Protocol"
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L108-L126 | [
"def",
"connection_lost",
"(",
"self",
",",
"exc",
")",
":",
"self",
".",
"_connected",
"=",
"False",
"logging",
".",
"debug",
"(",
"'Connection lost (address: {} port: {})'",
".",
"format",
"(",
"self",
".",
"remote_ip",
",",
"self",
".",
"port",
")",
")",
... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | _SiriDBProtocol.data_received | override asyncio.Protocol | siridb/connector/lib/protocol.py | def data_received(self, data):
'''
override asyncio.Protocol
'''
self._buffered_data.extend(data)
while self._buffered_data:
size = len(self._buffered_data)
if self._data_package is None:
if size < DataPackage.struct_datapackage.size:
... | def data_received(self, data):
'''
override asyncio.Protocol
'''
self._buffered_data.extend(data)
while self._buffered_data:
size = len(self._buffered_data)
if self._data_package is None:
if size < DataPackage.struct_datapackage.size:
... | [
"override",
"asyncio",
".",
"Protocol"
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L128-L151 | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"_buffered_data",
".",
"extend",
"(",
"data",
")",
"while",
"self",
".",
"_buffered_data",
":",
"size",
"=",
"len",
"(",
"self",
".",
"_buffered_data",
")",
"if",
"self",
".",
"_d... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | _SiriDBInfoProtocol.connection_made | override _SiriDBProtocol | siridb/connector/lib/protocol.py | def connection_made(self, transport):
'''
override _SiriDBProtocol
'''
self.transport = transport
self.remote_ip, self.port = transport.get_extra_info('peername')[:2]
logging.debug(
'Connection made (address: {} port: {})'
.format(self.remote_ip,... | def connection_made(self, transport):
'''
override _SiriDBProtocol
'''
self.transport = transport
self.remote_ip, self.port = transport.get_extra_info('peername')[:2]
logging.debug(
'Connection made (address: {} port: {})'
.format(self.remote_ip,... | [
"override",
"_SiriDBProtocol"
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L234-L249 | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"self",
".",
"transport",
"=",
"transport",
"self",
".",
"remote_ip",
",",
"self",
".",
"port",
"=",
"transport",
".",
"get_extra_info",
"(",
"'peername'",
")",
"[",
":",
"2",
"]",
"loggi... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | SiriDBConnection._register_server | Register a new SiriDB Server.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request. | siridb/connector/lib/connection.py | def _register_server(self, server, timeout=30):
'''Register a new SiriDB Server.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request.
'''
result = self._loop.run_until_complete(
self._protoc... | def _register_server(self, server, timeout=30):
'''Register a new SiriDB Server.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request.
'''
result = self._loop.run_until_complete(
self._protoc... | [
"Register",
"a",
"new",
"SiriDB",
"Server",
"."
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/connection.py#L65-L75 | [
"def",
"_register_server",
"(",
"self",
",",
"server",
",",
"timeout",
"=",
"30",
")",
":",
"result",
"=",
"self",
".",
"_loop",
".",
"run_until_complete",
"(",
"self",
".",
"_protocol",
".",
"send_package",
"(",
"CPROTO_REQ_REGISTER_SERVER",
",",
"data",
"=... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | SiriDBConnection._get_file | Request a SiriDB configuration file.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request. | siridb/connector/lib/connection.py | def _get_file(self, fn, timeout=30):
'''Request a SiriDB configuration file.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request.
'''
msg = FILE_MAP.get(fn, None)
if msg is None:
rai... | def _get_file(self, fn, timeout=30):
'''Request a SiriDB configuration file.
This method is used by the SiriDB manage tool and should not be used
otherwise. Full access rights are required for this request.
'''
msg = FILE_MAP.get(fn, None)
if msg is None:
rai... | [
"Request",
"a",
"SiriDB",
"configuration",
"file",
"."
] | SiriDB/siridb-connector | python | https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/connection.py#L77-L90 | [
"def",
"_get_file",
"(",
"self",
",",
"fn",
",",
"timeout",
"=",
"30",
")",
":",
"msg",
"=",
"FILE_MAP",
".",
"get",
"(",
"fn",
",",
"None",
")",
"if",
"msg",
"is",
"None",
":",
"raise",
"FileNotFoundError",
"(",
"'Cannot get file {!r}. Available file '",
... | dff33c183899c3ee21c3eab6b90cf4668afef1b0 |
train | _bits_to_float | Convert GeoHash bits to a float. | mzgeohash/geohash.py | def _bits_to_float(bits, lower=-90.0, middle=0.0, upper=90.0):
"""Convert GeoHash bits to a float."""
for i in bits:
if i:
lower = middle
else:
upper = middle
middle = (upper + lower) / 2
return middle | def _bits_to_float(bits, lower=-90.0, middle=0.0, upper=90.0):
"""Convert GeoHash bits to a float."""
for i in bits:
if i:
lower = middle
else:
upper = middle
middle = (upper + lower) / 2
return middle | [
"Convert",
"GeoHash",
"bits",
"to",
"a",
"float",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L8-L16 | [
"def",
"_bits_to_float",
"(",
"bits",
",",
"lower",
"=",
"-",
"90.0",
",",
"middle",
"=",
"0.0",
",",
"upper",
"=",
"90.0",
")",
":",
"for",
"i",
"in",
"bits",
":",
"if",
"i",
":",
"lower",
"=",
"middle",
"else",
":",
"upper",
"=",
"middle",
"mid... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | _float_to_bits | Convert a float to a list of GeoHash bits. | mzgeohash/geohash.py | def _float_to_bits(value, lower=-90.0, middle=0.0, upper=90.0, length=15):
"""Convert a float to a list of GeoHash bits."""
ret = []
for i in range(length):
if value >= middle:
lower = middle
ret.append(1)
else:
upper = middle
ret.append(0)
middle = (upper + lower) / 2
return... | def _float_to_bits(value, lower=-90.0, middle=0.0, upper=90.0, length=15):
"""Convert a float to a list of GeoHash bits."""
ret = []
for i in range(length):
if value >= middle:
lower = middle
ret.append(1)
else:
upper = middle
ret.append(0)
middle = (upper + lower) / 2
return... | [
"Convert",
"a",
"float",
"to",
"a",
"list",
"of",
"GeoHash",
"bits",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L18-L29 | [
"def",
"_float_to_bits",
"(",
"value",
",",
"lower",
"=",
"-",
"90.0",
",",
"middle",
"=",
"0.0",
",",
"upper",
"=",
"90.0",
",",
"length",
"=",
"15",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"length",
")",
":",
"if",
"va... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | _geohash_to_bits | Convert a GeoHash to a list of GeoHash bits. | mzgeohash/geohash.py | def _geohash_to_bits(value):
"""Convert a GeoHash to a list of GeoHash bits."""
b = map(BASE32MAP.get, value)
ret = []
for i in b:
out = []
for z in range(5):
out.append(i & 0b1)
i = i >> 1
ret += out[::-1]
return ret | def _geohash_to_bits(value):
"""Convert a GeoHash to a list of GeoHash bits."""
b = map(BASE32MAP.get, value)
ret = []
for i in b:
out = []
for z in range(5):
out.append(i & 0b1)
i = i >> 1
ret += out[::-1]
return ret | [
"Convert",
"a",
"GeoHash",
"to",
"a",
"list",
"of",
"GeoHash",
"bits",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L31-L41 | [
"def",
"_geohash_to_bits",
"(",
"value",
")",
":",
"b",
"=",
"map",
"(",
"BASE32MAP",
".",
"get",
",",
"value",
")",
"ret",
"=",
"[",
"]",
"for",
"i",
"in",
"b",
":",
"out",
"=",
"[",
"]",
"for",
"z",
"in",
"range",
"(",
"5",
")",
":",
"out",... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | _bits_to_geohash | Convert a list of GeoHash bits to a GeoHash. | mzgeohash/geohash.py | def _bits_to_geohash(value):
"""Convert a list of GeoHash bits to a GeoHash."""
ret = []
# Get 5 bits at a time
for i in (value[i:i+5] for i in xrange(0, len(value), 5)):
# Convert binary to integer
# Note: reverse here, the slice above doesn't work quite right in reverse.
total = sum([(bit*2**count... | def _bits_to_geohash(value):
"""Convert a list of GeoHash bits to a GeoHash."""
ret = []
# Get 5 bits at a time
for i in (value[i:i+5] for i in xrange(0, len(value), 5)):
# Convert binary to integer
# Note: reverse here, the slice above doesn't work quite right in reverse.
total = sum([(bit*2**count... | [
"Convert",
"a",
"list",
"of",
"GeoHash",
"bits",
"to",
"a",
"GeoHash",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L43-L53 | [
"def",
"_bits_to_geohash",
"(",
"value",
")",
":",
"ret",
"=",
"[",
"]",
"# Get 5 bits at a time",
"for",
"i",
"in",
"(",
"value",
"[",
"i",
":",
"i",
"+",
"5",
"]",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"value",
")",
",",
"5",
... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | decode | Decode a geohash. Returns a (lon,lat) pair. | mzgeohash/geohash.py | def decode(value):
"""Decode a geohash. Returns a (lon,lat) pair."""
assert value, "Invalid geohash: %s"%value
# Get the GeoHash bits
bits = _geohash_to_bits(value)
# Unzip the GeoHash bits.
lon = bits[0::2]
lat = bits[1::2]
# Convert to lat/lon
return (
_bits_to_float(lon, lower=-180.0, upper=180... | def decode(value):
"""Decode a geohash. Returns a (lon,lat) pair."""
assert value, "Invalid geohash: %s"%value
# Get the GeoHash bits
bits = _geohash_to_bits(value)
# Unzip the GeoHash bits.
lon = bits[0::2]
lat = bits[1::2]
# Convert to lat/lon
return (
_bits_to_float(lon, lower=-180.0, upper=180... | [
"Decode",
"a",
"geohash",
".",
"Returns",
"a",
"(",
"lon",
"lat",
")",
"pair",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L56-L68 | [
"def",
"decode",
"(",
"value",
")",
":",
"assert",
"value",
",",
"\"Invalid geohash: %s\"",
"%",
"value",
"# Get the GeoHash bits",
"bits",
"=",
"_geohash_to_bits",
"(",
"value",
")",
"# Unzip the GeoHash bits.",
"lon",
"=",
"bits",
"[",
"0",
":",
":",
"2",
"]... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | encode | Encode a (lon,lat) pair to a GeoHash. | mzgeohash/geohash.py | def encode(lonlat, length=12):
"""Encode a (lon,lat) pair to a GeoHash."""
assert len(lonlat) == 2, "Invalid lon/lat: %s"%lonlat
# Half the length for each component.
length /= 2
lon = _float_to_bits(lonlat[0], lower=-180.0, upper=180.0, length=length*5)
lat = _float_to_bits(lonlat[1], lower=-90.0, upper=90... | def encode(lonlat, length=12):
"""Encode a (lon,lat) pair to a GeoHash."""
assert len(lonlat) == 2, "Invalid lon/lat: %s"%lonlat
# Half the length for each component.
length /= 2
lon = _float_to_bits(lonlat[0], lower=-180.0, upper=180.0, length=length*5)
lat = _float_to_bits(lonlat[1], lower=-90.0, upper=90... | [
"Encode",
"a",
"(",
"lon",
"lat",
")",
"pair",
"to",
"a",
"GeoHash",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L70-L82 | [
"def",
"encode",
"(",
"lonlat",
",",
"length",
"=",
"12",
")",
":",
"assert",
"len",
"(",
"lonlat",
")",
"==",
"2",
",",
"\"Invalid lon/lat: %s\"",
"%",
"lonlat",
"# Half the length for each component.",
"length",
"/=",
"2",
"lon",
"=",
"_float_to_bits",
"(",
... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | adjacent | Return the adjacent geohash for a given direction. | mzgeohash/geohash.py | def adjacent(geohash, direction):
"""Return the adjacent geohash for a given direction."""
# Based on an MIT licensed implementation by Chris Veness from:
# http://www.movable-type.co.uk/scripts/geohash.html
assert direction in 'nsew', "Invalid direction: %s"%direction
assert geohash, "Invalid geohash: %s"%... | def adjacent(geohash, direction):
"""Return the adjacent geohash for a given direction."""
# Based on an MIT licensed implementation by Chris Veness from:
# http://www.movable-type.co.uk/scripts/geohash.html
assert direction in 'nsew', "Invalid direction: %s"%direction
assert geohash, "Invalid geohash: %s"%... | [
"Return",
"the",
"adjacent",
"geohash",
"for",
"a",
"given",
"direction",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L84-L108 | [
"def",
"adjacent",
"(",
"geohash",
",",
"direction",
")",
":",
"# Based on an MIT licensed implementation by Chris Veness from:",
"# http://www.movable-type.co.uk/scripts/geohash.html",
"assert",
"direction",
"in",
"'nsew'",
",",
"\"Invalid direction: %s\"",
"%",
"direction",
"... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | neighbors | Return all neighboring geohashes. | mzgeohash/geohash.py | def neighbors(geohash):
"""Return all neighboring geohashes."""
return {
'n': adjacent(geohash, 'n'),
'ne': adjacent(adjacent(geohash, 'n'), 'e'),
'e': adjacent(geohash, 'e'),
'se': adjacent(adjacent(geohash, 's'), 'e'),
's': adjacent(geohash, 's'),
'sw': adjacent(adjacent(geohash, 's'), ... | def neighbors(geohash):
"""Return all neighboring geohashes."""
return {
'n': adjacent(geohash, 'n'),
'ne': adjacent(adjacent(geohash, 'n'), 'e'),
'e': adjacent(geohash, 'e'),
'se': adjacent(adjacent(geohash, 's'), 'e'),
's': adjacent(geohash, 's'),
'sw': adjacent(adjacent(geohash, 's'), ... | [
"Return",
"all",
"neighboring",
"geohashes",
"."
] | transitland/mapzen-geohash | python | https://github.com/transitland/mapzen-geohash/blob/5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad/mzgeohash/geohash.py#L110-L122 | [
"def",
"neighbors",
"(",
"geohash",
")",
":",
"return",
"{",
"'n'",
":",
"adjacent",
"(",
"geohash",
",",
"'n'",
")",
",",
"'ne'",
":",
"adjacent",
"(",
"adjacent",
"(",
"geohash",
",",
"'n'",
")",
",",
"'e'",
")",
",",
"'e'",
":",
"adjacent",
"(",... | 5264d16dc2df00ebc4aedaa78ca8c6ee3fd655ad |
train | thunkify | Make a function immediately return a function of no args which, when called,
waits for the result, which will start being processed in another thread.
Taken from https://wiki.python.org/moin/PythonDecoratorLibrary. | pybar/run_manager.py | def thunkify(thread_name=None, daemon=True, default_func=None):
'''Make a function immediately return a function of no args which, when called,
waits for the result, which will start being processed in another thread.
Taken from https://wiki.python.org/moin/PythonDecoratorLibrary.
'''
def actual_dec... | def thunkify(thread_name=None, daemon=True, default_func=None):
'''Make a function immediately return a function of no args which, when called,
waits for the result, which will start being processed in another thread.
Taken from https://wiki.python.org/moin/PythonDecoratorLibrary.
'''
def actual_dec... | [
"Make",
"a",
"function",
"immediately",
"return",
"a",
"function",
"of",
"no",
"args",
"which",
"when",
"called",
"waits",
"for",
"the",
"result",
"which",
"will",
"start",
"being",
"processed",
"in",
"another",
"thread",
".",
"Taken",
"from",
"https",
":",
... | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L362-L410 | [
"def",
"thunkify",
"(",
"thread_name",
"=",
"None",
",",
"daemon",
"=",
"True",
",",
"default_func",
"=",
"None",
")",
":",
"def",
"actual_decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"thunked",
"(",
"*",
"arg... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | set_event_when_keyboard_interrupt | Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised
Parameters
----------
_lambda : function
Lambda function that points to Threading.Event() object
Returns
-------
wrapper : function
Examples
--------
@set_event_when_keyboard_interru... | pybar/run_manager.py | def set_event_when_keyboard_interrupt(_lambda):
'''Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised
Parameters
----------
_lambda : function
Lambda function that points to Threading.Event() object
Returns
-------
wrapper : function
Exa... | def set_event_when_keyboard_interrupt(_lambda):
'''Decorator function that sets Threading.Event() when keyboard interrupt (Ctrl+C) was raised
Parameters
----------
_lambda : function
Lambda function that points to Threading.Event() object
Returns
-------
wrapper : function
Exa... | [
"Decorator",
"function",
"that",
"sets",
"Threading",
".",
"Event",
"()",
"when",
"keyboard",
"interrupt",
"(",
"Ctrl",
"+",
"C",
")",
"was",
"raised"
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L655-L686 | [
"def",
"set_event_when_keyboard_interrupt",
"(",
"_lambda",
")",
":",
"def",
"wrapper",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapped_f",
"(",
"self",
",",
"*",
"f_args",
",",
"*",
"*",
"f_kwargs",
")",
":",
"try",
":",
"f",
"(",
... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.run_id | Run name without whitespace | pybar/run_manager.py | def run_id(self):
'''Run name without whitespace
'''
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', self.__class__.__name__)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | def run_id(self):
'''Run name without whitespace
'''
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', self.__class__.__name__)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"Run",
"name",
"without",
"whitespace"
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L83-L87 | [
"def",
"run_id",
"(",
"self",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"self",
".",
"__class__",
".",
"__name__",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.conf | Configuration (namedtuple) | pybar/run_manager.py | def conf(self):
'''Configuration (namedtuple)
'''
conf = namedtuple('conf', field_names=self._conf.keys())
return conf(**self._conf) | def conf(self):
'''Configuration (namedtuple)
'''
conf = namedtuple('conf', field_names=self._conf.keys())
return conf(**self._conf) | [
"Configuration",
"(",
"namedtuple",
")"
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L90-L94 | [
"def",
"conf",
"(",
"self",
")",
":",
"conf",
"=",
"namedtuple",
"(",
"'conf'",
",",
"field_names",
"=",
"self",
".",
"_conf",
".",
"keys",
"(",
")",
")",
"return",
"conf",
"(",
"*",
"*",
"self",
".",
"_conf",
")"
] | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.run_conf | Run configuration (namedtuple) | pybar/run_manager.py | def run_conf(self):
'''Run configuration (namedtuple)
'''
run_conf = namedtuple('run_conf', field_names=self._run_conf.keys())
return run_conf(**self._run_conf) | def run_conf(self):
'''Run configuration (namedtuple)
'''
run_conf = namedtuple('run_conf', field_names=self._run_conf.keys())
return run_conf(**self._run_conf) | [
"Run",
"configuration",
"(",
"namedtuple",
")"
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L97-L101 | [
"def",
"run_conf",
"(",
"self",
")",
":",
"run_conf",
"=",
"namedtuple",
"(",
"'run_conf'",
",",
"field_names",
"=",
"self",
".",
"_run_conf",
".",
"keys",
"(",
")",
")",
"return",
"run_conf",
"(",
"*",
"*",
"self",
".",
"_run_conf",
")"
] | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.default_run_conf | Default run configuration (namedtuple) | pybar/run_manager.py | def default_run_conf(self):
'''Default run configuration (namedtuple)
'''
default_run_conf = namedtuple('default_run_conf', field_names=self._default_run_conf.keys())
return default_run_conf(**self._default_run_conf) | def default_run_conf(self):
'''Default run configuration (namedtuple)
'''
default_run_conf = namedtuple('default_run_conf', field_names=self._default_run_conf.keys())
return default_run_conf(**self._default_run_conf) | [
"Default",
"run",
"configuration",
"(",
"namedtuple",
")"
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L110-L114 | [
"def",
"default_run_conf",
"(",
"self",
")",
":",
"default_run_conf",
"=",
"namedtuple",
"(",
"'default_run_conf'",
",",
"field_names",
"=",
"self",
".",
"_default_run_conf",
".",
"keys",
"(",
")",
")",
"return",
"default_run_conf",
"(",
"*",
"*",
"self",
".",... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase._init | Initialization before a new run. | pybar/run_manager.py | def _init(self, run_conf, run_number=None):
'''Initialization before a new run.
'''
self.stop_run.clear()
self.abort_run.clear()
self._run_status = run_status.running
self._write_run_number(run_number)
self._init_run_conf(run_conf) | def _init(self, run_conf, run_number=None):
'''Initialization before a new run.
'''
self.stop_run.clear()
self.abort_run.clear()
self._run_status = run_status.running
self._write_run_number(run_number)
self._init_run_conf(run_conf) | [
"Initialization",
"before",
"a",
"new",
"run",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L188-L195 | [
"def",
"_init",
"(",
"self",
",",
"run_conf",
",",
"run_number",
"=",
"None",
")",
":",
"self",
".",
"stop_run",
".",
"clear",
"(",
")",
"self",
".",
"abort_run",
".",
"clear",
"(",
")",
"self",
".",
"_run_status",
"=",
"run_status",
".",
"running",
... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.connect_cancel | Run given functions when a run is cancelled. | pybar/run_manager.py | def connect_cancel(self, functions):
'''Run given functions when a run is cancelled.
'''
self._cancel_functions = []
for func in functions:
if isinstance(func, basestring) and hasattr(self, func) and callable(getattr(self, func)):
self._cancel_functions.append... | def connect_cancel(self, functions):
'''Run given functions when a run is cancelled.
'''
self._cancel_functions = []
for func in functions:
if isinstance(func, basestring) and hasattr(self, func) and callable(getattr(self, func)):
self._cancel_functions.append... | [
"Run",
"given",
"functions",
"when",
"a",
"run",
"is",
"cancelled",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L248-L258 | [
"def",
"connect_cancel",
"(",
"self",
",",
"functions",
")",
":",
"self",
".",
"_cancel_functions",
"=",
"[",
"]",
"for",
"func",
"in",
"functions",
":",
"if",
"isinstance",
"(",
"func",
",",
"basestring",
")",
"and",
"hasattr",
"(",
"self",
",",
"func",... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.handle_cancel | Cancelling a run. | pybar/run_manager.py | def handle_cancel(self, **kwargs):
'''Cancelling a run.
'''
for func in self._cancel_functions:
f_args = getargspec(func)[0]
f_kwargs = {key: kwargs[key] for key in f_args if key in kwargs}
func(**f_kwargs) | def handle_cancel(self, **kwargs):
'''Cancelling a run.
'''
for func in self._cancel_functions:
f_args = getargspec(func)[0]
f_kwargs = {key: kwargs[key] for key in f_args if key in kwargs}
func(**f_kwargs) | [
"Cancelling",
"a",
"run",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L260-L266 | [
"def",
"handle_cancel",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func",
"in",
"self",
".",
"_cancel_functions",
":",
"f_args",
"=",
"getargspec",
"(",
"func",
")",
"[",
"0",
"]",
"f_kwargs",
"=",
"{",
"key",
":",
"kwargs",
"[",
"key",
... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.stop | Stopping a run. Control for loops. Gentle stop/abort.
This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete. | pybar/run_manager.py | def stop(self, msg=None):
'''Stopping a run. Control for loops. Gentle stop/abort.
This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete.
'''
if not self.stop_run.is_set():
if msg:
logging.info('%s%s ... | def stop(self, msg=None):
'''Stopping a run. Control for loops. Gentle stop/abort.
This event should provide a more gentle abort. The run should stop ASAP but the run is still considered complete.
'''
if not self.stop_run.is_set():
if msg:
logging.info('%s%s ... | [
"Stopping",
"a",
"run",
".",
"Control",
"for",
"loops",
".",
"Gentle",
"stop",
"/",
"abort",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L268-L278 | [
"def",
"stop",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"stop_run",
".",
"is_set",
"(",
")",
":",
"if",
"msg",
":",
"logging",
".",
"info",
"(",
"'%s%s Stopping run...'",
",",
"msg",
",",
"(",
"''",
"if",
"msg",
"... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunBase.abort | Aborting a run. Control for loops. Immediate stop/abort.
The implementation should stop a run ASAP when this event is set. The run is considered incomplete. | pybar/run_manager.py | def abort(self, msg=None):
'''Aborting a run. Control for loops. Immediate stop/abort.
The implementation should stop a run ASAP when this event is set. The run is considered incomplete.
'''
if not self.abort_run.is_set():
if msg:
logging.error('%s%s Aborting... | def abort(self, msg=None):
'''Aborting a run. Control for loops. Immediate stop/abort.
The implementation should stop a run ASAP when this event is set. The run is considered incomplete.
'''
if not self.abort_run.is_set():
if msg:
logging.error('%s%s Aborting... | [
"Aborting",
"a",
"run",
".",
"Control",
"for",
"loops",
".",
"Immediate",
"stop",
"/",
"abort",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L280-L291 | [
"def",
"abort",
"(",
"self",
",",
"msg",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"abort_run",
".",
"is_set",
"(",
")",
":",
"if",
"msg",
":",
"logging",
".",
"error",
"(",
"'%s%s Aborting run...'",
",",
"msg",
",",
"(",
"''",
"if",
"msg",
... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
train | RunManager.run_run | Runs a run in another thread. Non-blocking.
Parameters
----------
run : class, object
Run class or object.
run_conf : str, dict, file
Specific configuration for the run.
use_thread : bool
If True, run run in thread and returns blocking functio... | pybar/run_manager.py | def run_run(self, run, conf=None, run_conf=None, use_thread=False, catch_exception=True):
'''Runs a run in another thread. Non-blocking.
Parameters
----------
run : class, object
Run class or object.
run_conf : str, dict, file
Specific configuration for t... | def run_run(self, run, conf=None, run_conf=None, use_thread=False, catch_exception=True):
'''Runs a run in another thread. Non-blocking.
Parameters
----------
run : class, object
Run class or object.
run_conf : str, dict, file
Specific configuration for t... | [
"Runs",
"a",
"run",
"in",
"another",
"thread",
".",
"Non",
"-",
"blocking",
"."
] | SiLab-Bonn/pyBAR | python | https://github.com/SiLab-Bonn/pyBAR/blob/5ad95bbcd41cd358825823fb78f396cfce23593e/pybar/run_manager.py#L513-L578 | [
"def",
"run_run",
"(",
"self",
",",
"run",
",",
"conf",
"=",
"None",
",",
"run_conf",
"=",
"None",
",",
"use_thread",
"=",
"False",
",",
"catch_exception",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"conf",
",",
"basestring",
")",
"and",
"os",
"... | 5ad95bbcd41cd358825823fb78f396cfce23593e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.