repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
getsentry/rb
rb/ketama.py
Ketama.remove_node
def remove_node(self, node): """Removes node from circle and rebuild it.""" try: self._nodes.remove(node) del self._weights[node] except (KeyError, ValueError): pass self._rebuild_circle()
python
def remove_node(self, node): """Removes node from circle and rebuild it.""" try: self._nodes.remove(node) del self._weights[node] except (KeyError, ValueError): pass self._rebuild_circle()
[ "def", "remove_node", "(", "self", ",", "node", ")", ":", "try", ":", "self", ".", "_nodes", ".", "remove", "(", "node", ")", "del", "self", ".", "_weights", "[", "node", "]", "except", "(", "KeyError", ",", "ValueError", ")", ":", "pass", "self", ...
Removes node from circle and rebuild it.
[ "Removes", "node", "from", "circle", "and", "rebuild", "it", "." ]
569d1d13311f6c04bae537fc17e75da430e4ec45
https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/ketama.py#L60-L67
train
getsentry/rb
rb/ketama.py
Ketama.add_node
def add_node(self, node, weight=1): """Adds node to circle and rebuild it.""" self._nodes.add(node) self._weights[node] = weight self._rebuild_circle()
python
def add_node(self, node, weight=1): """Adds node to circle and rebuild it.""" self._nodes.add(node) self._weights[node] = weight self._rebuild_circle()
[ "def", "add_node", "(", "self", ",", "node", ",", "weight", "=", "1", ")", ":", "self", ".", "_nodes", ".", "add", "(", "node", ")", "self", ".", "_weights", "[", "node", "]", "=", "weight", "self", ".", "_rebuild_circle", "(", ")" ]
Adds node to circle and rebuild it.
[ "Adds", "node", "to", "circle", "and", "rebuild", "it", "." ]
569d1d13311f6c04bae537fc17e75da430e4ec45
https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/ketama.py#L69-L73
train
getsentry/rb
rb/ketama.py
Ketama.get_node
def get_node(self, key): """Return node for a given key. Else return None.""" pos = self._get_node_pos(key) if pos is None: return None return self._hashring[self._sorted_keys[pos]]
python
def get_node(self, key): """Return node for a given key. Else return None.""" pos = self._get_node_pos(key) if pos is None: return None return self._hashring[self._sorted_keys[pos]]
[ "def", "get_node", "(", "self", ",", "key", ")", ":", "pos", "=", "self", ".", "_get_node_pos", "(", "key", ")", "if", "pos", "is", "None", ":", "return", "None", "return", "self", ".", "_hashring", "[", "self", ".", "_sorted_keys", "[", "pos", "]", ...
Return node for a given key. Else return None.
[ "Return", "node", "for", "a", "given", "key", ".", "Else", "return", "None", "." ]
569d1d13311f6c04bae537fc17e75da430e4ec45
https://github.com/getsentry/rb/blob/569d1d13311f6c04bae537fc17e75da430e4ec45/rb/ketama.py#L75-L80
train
hobu/mgrs
mgrs/core.py
check_error
def check_error(result, func, cargs): "Error checking proper value returns" if result != 0: msg = 'Error in "%s": %s' % (func.__name__, get_errors(result) ) raise RTreeError(msg) return
python
def check_error(result, func, cargs): "Error checking proper value returns" if result != 0: msg = 'Error in "%s": %s' % (func.__name__, get_errors(result) ) raise RTreeError(msg) return
[ "def", "check_error", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "!=", "0", ":", "msg", "=", "'Error in \"%s\": %s'", "%", "(", "func", ".", "__name__", ",", "get_errors", "(", "result", ")", ")", "raise", "RTreeError", "(", "m...
Error checking proper value returns
[ "Error", "checking", "proper", "value", "returns" ]
759b3aba86779318854c73b8843ea956acb5eb3f
https://github.com/hobu/mgrs/blob/759b3aba86779318854c73b8843ea956acb5eb3f/mgrs/core.py#L77-L82
train
hobu/mgrs
mgrs/__init__.py
MGRS.ddtodms
def ddtodms(self, dd): """Take in dd string and convert to dms""" negative = dd < 0 dd = abs(dd) minutes,seconds = divmod(dd*3600,60) degrees,minutes = divmod(minutes,60) if negative: if degrees > 0: degrees = -degrees elif minutes ...
python
def ddtodms(self, dd): """Take in dd string and convert to dms""" negative = dd < 0 dd = abs(dd) minutes,seconds = divmod(dd*3600,60) degrees,minutes = divmod(minutes,60) if negative: if degrees > 0: degrees = -degrees elif minutes ...
[ "def", "ddtodms", "(", "self", ",", "dd", ")", ":", "negative", "=", "dd", "<", "0", "dd", "=", "abs", "(", "dd", ")", "minutes", ",", "seconds", "=", "divmod", "(", "dd", "*", "3600", ",", "60", ")", "degrees", ",", "minutes", "=", "divmod", "...
Take in dd string and convert to dms
[ "Take", "in", "dd", "string", "and", "convert", "to", "dms" ]
759b3aba86779318854c73b8843ea956acb5eb3f
https://github.com/hobu/mgrs/blob/759b3aba86779318854c73b8843ea956acb5eb3f/mgrs/__init__.py#L13-L26
train
hobu/mgrs
mgrs/__init__.py
MGRS.dmstodd
def dmstodd(self, dms): """ convert dms to dd""" size = len(dms) letters = 'WENS' is_annotated = False try: float(dms) except ValueError: for letter in letters: if letter in dms.upper(): is_annotated = True ...
python
def dmstodd(self, dms): """ convert dms to dd""" size = len(dms) letters = 'WENS' is_annotated = False try: float(dms) except ValueError: for letter in letters: if letter in dms.upper(): is_annotated = True ...
[ "def", "dmstodd", "(", "self", ",", "dms", ")", ":", "size", "=", "len", "(", "dms", ")", "letters", "=", "'WENS'", "is_annotated", "=", "False", "try", ":", "float", "(", "dms", ")", "except", "ValueError", ":", "for", "letter", "in", "letters", ":"...
convert dms to dd
[ "convert", "dms", "to", "dd" ]
759b3aba86779318854c73b8843ea956acb5eb3f
https://github.com/hobu/mgrs/blob/759b3aba86779318854c73b8843ea956acb5eb3f/mgrs/__init__.py#L28-L80
train
pydot/pydot-ng
pydot_ng/__init__.py
get_fobj
def get_fobj(fname, mode='w+'): """Obtain a proper file object. Parameters ---------- fname : string, file object, file descriptor If a string or file descriptor, then we create a file object. If *fname* is a file object, then we do nothing and ignore the specified *mode* parame...
python
def get_fobj(fname, mode='w+'): """Obtain a proper file object. Parameters ---------- fname : string, file object, file descriptor If a string or file descriptor, then we create a file object. If *fname* is a file object, then we do nothing and ignore the specified *mode* parame...
[ "def", "get_fobj", "(", "fname", ",", "mode", "=", "'w+'", ")", ":", "if", "is_string_like", "(", "fname", ")", ":", "fobj", "=", "open", "(", "fname", ",", "mode", ")", "close", "=", "True", "elif", "hasattr", "(", "fname", ",", "'write'", ")", ":...
Obtain a proper file object. Parameters ---------- fname : string, file object, file descriptor If a string or file descriptor, then we create a file object. If *fname* is a file object, then we do nothing and ignore the specified *mode* parameter. mode : str The mode of...
[ "Obtain", "a", "proper", "file", "object", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L111-L146
train
pydot/pydot-ng
pydot_ng/__init__.py
graph_from_dot_file
def graph_from_dot_file(path): """Load graph as defined by a DOT file. The file is assumed to be in DOT format. It will be loaded, parsed and a Dot class will be returned, representing the graph. """ fd = open(path, 'rb') data = fd.read() fd.close() return graph_from_dot_data(data...
python
def graph_from_dot_file(path): """Load graph as defined by a DOT file. The file is assumed to be in DOT format. It will be loaded, parsed and a Dot class will be returned, representing the graph. """ fd = open(path, 'rb') data = fd.read() fd.close() return graph_from_dot_data(data...
[ "def", "graph_from_dot_file", "(", "path", ")", ":", "fd", "=", "open", "(", "path", ",", "'rb'", ")", "data", "=", "fd", ".", "read", "(", ")", "fd", ".", "close", "(", ")", "return", "graph_from_dot_data", "(", "data", ")" ]
Load graph as defined by a DOT file. The file is assumed to be in DOT format. It will be loaded, parsed and a Dot class will be returned, representing the graph.
[ "Load", "graph", "as", "defined", "by", "a", "DOT", "file", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L286-L298
train
pydot/pydot-ng
pydot_ng/__init__.py
graph_from_edges
def graph_from_edges(edge_list, node_prefix='', directed=False): """Creates a basic graph out of an edge list. The edge list has to be a list of tuples representing the nodes connected by the edge. The values can be anything: bool, int, float, str. If the graph is undirected by default, it is only...
python
def graph_from_edges(edge_list, node_prefix='', directed=False): """Creates a basic graph out of an edge list. The edge list has to be a list of tuples representing the nodes connected by the edge. The values can be anything: bool, int, float, str. If the graph is undirected by default, it is only...
[ "def", "graph_from_edges", "(", "edge_list", ",", "node_prefix", "=", "''", ",", "directed", "=", "False", ")", ":", "if", "edge_list", "is", "None", ":", "edge_list", "=", "[", "]", "graph_type", "=", "\"digraph\"", "if", "directed", "else", "\"graph\"", ...
Creates a basic graph out of an edge list. The edge list has to be a list of tuples representing the nodes connected by the edge. The values can be anything: bool, int, float, str. If the graph is undirected by default, it is only calculated from one of the symmetric halves of the matrix.
[ "Creates", "a", "basic", "graph", "out", "of", "an", "edge", "list", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L301-L325
train
pydot/pydot-ng
pydot_ng/__init__.py
graph_from_adjacency_matrix
def graph_from_adjacency_matrix(matrix, node_prefix='', directed=False): """Creates a basic graph out of an adjacency matrix. The matrix has to be a list of rows of values representing an adjacency matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False. ...
python
def graph_from_adjacency_matrix(matrix, node_prefix='', directed=False): """Creates a basic graph out of an adjacency matrix. The matrix has to be a list of rows of values representing an adjacency matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False. ...
[ "def", "graph_from_adjacency_matrix", "(", "matrix", ",", "node_prefix", "=", "''", ",", "directed", "=", "False", ")", ":", "node_orig", "=", "1", "if", "directed", ":", "graph", "=", "Dot", "(", "graph_type", "=", "'digraph'", ")", "else", ":", "graph", ...
Creates a basic graph out of an adjacency matrix. The matrix has to be a list of rows of values representing an adjacency matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False.
[ "Creates", "a", "basic", "graph", "out", "of", "an", "adjacency", "matrix", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L328-L362
train
pydot/pydot-ng
pydot_ng/__init__.py
graph_from_incidence_matrix
def graph_from_incidence_matrix(matrix, node_prefix='', directed=False): """Creates a basic graph out of an incidence matrix. The matrix has to be a list of rows of values representing an incidence matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False. ...
python
def graph_from_incidence_matrix(matrix, node_prefix='', directed=False): """Creates a basic graph out of an incidence matrix. The matrix has to be a list of rows of values representing an incidence matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False. ...
[ "def", "graph_from_incidence_matrix", "(", "matrix", ",", "node_prefix", "=", "''", ",", "directed", "=", "False", ")", ":", "if", "directed", ":", "graph", "=", "Dot", "(", "graph_type", "=", "'digraph'", ")", "else", ":", "graph", "=", "Dot", "(", "gra...
Creates a basic graph out of an incidence matrix. The matrix has to be a list of rows of values representing an incidence matrix. The values can be anything: bool, int, float, as long as they can evaluate to True or False.
[ "Creates", "a", "basic", "graph", "out", "of", "an", "incidence", "matrix", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L365-L399
train
pydot/pydot-ng
pydot_ng/__init__.py
__find_executables
def __find_executables(path): """Used by find_graphviz path - single directory as a string If any of the executables are found, it will return a dictionary containing the program names as keys and their paths as values. Otherwise returns None """ success = False progs = { "do...
python
def __find_executables(path): """Used by find_graphviz path - single directory as a string If any of the executables are found, it will return a dictionary containing the program names as keys and their paths as values. Otherwise returns None """ success = False progs = { "do...
[ "def", "__find_executables", "(", "path", ")", ":", "success", "=", "False", "progs", "=", "{", "\"dot\"", ":", "\"\"", ",", "\"twopi\"", ":", "\"\"", ",", "\"neato\"", ":", "\"\"", ",", "\"circo\"", ":", "\"\"", ",", "\"fdp\"", ":", "\"\"", ",", "\"sf...
Used by find_graphviz path - single directory as a string If any of the executables are found, it will return a dictionary containing the program names as keys and their paths as values. Otherwise returns None
[ "Used", "by", "find_graphviz" ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L402-L454
train
pydot/pydot-ng
pydot_ng/__init__.py
find_graphviz
def find_graphviz(): """Locate Graphviz's executables in the system. Tries three methods: First: Windows Registry (Windows only) This requires Mark Hammond's pywin32 is installed. Secondly: Search the path It will look for 'dot', 'twopi' and 'neato' in all the directories specified in the...
python
def find_graphviz(): """Locate Graphviz's executables in the system. Tries three methods: First: Windows Registry (Windows only) This requires Mark Hammond's pywin32 is installed. Secondly: Search the path It will look for 'dot', 'twopi' and 'neato' in all the directories specified in the...
[ "def", "find_graphviz", "(", ")", ":", "# Method 1 (Windows only)", "if", "os", ".", "sys", ".", "platform", "==", "'win32'", ":", "HKEY_LOCAL_MACHINE", "=", "0x80000002", "KEY_QUERY_VALUE", "=", "0x0001", "RegOpenKeyEx", "=", "None", "RegQueryValueEx", "=", "None...
Locate Graphviz's executables in the system. Tries three methods: First: Windows Registry (Windows only) This requires Mark Hammond's pywin32 is installed. Secondly: Search the path It will look for 'dot', 'twopi' and 'neato' in all the directories specified in the PATH environment variable. ...
[ "Locate", "Graphviz", "s", "executables", "in", "the", "system", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L459-L599
train
pydot/pydot-ng
pydot_ng/__init__.py
Graph.get_node_list
def get_node_list(self): """Get the list of Node instances. This method returns the list of Node instances composing the graph. """ node_objs = list() for obj_dict_list in self.obj_dict['nodes'].values(): node_objs.extend([ Node(obj_dict=obj_...
python
def get_node_list(self): """Get the list of Node instances. This method returns the list of Node instances composing the graph. """ node_objs = list() for obj_dict_list in self.obj_dict['nodes'].values(): node_objs.extend([ Node(obj_dict=obj_...
[ "def", "get_node_list", "(", "self", ")", ":", "node_objs", "=", "list", "(", ")", "for", "obj_dict_list", "in", "self", ".", "obj_dict", "[", "'nodes'", "]", ".", "values", "(", ")", ":", "node_objs", ".", "extend", "(", "[", "Node", "(", "obj_dict", ...
Get the list of Node instances. This method returns the list of Node instances composing the graph.
[ "Get", "the", "list", "of", "Node", "instances", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L1250-L1264
train
pydot/pydot-ng
pydot_ng/__init__.py
Graph.del_edge
def del_edge(self, src_or_list, dst=None, index=None): """Delete an edge from the graph. Given an edge's (source, destination) node names all matching edges(s) will be deleted if 'index' is not specified or set to None. If there are several matching edges and 'index' is ...
python
def del_edge(self, src_or_list, dst=None, index=None): """Delete an edge from the graph. Given an edge's (source, destination) node names all matching edges(s) will be deleted if 'index' is not specified or set to None. If there are several matching edges and 'index' is ...
[ "def", "del_edge", "(", "self", ",", "src_or_list", ",", "dst", "=", "None", ",", "index", "=", "None", ")", ":", "if", "isinstance", "(", "src_or_list", ",", "(", "list", ",", "tuple", ")", ")", ":", "if", "dst", "is", "not", "None", "and", "isins...
Delete an edge from the graph. Given an edge's (source, destination) node names all matching edges(s) will be deleted if 'index' is not specified or set to None. If there are several matching edges and 'index' is given, only the edge in that position will be deleted. 'i...
[ "Delete", "an", "edge", "from", "the", "graph", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L1287-L1326
train
pydot/pydot-ng
pydot_ng/__init__.py
Graph.get_edge_list
def get_edge_list(self): """Get the list of Edge instances. This method returns the list of Edge instances composing the graph. """ edge_objs = list() for obj_dict_list in self.obj_dict['edges'].values(): edge_objs.extend([ Edge(obj_dict=obj_...
python
def get_edge_list(self): """Get the list of Edge instances. This method returns the list of Edge instances composing the graph. """ edge_objs = list() for obj_dict_list in self.obj_dict['edges'].values(): edge_objs.extend([ Edge(obj_dict=obj_...
[ "def", "get_edge_list", "(", "self", ")", ":", "edge_objs", "=", "list", "(", ")", "for", "obj_dict_list", "in", "self", ".", "obj_dict", "[", "'edges'", "]", ".", "values", "(", ")", ":", "edge_objs", ".", "extend", "(", "[", "Edge", "(", "obj_dict", ...
Get the list of Edge instances. This method returns the list of Edge instances composing the graph.
[ "Get", "the", "list", "of", "Edge", "instances", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L1366-L1380
train
pydot/pydot-ng
pydot_ng/__init__.py
Graph.to_string
def to_string(self): """Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string from. """ graph = list() if self.obj_dict.get('strict', None) is not None: if self == self.get_parent_graph() and self.o...
python
def to_string(self): """Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string from. """ graph = list() if self.obj_dict.get('strict', None) is not None: if self == self.get_parent_graph() and self.o...
[ "def", "to_string", "(", "self", ")", ":", "graph", "=", "list", "(", ")", "if", "self", ".", "obj_dict", ".", "get", "(", "'strict'", ",", "None", ")", "is", "not", "None", ":", "if", "self", "==", "self", ".", "get_parent_graph", "(", ")", "and",...
Returns a string representation of the graph in dot language. It will return the graph and all its subelements in string from.
[ "Returns", "a", "string", "representation", "of", "the", "graph", "in", "dot", "language", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L1463-L1545
train
pydot/pydot-ng
pydot_ng/__init__.py
Dot.write
def write(self, path, prog=None, format='raw'): """Write graph to file in selected format. Given a filename 'path' it will open/create and truncate such file and write on it a representation of the graph defined by the dot object and in the format specified by 'format'. 'path' c...
python
def write(self, path, prog=None, format='raw'): """Write graph to file in selected format. Given a filename 'path' it will open/create and truncate such file and write on it a representation of the graph defined by the dot object and in the format specified by 'format'. 'path' c...
[ "def", "write", "(", "self", ",", "path", ",", "prog", "=", "None", ",", "format", "=", "'raw'", ")", ":", "if", "prog", "is", "None", ":", "prog", "=", "self", ".", "prog", "fobj", ",", "close", "=", "get_fobj", "(", "path", ",", "'w+b'", ")", ...
Write graph to file in selected format. Given a filename 'path' it will open/create and truncate such file and write on it a representation of the graph defined by the dot object and in the format specified by 'format'. 'path' can also be an open file-like object, such as a Stri...
[ "Write", "graph", "to", "file", "in", "selected", "format", "." ]
16f39800b6f5dc28d291a4d7763bbac04b9efe72
https://github.com/pydot/pydot-ng/blob/16f39800b6f5dc28d291a4d7763bbac04b9efe72/pydot_ng/__init__.py#L1728-L1784
train
pawamoy/django-suit-dashboard
src/suit_dashboard/views.py
DashboardView.get_crumbs
def get_crumbs(self): """ Get crumbs for navigation links. Returns: tuple: concatenated list of crumbs using these crumbs and the crumbs of the parent classes through ``__mro__``. """ crumbs = [] for cls in reversed(type(self)....
python
def get_crumbs(self): """ Get crumbs for navigation links. Returns: tuple: concatenated list of crumbs using these crumbs and the crumbs of the parent classes through ``__mro__``. """ crumbs = [] for cls in reversed(type(self)....
[ "def", "get_crumbs", "(", "self", ")", ":", "crumbs", "=", "[", "]", "for", "cls", "in", "reversed", "(", "type", "(", "self", ")", ".", "__mro__", "[", "1", ":", "]", ")", ":", "crumbs", ".", "extend", "(", "getattr", "(", "cls", ",", "'crumbs'"...
Get crumbs for navigation links. Returns: tuple: concatenated list of crumbs using these crumbs and the crumbs of the parent classes through ``__mro__``.
[ "Get", "crumbs", "for", "navigation", "links", "." ]
c008f55f4168f7af62ba31e8b621df214bea1e96
https://github.com/pawamoy/django-suit-dashboard/blob/c008f55f4168f7af62ba31e8b621df214bea1e96/src/suit_dashboard/views.py#L30-L43
train
pawamoy/django-suit-dashboard
src/suit_dashboard/views.py
DashboardView.get
def get(self, request, *args, **kwargs): """ Django view get function. Add items of extra_context, crumbs and grid to context. Args: request (): Django's request object. *args (): request args. **kwargs (): request kwargs. Returns: ...
python
def get(self, request, *args, **kwargs): """ Django view get function. Add items of extra_context, crumbs and grid to context. Args: request (): Django's request object. *args (): request args. **kwargs (): request kwargs. Returns: ...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "context", "=", "self", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "self", ".", "extra_context", ")", "context"...
Django view get function. Add items of extra_context, crumbs and grid to context. Args: request (): Django's request object. *args (): request args. **kwargs (): request kwargs. Returns: response: render to response with context.
[ "Django", "view", "get", "function", "." ]
c008f55f4168f7af62ba31e8b621df214bea1e96
https://github.com/pawamoy/django-suit-dashboard/blob/c008f55f4168f7af62ba31e8b621df214bea1e96/src/suit_dashboard/views.py#L45-L66
train
pawamoy/django-suit-dashboard
src/suit_dashboard/widgets.py
realtime
def realtime(widget, url_name=None, url_regex=None, time_interval=None): """ Return a widget as real-time. Args: widget (Widget): the widget to register and return as real-time. url_name (str): the URL name to call to get updated content. url_regex (regex): the URL regex to be match...
python
def realtime(widget, url_name=None, url_regex=None, time_interval=None): """ Return a widget as real-time. Args: widget (Widget): the widget to register and return as real-time. url_name (str): the URL name to call to get updated content. url_regex (regex): the URL regex to be match...
[ "def", "realtime", "(", "widget", ",", "url_name", "=", "None", ",", "url_regex", "=", "None", ",", "time_interval", "=", "None", ")", ":", "if", "not", "hasattr", "(", "widget", ",", "'get_updated_content'", ")", ":", "raise", "AttributeError", "(", "'Wid...
Return a widget as real-time. Args: widget (Widget): the widget to register and return as real-time. url_name (str): the URL name to call to get updated content. url_regex (regex): the URL regex to be matched. time_interval (int): the interval of refreshment in milliseconds. Re...
[ "Return", "a", "widget", "as", "real", "-", "time", "." ]
c008f55f4168f7af62ba31e8b621df214bea1e96
https://github.com/pawamoy/django-suit-dashboard/blob/c008f55f4168f7af62ba31e8b621df214bea1e96/src/suit_dashboard/widgets.py#L22-L97
train
pawamoy/django-suit-dashboard
src/suit_dashboard/urls.py
get_realtime_urls
def get_realtime_urls(admin_view_func=lambda x: x): """ Get the URL for real-time widgets. Args: admin_view_func (callable): an admin_view method from an AdminSite instance. By default: identity. Returns: list: the list of the real-time URLs as django's ``url()``. """ ...
python
def get_realtime_urls(admin_view_func=lambda x: x): """ Get the URL for real-time widgets. Args: admin_view_func (callable): an admin_view method from an AdminSite instance. By default: identity. Returns: list: the list of the real-time URLs as django's ``url()``. """ ...
[ "def", "get_realtime_urls", "(", "admin_view_func", "=", "lambda", "x", ":", "x", ")", ":", "from", ".", "widgets", "import", "REALTIME_WIDGETS", "return", "[", "url", "(", "w", ".", "url_regex", ",", "admin_view_func", "(", "w", ".", "as_view", "(", ")", ...
Get the URL for real-time widgets. Args: admin_view_func (callable): an admin_view method from an AdminSite instance. By default: identity. Returns: list: the list of the real-time URLs as django's ``url()``.
[ "Get", "the", "URL", "for", "real", "-", "time", "widgets", "." ]
c008f55f4168f7af62ba31e8b621df214bea1e96
https://github.com/pawamoy/django-suit-dashboard/blob/c008f55f4168f7af62ba31e8b621df214bea1e96/src/suit_dashboard/urls.py#L10-L23
train
honeynet/beeswarm
beeswarm/server/db/database_setup.py
setup_db
def setup_db(connection_string): """ Sets up the database schema and adds defaults. :param connection_string: Database URL. e.g: sqlite:///filename.db This is usually taken from the config file. """ global DB_Session, engine new_database = False if connectio...
python
def setup_db(connection_string): """ Sets up the database schema and adds defaults. :param connection_string: Database URL. e.g: sqlite:///filename.db This is usually taken from the config file. """ global DB_Session, engine new_database = False if connectio...
[ "def", "setup_db", "(", "connection_string", ")", ":", "global", "DB_Session", ",", "engine", "new_database", "=", "False", "if", "connection_string", "==", "'sqlite://'", "or", "not", "database_exists", "(", "connection_string", ")", ":", "new_database", "=", "Tr...
Sets up the database schema and adds defaults. :param connection_string: Database URL. e.g: sqlite:///filename.db This is usually taken from the config file.
[ "Sets", "up", "the", "database", "schema", "and", "adds", "defaults", ".", ":", "param", "connection_string", ":", "Database", "URL", ".", "e", ".", "g", ":", "sqlite", ":", "///", "filename", ".", "db", "This", "is", "usually", "taken", "from", "the", ...
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/db/database_setup.py#L37-L85
train
honeynet/beeswarm
beeswarm/drones/honeypot/capabilities/ssh.py
SshWrapper.start_pty_request
def start_pty_request(self, channel, term, modes): """Start a PTY - intended to run it a (green)thread.""" request = self.dummy_request() request._sock = channel request.modes = modes request.term = term request.username = self.username # This should block until ...
python
def start_pty_request(self, channel, term, modes): """Start a PTY - intended to run it a (green)thread.""" request = self.dummy_request() request._sock = channel request.modes = modes request.term = term request.username = self.username # This should block until ...
[ "def", "start_pty_request", "(", "self", ",", "channel", ",", "term", ",", "modes", ")", ":", "request", "=", "self", ".", "dummy_request", "(", ")", "request", ".", "_sock", "=", "channel", "request", ".", "modes", "=", "modes", "request", ".", "term", ...
Start a PTY - intended to run it a (green)thread.
[ "Start", "a", "PTY", "-", "intended", "to", "run", "it", "a", "(", "green", ")", "thread", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/capabilities/ssh.py#L118-L130
train
honeynet/beeswarm
beeswarm/drones/honeypot/honeypot.py
Honeypot.check_time
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: ...
python
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", ")", ":", "poll", "=", "self", ".", "config", "[", "'timecheck'", "]", "[", "'poll'", "]", "ntp_poll", "=", "self", ".", "config", "[", "'timecheck'", "]", "[", "'ntp_pool'", "]", "while", "True", ":", "clnt", "=", "...
Make sure our Honeypot time is consistent, and not too far off from the actual time.
[ "Make", "sure", "our", "Honeypot", "time", "is", "consistent", "and", "not", "too", "far", "off", "from", "the", "actual", "time", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L111-L129
train
honeynet/beeswarm
beeswarm/drones/honeypot/honeypot.py
Honeypot.start
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'] ...
python
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", ")", ":", "# protocol handlers", "for", "c", "in", "handlerbase", ".", "HandlerBase", ".", "__subclasses__", "(", ")", ":", "cap_name", "=", "c", ".", "__name__", ".", "lower", "(", ")", "if", "cap_name", "in", "self", ".", ...
Starts services.
[ "Starts", "services", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L131-L167
train
honeynet/beeswarm
beeswarm/drones/honeypot/honeypot.py
Honeypot.stop
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.')
python
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", ")", ":", "for", "s", "in", "self", ".", "_servers", ":", "s", ".", "stop", "(", ")", "for", "g", "in", "self", ".", "_server_greenlets", ":", "g", ".", "kill", "(", ")", "logger", ".", "info", "(", "'All workers stopped...
Stops services
[ "Stops", "services" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L169-L178
train
honeynet/beeswarm
beeswarm/drones/honeypot/honeypot.py
Honeypot.prepare_environment
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...
python
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", ")", ":", "package_directory", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "beeswarm", ".", "__file__", ")", ")", "logger", ".", "info", "(", "'Copying data files to work...
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.
[ "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...
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/honeypot.py#L181-L193
train
honeynet/beeswarm
beeswarm/drones/client/baits/http.py
Http.start
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'] ...
python
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", ")", ":", "username", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=",...
Launches a new HTTP client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "HTTP", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/http.py#L49-L91
train
honeynet/beeswarm
beeswarm/drones/client/baits/http.py
Http._get_links
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...
python
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", ")", ":", "html_text", "=", "response", ".", "text", ".", "encode", "(", "'utf-8'", ")", "doc", "=", "document_fromstring", "(", "html_text", ")", "links", "=", "[", "]", "for", "e", "in", "doc", ".", ...
Parses the response text and returns all the links in it. :param response: The Response object.
[ "Parses", "the", "response", "text", "and", "returns", "all", "the", "links", "in", "it", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/http.py#L100-L110
train
honeynet/beeswarm
beeswarm/shared/misc/local_bootstrapper.py
bootstrap
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...
python
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", ")", ":", "root_logger", "=", "logging", ".", "getLogger", "(", ")", "root_logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "formatter", "=", "logging", ".", "Formatter", "(", "'%(a...
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.
[ "Bootstraps", "localhost", "configurations", "for", "a", "Beeswarm", "server", "and", "a", "honeypot", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/misc/local_bootstrapper.py#L39-L120
train
honeynet/beeswarm
beeswarm/shared/helpers.py
database_exists
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...
python
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", ")", ":", "url", "=", "copy", "(", "make_url", "(", "url", ")", ")", "database", "=", "url", ".", "database", "if", "url", ".", "drivername", ".", "startswith", "(", "'postgresql'", ")", ":", "url", ".", "database"...
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...
[ "Check", "if", "a", "database", "exists", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/helpers.py#L246-L297
train
honeynet/beeswarm
beeswarm/server/server.py
Server.message_proxy
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....
python
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", ")", ":", "public_keys_dir", "=", "os", ".", "path", ".", "join", "(", "work_dir", ",", "'certificates'", ",", "'public_keys'", ")", "secret_keys_dir", "=", "os", ".", "path", ".", "join", "(", "work_di...
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
[ "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",...
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L113-L176
train
honeynet/beeswarm
beeswarm/server/server.py
Server.start
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,...
python
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", ")", ":", "self", ".", "started", "=", "True", "if", "self", ".", "app", ":", "web_port", "=", "self", ".", "config", "[", "'network'", "]", "[", "'web_port'", "]", "logger", ".", "info", "(", "'Starting server listening on p...
Starts the BeeSwarm server.
[ "Starts", "the", "BeeSwarm", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L178-L194
train
honeynet/beeswarm
beeswarm/server/server.py
Server.get_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
python
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", ")", ":", "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
[ "Loads", "the", "configuration", "from", "the", "JSON", "file", "and", "returns", "it", ".", ":", "param", "configfile", ":", "Path", "to", "the", "configuration", "file" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/server.py#L207-L214
train
honeynet/beeswarm
beeswarm/drones/client/models/dispatcher.py
BaitDispatcher.time_in_range
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...
python
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", ")", ":", "curr", "=", "datetime", ".", "datetime", ".", "now", "(", ")", ".", "time", "(", ")", "if", "self", ".", "start_time", "<=", "self", ".", "end_time", ":", "return", "self", ".", "start_time", "<=", "cur...
Return true if current time is in the active range
[ "Return", "true", "if", "current", "time", "is", "in", "the", "active", "range" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/models/dispatcher.py#L101-L107
train
honeynet/beeswarm
beeswarm/drones/client/baits/vnc.py
Vnc.start
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'] ...
python
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", ")", ":", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=", "self", ".", "options", "[", "'port'", "]", "honeypot_id", "=", ...
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
[ "Launches", "a", "new", "Telnet", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", ".", "This", "session", "always", "fails", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/vnc.py#L37-L92
train
honeynet/beeswarm
beeswarm/drones/client/baits/clientbase.py
ClientBase.create_session
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() ...
python
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", ")", ":", "protocol", "=", "self", ".", "__class__", ".", "__name__", ".", "lower", "(", ")", "session", "=", "BaitSession", "(", "protocol", ",", "server_host"...
Creates a new session. :param server_host: IP address of the server :param server_port: Server port :return: A new `BaitSession` object.
[ "Creates", "a", "new", "session", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/clientbase.py#L31-L42
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.start
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'] ...
python
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", ")", ":", "username", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=",...
Launches a new FTP client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "FTP", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L64-L116
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.sense
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()
python
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", ")", ":", "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.
[ "Launches", "a", "few", "sensing", "commands", "such", "as", "ls", "or", "pwd", "and", "updates", "the", "current", "bait", "state", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L118-L126
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.decide
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...
python
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", ")", ":", "next_command_name", "=", "random", ".", "choice", "(", "self", ".", "COMMAND_MAP", "[", "self", ".", "state", "[", "'last_command'", "]", "]", ")", "param", "=", "''", "if", "next_command_name", "==", "'retrieve'", ...
Decides the next command to be launched based on the current state. :return: Tuple containing the next command name, and it's parameters.
[ "Decides", "the", "next", "command", "to", "be", "launched", "based", "on", "the", "current", "state", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L128-L140
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.act
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...
python
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", ")", ":", "command", "=", "getattr", "(", "self", ",", "cmd_name", ")", "if", "param", ":", "command", "(", "param", ")", "else", ":", "command", "(", ")" ]
Run the command with the parameters. :param cmd_name: The name of command to run :param param: Params for the command
[ "Run", "the", "command", "with", "the", "parameters", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L142-L153
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.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)
python
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", ")", ":", "logger", ".", "debug", "(", "'Sending FTP list command.'", ")", "self", ".", "state", "[", "'file_list'", "]", "=", "[", "]", "self", ".", "state", "[", "'dir_list'", "]", "=", "[", "]", "self", ".", "client", "...
Run the FTP LIST command, and update the state.
[ "Run", "the", "FTP", "LIST", "command", "and", "update", "the", "state", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L155-L162
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.retrieve
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...
python
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", ")", ":", "logger", ".", "debug", "(", "'Sending FTP retr command. Filename: {}'", ".", "format", "(", "filename", ")", ")", "self", ".", "client", ".", "retrbinary", "(", "'RETR {}'", ".", "format", "(", "fil...
Run the FTP RETR command, and download the file :param filename: Name of the file to download
[ "Run", "the", "FTP", "RETR", "command", "and", "download", "the", "file" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L164-L171
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp.cwd
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()
python
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", ")", ":", "logger", ".", "debug", "(", "'Sending FTP cwd command. New Workding Directory: {}'", ".", "format", "(", "newdir", ")", ")", "self", ".", "client", ".", "cwd", "(", "newdir", ")", "self", ".", "state", "...
Send the FTP CWD command :param newdir: Directory to change to
[ "Send", "the", "FTP", "CWD", "command" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L180-L188
train
honeynet/beeswarm
beeswarm/drones/client/baits/ftp.py
Ftp._process_list
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('-'): ...
python
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\t May 09 19:37 testftp.txt", "res", "=", "list_line", ".", "split", "(", "' '", ",", "8", ")", "if", "res", "[", "0", "]", ".", "startswith", "(", "'-'", ")", ":", ...
Processes a line of 'ls -l' output, and updates state accordingly. :param list_line: Line to process
[ "Processes", "a", "line", "of", "ls", "-", "l", "output", "and", "updates", "state", "accordingly", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ftp.py#L206-L217
train
honeynet/beeswarm
beeswarm/server/webapp/forms.py
validate_time_range
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(...
python
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", ")", ":", "string", "=", "field", ".", "data", "try", ":", "begin", ",", "end", "=", "string", ".", "split", "(", "'-'", ")", "begin", "=", "begin", ".", "strip", "(", ")", "end", "=", "end",...
Makes sure the form data is in 'hh:mm - hh:mm' format and the start time is less than end time.
[ "Makes", "sure", "the", "form", "data", "is", "in", "hh", ":", "mm", "-", "hh", ":", "mm", "format", "and", "the", "start", "time", "is", "less", "than", "end", "time", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/webapp/forms.py#L6-L24
train
honeynet/beeswarm
beeswarm/drones/client/client.py
Client.start
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__(): ...
python
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", ")", ":", "logger", ".", "info", "(", "'Starting client.'", ")", "self", ".", "dispatcher_greenlets", "=", "[", "]", "for", "_", ",", "entry", "in", "self", ".", "config", "[", "'baits'", "]", ".", "items", "(", ")", ":",...
Starts sending client bait to the configured Honeypot.
[ "Starts", "sending", "client", "bait", "to", "the", "configured", "Honeypot", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/client.py#L58-L78
train
honeynet/beeswarm
beeswarm/drones/client/baits/pop3s.py
Pop3s.start
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'] ...
python
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", ")", ":", "username", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=",...
Launches a new POP3 client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "POP3", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/pop3s.py#L30-L75
train
honeynet/beeswarm
beeswarm/server/db/database_actor.py
DatabaseActor.get_matching_session
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...
python
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", ")", ":", "db_session", "=", "db_session", "min_datetime", "=", "session", ".", "timestamp", "-", "timedelta", "(", "seconds", "=", "timediff", ")", "ma...
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 ...
[ "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", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/db/database_actor.py#L354-L393
train
honeynet/beeswarm
beeswarm/server/db/database_actor.py
DatabaseActor._classify_malicious_sessions
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) ...
python
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", ")", ":", "min_datetime", "=", "datetime", ".", "utcnow", "(", ")", "-", "timedelta", "(", "seconds", "=", "self", ".", "delay_seconds", ")", "db_session", "=", "database_setup", ".", "get_session", "(", ")",...
Will classify all unclassified sessions as malicious activity. :param delay_seconds: no sessions newer than (now - delay_seconds) will be processed.
[ "Will", "classify", "all", "unclassified", "sessions", "as", "malicious", "activity", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/server/db/database_actor.py#L414-L474
train
honeynet/beeswarm
beeswarm/drones/client/baits/ssh.py
Ssh.start
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'] ...
python
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", ")", ":", "username", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=",...
Launches a new SSH client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "SSH", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L51-L90
train
honeynet/beeswarm
beeswarm/drones/client/baits/ssh.py
Ssh.send_command
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')
python
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", ")", ":", "logger", ".", "debug", "(", "'Sending {0} command.'", ".", "format", "(", "cmd", ")", ")", "self", ".", "comm_chan", ".", "sendall", "(", "cmd", "+", "'\\n'", ")" ]
Send a command to the remote SSH server. :param cmd: The command to send
[ "Send", "a", "command", "to", "the", "remote", "SSH", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L92-L99
train
honeynet/beeswarm
beeswarm/drones/client/baits/ssh.py
Ssh.get_response
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)
python
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", ")", ":", "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* :return: Response data
[ "Get", "the", "response", "from", "the", "server", ".", "*", "This", "may", "not", "return", "the", "full", "response", "*" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L101-L109
train
honeynet/beeswarm
beeswarm/drones/client/baits/ssh.py
Ssh.connect_login
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'], ...
python
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", ")", ":", "self", ".", "client", ".", "connect", "(", "self", ".", "options", "[", "'server'", "]", ",", "self", ".", "options", "[", "'port'", "]", ",", "self", ".", "options", "[", "'username'", "]", ",", "self"...
Try to login to the Remote SSH Server. :return: Response text on successful login :raise: `AuthenticationFailed` on unsuccessful login
[ "Try", "to", "login", "to", "the", "Remote", "SSH", "Server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/ssh.py#L111-L127
train
honeynet/beeswarm
beeswarm/drones/honeypot/helpers/common.py
list2dict
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
python
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", ")", ":", "d", "=", "{", "}", "for", "key", ",", "value", "in", "list_of_options", ":", "d", "[", "key", "]", "=", "value", "return", "d" ]
Transforms a list of 2 element tuples to a dictionary
[ "Transforms", "a", "list", "of", "2", "element", "tuples", "to", "a", "dictionary" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/helpers/common.py#L10-L15
train
honeynet/beeswarm
beeswarm/drones/honeypot/helpers/common.py
path_to_ls
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...
python
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", ")", ":", "st", "=", "os", ".", "stat", "(", "fn", ")", "full_mode", "=", "'rwxrwxrwx'", "mode", "=", "''", "file_time", "=", "''", "d", "=", "''", "for", "i", "in", "range", "(", "9", ")", ":", "# Incrementally buil...
Converts an absolute path to an entry resembling the output of the ls command on most UNIX systems.
[ "Converts", "an", "absolute", "path", "to", "an", "entry", "resembling", "the", "output", "of", "the", "ls", "command", "on", "most", "UNIX", "systems", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/helpers/common.py#L27-L42
train
honeynet/beeswarm
beeswarm/drones/drone.py
Drone.start
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")...
python
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", ")", ":", "cert_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "work_dir", ",", "'certificates'", ")", "public_keys_dir", "=", "os", ".", "path", ".", "join", "(", "cert_path", ",", "'public_keys'", ")", "pri...
Starts services.
[ "Starts", "services", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L85-L104
train
honeynet/beeswarm
beeswarm/drones/drone.py
Drone._start_drone
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: ...
python
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", ")", ":", "with", "open", "(", "self", ".", "config_file", ",", "'r'", ")", "as", "config_file", ":", "self", ".", "config", "=", "json", ".", "load", "(", "config_file", ",", "object_hook", "=", "asciify", ")", "mod...
Restarts the drone
[ "Restarts", "the", "drone" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L106-L126
train
honeynet/beeswarm
beeswarm/drones/drone.py
Drone.stop
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 ...
python
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", ")", ":", "logging", ".", "debug", "(", "'Stopping drone, hang on.'", ")", "if", "self", ".", "drone", "is", "not", "None", ":", "self", ".", "drone_greenlet", ".", "unlink", "(", "self", ".", "on_exception", ")", "self", ".",...
Stops services
[ "Stops", "services" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/drone.py#L128-L139
train
honeynet/beeswarm
beeswarm/drones/client/baits/smtp.py
Smtp.start
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'] ...
python
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", ")", ":", "username", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=",...
Launches a new SMTP client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "SMTP", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L51-L103
train
honeynet/beeswarm
beeswarm/drones/client/baits/smtp.py
Smtp.get_one_mail
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] ...
python
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", ")", ":", "while", "True", ":", "mail_key", "=", "random", ".", "choice", "(", "self", ".", "mailbox", ".", "keys", "(", ")", ")", "mail", "=", "self", ".", "mailbox", "[", "mail_key", "]", "from_addr", "=", "mail"...
Choose and return a random email from the mail archive. :return: Tuple containing From Address, To Address and the mail body.
[ "Choose", "and", "return", "a", "random", "email", "from", "the", "mail", "archive", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L105-L120
train
honeynet/beeswarm
beeswarm/drones/client/baits/smtp.py
Smtp.connect
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)
python
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", ")", ":", "# TODO: local_hostname should be configurable", "self", ".", "client", "=", "smtplib", ".", "SMTP", "(", "self", ".", "options", "[", "'server'", "]", ",", "self", ".", "options", "[", "'port'", "]", ",", "local_host...
Connect to the SMTP server.
[ "Connect", "to", "the", "SMTP", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/smtp.py#L122-L128
train
honeynet/beeswarm
beeswarm/drones/honeypot/capabilities/shared/shell.py
Commands.handle
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)...
python
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", ")", ":", "if", "not", "self", ".", "authentication_ok", "(", ")", ":", "return", "if", "self", ".", "DOECHO", ":", "self", ".", "writeline", "(", "self", ".", "WELCOME", ")", "self", ".", "session_start", "(", ")", "whi...
The actual service to which the user has connected.
[ "The", "actual", "service", "to", "which", "the", "user", "has", "connected", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/honeypot/capabilities/shared/shell.py#L244-L273
train
honeynet/beeswarm
beeswarm/shared/asciify.py
_asciify_list
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, ...
python
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", ")", ":", "ret", "=", "[", "]", "for", "item", "in", "data", ":", "if", "isinstance", "(", "item", ",", "unicode", ")", ":", "item", "=", "_remove_accents", "(", "item", ")", "item", "=", "item", ".", "encode", ...
Ascii-fies list values
[ "Ascii", "-", "fies", "list", "values" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/asciify.py#L15-L27
train
honeynet/beeswarm
beeswarm/shared/asciify.py
_asciify_dict
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...
python
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", ")", ":", "ret", "=", "{", "}", "for", "key", ",", "value", "in", "data", ".", "iteritems", "(", ")", ":", "if", "isinstance", "(", "key", ",", "unicode", ")", ":", "key", "=", "_remove_accents", "(", "key", ")"...
Ascii-fies dict keys and values
[ "Ascii", "-", "fies", "dict", "keys", "and", "values" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/asciify.py#L30-L46
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
BaitTelnetClient.write_human
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)...
python
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_", ")", ":", "if", "self", ".", "IAC", "in", "buffer_", ":", "buffer_", "=", "buffer_", ".", "replace", "(", "self", ".", "IAC", ",", "self", ".", "IAC", "+", "self", ".", "IAC", ")", "self", ".", "...
Emulates human typing speed
[ "Emulates", "human", "typing", "speed" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L40-L49
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
Telnet.start
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'] ...
python
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", ")", ":", "login", "=", "self", ".", "options", "[", "'username'", "]", "password", "=", "self", ".", "options", "[", "'password'", "]", "server_host", "=", "self", ".", "options", "[", "'server'", "]", "server_port", "=", ...
Launches a new Telnet client session on the server taken from the `self.options` dict. :param my_ip: IP of this Client itself
[ "Launches", "a", "new", "Telnet", "client", "session", "on", "the", "server", "taken", "from", "the", "self", ".", "options", "dict", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L75-L122
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
Telnet.connect
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)
python
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", ")", ":", "self", ".", "client", "=", "BaitTelnetClient", "(", "self", ".", "options", "[", "'server'", "]", ",", "self", ".", "options", "[", "'port'", "]", ")", "self", ".", "client", ".", "set_option_negotiation_callback",...
Open a new telnet session on the remote server.
[ "Open", "a", "new", "telnet", "session", "on", "the", "remote", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L124-L129
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
Telnet.login
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....
python
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", ")", ":", "self", ".", "client", ".", "read_until", "(", "'Username: '", ")", "self", ".", "client", ".", "write", "(", "login", "+", "'\\r\\n'", ")", "self", ".", "client", ".", "read_until",...
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
[ "Login", "to", "the", "remote", "telnet", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L131-L145
train
honeynet/beeswarm
beeswarm/drones/client/baits/telnet.py
Telnet.logout
def logout(self): """ Logout from the remote server. """ self.client.write('exit\r\n') self.client.read_all() self.client.close()
python
def logout(self): """ Logout from the remote server. """ self.client.write('exit\r\n') self.client.read_all() self.client.close()
[ "def", "logout", "(", "self", ")", ":", "self", ".", "client", ".", "write", "(", "'exit\\r\\n'", ")", "self", ".", "client", ".", "read_all", "(", ")", "self", ".", "client", ".", "close", "(", ")" ]
Logout from the remote server.
[ "Logout", "from", "the", "remote", "server", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/telnet.py#L147-L153
train
honeynet/beeswarm
beeswarm/shared/models/base_session.py
BaseSession.add_auth_attempt
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(), ...
python
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", ")", ":", "entry", "=", "{", "'timestamp'", ":", "datetime", ".", "utcnow", "(", ")", ",", "'auth'", ":", "auth_type", ",", "'id'", ":", "uuid", ".", ...
:param username: :param password: :param auth_type: possible values: plain: plaintext username/password :return:
[ ":", "param", "username", ":", ":", "param", "password", ":", ":", "param", "auth_type", ":", "possible", "values", ":", "plain", ":", "plaintext", "username", "/", "password", ":", "return", ":" ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/shared/models/base_session.py#L54-L76
train
honeynet/beeswarm
beeswarm/drones/client/baits/shared/shell.py
Commands.sense
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...
python
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", ")", ":", "cmd_name", "=", "random", ".", "choice", "(", "self", ".", "senses", ")", "param", "=", "''", "if", "cmd_name", "==", "'ls'", ":", "if", "random", ".", "randint", "(", "0", ",", "1", ")", ":", "param", "=",...
Launch a command in the 'senses' List, and update the current state.
[ "Launch", "a", "command", "in", "the", "senses", "List", "and", "update", "the", "current", "state", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L102-L117
train
honeynet/beeswarm
beeswarm/drones/client/baits/shared/shell.py
Commands.decide
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...
python
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", ")", ":", "next_command_name", "=", "random", ".", "choice", "(", "self", ".", "COMMAND_MAP", "[", "self", ".", "state", "[", "'last_command'", "]", "]", ")", "param", "=", "''", "if", "next_command_name", "==", "'cd'", ":",...
Choose the next command to execute, and its parameters, based on the current state.
[ "Choose", "the", "next", "command", "to", "execute", "and", "its", "parameters", "based", "on", "the", "current", "state", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L119-L164
train
honeynet/beeswarm
beeswarm/drones/client/baits/shared/shell.py
Commands.act
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()
python
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", ")", ":", "command", "=", "getattr", "(", "self", ",", "cmd_name", ")", "if", "params", ":", "command", "(", "params", ")", "else", ":", "command", "(", ")" ]
Run the specified command with its parameters.
[ "Run", "the", "specified", "command", "with", "its", "parameters", "." ]
db51ea0bc29f631c3e3b5312b479ac9d5e31079a
https://github.com/honeynet/beeswarm/blob/db51ea0bc29f631c3e3b5312b479ac9d5e31079a/beeswarm/drones/client/baits/shared/shell.py#L166-L173
train
marselester/json-log-formatter
json_log_formatter/__init__.py
JSONFormatter.json_record
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...
python
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", ")", ":", "extra", "[", "'message'", "]", "=", "message", "if", "'time'", "not", "in", "extra", ":", "extra", "[", "'time'", "]", "=", "datetime", ".", "utcnow", "(", ")"...
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'})`. ...
[ "Prepares", "a", "JSON", "payload", "which", "will", "be", "logged", "." ]
2db6d5bf025486b0fb690d85e320d01dba614c0c
https://github.com/marselester/json-log-formatter/blob/2db6d5bf025486b0fb690d85e320d01dba614c0c/json_log_formatter/__init__.py#L94-L113
train
marselester/json-log-formatter
json_log_formatter/__init__.py
JSONFormatter.mutate_json_record
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...
python
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", ")", ":", "for", "attr_name", "in", "json_record", ":", "attr", "=", "json_record", "[", "attr_name", "]", "if", "isinstance", "(", "attr", ",", "datetime", ")", ":", "json_record", "[", "attr_nam...
Override it to convert fields of `json_record` to needed types. Default implementation converts `datetime` to string in ISO8601 format.
[ "Override", "it", "to", "convert", "fields", "of", "json_record", "to", "needed", "types", "." ]
2db6d5bf025486b0fb690d85e320d01dba614c0c
https://github.com/marselester/json-log-formatter/blob/2db6d5bf025486b0fb690d85e320d01dba614c0c/json_log_formatter/__init__.py#L115-L125
train
sonyxperiadev/pygerrit
pygerrit/stream.py
GerritStream.stop
def stop(self): """ Stop the thread. """ self._stop.set() if self._channel is not None: self._channel.close()
python
def stop(self): """ Stop the thread. """ self._stop.set() if self._channel is not None: self._channel.close()
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_stop", ".", "set", "(", ")", "if", "self", ".", "_channel", "is", "not", "None", ":", "self", ".", "_channel", ".", "close", "(", ")" ]
Stop the thread.
[ "Stop", "the", "thread", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/stream.py#L46-L50
train
sonyxperiadev/pygerrit
pygerrit/stream.py
GerritStream.run
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() ...
python
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", ")", ":", "channel", "=", "self", ".", "_ssh_client", ".", "get_transport", "(", ")", ".", "open_session", "(", ")", "self", ".", "_channel", "=", "channel", "channel", ".", "exec_command", "(", "\"gerrit stream-events\"", ")", "...
Listen to the stream and send events to the client.
[ "Listen", "to", "the", "stream", "and", "send", "events", "to", "the", "client", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/stream.py#L56-L77
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.run_command
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...
python
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", ")", ":", "if", "not", "isinstance", "(", "command", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"command must be a string\"", ")", "return", "self", ".", "_ssh_client", ".", "run_gerrit_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.
[ "Run", "a", "command", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L79-L91
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.query
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", "...
python
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", ")", ":", "results", "=", "[", "]", "command", "=", "[", "\"query\"", ",", "\"--current-patch-set\"", ",", "\"--all-approvals\"", ",", "\"--format JSON\"", ",", "\"--commit-message\"", "]", "if", "not", "isinstance", "...
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.
[ "Run", "a", "query", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L93-L129
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.start_event_stream
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()
python
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", ")", ":", "if", "not", "self", ".", "_stream", ":", "self", ".", "_stream", "=", "GerritStream", "(", "self", ",", "ssh_client", "=", "self", ".", "_ssh_client", ")", "self", ".", "_stream", ".", "start", "(", ...
Start streaming events from `gerrit stream-events`.
[ "Start", "streaming", "events", "from", "gerrit", "stream", "-", "events", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L131-L135
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.stop_event_stream
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()
python
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", ")", ":", "if", "self", ".", "_stream", ":", "self", ".", "_stream", ".", "stop", "(", ")", "self", ".", "_stream", ".", "join", "(", ")", "self", ".", "_stream", "=", "None", "with", "self", ".", "_events", ...
Stop streaming events from `gerrit stream-events`.
[ "Stop", "streaming", "events", "from", "gerrit", "stream", "-", "events", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L137-L144
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.get_event
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` ...
python
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", ")", ":", "try", ":", "return", "self", ".", "_events", ".", "get", "(", "block", ",", "timeout", ")", "except", "Empty", ":", "return", "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` instance, or `None` if: - `block` is...
[ "Get", "the", "next", "event", "from", "the", "queue", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L146-L162
train
sonyxperiadev/pygerrit
pygerrit/client.py
GerritClient.put_event
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: ...
python
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", ")", ":", "try", ":", "event", "=", "self", ".", "_factory", ".", "create", "(", "data", ")", "self", ".", "_events", ".", "put", "(", "event", ")", "except", "Full", ":", "raise", "GerritError", "(", "...
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.
[ "Create", "event", "from", "data", "and", "add", "it", "to", "the", "queue", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/client.py#L164-L177
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
_extract_version
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...
python
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", ")", ":", "if", "version_string", ":", "match", "=", "pattern", ".", "match", "(", "version_string", ".", "strip", "(", ")", ")", "if", "match", ":", "return", "match", ".", "group", "(", ...
Extract the version from `version_string` using `pattern`. Return the version as a string, with leading/trailing whitespace stripped.
[ "Extract", "the", "version", "from", "version_string", "using", "pattern", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L36-L47
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._configure
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() ...
python
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", ")", ":", "configfile", "=", "expanduser", "(", "\"~/.ssh/config\"", ")", "if", "not", "isfile", "(", "configfile", ")", ":", "raise", "GerritError", "(", "\"ssh config file '%s' does not exist\"", "%", "configfile", ")", "config"...
Configure the ssh parameters from the config file.
[ "Configure", "the", "ssh", "parameters", "from", "the", "config", "file", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L84-L111
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._do_connect
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...
python
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", ")", ":", "self", ".", "load_system_host_keys", "(", ")", "if", "self", ".", "username", "is", "None", "or", "self", ".", "port", "is", "None", ":", "self", ".", "_configure", "(", ")", "try", ":", "self", ".", "con...
Connect to the remote.
[ "Connect", "to", "the", "remote", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L113-L132
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient._connect
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...
python
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", ")", ":", "if", "not", "self", ".", "connected", ".", "is_set", "(", ")", ":", "try", ":", "self", ".", "lock", ".", "acquire", "(", ")", "# Another thread may have connected while we were", "# waiting to acquire the lock", "if", ...
Connect to the remote if not already connected.
[ "Connect", "to", "the", "remote", "if", "not", "already", "connected", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L134-L149
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient.get_remote_version
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...
python
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", ")", ":", "if", "self", ".", "remote_version", "is", "None", ":", "result", "=", "self", ".", "run_gerrit_command", "(", "\"version\"", ")", "version_string", "=", "result", ".", "stdout", ".", "read", "(", ")", "p...
Return the version of the remote Gerrit server.
[ "Return", "the", "version", "of", "the", "remote", "Gerrit", "server", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L151-L158
train
sonyxperiadev/pygerrit
pygerrit/ssh.py
GerritSSHClient.run_gerrit_command
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. ...
python
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", ")", ":", "if", "not", "isinstance", "(", "command", ",", "basestring", ")", ":", "raise", "ValueError", "(", "\"command must be a string\"", ")", "gerrit_command", "=", "\"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.
[ "Run", "the", "given", "command", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/ssh.py#L165-L194
train
sonyxperiadev/pygerrit
pygerrit/events.py
GerritEventFactory.register
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...
python
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", ")", ":", "def", "decorate", "(", "klazz", ")", ":", "\"\"\" Decorator. \"\"\"", "if", "name", "in", "cls", ".", "_events", ":", "raise", "GerritError", "(", "\"Duplicate event: %s\"", "%", "name", ")", "cls", "....
Decorator to register the event identified by `name`. Return the decorated class. Raise GerritError if the event is already registered.
[ "Decorator", "to", "register", "the", "event", "identified", "by", "name", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L40-L56
train
sonyxperiadev/pygerrit
pygerrit/events.py
GerritEventFactory.create
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...
python
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", ")", ":", "try", ":", "json_data", "=", "json", ".", "loads", "(", "data", ")", "except", "ValueError", "as", "err", ":", "logging", ".", "debug", "(", "\"Failed to load json data: %s: [%s]\"", ",", "str", "(", "...
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.
[ "Create", "a", "new", "event", "instance", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/events.py#L59-L85
train
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
_decode_response
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...
python
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", ")", ":", "content", "=", "response", ".", "content", ".", "strip", "(", ")", "logging", ".", "debug", "(", "content", "[", ":", "512", "]", ")", "response", ".", "raise_for_status", "(", ")", "if", "content", ...
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.
[ "Strip", "off", "Gerrit", "s", "magic", "prefix", "and", "decode", "a", "response", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L33-L53
train
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.put
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...
python
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", ")", ":", "kwargs", ".", "update", "(", "self", ".", "kwargs", ".", "copy", "(", ")", ")", "if", "\"data\"", "in", "kwargs", ":", "kwargs", "[", "\"headers\"", "]", ".", "update",...
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.
[ "Send", "HTTP", "PUT", "to", "the", "endpoint", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L121-L138
train
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.delete
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...
python
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", ")", ":", "kwargs", ".", "update", "(", "self", ".", "kwargs", ".", "copy", "(", ")", ")", "response", "=", "requests", ".", "delete", "(", "self", ".", "make_url", "(", "endpo...
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.
[ "Send", "HTTP", "DELETE", "to", "the", "endpoint", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L159-L173
train
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritRestAPI.review
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...
python
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", ")", ":", "endpoint", "=", "\"changes/%s/revisions/%s/review\"", "%", "(", "change_id", ",", "revision", ")", "self", ".", "post", "(", "endpoint", ",", "data", "=", "str", "("...
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.
[ "Submit", "a", "review", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L175-L191
train
sonyxperiadev/pygerrit
pygerrit/rest/__init__.py
GerritReview.add_comments
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': '...
python
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", ")", ":", "for", "comment", "in", "comments", ":", "if", "'filename'", "and", "'message'", "in", "comment", ".", "keys", "(", ")", ":", "msg", "=", "{", "}", "if", "'range'", "in", "comment", ".", ...
Add inline comments. :arg dict comments: Comments to add. Usage:: add_comments([{'filename': 'Makefile', 'line': 10, 'message': 'inline message'}]) add_comments([{'filename': 'Makefile', 'range':...
[ "Add", "inline", "comments", "." ]
756300120b0f4f4af19e0f985566d82bc80b4359
https://github.com/sonyxperiadev/pygerrit/blob/756300120b0f4f4af19e0f985566d82bc80b4359/pygerrit/rest/__init__.py#L241-L278
train
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBProtocol.connection_made
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: {})' ...
python
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", ")", ":", "self", ".", "_connected", "=", "True", "self", ".", "transport", "=", "transport", "self", ".", "remote_ip", ",", "self", ".", "port", "=", "transport", ".", "get_extra_info", "(", "'peern...
override asyncio.Protocol
[ "override", "asyncio", ".", "Protocol" ]
dff33c183899c3ee21c3eab6b90cf4668afef1b0
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L85-L106
train
SiriDB/siridb-connector
siridb/connector/lib/protocol.py
_SiriDBProtocol.connection_lost
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...
python
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", ")", ":", "self", ".", "_connected", "=", "False", "logging", ".", "debug", "(", "'Connection lost (address: {} port: {})'", ".", "format", "(", "self", ".", "remote_ip", ",", "self", ".", "port", ")", ")", ...
override asyncio.Protocol
[ "override", "asyncio", ".", "Protocol" ]
dff33c183899c3ee21c3eab6b90cf4668afef1b0
https://github.com/SiriDB/siridb-connector/blob/dff33c183899c3ee21c3eab6b90cf4668afef1b0/siridb/connector/lib/protocol.py#L108-L126
train