Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
mason-today-web
Commits
de2af576
Commit
de2af576
authored
Jul 17, 2018
by
Landon DeCoito
Browse files
refactored method names to use snake-case
parent
84563394
Changes
4
Hide whitespace changes
Inline
Side-by-side
mason-today/__init__.py
View file @
de2af576
...
...
@@ -4,7 +4,7 @@ from flask import Response
from
flask
import
render_template
# app imports
from
appmethods
import
updatebothdbs
,
runscheduleloop
from
appmethods
import
update
_
both
_
dbs
,
run
_
schedule
_
loop
from
redisactions
import
redisdb
# python imports
...
...
@@ -40,13 +40,13 @@ def display_GC_data():
@
app
.
route
(
"/api/lastupdate"
)
def
getlastupdate
():
def
get
_
last
_
update
():
resp
=
Response
(
redisdb
.
lindex
(
"dbupdatelog"
,
0
).
replace
(
"
\n
"
,
"</br>"
))
return
resp
try
:
thread
.
start_new_thread
(
runscheduleloop
,
())
thread
.
start_new_thread
(
run
_
schedule
_
loop
,
())
print
"started thread!"
except
:
print
"==================================================="
\
...
...
mason-today/appmethods.py
View file @
de2af576
# app imports
from
parscript
import
load_data
from
getconnectedscript
import
load_g
etconn
_data
from
getconnectedscript
import
load_g
c
_data
import
redisactions
as
f
# python imports
...
...
@@ -14,27 +14,24 @@ import schedule
# attempts to update both dbs and logs the result
def
updatebothdbs
():
livesuccess
=
f
.
livedbfill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
))
gcsuccess
=
f
.
gcdbfill
(
json
.
dumps
(
load_g
etconn
_data
(),
ensure_ascii
=
False
))
def
update
_
both
_
dbs
():
livesuccess
=
f
.
live
_
db
_
fill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
))
gcsuccess
=
f
.
gc
_
db
_
fill
(
json
.
dumps
(
load_g
c
_data
(),
ensure_ascii
=
False
))
successLog
=
str
(
datetime
.
datetime
.
now
())
\
+
"
\n\n
Attempted to update cache."
\
+
"
\n
25Live: "
+
str
(
livesuccess
)
\
+
"
\n
GC: "
+
str
(
gcsuccess
)
f
.
appendtoupdatelog
(
successLog
)
f
.
append
_
to
_
update
_
log
(
successLog
)
return
successLog
def
testprint
():
print
"Schedule action completed!"
# setting up cacheing
schedule
.
every
().
day
.
at
(
"02:00"
).
do
(
updatebothdbs
)
# this must be done after the update_both_dbs def
schedule
.
every
().
day
.
at
(
"02:00"
).
do
(
update_both_dbs
)
def
runscheduleloop
():
def
run
_
schedule
_
loop
():
runScheduler
=
True
while
runScheduler
:
schedule
.
run_pending
()
...
...
mason-today/getconnectedscript.py
View file @
de2af576
...
...
@@ -25,7 +25,7 @@ def splitAndConvertTime(strin):
return
returnlist
def
load_g
etconn
_data
():
def
load_g
c
_data
():
feedtext
=
requests
.
get
(
"https://getconnected.gmu.edu/events/events.rss"
).
text
feedtext
=
cleanup
(
feedtext
)
...
...
mason-today/redisactions.py
View file @
de2af576
...
...
@@ -15,13 +15,14 @@ import redis
# function. and every time we find an error we want to run a dberrorfill()
# function.
# setting up redis database
redisdb
=
redis
.
from_url
(
"redis://localhost:6379/0"
,
db
=
0
)
# this will update the live dictlist and the cachedate
# returns true if the dictlist is not empty, false otherwise
def
gcdbfill
(
dictlist
):
def
gc
_
db
_
fill
(
dictlist
):
success
=
redisdb
.
set
(
"gcdict"
,
dictlist
)
log
=
str
(
datetime
.
datetime
.
now
())
...
...
@@ -33,7 +34,7 @@ def gcdbfill(dictlist):
# saves new dictlist in place of previous 25Live dictlist
# returns true if the dictlist is not empty, false otherwise
def
livedbfill
(
dictlist
):
def
live
_
db
_
fill
(
dictlist
):
success
=
redisdb
.
set
(
"livedict"
,
dictlist
)
log
=
str
(
datetime
.
datetime
.
now
())
...
...
@@ -45,7 +46,7 @@ def livedbfill(dictlist):
# appends the log string to the head of our update long
# returns true if the head is the newest update
def
appendtoupdatelog
(
logstring
):
def
append
_
to
_
update
_
log
(
logstring
):
redisdb
.
lpush
(
"dbupdatelog"
,
logstring
)
return
redisdb
.
lindex
(
"dbupdatelog"
,
0
)
==
logstring
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