Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 compatible print commands #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions MockSSH.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def exit(self):
self.protocol.cmdstack[-1].resume()

def ctrl_c(self):
print 'Received CTRL-C, exiting..'
print('Received CTRL-C, exiting..')
self.writeln('^C')
self.exit()

def lineReceived(self, line):
print 'INPUT: %s' % line
print('INPUT:', line)

def resume(self):
pass
Expand Down Expand Up @@ -142,7 +142,7 @@ def __init__(self, protocol, prompt):
self.cmdpending = []

def lineReceived(self, line):
print 'CMD: %s' % line
print('CMD:', line)
for i in [x.strip() for x in line.strip().split(';')]:
if not len(i):
continue
Expand Down Expand Up @@ -192,10 +192,10 @@ def runOrPrompt():

cmdclass = self.protocol.getCommand(cmd)
if cmdclass:
print 'Command found: %s' % (line,)
print('Command found:', line)
self.protocol.call_command(cmdclass, *rargs)
else:
print 'Command not found: %s' % (line,)
print('Command not found:', line)
if len(line):
self.protocol.writeln('MockSSH: %s: command not found' % cmd)
runOrPrompt()
Expand Down Expand Up @@ -346,10 +346,10 @@ class SSHTransport(transport.SSHServerTransport):
hadVersion = False

def connectionMade(self):
print 'New connection: %s:%s (%s:%s) [session: %d]' % \
print('New connection: %s:%s (%s:%s) [session: %d]' % \
(self.transport.getPeer().host, self.transport.getPeer().port,
self.transport.getHost().host, self.transport.getHost().port,
self.transport.sessionno)
self.transport.sessionno))
self.interactors = []
self.ttylog_open = False
transport.SSHServerTransport.connectionMade(self)
Expand All @@ -364,7 +364,7 @@ def dataReceived(self, data):
transport.SSHServerTransport.dataReceived(self, data)

def ssh_KEXINIT(self, packet):
print 'Remote SSH version: %s' % (self.otherVersionString,)
print('Remote SSH version:', self.otherVersionString)
return transport.SSHServerTransport.ssh_KEXINIT(self, packet)

# this seems to be the only reliable place of catching lost connection
Expand Down Expand Up @@ -414,7 +414,7 @@ def call(self):
# Functions
def getRSAKeys(keypath="."):
if not os.path.exists(keypath):
print "Could not find specified keypath (%s)" % keypath
print("Could not find specified keypath:", keypath)
sys.exit(1)

pubkey = os.path.join(keypath, "public.key")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_mock_F5.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
print "tearDownClass"
print("tearDownClass")
MockSSH.stopThreadedServer()
shutil.rmtree(cls.keypath)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_mock_cisco.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setUpClass(cls):

@classmethod
def tearDownClass(cls):
print "tearDownClass"
print("tearDownClass")
MockSSH.stopThreadedServer()
shutil.rmtree(cls.keypath)

Expand Down