Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Use a custom wrapper around time()
Browse files Browse the repository at this point in the history
  • Loading branch information
tdemin committed Jun 13, 2019
1 parent ac75f1b commit 4148095
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project_amber/handlers/session.py
@@ -1,10 +1,10 @@
from json import dumps
from time import time

from flask import request

from project_amber.const import MATURE_SESSION, MSG_IMMATURE_SESSION, EMPTY_RESP
from project_amber.errors import Forbidden
from project_amber.helpers import time
from project_amber.helpers.auth import handleChecks, getSessions, getSession,\
removeSessionById
from project_amber.logging import log
Expand Down
8 changes: 8 additions & 0 deletions project_amber/helpers/__init__.py
@@ -0,0 +1,8 @@
from time import time as time_lib

def time() -> int:
"""
Wrapper around `time.time()`. Converts the result to `int` to prevent
getting fractions of seconds on some platforms.
"""
return int(time_lib())
2 changes: 1 addition & 1 deletion project_amber/helpers/auth.py
@@ -1,13 +1,13 @@
from hashlib import sha256
from base64 import b64encode
from time import time

from bcrypt import hashpw, gensalt, checkpw
from flask import request

from project_amber.const import MSG_NO_TOKEN, MSG_INVALID_TOKEN, \
MSG_USER_NOT_FOUND, MSG_USER_EXISTS
from project_amber.db import db
from project_amber.helpers import time
from project_amber.errors import Unauthorized, BadRequest, NotFound, \
InternalServerError, Conflict
from project_amber.logging import log
Expand Down
3 changes: 1 addition & 2 deletions project_amber/helpers/task.py
@@ -1,8 +1,7 @@
from time import time

from project_amber.const import MSG_TASK_NOT_FOUND, MSG_TASK_DANGEROUS
from project_amber.db import db
from project_amber.errors import NotFound, BadRequest
from project_amber.helpers import time
from project_amber.models.task import Task

def addTask(text: str, status: int, uid: int) -> int:
Expand Down

0 comments on commit 4148095

Please sign in to comment.