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

tableau / tabcmd / 16681203295

01 Aug 2025 05:21PM UTC coverage: 84.429%. First build
16681203295

Pull #286

github

web-flow
Merge 9f9a4e1c1 into 9b227d4ed
Pull Request #286: Replace raw strings with translation calls

53 of 63 new or added lines in 9 files covered. (84.13%)

2299 of 2723 relevant lines covered (84.43%)

0.84 hits per line

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

83.33
/tabcmd/commands/user/create_users_command.py
1
import tableauserverclient as TSC
1✔
2

3
from tabcmd.commands.auth.session import Session
1✔
4
from tabcmd.commands.constants import Errors
1✔
5
from tabcmd.execution.global_options import *
1✔
6
from tabcmd.execution.localize import _
1✔
7
from tabcmd.execution.logger_config import log
1✔
8
from .user_data import UserCommand
1✔
9

10

11
class CreateUsersCommand(UserCommand):
1✔
12
    """
13
    Command to add users to a site, based on information supplied in a comma-separated values (CSV) file.
14
    If the user is not already created on the server, the command creates the user before adding
15
    that user to the site
16
    """
17

18
    name: str = "createUsers"
1✔
19
    description: str = _("createusers.short_description")
1✔
20

21
    @staticmethod
1✔
22
    def define_args(create_users_parser):
1✔
23
        args_group = create_users_parser.add_argument_group(title=CreateUsersCommand.name)
1✔
24
        UserCommand.set_role_arg(args_group)
1✔
25
        set_users_file_positional(args_group)
1✔
26
        set_completeness_options(args_group)
1✔
27
        UserCommand.set_auth_arg(args_group)
1✔
28

29
    @staticmethod
1✔
30
    def run_command(args):
1✔
31
        logger = log(__class__.__name__, args.logging_level)
1✔
32
        logger.debug(_("tabcmd.launching"))
1✔
33
        session = Session()
1✔
34
        server = session.create_session(args, logger)
1✔
35
        number_of_users_listed = 0
1✔
36
        number_of_users_added = 0
1✔
37
        number_of_errors = 0
1✔
38

39
        ## TODO
40
        # If the server has only one site (the default site), the user is created and added to the site.
41
        # If the server has multiple sites, the user is created but is not added to any site.
42
        # To add users to a site, use createsiteusers.
43
        if args.site_name:
1✔
44
            creation_site = args.site_name
×
45
        else:
46
            creation_site = "current site"
1✔
47

48
        UserCommand.validate_file_for_import(args.filename, logger, detailed=True, strict=args.require_all_valid)
1✔
49

50
        logger.info(_("createusers.status").format(args.filename.name))
1✔
51
        user_obj_list = UserCommand.get_users_from_file(args.filename, logger)
1✔
52
        logger.info(_("session.monitorjob.percent_complete").format(0))
1✔
53
        error_list = []
1✔
54
        for user_obj in user_obj_list:
1✔
55
            try:
1✔
56
                number_of_users_listed += 1
1✔
57
                if args.role:
1✔
58
                    user_obj.site_role = args.role
×
59
                if args.auth_type:
×
60
                    user_obj.auth_setting = args.auth_type
×
61
                new_user = TSC.UserItem(user_obj.name)
×
62
                server.users.add(new_user)
×
63
                logger.info(_("common.output.succeeded").format(user_obj.name))
×
64
                number_of_users_added += 1
×
65
            except Exception as e:
1✔
66
                if Errors.is_resource_conflict(e) and args.continue_if_exists:
1✔
NEW
67
                    logger.info(_("tabcmd.errors.user_already_exists").format(user_obj.name))
×
68
                    continue
×
69

70
                number_of_errors += 1
1✔
71
                error_list.append(e)
1✔
72
                logger.debug(e)
1✔
73
        logger.info(_("session.monitorjob.percent_complete").format(100))
1✔
74
        logger.info(_("importcsvsummary.line.processed").format(number_of_users_listed))
1✔
75
        logger.info(_("importcsvsummary.line.skipped").format(number_of_errors))
1✔
76
        logger.info(_("importcsvsummary.users.added.count").format(number_of_users_added))
1✔
77
        if number_of_errors > 0:
1✔
78
            logger.info(_("importcsvsummary.error.details"))
1✔
79
        for exception in error_list:
1✔
80
            Errors.check_common_error_codes_and_explain(logger, exception)
1✔
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

© 2026 Coveralls, Inc