mirror of
https://github.com/rbreaves/kinto.git
synced 2025-08-02 09:06:40 +02:00
- Removed unneeded files
This commit is contained in:
@@ -1,53 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
import gi
|
||||
# import textwrap
|
||||
gi.require_version('Gtk', '3.0')
|
||||
|
||||
from gi.repository import Gtk
|
||||
from gi.repository import GObject
|
||||
|
||||
import os
|
||||
from subprocess import Popen, PIPE
|
||||
import fcntl
|
||||
|
||||
wnd = Gtk.Window()
|
||||
wnd.set_default_size(400, 400)
|
||||
wnd.connect("destroy", Gtk.main_quit)
|
||||
sw = Gtk.ScrolledWindow()
|
||||
label = Gtk.Label()
|
||||
label.set_alignment(0, 0)
|
||||
label.set_selectable(True)
|
||||
label.set_line_wrap(True)
|
||||
label.set_max_width_chars(150)
|
||||
sw.add_with_viewport(label)
|
||||
wnd.add(sw)
|
||||
wnd.show_all()
|
||||
sub_proc = Popen("journalctl -f --unit=xkeysnail.service -b", stdout=PIPE, shell=True)
|
||||
# sub_proc2 = Popen('fold', stdin=sub_proc.stdout, stdout=PIPE)
|
||||
# sub_proc2.communicate()
|
||||
sub_outp = ""
|
||||
|
||||
|
||||
def non_block_read(output):
|
||||
''' even in a thread, a normal read with block until the buffer is full '''
|
||||
fd = output.fileno()
|
||||
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
|
||||
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
|
||||
op = output.read()
|
||||
if op == None:
|
||||
return ''
|
||||
return op.decode('utf-8')
|
||||
|
||||
# def wrap(s, w):
|
||||
# return textwrap.fill(s, w)
|
||||
# def wrap(s, w):
|
||||
# return [s[i:i + w] for i in range(0, len(s), w)]
|
||||
|
||||
def update_terminal():
|
||||
# wrapper = textwrap.TextWrapper(width=50)
|
||||
# word_list = wrapper.wrap(text=sub_proc.stdout)
|
||||
label.set_text(label.get_text() + non_block_read(sub_proc.stdout))
|
||||
return sub_proc.poll() is None
|
||||
|
||||
GObject.timeout_add(100, update_terminal)
|
||||
Gtk.main()
|
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from gi.repository import Gtk,GObject, Vte
|
||||
from gi.repository import GLib
|
||||
import os
|
||||
|
||||
class TheWindow(Gtk.Window):
|
||||
|
||||
def __init__(self):
|
||||
Gtk.Window.__init__(self, title="inherited cell renderer")
|
||||
self.set_default_size(600, 300)
|
||||
global terminal
|
||||
terminal = Vte.Terminal()
|
||||
terminal.spawn_sync(
|
||||
Vte.PtyFlags.DEFAULT,
|
||||
os.environ['HOME'],
|
||||
["/bin/bash"],
|
||||
[],
|
||||
GLib.SpawnFlags.DO_NOT_REAP_CHILD,
|
||||
None,
|
||||
None,
|
||||
)
|
||||
|
||||
self.button = Gtk.Button("Do The Command")
|
||||
self.button2 = Gtk.Button("End Command")
|
||||
self.command = "journalctl -f --unit=xkeysnail.service -b\n"
|
||||
self.command2 = "send \003; echo 'hello'\n"
|
||||
# expect -c "send \003;"
|
||||
self.cmdbytes = str.encode(self.command)
|
||||
self.cmdbytes2 = str.encode(self.command2)
|
||||
command = Gtk.Label("The command: "+self.command)
|
||||
self.button.connect("clicked", self.InputToTerm, self.cmdbytes)
|
||||
self.button2.connect("clicked", self.InputToTerm, self.cmdbytes2)
|
||||
|
||||
box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
|
||||
box.pack_start(self.button, False, True, 0)
|
||||
box.pack_start(self.button2, False, True, 0)
|
||||
box.pack_start(command, False, True, 1)
|
||||
scroller = Gtk.ScrolledWindow()
|
||||
scroller.set_hexpand(True)
|
||||
scroller.set_vexpand(True)
|
||||
scroller.add(terminal)
|
||||
box.pack_start(scroller, False, True, 2)
|
||||
self.add(box)
|
||||
|
||||
def InputToTerm(self, clicker, cmd):
|
||||
terminal.feed_child_binary(cmd)
|
||||
print(Vte.get_minor_version())
|
||||
|
||||
|
||||
win = TheWindow()
|
||||
win.connect("delete-event", Gtk.main_quit)
|
||||
win.show_all()
|
||||
Gtk.main()
|
Reference in New Issue
Block a user