Compare commits
4 Commits
master
...
POCONSOLE-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf49309391 | ||
|
|
b0b964c45a | ||
|
|
5de541fc59 | ||
|
|
43f9ed378b |
1
.gitignore
vendored
@@ -5,3 +5,4 @@ sails/.tmp
|
||||
.remote-sync.json
|
||||
database.db
|
||||
venv/
|
||||
Henry_Pump_WebServer.egg-info/
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
# app/__init__.py
|
||||
|
||||
import os
|
||||
from flask import Flask
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
@@ -8,17 +9,17 @@ from flask_sqlalchemy import SQLAlchemy
|
||||
|
||||
UPLOAD_FOLDER = os.path.join(os.getcwd(), 'app', 'docs')
|
||||
|
||||
app = Flask('app', static_url_path='')
|
||||
app = Flask('app', static_url_path='', static_folder="hp_webserver/static")
|
||||
app.config.update(
|
||||
DEBUG=True,
|
||||
# SQLALCHEMY_DATABASE_URI='mysql+mysqlconnector://website:henrypump@127.0.0.1/poconsole'
|
||||
SQLALCHEMY_DATABASE_URI='sqlite:///../database.db',
|
||||
SQLALCHEMY_DATABASE_URI='sqlite:///./database.db',
|
||||
)
|
||||
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024
|
||||
app.secret_key = 'henry_pump'
|
||||
db = SQLAlchemy(app)
|
||||
|
||||
from datalogger import views
|
||||
from datalogger import api
|
||||
from datalogger.models import *
|
||||
from hp_webserver.datalogger import views
|
||||
from hp_webserver.datalogger import api
|
||||
from hp_webserver.datalogger.models import *
|
||||
1
hp_webserver/__main__.py
Normal file
@@ -0,0 +1 @@
|
||||
print("MAIN IN hp_datalogger")
|
||||
1
hp_webserver/datalogger/__main__.py
Normal file
@@ -0,0 +1 @@
|
||||
print("THIS IS THE MAIN FROM datalogger")
|
||||
@@ -2,8 +2,8 @@ from pycomm.ab_comm.clx import Driver as ClxDriver
|
||||
import traceback
|
||||
import math
|
||||
|
||||
from app.datalogger.models import Device
|
||||
from app import db
|
||||
from hp_webserver.datalogger.models import Device
|
||||
from hp_webserver import db
|
||||
|
||||
|
||||
def getMainPLC():
|
||||
@@ -7,9 +7,9 @@ from sqlalchemy import and_, desc
|
||||
from sqlalchemy.sql import func
|
||||
from datetime import datetime
|
||||
|
||||
from app import app, db
|
||||
from app.datalogger.models import *
|
||||
from app.datalogger.getDailyTotals import getTotals
|
||||
from hp_webserver import app, db
|
||||
from hp_webserver.datalogger.models import *
|
||||
from hp_webserver.datalogger.getDailyTotals import getTotals
|
||||
from pycomm_helper.utils import readTag, writeTag
|
||||
from random import random
|
||||
|
||||
@@ -52,6 +52,7 @@ def tagsattime_to_obj(tup):
|
||||
@app.route('/', defaults={'path': ''})
|
||||
@app.route('/<path:path>')
|
||||
def catch_all(path):
|
||||
print("caught something!")
|
||||
return app.send_static_file('index.html')
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 357 KiB After Width: | Height: | Size: 357 KiB |
0
app/static/images/icons/_blank.png → hp_webserver/static/images/icons/_blank.png
Executable file → Normal file
|
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
0
app/static/images/icons/_page.png → hp_webserver/static/images/icons/_page.png
Executable file → Normal file
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
app/static/images/icons/doc.png → hp_webserver/static/images/icons/doc.png
Executable file → Normal file
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
0
app/static/images/icons/gif.png → hp_webserver/static/images/icons/gif.png
Executable file → Normal file
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
0
app/static/images/icons/jpg.png → hp_webserver/static/images/icons/jpg.png
Executable file → Normal file
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
0
app/static/images/icons/pdf.png → hp_webserver/static/images/icons/pdf.png
Executable file → Normal file
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
app/static/images/icons/png.png → hp_webserver/static/images/icons/png.png
Executable file → Normal file
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
0
app/static/images/icons/txt.png → hp_webserver/static/images/icons/txt.png
Executable file → Normal file
|
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
0
app/static/images/icons/xls.png → hp_webserver/static/images/icons/xls.png
Executable file → Normal file
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
app/static/images/icons/xlsx.png → hp_webserver/static/images/icons/xlsx.png
Executable file → Normal file
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
0
app/static/images/icons/zip.png → hp_webserver/static/images/icons/zip.png
Executable file → Normal file
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 130 KiB |
8
run.py
@@ -1,8 +1,8 @@
|
||||
from app import app
|
||||
from hp_webserver import app
|
||||
import ssl
|
||||
|
||||
# context = ssl.SSLContext(protocol=ssl.PROTOCOL_TLSv1_2)
|
||||
# context.load_cert_chain('/Users/patrickjmcd/Henry_Pump/tagserver/web_db/flask/app/hplumberjack.crt', '/Users/patrickjmcd/Henry_Pump/tagserver/web_db/flask/app/hplumberjack.key')
|
||||
def run_app():
|
||||
app.run(host="0.0.0.0", debug=True, ssl_context='adhoc')
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run(host="0.0.0.0", debug=True, ssl_context='adhoc')
|
||||
run_app()
|
||||
|
||||
18
setup.py
Normal file
@@ -0,0 +1,18 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='Henry Pump WebServer',
|
||||
version='2.0',
|
||||
long_description=__doc__,
|
||||
packages=['hp_webserver', 'hp_webserver.datalogger'],
|
||||
include_package_data=True,
|
||||
zip_safe=False,
|
||||
install_requires=[
|
||||
'Flask>=0.11.1',
|
||||
'Flask-Restless>=0.17.0',
|
||||
'Flask-SQLAlchemy>=2.1',
|
||||
'pyOpenSSL>=16.2.0',
|
||||
'requests>=2.12.1',
|
||||
'Twisted>=16.6.0',
|
||||
]
|
||||
)
|
||||
16
setupdb.py
@@ -1,18 +1,20 @@
|
||||
import sys
|
||||
# the sqlalchemy db object
|
||||
from app import db
|
||||
from hp_webserver import db
|
||||
|
||||
# we have to import the models so that sqlalchemy can detect them and create the db
|
||||
# how else would it know what to create ?
|
||||
from app.datalogger.models import *
|
||||
from hp_webserver.datalogger.models import *
|
||||
|
||||
|
||||
def main():
|
||||
def setupdb(seed=False):
|
||||
# creates the database
|
||||
db.create_all()
|
||||
|
||||
# after the last command you should now be able to see database.db file
|
||||
# in the project folder
|
||||
if seed:
|
||||
seed()
|
||||
|
||||
|
||||
def seed():
|
||||
@@ -138,11 +140,15 @@ def seed():
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
try:
|
||||
if sys.argv[1] == "seed":
|
||||
seed()
|
||||
setupdb(seed=True)
|
||||
print("Created database.db file and seeded data.")
|
||||
else:
|
||||
setupdb()
|
||||
except Exception as e:
|
||||
setupdb()
|
||||
print("Created database.db file. To seed data, run 'python setupdb.py seed'")
|
||||
|
||||
2
start.sh
@@ -1,5 +1,5 @@
|
||||
#!/bin/bash
|
||||
OLDDIR=$PWD
|
||||
cd /root/www
|
||||
twistd --pidfile=/root/webserver.pid web --https=5000 --wsgi app.app -c /root/ssl/poconsole.crt -k /root/ssl/poconsole.key
|
||||
twistd --pidfile=/root/webserver.pid web --https=5000 --wsgi hp_webserver.app -c /root/ssl/poconsole.crt -k /root/ssl/poconsole.key
|
||||
cd $OLDDIR
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import sys
|
||||
# the sqlalchemy db object
|
||||
from app import db
|
||||
|
||||
# we have to import the models so that sqlalchemy can detect them and create the db
|
||||
# how else would it know what to create ?
|
||||
from app.datalogger.models import *
|
||||
|
||||
num_tapers = BackupRestore(tag="Card_Current.Params.Num_Tapers", device_id=1)
|
||||
taper_length = [BackupRestore(tag="Taper.Taper[{}].Setup.Length".format(i), device_id=1) for i in range(1, 10)]
|
||||
taper_diameter = [BackupRestore(tag="Taper.Taper[{}].Setup.Diameter".format(i), device_id=1) for i in range(1, 10)]
|
||||
taper_material = [BackupRestore(tag="Taper.Taper[{}].Setup.Material".format(i), device_id=1) for i in range(1, 10)]
|
||||
pump_diameter = BackupRestore(tag='UnitConfig.Pump_Diameter', device_id=1)
|
||||
|
||||
db.session.add(num_tapers)
|
||||
for i in range(0, len(taper_length)):
|
||||
db.session.add(taper_length[i])
|
||||
|
||||
for i in range(0, len(taper_diameter)):
|
||||
db.session.add(taper_diameter[i])
|
||||
|
||||
for i in range(0, len(taper_material)):
|
||||
db.session.add(taper_material[i])
|
||||
|
||||
db.session.add(pump_diameter)
|
||||
|
||||
db.session.commit()
|
||||