_configure_settings()
-_configure_logging()
+_configure_logging(module='eventrelay')
def print_usage():
event = sys.argv[1]
thread_id = sys.argv[2]
+ logging.debug('hello!')
logging.debug('event = %s' % event)
logging.debug('thread_id = %s' % thread_id)
except Exception as e:
logging.error('failed to relay event: %s' % e)
+
+ logging.debug('bye!')
signal.signal(signal.SIGCHLD, child_handler)
-def _configure_logging():
+def _configure_logging(module=None):
+ if module:
+ format = '%(asctime)s: [{module}] %(levelname)s: %(message)s'.format(module=module)
+
+ else:
+ format = '%(asctime)s: %(levelname)s: %(message)s'
+
logging.basicConfig(filename=None, level=settings.LOG_LEVEL,
- format='%(asctime)s: %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
+ format=format, datefmt='%Y-%m-%d %H:%M:%S')
logging.getLogger('tornado').setLevel(logging.WARN)
_configure_settings()
_configure_signals()
-_configure_logging()
+_configure_logging(module='sendmail')
import config
import mediafiles
if files:
logging.debug('attached %d pictures' % len(files))
+ logging.debug('sending email message')
conn.sendmail(_from, to, email.as_string())
conn.quit()
camera_config = config.get_camera(camera_id)
def on_media_files(media_files):
+ logging.debug('got media files')
+
timestamp = time.mktime(moment.timetuple())
media_files = [m for m in media_files if abs(m['timestamp'] - timestamp) < timespan] # filter out non-recent media files
media_files.sort(key=lambda m: m['timestamp'], reverse=True)
media_files = [os.path.join(camera_config['target_dir'], re.sub('^/', '', m['path'])) for m in media_files]
+
+ logging.debug('selected %d pictures' % len(media_files))
format_dict = {
'camera': camera_config['@name'],
if not timespan:
return on_media_files([])
-
+
+ logging.debug('creating email message')
+
time.sleep(timespan) # give motion some time to create motion pictures
mediafiles.list_media(camera_config, media_type='picture', callback=on_media_files)
timespan = int(sys.argv[10])
except:
- timespan = 5
+ timespan = 0
+
+ logging.debug('hello!')
message = messages.get(msg_id)
subject = subjects.get(msg_id)
io_loop.add_timeout(datetime.timedelta(seconds=settings.SMTP_TIMEOUT), ioloop_timeout)
io_loop.start()
+
+ logging.debug('bye!')
\ No newline at end of file
from tornado.ioloop import IOLoop
import diskctl
-import motionctl
import powerctl
import settings
-import smbctl
import update
import utils
import v4l2ctl
def motion_camera_ui_to_dict(ui, old_config=None):
+ import smbctl
+
old_config = dict(old_config or {})
main_config = get_main() # needed for surveillance password
def motion_camera_dict_to_ui(data):
+ import smbctl
+
ui = {
# device
'name': data['@name'],
if on_event_start:
on_event_start = [e.strip() for e in on_event_start.split(';')]
+ ui['email_notifications_picture_time_span'] = 0
command_notifications = []
for e in on_event_start:
if e.count('sendmail.py') and e.count('motion_start'):
ui['email_notifications_picture_time_span'] = int(e[10])
except:
- ui['email_notifications_picture_time_span'] = 5
+ ui['email_notifications_picture_time_span'] = 0
elif e.count('webhook.py'):
e = shlex.split(e)
def is_old_motion():
+ import motionctl
+
try:
binary, version = motionctl.find_motion() # @UnusedVariable
from tornado import ioloop
import config
-import motionctl
import settings
def _check_mounts():
+ import motionctl
+
logging.debug('checking SMB mounts...')
stop, start = update_mounts()
<tr class="settings-item advanced-setting" min="0" max="60" required="true">
<td class="settings-item-label"><span class="settings-item-label">Attached Pictures Time Span</span></td>
<td class="settings-item-value"><input type="text" class="number styled notifications camera-config" id="emailPictureTimeSpanEntry"><span class="settings-item-unit">seconds</span></td>
- <td><span class="help-mark" title="defines the picture search time interval to use when creating email attachments (higher values generate emails with more pictures at the cost of an increased notification delay)">?</span></td>
+ <td><span class="help-mark" title="defines the picture search time interval to use when creating email attachments (higher values generate emails with more pictures at the cost of an increased notification delay); set to 0 to disable picture attachments">?</span></td>
</tr>
<tr class="settings-item advanced-setting">
<td colspan="100"><div class="settings-item-separator"></div></td>