mirror of
https://github.com/zoriya/AnonymousGoose.git
synced 2026-06-06 07:15:38 +00:00
Solving the print bug when closing the first terminal
This commit is contained in:
@@ -46,6 +46,7 @@ class AnonymousGoose:
|
|||||||
def key_pressed(self, key):
|
def key_pressed(self, key):
|
||||||
if key.Ascii == 27:
|
if key.Ascii == 27:
|
||||||
self.should_exit = True
|
self.should_exit = True
|
||||||
|
Term.print_all("IMPOSSIBLE. You defeated my virus. There is no w...\n")
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
if self.stopped:
|
if self.stopped:
|
||||||
|
|||||||
+20
-12
@@ -2,6 +2,7 @@ import os
|
|||||||
import shutil
|
import shutil
|
||||||
import time
|
import time
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from command_helper import CommandHelper
|
from command_helper import CommandHelper
|
||||||
|
|
||||||
|
|
||||||
@@ -31,10 +32,9 @@ class Term:
|
|||||||
"sakura",
|
"sakura",
|
||||||
"rxvt-unicode"
|
"rxvt-unicode"
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.tty = self.create_tty()
|
self.tty = self.create_tty()
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
def print(self, msg):
|
def print(self, msg):
|
||||||
try:
|
try:
|
||||||
@@ -48,9 +48,12 @@ class Term:
|
|||||||
try:
|
try:
|
||||||
with open(self.tty, "w") as file:
|
with open(self.tty, "w") as file:
|
||||||
for char in msg:
|
for char in msg:
|
||||||
file.write(char)
|
try:
|
||||||
file.flush()
|
file.write(char)
|
||||||
time.sleep(random.uniform(0, 0.2))
|
file.flush()
|
||||||
|
time.sleep(random.uniform(0, 0.2))
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
return False
|
return False
|
||||||
except OSError:
|
except OSError:
|
||||||
@@ -65,13 +68,13 @@ class Term:
|
|||||||
f.append(open(f"/dev/pts/{file}", "w"))
|
f.append(open(f"/dev/pts/{file}", "w"))
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
for char in msg:
|
for char in msg:
|
||||||
for fd in f:
|
for fd in f:
|
||||||
fd.flush()
|
fd.flush()
|
||||||
fd.write(char)
|
fd.write(char)
|
||||||
time.sleep(random.uniform(0, 0.2))
|
time.sleep(random.uniform(0, 0.2))
|
||||||
|
|
||||||
for file in f:
|
for file in f:
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
@@ -87,13 +90,18 @@ class Term:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def create_tty():
|
def create_tty():
|
||||||
li = [i for i in range(100)]
|
li = []
|
||||||
for tty in sorted(os.listdir("/dev/pts")):
|
current = None
|
||||||
|
for tty in os.listdir("/dev/pts"):
|
||||||
if tty.isdigit():
|
if tty.isdigit():
|
||||||
if int(tty) in li:
|
li.append(int(tty))
|
||||||
li.remove(int(tty))
|
|
||||||
CommandHelper.run_async(Term.find_terminal())
|
CommandHelper.run_async(Term.find_terminal())
|
||||||
return f"/dev/pts/{min(li)}"
|
time.sleep(1)
|
||||||
|
for tty in os.listdir("/dev/pts"):
|
||||||
|
if tty.isdigit():
|
||||||
|
if int(tty) not in li:
|
||||||
|
current = int(tty)
|
||||||
|
return f"/dev/pts/{current}"
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_terminal():
|
def find_terminal():
|
||||||
|
|||||||
Reference in New Issue
Block a user