import asyncio
import asyncssh

from pyplus.collection import qdict
from jsshd.command import run_command


class SSHServerSession(asyncssh.SSHServerSession):
    def __init__(self, server):
        self.__user_server = server

    def connection_made(self, chan):
        self._chan = chan

    def shell_requested(self): return False

    def exec_requested(self, command):
        async def run_callback(command):
            try:
                env = qdict(channel=self._chan)
                result = await run_command(command, env)
                if isinstance(result, BaseException):
                    self._chan.write(str(result) + '\n')
                    self._chan._report_response(False)
                else:
                    self._chan.write(result + '\n')
                    self._chan._report_response(True)
                self._chan.exit(0)
            except:
                pass

        # parse and check command
        asyncio.get_event_loop().create_task(run_callback(command))

        return None



1c9b3eab5e21101382a836807cd2d5cff1fb2bc6
<mask token>


class SSHServerSession(asyncssh.SSHServerSession):
    <mask token>
    <mask token>
    <mask token>
    <mask token>

<mask token>


class SSHServerSession(asyncssh.SSHServerSession):

    def __init__(self, server):
        self.__user_server = server
    <mask token>
    <mask token>

    def exec_requested(self, command):

        async def run_callback(command):
            try:
                env = qdict(channel=self._chan)
                result = await run_command(command, env)
                if isinstance(result, BaseException):
                    self._chan.write(str(result) + '\n')
                    self._chan._report_response(False)
                else:
                    self._chan.write(result + '\n')
                    self._chan._report_response(True)
                self._chan.exit(0)
            except:
                pass
        asyncio.get_event_loop().create_task(run_callback(command))
        return None

<mask token>


class SSHServerSession(asyncssh.SSHServerSession):

    def __init__(self, server):
        self.__user_server = server

    def connection_made(self, chan):
        self._chan = chan

    def shell_requested(self):
        return False

    def exec_requested(self, command):

        async def run_callback(command):
            try:
                env = qdict(channel=self._chan)
                result = await run_command(command, env)
                if isinstance(result, BaseException):
                    self._chan.write(str(result) + '\n')
                    self._chan._report_response(False)
                else:
                    self._chan.write(result + '\n')
                    self._chan._report_response(True)
                self._chan.exit(0)
            except:
                pass
        asyncio.get_event_loop().create_task(run_callback(command))
        return None

import asyncio
import asyncssh
from pyplus.collection import qdict
from jsshd.command import run_command


class SSHServerSession(asyncssh.SSHServerSession):

    def __init__(self, server):
        self.__user_server = server

    def connection_made(self, chan):
        self._chan = chan

    def shell_requested(self):
        return False

    def exec_requested(self, command):

        async def run_callback(command):
            try:
                env = qdict(channel=self._chan)
                result = await run_command(command, env)
                if isinstance(result, BaseException):
                    self._chan.write(str(result) + '\n')
                    self._chan._report_response(False)
                else:
                    self._chan.write(result + '\n')
                    self._chan._report_response(True)
                self._chan.exit(0)
            except:
                pass
        asyncio.get_event_loop().create_task(run_callback(command))
        return None

import asyncio
import asyncssh

from pyplus.collection import qdict
from jsshd.command import run_command


class SSHServerSession(asyncssh.SSHServerSession):
    def __init__(self, server):
        self.__user_server = server

    def connection_made(self, chan):
        self._chan = chan

    def shell_requested(self): return False

    def exec_requested(self, command):
        async def run_callback(command):
            try:
                env = qdict(channel=self._chan)
                result = await run_command(command, env)
                if isinstance(result, BaseException):
                    self._chan.write(str(result) + '\n')
                    self._chan._report_response(False)
                else:
                    self._chan.write(result + '\n')
                    self._chan._report_response(True)
                self._chan.exit(0)
            except:
                pass

        # parse and check command
        asyncio.get_event_loop().create_task(run_callback(command))

        return None


