Skip to content

Instantly share code, notes, and snippets.

View gs-niteesh's full-sized avatar

Niteesh Babu G S gs-niteesh

  • India, Tamil Nadu
View GitHub Profile
@gs-niteesh
gs-niteesh / tui.py
Created July 13, 2021 15:33
incomplete tui file
# Copyright (c) 2021
#
# Authors:
# Niteesh Babu G S <niteesh.gs@gmail.com>
#
# This work is licensed under the terms of the GNU GPL, version 2 or
# later. See the COPYING file in the top-level directory.
import argparse
import asyncio
"""
Simple visitor
"""
import sys
import pprint
from .schema import QAPISchema, QAPISchemaVisitor
class Dict(dict):
def __add__(self, rhs):
@gs-niteesh
gs-niteesh / qmp_show_doc.py
Created June 28, 2021 17:17
qmp_show_doc.py
"""
Simple visitor
"""
import sys
from .schema import QAPISchema, QAPISchemaVisitor
class SimpleVisitor(QAPISchemaVisitor):
"""
Proposal for a minimum draft prototype:
- Uses Async QMP library
- Accepts a server destination on the command-line like the existing qmp-shell
- Probably use the argparse library for this.
- Connects to that server on startup.
- Uses a two-panel urwid TUI
- Text entry area:
- User can type a command
@gs-niteesh
gs-niteesh / autocomplete.py
Created June 9, 2021 19:46
aqmp_autocomplete_prototype.py
import urwid
import complete
from blinker import Signal
import logging
logging.basicConfig(filename='log.txt', level=logging.INFO)
start_suggestion = Signal()
select_suggestion = Signal()
reset_suggestion = Signal()
@gs-niteesh
gs-niteesh / gist:38e430ec4e77d46ae211fac61d9715cc
Created June 3, 2021 17:19
QMP_SHELL _do_recv backtrace on returning Message('') on excpetion
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:aqmp.qmp_protocol:Connecting ...
DEBUG:asyncio:Get address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1> took 1.471ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 1234))]
DEBUG:asyncio:<asyncio.TransportSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 38718), raddr=('127.0.0.1', 1234)> connected to localhost:1234: (<_SelectorSocketTransport fd=9 read=polling write=<idle, bufsize=0>>, <asyncio.streams.StreamReaderProtocol object at 0x7f61e67ad910>)
DEBUG:aqmp.qmp_protocol:Connected
DEBUG:aqmp.qmp_protocol:Awaiting greeting ...
DEBUG:aqmp.qmp_protocol:<-- {
"QMP": {
"version": {
@gs-niteesh
gs-niteesh / gist:1942174491750736ac9ac80f1b53d27c
Created June 3, 2021 17:18
QMP_SHELL on_recv return none on exception
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:aqmp.qmp_protocol:Connecting ...
DEBUG:asyncio:Get address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1> took 1.495ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 1234))]
DEBUG:asyncio:<asyncio.TransportSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 37744), raddr=('127.0.0.1', 1234)> connected to localhost:1234: (<_SelectorSocketTransport fd=9 read=polling write=<idle, bufsize=0>>, <asyncio.streams.StreamReaderProtocol object at 0x7fe7b3aaa910>)
DEBUG:aqmp.qmp_protocol:Connected
DEBUG:aqmp.qmp_protocol:Awaiting greeting ...
DEBUG:aqmp.qmp_protocol:<-- {
"QMP": {
"version": {
@gs-niteesh
gs-niteesh / gist:1a71533bdf578287145dabd254777b5f
Created June 3, 2021 16:17
QMP_SHELL Prototype V1 - EOF backtrace
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:aqmp.qmp_protocol:Connecting ...
DEBUG:asyncio:Get address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1>
DEBUG:asyncio:Getting address info localhost:1234, type=<SocketKind.SOCK_STREAM: 1> took 1.413ms: [(<AddressFamily.AF_INET: 2>, <SocketKind.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 1234))]
DEBUG:asyncio:<asyncio.TransportSocket fd=9, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('127.0.0.1', 35554), raddr=('127.0.0.1', 1234)> connected to localhost:1234: (<_SelectorSocketTransport fd=9 read=polling write=<idle, bufsize=0>>, <asyncio.streams.StreamReaderProtocol object at 0x7f5eb0f648e0>)
DEBUG:aqmp.qmp_protocol:Connected
DEBUG:aqmp.qmp_protocol:Awaiting greeting ...
DEBUG:aqmp.qmp_protocol:<-- {
"QMP": {
"version": {
import requests
import sys
from threading import Thread
import queue
import logging
logging.basicConfig(level=logging.INFO)
logging = logging.getLogger(__name__)
class Worker(Thread):
import asyncio
import logging
import sys
logging.basicConfig(level=logging.DEBUG)
log = logging.getLogger('server')
class Session:
def __init__(self, name, reader, writer):
self._name = name