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
de2af576
Commit
de2af576
authored
Jul 17, 2018
by
Landon DeCoito
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored method names to use snake-case
parent
84563394
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
18 deletions
+16
-18
mason-today/__init__.py
mason-today/__init__.py
+3
-3
mason-today/appmethods.py
mason-today/appmethods.py
+8
-11
mason-today/getconnectedscript.py
mason-today/getconnectedscript.py
+1
-1
mason-today/redisactions.py
mason-today/redisactions.py
+4
-3
No files found.
mason-today/__init__.py
View file @
de2af576
...
@@ -4,7 +4,7 @@ from flask import Response
...
@@ -4,7 +4,7 @@ from flask import Response
from
flask
import
render_template
from
flask
import
render_template
# app imports
# app imports
from
appmethods
import
update
bothdbs
,
runschedule
loop
from
appmethods
import
update
_both_dbs
,
run_schedule_
loop
from
redisactions
import
redisdb
from
redisactions
import
redisdb
# python imports
# python imports
...
@@ -40,13 +40,13 @@ def display_GC_data():
...
@@ -40,13 +40,13 @@ def display_GC_data():
@
app
.
route
(
"/api/lastupdate"
)
@
app
.
route
(
"/api/lastupdate"
)
def
get
last
update
():
def
get
_last_
update
():
resp
=
Response
(
redisdb
.
lindex
(
"dbupdatelog"
,
0
).
replace
(
"
\n
"
,
"</br>"
))
resp
=
Response
(
redisdb
.
lindex
(
"dbupdatelog"
,
0
).
replace
(
"
\n
"
,
"</br>"
))
return
resp
return
resp
try
:
try
:
thread
.
start_new_thread
(
run
schedule
loop
,
())
thread
.
start_new_thread
(
run
_schedule_
loop
,
())
print
"started thread!"
print
"started thread!"
except
:
except
:
print
"==================================================="
\
print
"==================================================="
\
...
...
mason-today/appmethods.py
View file @
de2af576
# app imports
# app imports
from
parscript
import
load_data
from
parscript
import
load_data
from
getconnectedscript
import
load_g
etconn
_data
from
getconnectedscript
import
load_g
c
_data
import
redisactions
as
f
import
redisactions
as
f
# python imports
# python imports
...
@@ -14,27 +14,24 @@ import schedule
...
@@ -14,27 +14,24 @@ import schedule
# attempts to update both dbs and logs the result
# attempts to update both dbs and logs the result
def
update
both
dbs
():
def
update
_both_
dbs
():
livesuccess
=
f
.
live
db
fill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
))
livesuccess
=
f
.
live
_db_
fill
(
json
.
dumps
(
load_data
(),
ensure_ascii
=
False
))
gcsuccess
=
f
.
gc
dbfill
(
json
.
dumps
(
load_getconn
_data
(),
ensure_ascii
=
False
))
gcsuccess
=
f
.
gc
_db_fill
(
json
.
dumps
(
load_gc
_data
(),
ensure_ascii
=
False
))
successLog
=
str
(
datetime
.
datetime
.
now
())
\
successLog
=
str
(
datetime
.
datetime
.
now
())
\
+
"
\n\n
Attempted to update cache."
\
+
"
\n\n
Attempted to update cache."
\
+
"
\n
25Live: "
+
str
(
livesuccess
)
\
+
"
\n
25Live: "
+
str
(
livesuccess
)
\
+
"
\n
GC: "
+
str
(
gcsuccess
)
+
"
\n
GC: "
+
str
(
gcsuccess
)
f
.
append
toupdate
log
(
successLog
)
f
.
append
_to_update_
log
(
successLog
)
return
successLog
return
successLog
def
testprint
():
print
"Schedule action completed!"
# setting up cacheing
# 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
run
schedule
loop
():
def
run
_schedule_
loop
():
runScheduler
=
True
runScheduler
=
True
while
runScheduler
:
while
runScheduler
:
schedule
.
run_pending
()
schedule
.
run_pending
()
...
...
mason-today/getconnectedscript.py
View file @
de2af576
...
@@ -25,7 +25,7 @@ def splitAndConvertTime(strin):
...
@@ -25,7 +25,7 @@ def splitAndConvertTime(strin):
return
returnlist
return
returnlist
def
load_g
etconn
_data
():
def
load_g
c
_data
():
feedtext
=
requests
.
get
(
feedtext
=
requests
.
get
(
"https://getconnected.gmu.edu/events/events.rss"
).
text
"https://getconnected.gmu.edu/events/events.rss"
).
text
feedtext
=
cleanup
(
feedtext
)
feedtext
=
cleanup
(
feedtext
)
...
...
mason-today/redisactions.py
View file @
de2af576
...
@@ -15,13 +15,14 @@ import redis
...
@@ -15,13 +15,14 @@ import redis
# function. and every time we find an error we want to run a dberrorfill()
# function. and every time we find an error we want to run a dberrorfill()
# function.
# function.
# setting up redis database
# setting up redis database
redisdb
=
redis
.
from_url
(
"redis://localhost:6379/0"
,
db
=
0
)
redisdb
=
redis
.
from_url
(
"redis://localhost:6379/0"
,
db
=
0
)
# this will update the live dictlist and the cachedate
# this will update the live dictlist and the cachedate
# returns true if the dictlist is not empty, false otherwise
# returns true if the dictlist is not empty, false otherwise
def
gc
db
fill
(
dictlist
):
def
gc
_db_
fill
(
dictlist
):
success
=
redisdb
.
set
(
"gcdict"
,
dictlist
)
success
=
redisdb
.
set
(
"gcdict"
,
dictlist
)
log
=
str
(
datetime
.
datetime
.
now
())
log
=
str
(
datetime
.
datetime
.
now
())
...
@@ -33,7 +34,7 @@ def gcdbfill(dictlist):
...
@@ -33,7 +34,7 @@ def gcdbfill(dictlist):
# saves new dictlist in place of previous 25Live dictlist
# saves new dictlist in place of previous 25Live dictlist
# returns true if the dictlist is not empty, false otherwise
# returns true if the dictlist is not empty, false otherwise
def
live
db
fill
(
dictlist
):
def
live
_db_
fill
(
dictlist
):
success
=
redisdb
.
set
(
"livedict"
,
dictlist
)
success
=
redisdb
.
set
(
"livedict"
,
dictlist
)
log
=
str
(
datetime
.
datetime
.
now
())
log
=
str
(
datetime
.
datetime
.
now
())
...
@@ -45,7 +46,7 @@ def livedbfill(dictlist):
...
@@ -45,7 +46,7 @@ def livedbfill(dictlist):
# appends the log string to the head of our update long
# appends the log string to the head of our update long
# returns true if the head is the newest update
# returns true if the head is the newest update
def
append
toupdate
log
(
logstring
):
def
append
_to_update_
log
(
logstring
):
redisdb
.
lpush
(
"dbupdatelog"
,
logstring
)
redisdb
.
lpush
(
"dbupdatelog"
,
logstring
)
return
redisdb
.
lindex
(
"dbupdatelog"
,
0
)
==
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