From 46192b0a0305437f2bb2291afb5c5682ea3a3d3b Mon Sep 17 00:00:00 2001 From: Navan Chauhan Date: Mon, 24 Aug 2020 16:14:23 +0530 Subject: [PATCH] added check for WiFi @ Home --- app/__init__.py | 12 ++++++++++++ app/dock_docker.py | 3 ++- app/views.py | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 7c47fd8..c018044 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -4,6 +4,18 @@ from flask import Flask # location where file uploads will be stored UPLOAD_FOLDER = './app/static/uploads' DB_HOST = 'navanspi.duckdns.org' #'navanspi.duckdns.org' + +import subprocess +import hashlib +ssid = b'j\xa0\x1b\xd6p\xe9\xa4\\b\x12\xedD\xaeX\x8a\xf8' + +try: + output = subprocess.check_output(['sudo', 'iwgetid']) + if hashlib.md5(bytes(output.decode().split('"')[1],encoding="utf-8")).digest() == ssid: + DB_HOST = '192.168.1.6' +except: + None + DB_PORT = 3306 DB_USER = 'curieweb' DB_PASSWORD = 'curie-web-russian-54' diff --git a/app/dock_docker.py b/app/dock_docker.py index 78f74e1..5906520 100644 --- a/app/dock_docker.py +++ b/app/dock_docker.py @@ -1,6 +1,7 @@ import mysql.connector as con +from app import app -mycon = con.connect(host="192.168.1.6",user="curieweb",password="curie-web-russian-54",port=3306,database="curie") +mycon = con.connect(host=app.config['DB_HOST'],user="curieweb",password="curie-web-russian-54",port=3306,database="curie") mycursor = mycon.cursor() sql_select_Query = "select * from curieweb where done=0 LIMIT 1" diff --git a/app/views.py b/app/views.py index 89b0374..03e74f4 100644 --- a/app/views.py +++ b/app/views.py @@ -133,7 +133,7 @@ def wtform(): flash_errors(myform) return render_template('wtform.html', form=myform) -tfWorking = 0 +tfWorking = -1 if tfWorking == -1: try: