当前位置: 首页>>代码示例>>Python>>正文


Python time.now函数代码示例

本文整理汇总了Python中websauna.utils.time.now函数的典型用法代码示例。如果您正苦于以下问题:Python now函数的具体用法?Python now怎么用?Python now使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了now函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: resolve

    def resolve(self, capture_data: Optional[dict]=None):

        if now() > self.deadline_at:
            raise ManualConfirmationError("Cannot confirm after deadline.")

        self.action_taken_at = now()
        self.state = ManualConfirmationState.resolved

        self.update_capture_data(capture_data)
开发者ID:websauna,项目名称:websauna.wallet,代码行数:9,代码来源:confirmation.py

示例2: mark_performed

    def mark_performed(self):
        """
        Incoming: This operation has been registered to database. It may need more confirmations.

        Outgoing: This operation has been broadcasted to network. It's completion and confirmation might require further network confirmations."""
        self.performed_at = now()
        self.state = CryptoOperationState.pending
开发者ID:websauna,项目名称:websauna.wallet,代码行数:7,代码来源:blockchain.py

示例3: main

def main(argv=sys.argv):

    if len(argv) < 3:
        usage(argv)

    config_uri = argv[1]
    request = init_websauna(config_uri)

    User = get_user_class(request.registry)
    dbsession = request.dbsession

    if len(argv) == 4:
        password = argv[3]
    else:
        password = getpass.getpass("Password:")
        password2 = getpass.getpass("Password (again):")

        if password != password2:
            sys.exit("Password did not match")

    with transaction.manager:
        u = User(email=argv[2], username=argv[2])
        u.password = password
        u.registration_source = "command_line"
        u.activated_at = now()
        dbsession.add(u)
        dbsession.flush()

        request.registry.notify(UserCreated(request, u))

        print("Created user #{}: {}, admin: {}".format(u.id, u.email, u.is_admin()))
开发者ID:agronholm,项目名称:websauna,代码行数:31,代码来源:createuser.py

示例4: create_user

def create_user(dbsession:Session, registry:Registry, email:str=EMAIL, password:str=PASSWORD, admin:bool=False) -> User:
    """A helper function to create normal and admin users for tests.

    :param admin: If True run :py:class:`websauna.system.user.usermixin.SiteCreator` login and set the user to admin group.
    """

    user = User(email=email)

    if password:
        hasher = registry.getUtility(IPasswordHasher)
        user.hashed_password = hasher.hash_password(password)

    user.user_registration_source = "dummy"
    dbsession.add(user)
    dbsession.flush()
    user.username = user.generate_username()
    user.activated_at = now()

    assert user.can_login()

    # First user, make it admin
    if admin:
        site_creator = get_site_creator(registry)
        site_creator.init_empty_site(dbsession, user)

    return user
开发者ID:debonzi,项目名称:websauna,代码行数:26,代码来源:utils.py

示例5: create

def create(request, username, email, password=None, source="command_line", admin=False):
    """Create a new site user from command line.

    :param request:
    :param username:
    :param email:
    :param password:
    :param source:
    :param admin: Set this user to admin. The first user is always implicitly admin.
    :return:
    """
    User = get_user_class(request.registry)
    dbsession = request.dbsession
    u = dbsession.query(User).filter_by(email=email).first()
    if u is not None:
        return u

    u = User(email=email, username=username)

    if password:
        user_registry = get_user_registry(request)
        user_registry.set_password(u, password)

    u.registration_source = source
    u.activated_at = now()
    dbsession.add(u)
    dbsession.flush()

    request.registry.notify(UserCreated(request, u))

    if admin:
        group = dbsession.query(Group).filter_by(name="admin").one_or_none()
        group.users.append(u)

    return u
开发者ID:websauna,项目名称:websauna,代码行数:35,代码来源:createuser.py

示例6: add_object

    def add_object(self, obj):
        """Flush newly created object to persist storage."""

        # Users created through admin are useable right away
        obj.activated_at = now()

        super(UserAdd, self).add_object(obj)
开发者ID:agronholm,项目名称:websauna,代码行数:7,代码来源:adminviews.py

