2020-08-02 00:55:48 +02:00
|
|
|
import os
|
|
|
|
import random
|
|
|
|
import subprocess
|
|
|
|
from os import path
|
|
|
|
|
2020-08-02 13:58:47 +02:00
|
|
|
from print_helpers import print_gr
|
|
|
|
|
2020-08-02 00:55:48 +02:00
|
|
|
|
|
|
|
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:]
|
2020-08-02 13:58:47 +02:00
|
|
|
print_gr(hacker)
|
2020-08-02 00:55:48 +02:00
|
|
|
except KeyboardInterrupt:
|
|
|
|
print(columns)
|
2020-08-02 13:58:47 +02:00
|
|
|
print_gr("Finished")
|
2020-08-02 00:55:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
functions = {
|
|
|
|
"runBash": run_bash,
|
|
|
|
"runPy": run_py
|
|
|
|
}
|