瀏覽代碼

version 0.3 input
new style of configuration values
home extended
new side menu entries
new pictures


git-svn-id: svn://svn.siningsoft.de/myCar@8 4258477e-9397-4ceb-bd8a-6305f6291781

devnull 7 年之前
父節點
當前提交
9879dc31e0
共有 14 個文件被更改,包括 154 次插入28 次删除
  1. 40 0
      data/log/myCar_Application.log
  2. 0 0
      data/log/mycar.log
  3. 0 0
      doc/pip.svg
  4. 二進制
      doc/python.png
  5. 27 0
      lib/bluetooth.py
  6. 5 1
      lib/config.py
  7. 52 17
      myCar.py
  8. 二進制
      static/img/pip.png
  9. 二進制
      static/img/python.png
  10. 1 1
      templates/VERSION
  11. 10 7
      templates/base.html
  12. 10 1
      templates/conf/main.html
  13. 8 0
      templates/empty.html
  14. 1 1
      templates/index.html

+ 40 - 0
data/log/myCar_Application.log

@@ -0,0 +1,40 @@
+WARNING:werkzeug: * Debugger is active!
+INFO:werkzeug: * Debugger PIN: 152-523-008
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /conf HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/css/pure/side-menu.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/css/pure/grids-responsive.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/css/pure/pure.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/css/myCar.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/js/ui.js HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/img/logo_smaller.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/img/nosave.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:35:45] "GET /static/img/save.png HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /conf HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/css/myCar.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/css/pure/pure.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/css/pure/side-menu.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/css/pure/grids-responsive.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/img/save.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/img/logo_smaller.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/img/nosave.png HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:36:49] "GET /static/js/ui.js HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /conf HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/css/pure/pure.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/css/pure/side-menu.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/css/pure/grids-responsive.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/css/myCar.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/img/nosave.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/img/logo_smaller.png HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/img/save.png HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/js/ui.js HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:38:44] "GET /static/img/favicon.ico HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /conf HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/css/pure/grids-responsive.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/css/myCar.css HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/css/pure/pure.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/css/pure/side-menu.css HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/img/logo_smaller.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/img/save.png HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/img/nosave.png HTTP/1.1" 200 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/js/ui.js HTTP/1.1" 304 -
+INFO:werkzeug:127.0.0.1 - - [07/Mar/2019 00:39:07] "GET /static/img/favicon.ico HTTP/1.1" 200 -

+ 0 - 0
data/log/mycar.log


File diff suppressed because it is too large
+ 0 - 0
doc/pip.svg


二進制
doc/python.png


+ 27 - 0
lib/bluetooth.py

@@ -0,0 +1,27 @@
+def bt_ctrl_ispowered():
+    # this method will return available bluetooth devices as a list for the web template output
+    import bluew
+    #return len(bluew.controllers())
+    bt_ctrl_powered = False
+
+    for dev in bluew.controllers():
+        if dev.Powered == True:
+            bt_ctrl_powered = True
+
+    return bt_ctrl_powered
+
+def bt_getDevices():
+    import bluew
+    #return len(bluew.devices())
+    if bt_ctrl_ispowered() == True:
+        retdevs = bluew.devices()
+    else:
+        retdevs = []    
+
+    return retdevs
+
+def bt_getControllers():
+    import bluew
+    retctrl = bluew.controllers()
+    return retctrl
+

+ 5 - 1
lib/config.py

@@ -9,12 +9,16 @@ def myCar_read_config_defaults(config):
         config['connections'] = { 'bt_dev' : '/dev/rfcomm',
                                   'gps_dev' : '/dev/ttyS1',
                                   'wifi_pwd' : 'myCar123' }
+        config['startup'] = { 'bt_connect' : True,
+                              'autorecord' : True }
 
     # return a valid config object either 
     # with or without default values
     return config
 
 def myCar_save_config(config):
