Skip to content

Commit

Permalink
@wvangeit review: add some psychedelic component
Browse files Browse the repository at this point in the history
  • Loading branch information
sanderegg committed Feb 23, 2024
1 parent 4735b81 commit 00f506c
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion services/sleeper/src/sleeper/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import json
import random
import string
import time
import subprocess

Expand Down Expand Up @@ -58,10 +59,25 @@ def walk_to_bed(amount_to_walk: int = 0) -> None:
time.sleep(0.5)


def generate_random_words(word_length, total_length):
words = []
while total_length > 0:
word = "".join(
random.choices(
string.ascii_lowercase + string.ascii_uppercase, k=word_length
)
)
spacer = " " if total_length > word_length else ""
words.append(word + spacer)
total_length -= word_length + len(spacer)
return "".join(words)


def dream(output_folder: Path, dream_size_bytes: int) -> None:
output_3_file = output_folder / "dream.txt"
with output_3_file.open("wb") as fp:
fp.write(f"I am a {dream_size_bytes} dream".encode())
psychedelic_content = generate_random_words(6, dream_size_bytes).encode()
fp.write(psychedelic_content)
fp.truncate(dream_size_bytes)
print(f"What a dream! it was {dream_size_bytes}!! Amazing!")

Expand Down

0 comments on commit 00f506c

Please sign in to comment.