-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from psyciknz/image-playback
Image playback and Mqtt auth
- Loading branch information
Showing
8 changed files
with
355 additions
and
24 deletions.
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 |
---|---|---|
|
@@ -3,3 +3,4 @@ config.ini | |
*.pyc | ||
.pytest_cache/* | ||
build.config | ||
image.jpg |
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,6 @@ | ||
language: python | ||
python: | ||
- "2.7" | ||
- "3.7" | ||
# command to run tests | ||
install: pip install -r requirements.txt | ||
script: pytest | ||
script: pytest test_onreceive.py |
Large diffs are not rendered by default.
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
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,83 @@ | ||
import pytest | ||
import CameraEvents | ||
import datetime | ||
try: | ||
#python 3+ | ||
from configparser import ConfigParser | ||
except: | ||
# Python 2.7 | ||
from ConfigParser import ConfigParser | ||
|
||
class dummy_mqtt(object): | ||
pass | ||
def publish(self,topic,payload): | ||
pass | ||
|
||
def create_device(): | ||
device_cfg = {} | ||
channels = {} | ||
device_cfg["channels"] = channels | ||
#device_cfg.set(["channels"] | ||
device_cfg["Name"] = "test" | ||
device_cfg["user"] = "user" | ||
device_cfg["password"] = "pass" | ||
device_cfg["auth"] = "digest" | ||
device_cfg["mqtt"] = "localhsot" | ||
device_cfg["protocol"] = "http" | ||
device_cfg["host"] = "192.168.1.108" | ||
device_cfg["port"] = 80 | ||
device_cfg["alerts"] = False | ||
device_cfg["snapshotoffset"] = 0 | ||
client = dummy_mqtt() | ||
client.connected_flag = True | ||
|
||
basetopic = "CameraEvents" | ||
|
||
device = CameraEvents.DahuaDevice("Camera", device_cfg, client,basetopic) | ||
return device | ||
|
||
def read_config(): | ||
cp = ConfigParser() | ||
filename = {"config.ini","conf/config.ini"} | ||
dataset = cp.read(filename) | ||
|
||
try: | ||
if len(dataset) != 1: | ||
raise ValueError( "Failed to open/find all files") | ||
camera_items = cp.items( "Cameras" ) | ||
for key, camera_key in camera_items: | ||
#do something with path | ||
camera_cp = cp.items(camera_key) | ||
camera = {} | ||
#temp = cp.get(camera_key,"host") | ||
camera["host"] = cp.get(camera_key,'host') | ||
except Exception as ex: | ||
pass | ||
|
||
def test_dahua_create(): | ||
device = create_device() | ||
assert device is not None | ||
|
||
def test_dahua_take_snapshot(): | ||
device = create_device() | ||
device.host = 'cam-nvr.andc.nz' | ||
device.user = 'IOS' | ||
device.password = 'Dragon25' | ||
image = device.SnapshotImage(1,"Garage","message",nopublish=True) | ||
assert image is not None | ||
if len(image) > 600: | ||
sized = True | ||
assert sized is True | ||
|
||
def test_dahua_search_images(): | ||
device = create_device() | ||
device.host = 'cam-nvr.andc.nz' | ||
device.user = 'IOS' | ||
device.password = 'Dragon25' | ||
starttime = datetime.datetime.now() - datetime.timedelta(minutes=25) | ||
endtime = datetime.datetime.now() | ||
result = device.SearchImages(2, starttime,endtime,"") | ||
assert result is not None | ||
#if len(image) > 600: | ||
# sized = True | ||
#assert sized is True |
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 |
---|---|---|
|
@@ -2,4 +2,6 @@ paho-mqtt | |
pycurl | ||
ConfigParser | ||
requests | ||
imageio | ||
Slacker | ||
|