-    import configparser
+    import configparser, logging
+    
     with open('data/etc/myCar.conf', 'w') as configfile:
         config.write(configfile)
+        logging.info('configuration saved')

+ 52 - 17
myCar.py

@@ -1,8 +1,10 @@
 #!/usr/bin/python3
 
+import logging
 import configparser
 import lib.config
 import lib.app_control
+import lib.bluetooth
 
 # we need to initially load the configuration file.
 # This is loaded via a local symlink
@@ -17,6 +19,22 @@ import atexit
 atexit.register(lib.app_control.myCar_exit, myCar_config)
 
 
+# lets start with log handling here
+import logging, os
+from pathlib import Path
+# first check, if the logentry is a directory
+if Path(myCar_config['paths'].get('log')).is_dir():
+    # now check if we can write ther:
+    myCar_logfile=myCar_config['paths'].get('log') + '/' + 'myCar_Application.log'
+    try:    
+        fp = open(myCar_logfile , 'w')
+    except PermissionError:
+        logging.warning('directory ' + myCar_logfile + ' not writeable')
+    else:
+        fp.close()
+        logging.basicConfig(filename=myCar_logfile,level=logging.INFO)
+
+        
 
 from flask import Flask
 from flask import url_for
@@ -28,30 +46,18 @@ app = Flask(__name__)
 
 @app.route('/')
 def myCar_root():
-    return render_template('index.html')
+    return render_template('index.html', bt_ctrl_ispowered=lib.bluetooth.bt_ctrl_ispowered())
 
 @app.route('/bluetooth/controller')
 def myCar_bluetooth_controller():
-    # this method will return available bluetooth devices as a list for the web template output
-    import bluew
-    #return len(bluew.controllers())
-    return render_template('bluetooth/controller.html', bt_ctrl=bluew.controllers())
+    return render_template('bluetooth/controller.html', bt_ctrl=lib.bluetooth.bt_getControllers())
 
 @app.route('/bluetooth/devices')
 def myCar_bluetooth_devices():
-    # this method will return available bluetooth devices as a list for the web template output
-    import bluew
-    #return len(bluew.controllers())
-    bt_ctrl_powered = False
-
-    for dev in bluew.controllers():
-        if dev.Powered == True:
-            bt_ctrl_powered = True
-    
-    if bt_ctrl_powered == False:
-        return render_template('bluetooth/controller.html', bt_ctrl=bluew.controllers(), bt_error="All Bluetooth Adapters are powered off")
+    if lib.bluetooth.bt_ctrl_ispowered == False:
+        return render_template('bluetooth/controller.html', bt_ctrl=lib.bluetooth.bt_getControllers(), bt_error="All Bluetooth Adapters are powered off")
     else:
-        return render_template('bluetooth/devices.html', bt_dev=bluew.devices())
+        return render_template('bluetooth/devices.html', bt_dev=lib.bluetooth.bt_getDevices())
 
 @app.route('/bluetooth/connect', methods=['POST'])
 def myCar_bluetooth_connect():
@@ -71,6 +77,8 @@ def myCar_bluetooth_connect():
 
             #try:
             bt_dst_mac = request.form['bt_dst_mac']
+
+            logging.info('Bluetooth trying to connect to ' + bt_dst_mac)
             # pair
             bluew.pair(bt_dst_mac)
 
@@ -117,3 +125,30 @@ def myCar_conf_save():
     return redirect(url_for('myCar_conf'), code=302)
             
 
+@app.route('/gps')
+def myCar_gps():
+    # dummy implementation before code is ready
+    return render_template('empty.html')
+    
+@app.route('/wifi')
+def myCar_wifi():
+    # dummy implementation before code is ready
+    return render_template('empty.html')
+
+@app.route('/system')
+def myCar_system():
+    # dummy implementation before code is ready
+    return render_template('empty.html')
+
+
+@app.route('/live')
+def myCar_live():
+    # dummy implementation before code is ready
+    return render_template('empty.html')
+
+
+@app.route('/record')
+def myCar_record():
+    # dummy implementation before code is ready
+    return render_template('empty.html')
+

