linux-tools/modules/hacker/__init__.py
2020-08-02 13:58:47 +02:00

36 lines
853 B
Python

import os
import random
import subprocess
from os import path
from print_helpers import print_gr
def run_bash():
try:
subprocess.run("bash hacker.sh", shell=True, cwd=path.dirname(__file__))
except KeyboardInterrupt:
pass
def run_py():
columns = int(os.popen('stty size', 'r').read().split()[1]) # length of current line
try:
while True:
num_to_show = random.randint(0, 1)
count = random.randint(3, columns // 20)
hacker = " " * columns
for i in range(count):
pos = random.randint(0, columns)
hacker = hacker[:pos] + str(num_to_show) + hacker[pos + 1:]
print_gr(hacker)
except KeyboardInterrupt:
print(columns)
print_gr("Finished")
functions = {
"runBash": run_bash,
"runPy": run_py
}