-
Notifications
You must be signed in to change notification settings - Fork 58
Refactor package to be imported as a single package #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 10 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
91c92b0
Apply intial changes to make repo perform better as a Python module
00835e3
Add changes from original examples file, apply find_packages to setup…
86117de
Improvements to motion detection and download methods, add to examples
7afa58a
Version bump
856ede1
Resolve issue when querying motion files results in empty results
84ed848
Add back pipfiles, README
b10c29c
Move description read-in beneath metadata
17bc207
Add description to new example. Swap import on original example
63537f9
Enforce lowercase standard on all submodule files, improve type hinti…
7283bd3
Reduce redundant code, remove unused arguments
0a48984
Complete second logic pass, remove underscore from package name
4c4dd7d
Complete second logic pass, remove underscore from package name
2b3e142
Updated project structure and some file names.
Benehiko 0fdd0df
Merge branch 'master' into develop
Benehiko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
secrets.cfg | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Downloads all motion events from camera from the past hour.""" | ||
import os | ||
from configparser import RawConfigParser | ||
from datetime import datetime as dt, timedelta | ||
from reolink_api import Camera | ||
|
||
|
||
def read_config(props_path: str) -> dict: | ||
"""Reads in a properties file into variables. | ||
|
||
NB! this config file is kept out of commits with .gitignore. The structure of this file is such: | ||
# secrets.cfg | ||
[camera] | ||
ip={ip_address} | ||
username={username} | ||
password={password} | ||
""" | ||
config = RawConfigParser() | ||
assert os.path.exists(props_path), f"Path does not exist: {props_path}" | ||
config.read(props_path) | ||
return config | ||
|
||
|
||
# Read in your ip, username, & password | ||
# (NB! you'll likely have to create this file. See tests/test_camera.py for details on structure) | ||
config = read_config('../secrets.cfg') | ||
|
||
ip = config.get('camera', 'ip') | ||
un = config.get('camera', 'username') | ||
pw = config.get('camera', 'password') | ||
|
||
# Connect to camera | ||
cam = Camera(ip, un, pw) | ||
|
||
start = (dt.now() - timedelta(hours=1)) | ||
end = dt.now() | ||
# Collect motion events between these timestamps for substream | ||
processed_motions = cam.get_motion_files(start=start, end=end, streamtype='sub') | ||
|
||
dl_dir = os.path.join(os.path.expanduser('~'), 'Downloads') | ||
for i, motion in enumerate(processed_motions): | ||
fname = motion['filename'] | ||
# Download the mp4 | ||
resp = cam.get_file(fname, output_path=os.path.join(dl_dir, f'motion_event_{i}.mp4')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import cv2 | ||
|
||
from Camera import Camera | ||
from reolink_api import Camera | ||
|
||
|
||
def non_blocking(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .api_handler import APIHandler | ||
from .camera import Camera | ||
|
||
__version__ = "0.1.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
import io | ||
|
||
import yaml | ||
from typing import Optional, Dict | ||
|
||
|
||
class ConfigHandler: | ||
camera_settings = {} | ||
|
||
@staticmethod | ||
def load() -> yaml or None: | ||
def load() -> Optional[Dict]: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting here that |
||
try: | ||
stream = io.open("config.yml", 'r', encoding='utf8') | ||
data = yaml.safe_load(stream) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pointing out this change here.