示例#1
0
def shoot_unit():
    os.system('clear')
    fname = random.choice(fnames)
    path = relpath(fname)
    shoot(
        "%(div)s\n%(name)s\n%(div)s\n" % {
            'div': "-" * len(path),
            'name': path
            },
        color='blue'
        )
    spinning_cursor(random.random()*5)
    with open(path, 'r') as f:
        shoot_file(fname, 'white')
        shoot("\n")
        spinning_cursor(random.random()*5)
        shoot("\n\n")

        if not fname.endswith(".py"):
            return

        for line in f.readlines():
            shoot("[profile] %s" % line.strip())
            spinning_cursor(random.random()*5)
            try:
                cProfile.run('re.compile("%s")' % line.strip())
            except Exception as e:
                shoot("[exception] %s" % e)
            spinning_cursor(random.random()*5)
示例#2
0
def send_osc(client, msg):
    msg.setAddress("/action")
    if 'event' not in msg:
        msg.extend(['event', 1])
    try:
        client.send(msg)
        shoot('\n')
        log_post('DEBUG: sending to the client: %s' % msg)
    except OSC.OSCClientError as err:
        log_post(
            "ERROR: %s OSC.OSCClientError %s\n" % (
                datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f'), err
                ),
            output=sys.stderr
            )
示例#3
0
def main(*fnames):
    data = []
    for fname in fnames:
        with open(fname, 'r+') as fp:
            data.extend(json.load(fp))
            fp.close()

    i = 0
    stop = len(data)
    while True:
        freeze = random.random() * 0.5
        step = random.randint(1, 3)
        slc = min(i + step, stop - 1)

        tmp_ = data[i:slc]
        if tmp_:
            for x in tmp_:
                x.update(status=weighted_choice([('error',
                                                  .05), ('debug',
                                                         .65), ('info', .3)]))
            func = random.choice([prettify_json, prettify_pprint])
            shoot(func(tmp_))
            i += step
        else:
            i = 0
            # clear output each time the whole trace file is out
            os.system('clear')
            spinning_cursor(random.random())

        # occasionally output line breaks
        if weighted_choice([(True, 1), (False, 9)]):
            shoot('\n')

        # occasionally output table
        if weighted_choice([(True, 0.5), (False, 9.5)]):
            shoot('\n')
            shoot_table()
            freeze = random.uniform(0.2, 0.8)

        # occasionally output the whole random file from the current dir
        if weighted_choice([(True, 0.1), (False, 9.9)]):
            try:
                shoot_file()
            except IndexError:
                pass
            freeze = random.uniform(0.2, 0.8)

        time.sleep(freeze)
示例#4
0
# -*- coding: utf-8 -*-

import os
import time
import random
from utils import shoot, random, spinning_cursor, rand_string, weighted_choice

i = 0
curr = 0
while True:
    disp = int((curr + random.uniform(1, 35)) / 2.)  # smooth it out
    curr = disp

    attrs = None if disp > 25 else ['dark']

    shoot('{0: <35}'.format("|" * disp), 'white', attrs=attrs)
    time.sleep(random.random() * 0.1)
    i += 1

    # occasionally clear the screen and output rand string
    if i >= 100:
        if weighted_choice([(True, 1), (False, 9)]):
            os.system('clear')
            shoot("\n%s\n" % rand_string(random.randint(200, 800)),
                  color='red')
            spinning_cursor(random.random() * 0.5)
        i = 0
示例#5
0
            },
        color='blue'
        )
    spinning_cursor(random.random()*5)
    with open(path, 'r') as f:
        shoot_file(fname, 'white')
        shoot("\n")
        spinning_cursor(random.random()*5)
        shoot("\n\n")

        if not fname.endswith(".py"):
            return

        for line in f.readlines():
            shoot("[profile] %s" % line.strip())
            spinning_cursor(random.random()*5)
            try:
                cProfile.run('re.compile("%s")' % line.strip())
            except Exception as e:
                shoot("[exception] %s" % e)
            spinning_cursor(random.random()*5)

while True:
    try:
        shoot_unit()
    except Exception as e:
        shoot("[exception] %s" % e)

    shoot("\n\n")
    time.sleep(random.random()*1.5)
示例#6
0
import time

from utils import shoot, shoot_file, shoot_table, \
                  weighted_choice, random, spinning_cursor
from utils import relpath

fname = relpath('osceleton.trace')
with open(fname, 'r+') as f:
    lines = f.readlines()
    f.close()

i = 0
while True:
    freeze = random.random() * 0.3
    try:
        shoot(lines[i])
        i += 1
    except IndexError:
        i = 0
        # clear output each time the whole trace file is out
        os.system('clear')
        spinning_cursor(random.random())

    # occasionally output line breaks
    if weighted_choice([(True, 1), (False, 9)]):
        shoot('\n')

    # occasionally output table
    if weighted_choice([(True, 0.5), (False, 9.5)]):
        shoot('\n')
        shoot_table()
示例#7
0
import sys
from termcolor import colored

from utils import shoot, weighted_choice, random

lines = []
for line in sys.stdin:
    # colorize line
    if weighted_choice([(True, 1), (False, 9)]):
        word = 'debug' if 'debug' in line else 'info'
        line = line.replace(word, random.choice(['warning', 'error']))

    lines.append(line)
    if len(lines) >= 1000:
        with open('stderr.log', 'w+') as log:
            log.seek(0)
            log.writelines(lines)
            log.truncate()
            log.close()
        lines = []

    shoot(line)

log.close()
示例#8
0
# -*- coding: utf-8 -*-

import os
import time
import random
from utils import shoot, random, spinning_cursor, rand_string, weighted_choice

i = 0
curr = 0
while True:
    disp = (curr + random.uniform(1, 40)) / 2.  # smooth it out
    curr = disp
    attrs = None if curr > 27 else ['dark']
    shoot('{0: <35}'.format("|" * int(disp)) + ('%.3f' % disp),
          color='white',
          attrs=attrs)
    time.sleep(random.random() * 0.05)
    i += 1

    # occasionally clear the screen and output rand string
    if i >= 100:
        if weighted_choice([(True, 1), (False, 9)]):
            os.system('clear')
            shoot("\n%s\n" % rand_string(random.randint(200, 800)),
                  color='blue')
            spinning_cursor(random.random() * 0.5)
        i = 0