import os
import re
import subprocess
+import utils
def _list_mounts():
def _list_disks_fdisk():
try:
- output = subprocess.check_output(['fdisk', '-l'], stderr=open('/dev/null', 'w'))
+ output = subprocess.check_output(['fdisk', '-l'], stderr=utils.DEV_NULL)
except Exception as e:
logging.error('failed to list disks using "fdisk -l": %s' % e, exc_info=True)
def find_ffmpeg():
try:
- return subprocess.check_output(['which', 'ffmpeg'], stderr=open('/dev/null', 'w')).strip()
+ return subprocess.check_output(['which', 'ffmpeg'], stderr=utils.DEV_NULL).strip()
except subprocess.CalledProcessError: # not found
return None
else: # autodetect motion binary path
try:
- binary = subprocess.check_output(['which', 'motion'], stderr=open('/dev/null', 'w')).strip()
+ binary = subprocess.check_output(['which', 'motion'], stderr=utils.DEV_NULL).strip()
except subprocess.CalledProcessError: # not found
return None
import logging
import os
import subprocess
+import utils
def _find_prog(prog):
try:
- return subprocess.check_output(['which', prog], stderr=open('/dev/null', 'w')).strip()
+ return subprocess.check_output(['which', prog], stderr=utils.DEV_NULL).strip()
except subprocess.CalledProcessError: # not found
return None
import re
import subprocess
import time
+import utils
from tornado.ioloop import IOLoop
def find_mount_cifs():
try:
- return subprocess.check_output(['which', 'mount.cifs'], stderr=open('/dev/null', 'w')).strip()
+ return subprocess.check_output(['which', 'mount.cifs'], stderr=utils.DEV_NULL).strip()
except subprocess.CalledProcessError: # not found
return None
_SIGNATURE_REGEX = re.compile('[^a-zA-Z0-9/?_.=&{}\[\]":, _-]')
_SPECIAL_COOKIE_NAMES = {'expires', 'domain', 'path', 'secure', 'httponly'}
+DEV_NULL = open('/dev/null', 'w')
+
COMMON_RESOLUTIONS = [
(320, 240),
def find_v4l2_ctl():
try:
- return subprocess.check_output(['which', 'v4l2-ctl'], stderr=open('/dev/null', 'w')).strip()
+ return subprocess.check_output(['which', 'v4l2-ctl'], stderr=utils.DEV_NULL).strip()
except subprocess.CalledProcessError: # not found
return None