ffplayout/tests/run_time_machine.py

42 lines
982 B
Python
Raw Normal View History

#!/usr/bin/env python3
2021-02-11 09:44:58 +01:00
"""
Test script, for simulating different date and time.
This is useful for testing the transition from one playlist to another,
specially when the day_start time is in the night.
"""
import datetime
import os
import sys
2021-07-04 13:36:51 +02:00
from importlib import import_module
import time_machine
2021-03-01 12:50:44 +01:00
try:
from zoneinfo import ZoneInfo
except ImportError:
from backports.zoneinfo import ZoneInfo
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
2021-02-11 09:28:15 +01:00
# set time zone
_TZ = ZoneInfo("Europe/Berlin")
# fake date and time
2021-07-04 13:36:51 +02:00
SOURCE_TIME = [2021, 6, 24, 23, 57, 30]
2021-02-11 09:28:15 +01:00
@time_machine.travel(datetime.datetime(*SOURCE_TIME, tzinfo=_TZ))
def run_in_time_machine():
2021-07-04 13:36:51 +02:00
if stdin_args.mode:
output = import_module(f'ffplayout.output.{stdin_args.mode}').output
output()
else:
desktop.output()
if __name__ == '__main__':
2021-02-09 16:29:58 +01:00
from ffplayout.output import desktop
2021-07-04 13:36:51 +02:00
from ffplayout.utils import stdin_args
run_in_time_machine()