maybe fixed ssh connection

This commit is contained in:
phixxy 2024-04-17 11:56:31 -07:00
parent 55c81f47fb
commit 9a9a74f19f

View file

@ -37,14 +37,15 @@ class WakeOnLan(commands.Cog):
async def sleep(self, ctx, amount=5): async def sleep(self, ctx, amount=5):
if ctx.author.id == self.admin_id: if ctx.author.id == self.admin_id:
#use ssh to login and shutdown #use ssh to login and shutdown
ssh_client = asyncssh.connect( async with asyncssh.connect(
self.stable_diffusion_ip, self.stable_diffusion_ip,
username=self.stable_diffusion_login, username=self.stable_diffusion_login,
password=self.stable_diffusion_password, password=self.stable_diffusion_password,
timeout=10, timeout=10,
) ) as ssh_client:
try: try:
await ssh_client.run("shutdown /s") result = await ssh_client.run("shutdown /s")
await ctx.send(result.stdout)
#await ssh_client.run("sudo shutdown -h now") #await ssh_client.run("sudo shutdown -h now")
except: except:
self.logger.exception("WakeOnLan: Sleeping failed") self.logger.exception("WakeOnLan: Sleeping failed")