-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcamtest.py
More file actions
54 lines (44 loc) · 1.47 KB
/
camtest.py
File metadata and controls
54 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
from foscontrol import Cam
import sys
try: # PY3
from configparser import ConfigParser
except ImportError:
from ConfigParser import SafeConfigParser as ConfigParser
################################
# Don't forget to edit cam.cfg #
# to reflect you setup! #
################################
if __name__ == "__main__":
config = ConfigParser()
# see cam.cfg.example
config.read(['cam.cfg'])
prot = config.get('general', 'protocol')
host = config.get('general', 'host')
port = config.get('general', 'port')
user = config.get('general', 'user')
passwd = config.get('general', 'password')
if sys.hexversion < 0x03040300:
# parameter context not available
ctx = None
else:
# disable cert checking
# see also http://tuxpool.blogspot.de/2016/05/accessing-servers-with-self-signed.html
import ssl
ctx = ssl.create_default_context()
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
# connection to the camera
do = Cam(prot, host, port, user, passwd, context=ctx)
# display basic camera info
res = do.getDevInfo()
if res.result == 0: # quick check
print("""product name: %s
serial number: %s
camera name: %s
firmware version: %s
hardware version: %s""" % (res.productName, res.serialNo, res.devName, res.firmwareVer, res.hardwareVer))
else:
print(res._result)