def test_get_billing_calendar_november_returns_correct_calendar(self):
     date = '2020-11-30'
     calendar = bc.get_billing_calendar(date)
     self.assertEqual(dt(2020, 11, 1), calendar.current_month_first_day)
     self.assertEqual(dt(2020, 11, 30), calendar.current_month_last_day)
     self.assertEqual(dt(2020, 10, 1), calendar.previous_month_first_day)
     self.assertEqual(dt(2020, 10, 31), calendar.previous_month_last_day)
     self.assertEqual(30, calendar.days_in_current_month)
 def test_get_billing_calendar_january_returns_correct_calendar(self):
     date = '2020-01-31'
     calendar = bc.get_billing_calendar(date)
     self.assertEqual(dt(2020, 1, 1), calendar.current_month_first_day)
     self.assertEqual(dt(2020, 1, 31), calendar.current_month_last_day)
     self.assertEqual(dt(2019, 12, 1), calendar.previous_month_first_day)
     self.assertEqual(dt(2019, 12, 31), calendar.previous_month_last_day)
     self.assertEqual(31, calendar.days_in_current_month)
 def test_get_billing_calendar_leap_year_feb_returns_correct_calendar(self):
     date = '2020-02-29'
     calendar = bc.get_billing_calendar(date)
     self.assertEqual(dt(2020, 2, 1), calendar.current_month_first_day)
     self.assertEqual(dt(2020, 2, 29), calendar.current_month_last_day)
     self.assertEqual(dt(2020, 1, 1), calendar.previous_month_first_day)
     self.assertEqual(dt(2020, 1, 31), calendar.previous_month_last_day)
     self.assertEqual(29, calendar.days_in_current_month)
 def test_get_billing_calendar_not_leap_year_march_returns_correct_calendar(
         self):
     date = '2019-03-31'
     calendar = bc.get_billing_calendar(date)
     self.assertEqual(dt(2019, 3, 1), calendar.current_month_first_day)
     self.assertEqual(dt(2019, 3, 31), calendar.current_month_last_day)
     self.assertEqual(dt(2019, 2, 1), calendar.previous_month_first_day)
     self.assertEqual(dt(2019, 2, 28), calendar.previous_month_last_day)
     self.assertEqual(31, calendar.days_in_current_month)
Ejemplo n.º 5
0
def test_video_decompile_nometa(setup_module):
    # this file has no metadata - we have to take a guess of 9 to 5
    with TemporaryDirectory() as tempd:
        logging.getLogger().setLevel(logging.DEBUG)
        cl = [
            str(TEST_DATA / "2000-01-01-no-meta.mp4"), "--output", tempd,
            "--start", "04:00", "--interval", "30", "-ll", "DEBUG"
        ]
        with pytest.raises(SystemExit) as exc:
            video_decompile_console(cl)
        assert exc.value.code == 0

        tempp = Path(tempd)
        images = sorted(list((tempp / "2000-01-01").glob("*.jpg")))
        assert len(images) == frames(TEST_DATA / "2000-01-01-no-meta.mp4")
        assert str2dt(Path(images[0]).stem) == dt(2000, 1, 1, 4, 0, 0)
        assert pytest.approx(str2dt(Path(images[-1]).stem).timestamp(),
                             dt(2000, 1, 1, 19, 0, 0).timestamp(),
                             abs=30)
Ejemplo n.º 6
0
def test_video_decompile_nometa2(setup_module):
    # this file has no metadata - and is disjoint
    # specify start, end and deduce interval
    with TemporaryDirectory() as tempd:
        logging.getLogger().setLevel(logging.DEBUG)
        cl = [
            str(TEST_DATA / "2019-11-07-disjoint-no-meta.mp4"), "--output",
            tempd, "--start", "09:55", "--end", "12:15", "-ll", "DEBUG"
        ]
        with pytest.raises(SystemExit) as exc:
            video_decompile_console(cl)
        assert exc.value.code == 0

        tempp = Path(tempd)
        images = sorted(list((tempp / "2019-11-07").glob("*.jpg")))
        assert len(images) == frames(TEST_DATA /
                                     "2019-11-07-disjoint-no-meta.mp4")
        assert str2dt(Path(images[0]).stem) == dt(2019, 11, 7, 9, 55, 0)
        assert pytest.approx(str2dt(Path(images[-1]).stem).timestamp(),
                             dt(2019, 11, 7, 12, 15, 0).timestamp(),
                             abs=30)
Ejemplo n.º 7
0
def not_test_video_decompile_ocr():
    # this file has no metadata - and is disjoint
    # use ocr to read timestamp
    with TemporaryDirectory() as tempd:
        logging.getLogger().setLevel(logging.DEBUG)
        cl = [
            str(TEST_DATA / "2019-11-07-disjoint-no-meta.mp4"), "--output",
            tempd, "--start", "09:55", "--interval", "30", "--ocr", "-ll",
            "DEBUG"
        ]
        with pytest.raises(SystemExit) as exc:
            video_decompile_console(cl)
        assert exc.value.code == 0

        tempp = Path(tempd)
        images = sorted(list((tempp / "2019-11-07").glob("*.jpg")))
        assert len(images) == frames(TEST_DATA /
                                     "2019-11-07-disjoint-no-meta.mp4")
        assert str2dt(Path(images[0]).stem) == dt(2000, 1, 1, 4, 0, 0)
        assert pytest.approx(str2dt(Path(images[-1]).stem).timestamp(),
                             dt(2000, 1, 1, 19, 0, 0).timestamp(),
                             abs=30)
Ejemplo n.º 8
0
def test_video_info(setup_module):
    v1 = VideoInfo(TEST_DATA / "sample1.mp4")
    assert v1.frames == 55
    assert v1.valid
    assert v1.fps == 1

    v2 = VideoInfo(TEST_DATA / "sample2.mp4")
    assert v2.frames == 444
    assert v2.fps == 20

    v3 = VideoInfo(TEST_DATA / "metadata.mp4")
    print(v3)
    assert v3.real_duration == timedelta(seconds=259200)
    assert v3.real_start == dt(2000, 1, 1, 1, 0, 0)
Ejemplo n.º 9
0
    ),
    dcc.RadioItems(
        options=[
            {'label': 'Python', 'value': 'py'},
            {'label': 'SQL', 'value': 'sql'},
            {'label': 'JavaScript', 'value': 'js'}
        ],
        value = 'js',
        labelStyle = {'display': 'inline-block'}
    ),
    html.Button("Kup teraz!"),
    html.Button("Kup potem!", disabled=True,),
    html.Button("Kup wszystko!", type='submit'),
    dcc.DatePickerSingle(
        date= dt(2020,8,17),
        display_format='YYYY-MM-DD'
),
    dcc.DatePickerRange(
        start_date=dt(2020,10,10),
        end_date=dt(2020,11,11),
        min_date_allowed=dt(2020,10,10),
        max_date_allowed=dt(2020,11,11)
    ),
    dcc.Markdown(
'''
1. Kup już
2. Kup potem
3. Kup wszystko

* 1
Ejemplo n.º 10
0
Write a Python program to calculate number of days between two dates.
"""
# importing date from datetime module
from _datetime import date as dt
#asking from user to enter 1st date
day1 = int(input("Enter 1st date "))

#asking from user to enter 1st month
month1 = int(input("Enter 1st month "))

#asking from user to enter 1st year
year1 = int(input("Enter 1st year"))

#asking from user to enter 2nd date
day2 = int(input("Enter 2nd date "))

#asking from user to enter 2nd month
month2 = int(input("Enter 2nd month "))

#asking from user to enter 2nd year
year2 = int(input("Enter 2nd year"))

#converting input into date object
date1 =dt(year1,month1,day1)
#converting input into date object
date2 =dt(year2,month2,day2)
#getting the difference between date 1 and date2
val =date2-date1
#printing the difference
print(val)
Ejemplo n.º 11
0
def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAmin()
    except:
        return False

if is_admin():

    # hosts_temp = r"hosts"
    # hosts_path = r"C:\Windows\System32\drivers\etc\hosts"
    hosts_path = r"hosts"
    redirect_IP = "127.0.0.1"
    websites_to_block = ["www.facebook.com", "facebook.com", "https://outlook.live.com/owa/", "outlook.live.com"]

    while True:
        if dt(dt.now().year, dt.now().month, dt.now().day, 8) < dt.now() < dt(dt.now().year, dt.now().month, dt.now().day, 23):
            print("Working hours...")
            with open(hosts_path, "r+") as file:
                content = file.read()
                for website in websites_to_block:
                    if website in content:
                        pass
                    else:
                        file.write(redirect_IP + " " + website + "\n")
        else:
            with open(hosts_path, "r+") as file:
                content = file.readlines()
                file.seek(0)
                for line in content:
                    if not any(website in line for website in websites_to_block):
                        file.write(line)