示例7: reset_password

    def reset_password(self, user: UserMixin, password: str):
        """Reset user password and clear all pending activation issues."""

        self.set_password(user, password)

        if not user.activated_at:
            user.activated_at = now()
        self.dbsession.delete(user.activation)
开发者ID:LukeSwart,项目名称:websauna,代码行数:8,代码来源:userregistry.py

示例8: initialize_object

    def initialize_object(self, form, appstruct, obj: User):
        password = appstruct.pop("password")
        form.schema.objectify(appstruct, obj)
        hasher = self.request.registry.getUtility(IPasswordHasher)
        obj.hashed_password = hasher.hash_password(password)

        # Users created through admin are useable right away, so activate the user
        obj.activated_at = now()
开发者ID:frispete,项目名称:websauna,代码行数:8,代码来源:adminviews.py

示例9: create_blank_user

 def create_blank_user(self, user_model, dbsession, email) -> IUserModel:
     """Create a new blank user instance as we could not find matching user with the existing details."""
     user = user_model(email=email)
     dbsession.add(user)
     dbsession.flush()
     user.username = user.generate_username()
     user.registration_source = self.provider_id
     user.activated_at = now()
     return user
开发者ID:frispete,项目名称:websauna,代码行数:9,代码来源:social.py

示例10: mark_cancelled

    def mark_cancelled(self, error: Optional[str]=None):
        """This operation cannot be completed.

        Calling this implies automatic :meth:`reverse` of the operation.
        """
        self.failed_at = now()
        self.state = CryptoOperationState.cancelled
        self.other_data["error"] = error
        self.reverse()
开发者ID:websauna,项目名称:websauna.wallet,代码行数:9,代码来源:blockchain.py

示例11: update_login_data

    def update_login_data(self, user):
        request = self.request
        if not user.last_login_at:
            e = events.FirstLogin(request, user)
            request.registry.notify(e)

        # Update user security details
        user.last_login_at = now()
        user.last_login_ip = request.client_addr
开发者ID:LukeSwart,项目名称:websauna,代码行数:9,代码来源:loginservice.py

示例12: activate_user

    def activate_user(request, dbsession, user):
        """Checks to perform when the user becomes a valid user for the first time.

        If this user has already started sign up process through email we need to cancel that.
        """
        user.activated_at = now()

        # Cancel any pending email activations if the user chooses the option to use social media login
        if user.activation:
            dbsession.delete(user.activation)
开发者ID:frispete,项目名称:websauna,代码行数:10,代码来源:social.py

示例13: require_confirmation

    def require_confirmation(cls, user: User, phone_number, timeout=4*3600):
        assert cls.get_pending_confirmation(user) == None
        dbsession = Session.object_session(user)

        confirmation = UserNewPhoneNumberConfirmation()
        confirmation.user = user
        confirmation.deadline_at = now() + datetime.timedelta(seconds=timeout)
        confirmation.require_sms(phone_number)
        dbsession.add(confirmation)
        dbsession.flush()
        return confirmation
开发者ID:websauna,项目名称:websauna.wallet,代码行数:11,代码来源:confirmation.py

示例14: user_auth_details_changes

def user_auth_details_changes(event:UserAuthSensitiveOperation):
    """Default logic how to invalidate sessions on user auth detail changes.

    If you are using different session management model you can install a custom handle.

    :param event: Incoming event instance
    """

    user = event.user

    # Update the timestamp which session validation checks on every request
    user.last_auth_sensitive_operation_at = now()
开发者ID:LukeSwart,项目名称:websauna,代码行数:12,代码来源:subscribers.py

示例15: check_wallet_creation

def check_wallet_creation(request) -> bool:
    """Check if we have notified this user about wallet creation yet.

    :return: True if this was a wallet creation event
    """
    user = request.user

    if not "wallet_creation_notified_at" in request.user.user_data:
        request.user.user_data["wallet_creation_notified_at"] = now().isoformat()
        request.registry.notify(WalletCreated(request, user))
        return True
    else:
        return False
开发者ID:websauna,项目名称:websauna.wallet,代码行数:13,代码来源:starterassets.py


注:本文中的websauna.utils.time.now函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。