Skip to content

Commit

Permalink
#42 avoid crushing if github sync does not work
Browse files Browse the repository at this point in the history
  • Loading branch information
marilenadaquino committed Oct 11, 2021
1 parent 50a76f3 commit b0320dc
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ def GET(self, name):
the record ID (a timestamp)
"""

web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
#web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
web.header("Content-Type","text/html; charset=utf-8")
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
Expand Down Expand Up @@ -505,7 +505,10 @@ def POST(self, name):
userID = user.replace('@','-at-').replace('.','-dot-')
file_path = mapping.inputToRDF(recordData, userID, 'not modified')
if conf.github_backup == "True":
github_sync.push(file_path,"main", session['gituser'], session['username'], session['bearer_token'])
try:
github_sync.push(file_path,"main", session['gituser'], session['username'], session['bearer_token'])
except Exception as e:
print(e)
whereto = prefixLocal+'/' if user == 'anonymous' else prefixLocal+'welcome-1'
raise web.seeother(whereto)
else:
Expand All @@ -523,7 +526,7 @@ def GET(self, name):
the record ID (a timestamp)
"""

web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
#web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
web.header("Content-Type","text/html; charset=utf-8")
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
Expand Down Expand Up @@ -588,8 +591,11 @@ def POST(self, name):
graphToClear = conf.base+name+'/'
file_path = mapping.inputToRDF(recordData, userID, 'modified', graphToClear)
if conf.github_backup == "True":
github_sync.push(file_path,"main", session['gituser'],
try:
github_sync.push(file_path,"main", session['gituser'],
session['username'], session['bearer_token'], '(modified)')
except Exception as e:
print(e)
u.log_output('MODIFIED RECORD', session['logged_in'], session['username'], recordID )
raise web.seeother(prefixLocal+'welcome-1')

Expand All @@ -605,7 +611,7 @@ def GET(self, name):
the record ID (a timestamp)
"""

web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
#web.header("Cache-Control", "no-cache, max-age=0, must-revalidate, no-store")
web.header("Content-Type","text/html; charset=utf-8")
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
Expand Down Expand Up @@ -670,8 +676,11 @@ def POST(self, name):
graphToClear = conf.base+name+'/'
file_path = mapping.inputToRDF(recordData, userID, 'modified',graphToClear)
if conf.github_backup == "True":
github_sync.push(file_path,"main", session['gituser'],
try:
github_sync.push(file_path,"main", session['gituser'],
session['username'], session['bearer_token'], '(reviewed)')
except Exception as e:
print(e)
u.log_output('REVIEWED (NOT PUBLISHED) RECORD', session['logged_in'], session['username'], recordID )
raise web.seeother(prefixLocal+'welcome-1')

Expand All @@ -695,8 +704,11 @@ def POST(self, name):
graphToClear = conf.base+name+'/'
file_path= mapping.inputToRDF(recordData, userID, 'published',graphToClear)
if conf.github_backup == "True":
github_sync.push(file_path,"main", session['gituser'],
try:
github_sync.push(file_path,"main", session['gituser'],
session['username'], session['bearer_token'], '(published)')
except Exception as e:
print(e)
u.log_output('PUBLISHED RECORD', session['logged_in'], session['username'], name )
raise web.seeother(prefixLocal+'welcome-1')

Expand Down

0 comments on commit b0320dc

Please sign in to comment.