linux-tools/modules/hacker/Hacker.py

30 lines
886 B
Python
Raw Normal View History

2020-03-21 23:49:29 +01:00
import subprocess
from os import path
import os
import random
class Hacker:
def run_bash(self):
try:
subprocess.run("bash hacker.sh", shell=True, cwd=path.dirname(__file__))
except KeyboardInterrupt:
pass
def run_py(self):
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("\033[92m" + hacker)
except KeyboardInterrupt:
print(columns)
print("Finished")
print("\033[0m")