二進制
static/img/pip.png


二進制
static/img/python.png


+ 1 - 1
templates/VERSION

@@ -1,2 +1,2 @@
-Version: 0.1
+Version: 0.3
 SVN-Commit: 

+ 10 - 7
templates/base.html

@@ -26,17 +26,20 @@
 
             <ul class="pure-menu-list">
 
-                <li class="pure-menu-item"><div class="pure-menu-link">Live Data</div></li>
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_live') }}" class="pure-menu-link">Live Data</a></li>
 
-                <li class="pure-menu-item"><div class="pure-menu-link">Recordings</div></li>
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_live') }}" class="pure-menu-link">Recordings</a></li>
    
                 <li class="pure-menu-item"><a href="{{ url_for('myCar_conf') }}" class="pure-menu-link">Configuration</a></li>
-                
-                    
-                <li class="pure-menu-item pure-menu-selected"><div class="pure-menu-link">Bluetooth</div></li>
 
-                <li class="pure-menu-item"><a href="{{ url_for('myCar_bluetooth_controller') }}" class="pure-menu-link">   Controller</a></li>
-                <li class="pure-menu-item"><a href="{{ url_for('myCar_bluetooth_devices') }}" class="pure-menu-link">   Devices</a></li>
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_bluetooth_controller') }}" class="pure-menu-link">Bluetooth Controller</a></li>
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_bluetooth_devices') }}" class="pure-menu-link">Bluetooth Devices</a></li>
+
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_gps') }}" class="pure-menu-link">GPS</a></li>
+
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_wifi') }}" class="pure-menu-link">WiFi</a></li>
+
+                <li class="pure-menu-item"><a href="{{ url_for('myCar_system') }}" class="pure-menu-link">System</a></li>
 
             </ul>
         </div>

+ 10 - 1
templates/conf/main.html

@@ -22,7 +22,16 @@
 
                     <div class="pure-control-group">
                                 <label for="[{{ section }}][{{ confval }}]">{{ confval }}</label>
-                                <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" value="{{ config[section][confval] }}" placeholder="{{ confval }}">
+
+                                {% if config[section][confval] == "True" %}
+                                     <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" type="radio" value="True" checked><label for="[{{ section }}][{{ confval }}]">True</label>
+                                     <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" type="radio" value="False"><label for="[{{ section }}][{{ confval }}]">False</label> 
+                                {% elif config[section][confval] == "False" %}
+                                     <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" type="radio" value="True"><label for="[{{ section }}][{{ confval }}]">True</label> 
+                                     <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" type="radio" value="False" checked><label for="[{{ section }}][{{ confval }}]">False</label>
+                                {% else %}
+                                    <input name="[{{ section }}][{{ confval }}]" id="[{{ section }}][{{ confval }}]" value="{{ config[section][confval] }}" placeholder="{{ confval }}">
+                                {% endif %}
                     </div>
               
                 {% endfor %}

+ 8 - 0
templates/empty.html

@@ -0,0 +1,8 @@
+{% extends 'base.html' %}
+{% block content %}
+
+
+<h1>Empty template</h1>
+
+
+{% endblock %}

+ 1 - 1
templates/index.html

@@ -6,7 +6,7 @@
 
 <div class="pure-g">
     <div class="pure-u-1-3">
-        {% if bt_ctrl_isactive == True %}
+        {% if bt_ctrl_ispowered == True %}
             <div class="pure-g">
                 <div class="pure-u-1-2"><img src="{{ url_for('static', filename='img/wireless_2_green.png') }}" class="pure-img"></div>
                 <div class="pure-u-1-2 myCar-text-green">Bluetooth Controller</div>

Some files were not shown because too many files changed in this diff