Skip to content

Commit

Permalink
Refactor pep8
Browse files Browse the repository at this point in the history
  • Loading branch information
Maciej Prostak committed May 11, 2021
1 parent f771a70 commit 2db6de1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions emulate/emulate_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UserCodeException(BaseException):


class NoCodeInDatabaseException(BaseException):
"""Exception when there is no code in databae"""
"""Exception when there is no code in database"""


def check_process(process) -> None:
Expand Down Expand Up @@ -120,13 +120,15 @@ def retrieve_next_animation() -> Code:
random_pk = random.choice(pk_list)
return Code.objects.get(pk=random_pk)


def is_time_between(begin_time, end_time, check_time=None) -> bool:
check_time = check_time or datetime.now().time()
if begin_time < end_time:
return check_time >= begin_time and check_time <= end_time
return begin_time <= check_time <= end_time
else: # crosses midnight
return check_time >= begin_time or check_time <= end_time


def should_animate() -> bool:
cfg = Config.objects.first()
if cfg is None:
Expand All @@ -139,11 +141,13 @@ def should_animate() -> bool:
return True
return is_time_between(cfg.animation_start_time, cfg.animation_end_time)


def reset_dmx_values():
number_of_values = 5 * 28 * 3 # 5 rows, 28 columns, 3 color values
number_of_values = 5 * 28 * 3 # 5 rows, 28 columns, 3 color values
serialized = ",".join("0" * number_of_values)
redis_db.set('DMXvalues', serialized)


def main():
while True:
logging.info(f'Running code for {CODE_EMULATION_WAIT_TIME_SECONDS} seconds')
Expand Down

0 comments on commit 2db6de1

Please # to comment.