Skip to content

Commit

Permalink
resolve python 3 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gsksivesh committed May 14, 2019
1 parent 02215b0 commit 3eb2116
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: python

python:
- "2.7"
- "3.6"

install:
- "pip install -r requirements.txt"
Expand Down
8 changes: 6 additions & 2 deletions dagobah/backend/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def is_object_id(o):
def commit_dagobah(self, dagobah_json):
dagobah_json['_id'] = dagobah_json['dagobah_id']
append = {'save_date': datetime.utcnow()}
self.dagobah_coll.save(dict(dagobah_json.items() + append.items()))
result_dict = dagobah_json.copy()
result_dict.update(append)
self.dagobah_coll.save(result_dict)

def delete_dagobah(self, dagobah_id):
""" Deletes the Dagobah and all child Jobs from the database.
Expand All @@ -114,7 +116,9 @@ def delete_dagobah(self, dagobah_id):
def commit_job(self, job_json):
job_json['_id'] = job_json['job_id']
append = {'save_date': datetime.utcnow()}
self.job_coll.save(dict(job_json.items() + append.items()))
result_dict = job_json.copy()
result_dict.update(append)
self.job_coll.save(result_dict)

def delete_job(self, job_id):
self.job_coll.remove({'_id': job_id})
Expand Down
2 changes: 2 additions & 0 deletions dagobah/core/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def default(self, o):
from bson import ObjectId
if isinstance(o, ObjectId):
return str(o)
if isinstance(o, bytes):
return str(o)
except ImportError:
pass
if isinstance(o, datetime):
Expand Down
2 changes: 1 addition & 1 deletion dagobah/daemon/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def do_login():
""" Attempt to auth using single login. Rate limited at the site level. """

dt_filter = lambda x: x >= datetime.utcnow() - timedelta(seconds=60)
app.config['AUTH_ATTEMPTS'] = filter(dt_filter, app.config['AUTH_ATTEMPTS'])
app.config['AUTH_ATTEMPTS'] = list(filter(dt_filter, app.config['AUTH_ATTEMPTS']))

if len(app.config['AUTH_ATTEMPTS']) > app.config['AUTH_RATE_LIMIT']:
return redirect(url_for('login',
Expand Down
2 changes: 2 additions & 0 deletions dagobah/daemon/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ def default(self, obj):
try:
if isinstance(obj, ObjectId):
return str(obj)
if isinstance(obj, bytes):
return str(obj)
except NameError:
pass

Expand Down
2 changes: 1 addition & 1 deletion dagobah/email/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from datetime import datetime
# noinspection PyUnresolvedReferences
from email.MIMEMultipart import MIMEMultipart
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

import premailer
Expand Down

0 comments on commit 3eb2116

Please sign in to comment.