• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zopefoundation / Zope / 6263629025

21 Sep 2023 03:12PM UTC coverage: 82.146% (-0.01%) from 82.159%
6263629025

Pull #1164

github

web-flow
[pre-commit.ci lite] apply automatic fixes
Pull Request #1164: Move all linters to pre-commit.

4353 of 6963 branches covered (0.0%)

Branch coverage included in aggregate %.

487 of 487 new or added lines in 186 files covered. (100.0%)

27394 of 31684 relevant lines covered (86.46%)

0.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Zope2/utilities/adduser.py
1
##############################################################################
2
#
3
# Copyright (c) 2010 Zope Foundation and Contributors.
4
#
5
# This software is subject to the provisions of the Zope Public License,
6
# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
7
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
8
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
9
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
10
# FOR A PARTICULAR PURPOSE
11
#
12
##############################################################################
13
"""Add a Zope management user to the root Zope user folder."""
×
14

15
import argparse
×
16
import sys
×
17

18
from Zope2.utilities.finder import ZopeFinder
×
19

20

21
def adduser(app, user, pwd):
×
22
    import transaction
×
23
    result = app.acl_users._doAddUser(user, pwd, ['Manager'], [])
×
24
    transaction.commit()
×
25
    return result
×
26

27

28
def main(argv=sys.argv):
×
29
    parser = argparse.ArgumentParser(
×
30
        description='Add a Zope management user to the root Zope user folder.'
31
    )
32
    parser.add_argument(
×
33
        "-c",
34
        "--configuration",
35
        help="Path to Zope configuration file",
36
        nargs="?",
37
        type=str,
38
        default=None,
39
    )
40
    parser.add_argument("user", help="name of user to be created")
×
41
    parser.add_argument("password", help="new password for the user")
×
42
    args = parser.parse_args(argv[1:])
×
43
    finder = ZopeFinder(argv)
×
44
    finder.filter_warnings()
×
45
    app = finder.get_app(config_file=args.configuration)
×
46
    result = adduser(app, args.user, args.password)
×
47
    if result:
×
48
        print(f"User {args.user} created.")
×
49
    else:
50
        print("Got no result back. User creation may have failed.")
×
51
        print("Maybe the user already exists and nothing is done then.")
×
52
        print("Or the implementation does not give info when it succeeds.")
×
53

54

55
if __name__ == '__main__':
56
    main()
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc