]> www.vanbest.org Git - motioneye-debian/commitdiff
remove obsolete relayevent.py
authorCalin Crisan <ccrisan@gmail.com>
Sun, 28 May 2017 11:18:59 +0000 (14:18 +0300)
committerCalin Crisan <ccrisan@gmail.com>
Sun, 28 May 2017 11:18:59 +0000 (14:18 +0300)
motioneye/config.py
motioneye/meyectl.py
motioneye/relayevent.py [deleted file]

index c1248b7cff8c38baad1082f4b883b5bb6541661d..48e8cf53ea0aa2e96a1ec4b82ed8beb49f422d4b 100644 (file)
@@ -1399,7 +1399,7 @@ def motion_camera_dict_to_ui(data):
             ui['web_hook_notifications_http_method'] = e[-2]
             ui['web_hook_notifications_url'] = e[-1]
         
-        elif e.count('relayevent') or e.count('eventrelay.py'):
+        elif e.count('relayevent'):
             continue # ignore internal relay script
 
         else: # custom command
@@ -1426,7 +1426,7 @@ def motion_camera_dict_to_ui(data):
             ui['web_hook_storage_http_method'] = e[-2]
             ui['web_hook_storage_url'] = e[-1]
 
-        elif e.count('relayevent') or e.count('eventrelay.py'):
+        elif e.count('relayevent'):
             continue # ignore internal relay script
 
         else: # custom command
index 3d93bb8ce66dd2be75693fbc99c60f4aed210345..22838b59f70c3736deb9560a9be1a6ca20c7fd8d 100755 (executable)
@@ -199,7 +199,6 @@ def make_arg_parser(command=None):
         description = 'available commands:\n'
         description += '  startserver\n'
         description += '  stopserver\n'
-        description += '  relayevent\n'
         description += '  sendmail\n'
         description += '  webhook\n'
         description += '  shell\n\n'
@@ -259,10 +258,6 @@ def main():
         import sendmail
         sendmail.main(arg_parser, sys.argv[2:])
     
-    elif command == 'relayevent':
-        import relayevent
-        relayevent.main(arg_parser, sys.argv[2:])
-
     elif command == 'webhook':
         import webhook
         webhook.main(arg_parser, sys.argv[2:])
diff --git a/motioneye/relayevent.py b/motioneye/relayevent.py
deleted file mode 100644 (file)
index cbae71e..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-
-# Copyright (c) 2013 Calin Crisan
-# This file is part of motionEye.
-#
-# motionEye is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-# 
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-
-
-# THIS SCRIPT IS NO LONGER USED BUT IS KEPT FOR COMPATIBILITY REASONS,
-# AS OLDER CONFIGS MIGHT STILL REFERENCE IT
-# NEWER CONFIGS WILL USE motioneye/scripts/relayevent.sh,
-# AS IT'S CONSIDERABLY FASTER 
-
-
-
-import errno
-import json
-import logging
-import os.path
-import sys
-import urllib2
-
-sys.path.append(os.path.join(os.path.dirname(sys.argv[0]),'src'))
-
-import settings
-import utils
-
-
-def get_admin_credentials():
-    # this shortcut function is a bit faster than using the config module functions
-    config_file_path = os.path.join(settings.CONF_PATH, 'motion.conf')
-    
-    logging.debug('reading main config from file %(path)s...' % {'path': config_file_path}) 
-
-    lines = None
-    try:
-        file = open(config_file_path, 'r')
-    
-    except IOError as e:
-        if e.errno == errno.ENOENT:  # file does not exist
-            logging.info('main config file %(path)s does not exist, using default values' % {'path': config_file_path})
-            
-            lines = []
-        
-        else:
-            logging.error('could not open main config file %(path)s: %(msg)s' % {
-                    'path': config_file_path, 'msg': unicode(e)})
-            
-            raise
-
-    if lines is None:
-        try:
-            lines = [l[:-1] for l in file.readlines()]
-        
-        except Exception as e:
-            logging.error('could not read main config file %(path)s: %(msg)s' % {
-                    'path': config_file_path, 'msg': unicode(e)})
-            
-            raise
-        
-        finally:
-            file.close()
-    
-    admin_username = 'admin'
-    admin_password = ''
-    for line in lines:
-        line = line.strip()
-        if not line.startswith('#'):
-            continue
-        
-        line = line[1:].strip()
-        if line.startswith('@admin_username'):
-            parts = line.split(' ', 1)
-            admin_username = parts[1] if len(parts) > 1 else ''
-            
-            continue
-        
-        if line.startswith('@admin_password'):
-            parts = line.split(' ', 1)
-            admin_password = parts[1] if len(parts) > 1 else ''
-
-            continue
-    
-    return admin_username, admin_password
-
-
-def parse_options(parser, args):
-    parser.add_argument('event', help='the name of the event to relay')
-    parser.add_argument('thread_id', help='the id of the thread')
-    parser.add_argument('filename', nargs='?', help='the name of the file related to the event')
-
-    return parser.parse_args(args)
-    
-
-def main(parser, args):
-    import meyectl
-    
-    options = parse_options(parser, args)
-    
-    meyectl.configure_logging('relayevent', options.log_to_file)
-    meyectl.configure_tornado()
-
-    logging.debug('hello!')
-    logging.debug('event = %s' % options.event)
-    logging.debug('thread_id = %s' % options.thread_id)
-    if options.filename:
-        logging.debug('filename = %s' % options.filename)
-    
-    admin_username, admin_password = get_admin_credentials()
-    
-    data = {
-        '_username': admin_username,
-        'thread_id': options.thread_id,
-        'event': options.event
-    }
-    
-    if options.filename:
-        data['filename'] = options.filename
-    
-    path = '/_relay_event/'
-    body = json.dumps(data)
-    
-    signature = utils.compute_signature('POST', path, body, admin_password)
-    
-    url = 'http://127.0.0.1:%(port)s' + path + '?_signature=' + signature
-    url = url % {'port': settings.PORT}
-    
-    request = urllib2.Request(url, data=body, headers={'Content-Type': 'application/json'})
-    
-    try:
-        response = urllib2.urlopen(request)
-        response = json.load(response)
-        if response.get('error'):
-            raise Exception(response['error'])
-        
-        logging.debug('event successfully relayed')
-    
-    except Exception as e:
-        logging.error('failed to relay event: %s' % e)
-
-    logging.debug('bye!')