Skip to content

Commit e41e05c

Browse files
committed
Update examples to python 3.7 and add some other minor improvements
1 parent 17b02ff commit e41e05c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+134
-125
lines changed

examples/callback_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -46,6 +46,6 @@ async def run_client() -> None:
4646
await chan.wait_closed()
4747

4848
try:
49-
asyncio.get_event_loop().run_until_complete(run_client())
49+
asyncio.run(run_client())
5050
except (OSError, asyncssh.Error) as exc:
5151
sys.exit('SSH connection failed: ' + str(exc))

examples/callback_client2.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -37,6 +37,6 @@ async def run_client() -> None:
3737
await chan.wait_closed()
3838

3939
try:
40-
asyncio.get_event_loop().run_until_complete(run_client())
40+
asyncio.run(run_client())
4141
except (OSError, asyncssh.Error) as exc:
4242
sys.exit('SSH connection failed: ' + str(exc))

examples/callback_client3.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -40,6 +40,6 @@ async def run_client() -> None:
4040
await chan.wait_closed()
4141

4242
try:
43-
asyncio.get_event_loop().run_until_complete(run_client())
43+
asyncio.run(run_client())
4444
except (OSError, asyncssh.Error) as exc:
4545
sys.exit('SSH connection failed: ' + str(exc))

examples/callback_math_server.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -64,6 +64,9 @@ def eof_received(self) -> bool:
6464
def break_received(self, msec: int) -> bool:
6565
return self.eof_received()
6666

67+
def soft_eof_received(self) -> None:
68+
self.eof_received()
69+
6770
class MySSHServer(asyncssh.SSHServer):
6871
def session_requested(self) -> asyncssh.SSHServerSession:
6972
return MySSHServerSession()
@@ -73,7 +76,7 @@ async def start_server() -> None:
7376
server_host_keys=['ssh_host_key'],
7477
authorized_client_keys='ssh_user_ca')
7578

76-
loop = asyncio.get_event_loop()
79+
loop = asyncio.new_event_loop()
7780

7881
try:
7982
loop.run_until_complete(start_server())

examples/chat_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2016-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2016-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -76,7 +76,7 @@ async def start_server() -> None:
7676
authorized_client_keys='ssh_user_ca',
7777
process_factory=ChatClient.handle_client)
7878

79-
loop = asyncio.get_event_loop()
79+
loop = asyncio.new_event_loop()
8080

8181
try:
8282
loop.run_until_complete(start_server())

examples/check_exit_status.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -34,6 +34,6 @@ async def run_client() -> None:
3434
file=sys.stderr)
3535

3636
try:
37-
asyncio.get_event_loop().run_until_complete(run_client())
37+
asyncio.run(run_client())
3838
except (OSError, asyncssh.Error) as exc:
3939
sys.exit('SSH connection failed: ' + str(exc))

examples/chroot_sftp_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2016-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2016-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -40,7 +40,7 @@ async def start_server() -> None:
4040
authorized_client_keys='ssh_user_ca',
4141
sftp_factory=MySFTPServer)
4242

43-
loop = asyncio.get_event_loop()
43+
loop = asyncio.new_event_loop()
4444

4545
try:
4646
loop.run_until_complete(start_server())

examples/direct_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -44,6 +44,6 @@ async def run_client() -> None:
4444
await chan.wait_closed()
4545

4646
try:
47-
asyncio.get_event_loop().run_until_complete(run_client())
47+
asyncio.run(run_client())
4848
except (OSError, asyncssh.Error) as exc:
4949
sys.exit('SSH connection failed: ' + str(exc))

examples/direct_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -52,7 +52,7 @@ async def start_server() -> None:
5252
server_host_keys=['ssh_host_key'],
5353
authorized_client_keys='ssh_user_ca')
5454

55-
loop = asyncio.get_event_loop()
55+
loop = asyncio.new_event_loop()
5656

5757
try:
5858
loop.run_until_complete(start_server())

examples/editor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#!/usr/bin/env python3.6
1+
#!/usr/bin/env python3.7
22
#
3-
# Copyright (c) 2013-2021 by Ron Frederick <[email protected]> and others.
3+
# Copyright (c) 2013-2024 by Ron Frederick <[email protected]> and others.
44
#
55
# This program and the accompanying materials are made available under
66
# the terms of the Eclipse Public License v2.0 which accompanies this
@@ -53,7 +53,7 @@ async def start_server() -> None:
5353
authorized_client_keys='ssh_user_ca',
5454
process_factory=handle_client)
5555

56-
loop = asyncio.get_event_loop()
56+
loop = asyncio.new_event_loop()
5757

5858
try:
5959
loop.run_until_complete(start_server())

0 commit comments

Comments
 (0)