Changes based on style and lint checks. (final_code_quality_2) #1357

Merged
coffeedogs merged 1 commits from final_code_quality_2 into v0.6 2018-10-31 18:09:58 +01:00
coffeedogs commented 2018-10-04 16:25:43 +02:00 (Migrated from github.com)

Changes based on style and lint checks. (final_code_quality_2)

Changes based on style and lint checks. (final_code_quality_2)
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:23:11 +02:00
@ -3,3 +8,4 @@
from PyQt4 import QtCore, QtGui
class SettingsMixin(object):
PeterSurda (Migrated from github.com) commented 2018-10-10 13:23:11 +02:00

Mixin for adding geometry and state saving between restarts.

Mixin for adding geometry and state saving between restarts.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:24:04 +02:00
@ -5,2 +10,4 @@
class SettingsMixin(object):
"""Mixin for adding geometry and state saving between restarts."""
def warnIfNoObjectName(self):
PeterSurda (Migrated from github.com) commented 2018-10-10 13:24:04 +02:00

Handle objects which don't have a name. Currently it ignores them. Objects without a name can't have their state/geometry saved as they don't have an identifier.

Handle objects which don't have a name. Currently it ignores them. Objects without a name can't have their state/geometry saved as they don't have an identifier.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:25:23 +02:00
@ -11,2 +21,4 @@
def writeState(self, source):
"""Save object state (e.g. relative position of a splitter)"""
self.warnIfNoObjectName()
PeterSurda (Migrated from github.com) commented 2018-10-10 13:25:23 +02:00

Save object state (e.g. relative position of a splitter)

Save object state (e.g. relative position of a splitter)
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:25:48 +02:00
@ -18,3 +30,4 @@
def writeGeometry(self, source):
"""Save object geometry (e.g. window size and position)"""
self.warnIfNoObjectName()
settings = QtCore.QSettings()
PeterSurda (Migrated from github.com) commented 2018-10-10 13:25:48 +02:00

Save object geometry (e.g. window size and position)

Save object geometry (e.g. window size and position)
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:26:09 +02:00
@ -26,3 +39,4 @@
"""Load object geometry"""
self.warnIfNoObjectName()
settings = QtCore.QSettings()
try:
PeterSurda (Migrated from github.com) commented 2018-10-10 13:26:09 +02:00

Load object geometry

Load object geometry
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:26:22 +02:00
@ -35,4 +50,4 @@
self.warnIfNoObjectName()
settings = QtCore.QSettings()
try:
state = settings.value("/".join([str(self.objectName()), "state"]))
PeterSurda (Migrated from github.com) commented 2018-10-10 13:26:22 +02:00

Load object state

Load object state
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:26:47 +02:00
@ -47,3 +64,3 @@
self.readState(self)
def saveSettings(self):
PeterSurda (Migrated from github.com) commented 2018-10-10 13:26:46 +02:00

Main window with Settings functionality.

Main window with Settings functionality.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:27:38 +02:00
@ -49,2 +65,4 @@
def saveSettings(self):
"""Save main window settings"""
self.writeState(self)
PeterSurda (Migrated from github.com) commented 2018-10-10 13:27:37 +02:00

Load main window settings.

Load main window settings.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:27:49 +02:00
@ -53,2 +71,4 @@
class STableWidget(QtGui.QTableWidget, SettingsMixin):
"""Table widget with Settings functionality"""
# pylint: disable=too-many-ancestors
PeterSurda (Migrated from github.com) commented 2018-10-10 13:27:48 +02:00

Save main window settings

Save main window settings
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:28:12 +02:00
@ -56,3 +77,4 @@
self.readState(self.horizontalHeader())
def saveSettings(self):
"""Save table settings."""
PeterSurda (Migrated from github.com) commented 2018-10-10 13:28:11 +02:00

Table widget with Settings functionality

Table widget with Settings functionality
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:28:25 +02:00
@ -59,3 +81,3 @@
self.writeState(self.horizontalHeader())
PeterSurda (Migrated from github.com) commented 2018-10-10 13:28:25 +02:00

Load table settings.

Load table settings.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:28:38 +02:00
@ -62,2 +84,4 @@
class SSplitter(QtGui.QSplitter, SettingsMixin):
"""Splitter with Settings functionality."""
def loadSettings(self):
"""Load splitter settings"""
PeterSurda (Migrated from github.com) commented 2018-10-10 13:28:38 +02:00

Save table settings.

Save table settings.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:28:53 +02:00
@ -67,2 +91,3 @@
"""Save splitter settings."""
self.writeState(self)
PeterSurda (Migrated from github.com) commented 2018-10-10 13:28:53 +02:00

Splitter with Settings functionality.

Splitter with Settings functionality.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:29:04 +02:00
@ -68,3 +93,3 @@
class STreeWidget(QtGui.QTreeWidget, SettingsMixin):
PeterSurda (Migrated from github.com) commented 2018-10-10 13:29:04 +02:00

Load splitter settings

Load splitter settings
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:29:15 +02:00
@ -71,3 +98,2 @@
def loadSettings(self):
#recurse children
#self.readState(self)
"""Load tree settings."""
PeterSurda (Migrated from github.com) commented 2018-10-10 13:29:15 +02:00

Save splitter settings.

Save splitter settings.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:29:31 +02:00
@ -76,3 +104,2 @@
def saveSettings(self):
#recurse children
#self.writeState(self)
"""Save tree settings"""
PeterSurda (Migrated from github.com) commented 2018-10-10 13:29:31 +02:00

Tree widget with settings functionality.

Tree widget with settings functionality.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:29:42 +02:00
@ -79,1 +105,4 @@
"""Save tree settings"""
# recurse children
# self.writeState(self)
pass
PeterSurda (Migrated from github.com) commented 2018-10-10 13:29:42 +02:00

Load tree settings.

Load tree settings.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:29:52 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:29:52 +02:00

Save tree settings

Save tree settings
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:30:30 +02:00
@ -5,2 +12,4 @@
class Socks5AuthError(ProxyError):
"""Thrown when the socks5 protocol encounters an authentication error"""
PeterSurda (Migrated from github.com) commented 2018-10-10 13:30:30 +02:00

Thrown when the socks5 protocol encounters an authentication error

Thrown when the socks5 protocol encounters an authentication error
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:30:51 +02:00
@ -24,1 +26,3 @@
"Unknown error")
"General SOCKS server failure",
"Connection not allowed by ruleset",
"Network unreachable",
PeterSurda (Migrated from github.com) commented 2018-10-10 13:30:51 +02:00

Thrown when socks5 protocol encounters an error

Thrown when socks5 protocol encounters an error
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:31:12 +02:00
@ -42,3 +54,4 @@
"""Perform authentication if peer is requesting it."""
ret = struct.unpack('BB', self.read_buf[:2])
if ret[0] != 5:
# general error
PeterSurda (Migrated from github.com) commented 2018-10-10 13:31:12 +02:00

Protocol initialisation (before connection is established)

Protocol initialisation (before connection is established)
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:32:23 +02:00
@ -98,3 +113,4 @@
def state_proxy_addr_1(self):
"""Handle IPv4 address returned for peer"""
self.boundaddr = self.read_buf[0:4]
self.set_state("proxy_port", length=4, expectBytes=2)
PeterSurda (Migrated from github.com) commented 2018-10-10 13:32:22 +02:00

Perform authentication if peer is requesting it.

Perform authentication if peer is requesting it.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:33:51 +02:00
@ -131,3 +158,4 @@
def state_auth_done(self):
"""Request connection to be made"""
# Now we can request the actual connection
self.append_write_buf(struct.pack('BBB', 0x05, 0x01, 0x00))
PeterSurda (Migrated from github.com) commented 2018-10-10 13:33:50 +02:00

Handle response to authentication attempt

Handle response to authentication attempt
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:34:19 +02:00
@ -151,6 +181,7 @@ class Socks5Connection(Socks5):
return True
PeterSurda (Migrated from github.com) commented 2018-10-10 13:34:19 +02:00

Handle feedback from socks5 while it is connecting on our behalf.

Handle feedback from socks5 while it is connecting on our behalf.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:36:41 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:36:41 +02:00

Handle IPv4 address returned for peer

Handle IPv4 address returned for peer
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:37:27 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:37:27 +02:00

Handle other addresses than IPv4 returned for peer (e.g. IPv6, onion, ...). This is part 1 which retrieves the length of the data.

Handle other addresses than IPv4 returned for peer (e.g. IPv6, onion, ...). This is part 1 which retrieves the length of the data.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:37:42 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:37:42 +02:00

Handle other addresses than IPv4 returned for peer (e.g. IPv6, onion, ...). This is part 2 which retrieves the data.

Handle other addresses than IPv4 returned for peer (e.g. IPv6, onion, ...). This is part 2 which retrieves the data.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:37:57 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:37:57 +02:00

Handle peer's port being returned.

Handle peer's port being returned.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:38:34 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:38:34 +02:00

Handle eturn value when using SOCKS5 for DNS resolving instead of connecting.

Handle eturn value when using SOCKS5 for DNS resolving instead of connecting.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:39:37 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:39:37 +02:00

Child socks5 class used for making outbound connections.

Child socks5 class used for making outbound connections.
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:40:04 +02:00
@ -112,3 +136,4 @@
def state_proxy_port(self):
"""Handle peer's port being returned."""
self.boundport = struct.unpack(">H", self.read_buf[0:2])[0]
PeterSurda (Migrated from github.com) commented 2018-10-10 13:40:03 +02:00

Init

Init
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:40:20 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:40:20 +02:00

Request connection to be made

Request connection to be made
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:41:31 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:41:30 +02:00

Tell socks5 to initiate a connection

Tell socks5 to initiate a connection
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:41:41 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:41:41 +02:00

DNS resolver class using socks5

DNS resolver class using socks5
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:41:51 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:41:50 +02:00

Init

Init
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:42:05 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:42:05 +02:00

Perform resolving

Perform resolving
PeterSurda (Migrated from github.com) reviewed 2018-10-10 13:43:25 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-10 13:43:25 +02:00

Resolving is done, process the return value. To use this within PyBitmessage, a callback needs to be implemented which hasn't been done yet.

Resolving is done, process the return value. To use this within PyBitmessage, a callback needs to be implemented which hasn't been done yet.
PeterSurda (Migrated from github.com) requested changes 2018-10-10 13:44:51 +02:00
PeterSurda (Migrated from github.com) left a comment

Add docstrings, otherwise OK, however I would also test it against a SOCKS5 server (e.g. the one used by tor) to make sure nothing breaks

Add docstrings, otherwise OK, however I would also test it against a SOCKS5 server (e.g. the one used by tor) to make sure nothing breaks
PeterSurda (Migrated from github.com) reviewed 2018-10-27 13:16:06 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-27 13:16:05 +02:00

typo

typo
PeterSurda (Migrated from github.com) reviewed 2018-10-27 13:17:00 +02:00
PeterSurda (Migrated from github.com) commented 2018-10-27 13:17:00 +02:00

typo

typo
PeterSurda (Migrated from github.com) approved these changes 2018-10-27 13:17:50 +02:00
PeterSurda (Migrated from github.com) left a comment

I found two typos in docstrings which can be ignored.

I found two typos in docstrings which can be ignored.
coffeedogs (Migrated from github.com) reviewed 2018-10-31 13:55:19 +01:00
@ -112,3 +136,4 @@
def state_proxy_port(self):
"""Handle peer's port being returned."""
self.boundport = struct.unpack(">H", self.read_buf[0:2])[0]
coffeedogs (Migrated from github.com) commented 2018-10-31 13:55:18 +01:00

Went for """Child socks5 class used for making outbound connections.""", assuming you were thinking about commenting the __init__ method with your comment

Went for """Child socks5 class used for making outbound connections.""", assuming you were thinking about commenting the `__init__` method with your comment
This repo is archived. You cannot comment on pull requests.
No description provided.