# Path: indicomobile/util/date_time.py
# def nowutc():
#     return timezone('UTC').localize(datetime.utcnow())


import uuid
import pickle
from datetime import timedelta
from flask.sessions import SessionInterface, SessionMixin
from werkzeug.datastructures import CallbackDict
from redis import StrictRedis
from dateutil.parser import parse
from indicomobile.util.date_time import nowutc
        CallbackDict.__init__(self, initial, on_update)
        self.sid = sid
        self.new = new
        self.modified = False


class IndicoMobileSessionInterfaceBasic(SessionInterface):

    temporary_session_lifetime = timedelta(days=7)

    def generate_sid(self):
        return uuid.uuid4().hex

    def get_storage_expiration_time(self, app, session):
        if session.permanent:
            return int(session.get("oauth_token_ttl"))
        else:
            return self.temporary_session_lifetime

    def get_expiration_time(self, app, session):
        if session.permanent:
            return parse(session.get("oauth_token_expiration_timestamp"))

    def open_session(self, app, request):
        sid = request.cookies.get(app.session_cookie_name)
        if not sid:
            return self.session_class(sid=self.generate_sid(), new=True)
        stored_session = self._get_session(sid)
        if stored_session is not None:
            if (stored_session.get("oauth_token_expiration_timestamp")):

# Path: indicomobile/util/date_time.py
# def nowutc():
#     return timezone('UTC').localize(datetime.utcnow())


# Path: indicomobile/core/session_interface.py
import uuid
import pickle
from datetime import timedelta
from flask.sessions import SessionInterface, SessionMixin
from werkzeug.datastructures import CallbackDict
from redis import StrictRedis
from dateutil.parser import parse
from indicomobile.util.date_time import nowutc

        CallbackDict.__init__(self, initial, on_update)
        self.sid = sid
        self.new = new
        self.modified = False


class IndicoMobileSessionInterfaceBasic(SessionInterface):

    temporary_session_lifetime = timedelta(days=7)

    def generate_sid(self):
        return uuid.uuid4().hex

    def get_storage_expiration_time(self, app, session):
        if session.permanent:
            return int(session.get("oauth_token_ttl"))
        else:
            return self.temporary_session_lifetime

    def get_expiration_time(self, app, session):
        if session.permanent:
            return parse(session.get("oauth_token_expiration_timestamp"))

    def open_session(self, app, request):
        sid = request.cookies.get(app.session_cookie_name)
        if not sid:
            return self.session_class(sid=self.generate_sid(), new=True)
        stored_session = self._get_session(sid)
        if stored_session is not None:
            if (stored_session.get("oauth_token_expiration_timestamp")):

                if parse(stored_session.get("oauth_token_expiration_timestamp")) > nowutc():