Skip to content

Commit

Permalink
raise warnings properly
Browse files Browse the repository at this point in the history
  • Loading branch information
shravanasati committed Oct 13, 2024
1 parent fd3ed34 commit 58becd6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 28 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Change Log
- Minor bug fixes.
--------------

0.4 (13/10/24)
0.5 (13/10/24)
--------------
- Remove the `HighFPSWarning` and `InvalidFPS` exception classes.
- Raise frame count by almost 2 times.
Expand Down
24 changes: 13 additions & 11 deletions pyscreenrec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
# type: ignore
from pyscreeze import screenshot
from time import sleep

# type: ignore
import cv2
import os
from threading import Thread
from time import sleep
from warnings import warn

# type: ignore
import cv2
from natsort import natsorted
from pyscreeze import screenshot


class InvalidCodec(Exception):
Expand Down Expand Up @@ -75,7 +72,7 @@ def _start_recording(self, video_name: str, fps: int) -> None:

# checking if screen is already being recorded
if self.__running:
raise ScreenRecordingInProgress("Screen recording is already running.")
warn("Screen recording is already running.", ScreenRecordingInProgress)

else:
if self.__start_mode == "start":
Expand Down Expand Up @@ -141,7 +138,8 @@ def stop_recording(self) -> None:
Stops screen recording.
"""
if not self.__running:
raise NoScreenRecordingInProgress("No screen recording session is going on.")
warn("No screen recording session is going on.", NoScreenRecordingInProgress)
return

self.__running = False

Expand All @@ -154,7 +152,8 @@ def pause_recording(self) -> None:
Pauses screen recording.
"""
if not self.__running:
raise NoScreenRecordingInProgress("No screen recording session is going on.")
warn("No screen recording session is going on.", NoScreenRecordingInProgress)
return

self.__running = False

Expand All @@ -163,7 +162,8 @@ def resume_recording(self) -> None:
Resumes screen recording.
"""
if self.__running:
raise ScreenRecordingInProgress("Screen recording is already running.")
warn("Screen recording is already running.", ScreenRecordingInProgress)
return

self.__start_mode = "resume"
self.start_recording(self.video_name)
Expand Down Expand Up @@ -215,6 +215,8 @@ def __repr__(self) -> str:
rec = ScreenRecorder()
print("recording started")
rec.start_recording(fps=30)
rec.resume_recording()
time.sleep(10)
print("recording ended")
rec.stop_recording()
rec.pause_recording()
32 changes: 16 additions & 16 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
from setuptools import find_packages, setup

VERSION = 0.4
VERSION = "0.5"
with open("README.md") as f:
README = f.read()

setup(
name = "pyscreenrec",
version = VERSION,
description = "A small and cross-platform python library for recording screen.",
long_description_content_type = "text/markdown",
long_description = README,
name="pyscreenrec",
version=VERSION,
description="A small and cross-platform python library for recording screen.",
long_description_content_type="text/markdown",
long_description=README,
url="https://github.com/shravanasati/pyscreenrec",
author = "Shravan Asati",
author_email = "[email protected]",
packages = find_packages(),
install_requires = ["pyscreeze", "opencv-python", "natsort"],
license = 'MIT',
keywords = ["python", "screen recording", "screen", "recording", "screenshots"],
classifiers = [
author="Shravan Asati",
author_email="[email protected]",
packages=find_packages(),
install_requires=["pyscreeze", "opencv-python", "natsort"],
license="MIT",
keywords=["python", "screen recording", "screen", "recording", "screenshots"],
classifiers=[
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
Expand All @@ -28,6 +28,6 @@
"Operating System :: Unix",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Topic :: Software Development :: Libraries"
]
)
"Topic :: Software Development :: Libraries",
],
)

0 comments on commit 58becd6

Please sign in to comment.