Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mason-today-web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
8
Issues
8
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SRCT
mason-today-web
Commits
60e4d24d
Commit
60e4d24d
authored
May 18, 2018
by
Landon DeCoito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
started database implementation. added redisactions.py to facilitate that
parent
f4c6fb68
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
4 deletions
+51
-4
mason-today/__init__.py
mason-today/__init__.py
+11
-4
mason-today/redisactions.py
mason-today/redisactions.py
+40
-0
No files found.
mason-today/__init__.py
View file @
60e4d24d
...
...
@@ -10,8 +10,15 @@ from getconnectedscript import load_getconn_data
# python imports
import
json
# other imports
import
redis
from
redisactions
import
*
# setting up flask instance
app
=
Flask
(
__name__
)
# setting up redis database
redisdb
=
redis
.
from_url
(
"redis://localhost:6379/0"
,
db
=
0
)
@
app
.
route
(
"/"
)
def
display_default
():
...
...
@@ -21,15 +28,15 @@ def display_default():
@
app
.
route
(
"/api/25live"
)
def
display_data
():
resp
=
Response
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
)
.
encode
(
'utf-8'
))
livedbfill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
)
)
resp
=
Response
(
redisdb
.
get
(
"livedict"
))
#
.encode('utf-8'))
resp
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
return
resp
@
app
.
route
(
"/api/getconnected"
)
def
display_GC_data
():
resp
=
Response
(
json
.
dumps
(
load_getconn_data
(),
ensure_ascii
=
False
)
.
encode
(
'utf-8'
))
gcdbfill
(
json
.
dumps
(
load_getconn_data
(),
ensure_ascii
=
False
)
)
resp
=
Response
(
redisdb
.
get
(
"gcdict"
))
#
.encode('utf-8'))
resp
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
return
resp
mason-today/redisactions.py
0 → 100644
View file @
60e4d24d
# third party imports
import
redis
from
__init__
import
redisdb
# I'm thinking we store a couple things
# first: a key-value where the value is the dictlist
# second: a k-v for a list of errored events
# use rpush(key, value) to append a dblist (rpushx() to check if it exists)
# use del(key) to remove a k-v
# so we everytime we run parscript or gcscript we want to run a dbfill()
# function. and every time we find an error we want to run a dberrorfill()
# function.
# this will update the
# returns true if the dictlist is not empty, false otherwise
def
gcdbfill
(
dictlist
):
try
:
redisdb
.
set
(
"gcdict"
,
dictlist
)
except
e
:
return
False
if
redisdb
.
get
(
"gcdict"
)
is
not
None
:
return
True
else
:
return
False
# saves new dictlist in place of previous 25Live dictlist
# returns true if the dictlist is empty, false otherwise
def
livedbfill
(
dictlist
):
try
:
redisdb
.
set
(
"livedict"
,
dictlist
)
except
e
:
return
False
if
redisdb
.
get
(
"livedict"
)
is
not
None
:
return
True
else
:
return
False
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment