Skip to content
Snippets Groups Projects
Commit e0c5ddff authored by Brandon Wiley's avatar Brandon Wiley
Browse files

Reformatted according to PEP 8 guidelines

parent 51866990
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyptlib.easy.client import init, reportSucess, reportFailure, reportEnd
from pyptlib.easy.client import init, reportSucess, reportFailure, \
reportEnd
class TransportLaunchException(Exception):
pass
pass
def launchClient(self, name, port):
if name != 'dummy':
raise TransportLaunchException('Tried to launch unsupported transport %s'
% name)
if __name__ == '__main__':
supportedTransports = ['dummy', 'rot13']
matchedTransports=init(supportedTransports)
matchedTransports = init(supportedTransports)
for transport in matchedTransports:
try:
launchClient(transport, 8182)
reportSuccess(transport, 5, ('127.0.0.1', 8182), None, None)
except TransportLaunchException:
reportFailure(transport, 'Failed to launch')
try:
launchClient(transport, 8182)
reportSuccess(transport, 5, ('127.0.0.1', 8182), None, None)
except TransportLaunchException:
reportFailure(transport, 'Failed to launch')
reportEnd()
#!/usr/bin/python
# -*- coding: utf-8 -*-
from pyptlib.easy.server import init, reportSucess, reportFailure, reportEnd
from pyptlib.easy.server import init, reportSucess, reportFailure, \
reportEnd
class TransportLaunchException(Exception):
pass
pass
def launchServer(self, name, port):
if name != 'dummy':
raise TransportLaunchException('Tried to launch unsupported transport %s'
% name)
if __name__ == '__main__':
supportedTransports = ['dummy', 'rot13']
matchedTransports=init(supportedTransports)
matchedTransports = init(supportedTransports)
for transport in matchedTransports:
try:
launchServer(transport, 8182)
reportSuccess(transport, ('127.0.0.1', 8182), None)
except TransportLaunchException:
reportFailure(transport, 'Failed to launch')
reportEnd()
\ No newline at end of file
try:
launchServer(transport, 8182)
reportSuccess(transport, ('127.0.0.1', 8182), None)
except TransportLaunchException:
reportFailure(transport, 'Failed to launch')
reportEnd()
......@@ -12,13 +12,14 @@ from socket import inet_ntoa
from pyptlib.config import EnvException
from pyptlib.client import ClientConfig
def init(transports):
supportedTransportVersion = '1'
try:
config = ClientConfig()
config = ClientConfig()
except EnvException:
return []
return []
if config.checkManagedTransportVersion(supportedTransportVersion):
config.writeVersion(supportedTransportVersion)
......@@ -26,19 +27,29 @@ def init(transports):
config.writeVersionError()
return []
matchedTransports=[]
matchedTransports = []
for transport in transports:
if config.checkTransportEnabled(supportedTransport):
matchedTransports.append(transport)
if config.checkTransportEnabled(supportedTransport):
matchedTransports.append(transport)
return matchedTransports
def reportSuccess(name, socksVersion, address, args, optArgs):
def reportSuccess(
name,
socksVersion,
address,
args,
optArgs,
):
config.writeMethod(name, socksVersion, address, args, optArgs)
def reportFailure(name, message):
config.writeMethodError(name, message)
def reportEnd():
config.writeMethodEnd()
......@@ -12,13 +12,14 @@ from socket import inet_ntoa
from pyptlib.config import EnvException
from pyptlib.client import ServerConfig
def init(transports):
supportedTransportVersion = '1'
try:
config = ServerConfig()
config = ServerConfig()
except EnvException:
return []
return []
if config.checkManagedTransportVersion(supportedTransportVersion):
config.writeVersion(supportedTransportVersion)
......@@ -26,19 +27,27 @@ def init(transports):
config.writeVersionError()
return []
matchedTransports=[]
matchedTransports = []
for transport in transports:
if config.checkTransportEnabled(supportedTransport):
matchedTransports.append(transport)
if config.checkTransportEnabled(supportedTransport):
matchedTransports.append(transport)
return matchedTransports
def reportSuccess(name, address, args, options):
def reportSuccess(
name,
address,
args,
options,
):
config.writeMethod(name, address, options)
def reportFailure(name, message):
config.writeMethodError(name, message)
def reportEnd():
config.writeMethodEnd()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment