예제 #1
0
    def test_method_get_instance(self):
        """User instance get single user by primary key"""

        user = User.get(TEST_USERNAME)

        # make sure one user is returned
        self.assertIsInstance(user, User)
예제 #2
0
    def test_method_get_instance(self):
        """User instance get single user by primary key"""

        user = User.get(TEST_USERNAME)

        # make sure one user is returned
        self.assertIsInstance(user, User)
예제 #3
0
파일: ooto.py 프로젝트: DarkRoseAM/dpa-pipe
    def validate(self):

        if not self._message:
            raise ActionError("Message can not be empty.")

        try:
            self._sender = User.current()
        except UserError:
            raise ActionError("Could not identify current user.")

        # get ooto notification recipients from the configs
        ptask_area = PTaskArea.current()
        ooto_config = ptask_area.config(
            OOTO_CONFIG_PATH,
            composite_ancestors=True,
            composite_method="append",
        )

        ooto_notify = ooto_config.get('notify', [])
        self._to.extend(ooto_notify)

        # for all usernames specified, make sure they're a valid user,
        # get their email addresses.
        recipients = set()
        for recipient in self._to:
            
            # assume already a valid email address
            if "@" in recipient:
                recipients.add(recipient)
            else:
                try:
                    recipient = User.get(recipient)
                except UserError:
                    raise ActionError(
                        "Could not identify user: "******"\n\nCurrent ptask: {p}".format(p=ptask_area.spec)
        self._message += "\n\n- {s}".format(s=self._sender.full_name)

        self._subject = "OOTO: {fn} ({un})".format(
            fn=self.sender.full_name,
            un=self.sender.username,
        )
예제 #4
0
    def validate(self):

        if not self._message:
            raise ActionError("Message can not be empty.")

        try:
            self._sender = User.current()
        except UserError:
            raise ActionError("Could not identify current user.")

        # get ooto notification recipients from the configs
        ptask_area = PTaskArea.current()
        ooto_config = ptask_area.config(
            OOTO_CONFIG_PATH,
            composite_ancestors=True,
            composite_method="append",
        )

        ooto_notify = ooto_config.get('notify', [])
        self._to.extend(ooto_notify)

        # for all usernames specified, make sure they're a valid user,
        # get their email addresses.
        recipients = set()
        for recipient in self._to:
            
            # assume already a valid email address
            if "@" in recipient:
                recipients.add(recipient)
            else:
                try:
                    recipient = User.get(recipient)
                except UserError:
                    raise ActionError(
                        "Could not identify user: "******"\n\nCurrent ptask: {p}".format(p=ptask_area.spec)
        self._message += "\n\n- {s}".format(s=self._sender.full_name)

        self._subject = "OOTO: {fn} ({un})".format(
            fn=self.sender.full_name,
            un=self.sender.username,
        )
예제 #5
0
def emails_from_unames(unames):

    emails = set()

    for uname in unames:
            
        # assume already a valid email address
        if "@" in uname:
            emails.add(uname)
        else:
            try:
                user = User.get(uname)
            except UserError:
                raise NotificationError("Could not identify user: " + str(uname))
            else:
                emails.add(user.email)

    return list(emails)
예제 #6
0
def emails_from_unames(unames):

    emails = set()

    for uname in unames:

        # assume already a valid email address
        if "@" in uname:
            emails.add(uname)
        else:
            try:
                user = User.get(uname)
            except UserError:
                raise NotificationError("Could not identify user: " +
                                        str(uname))
            else:
                emails.add(user.email)

    return list(emails)
예제 #7
0
파일: info.py 프로젝트: chippey/dpa-pipe
    def execute(self):

        try:
            user = User.get(self.username)
        except UserError:
            self.logger.error(
                'Could not determine user from: "{u}"'.format(u=self.username)
            )
            raise

        # output headers. reused while defining the look of the output
        username = '******'
        last_name = 'Last'
        first_name = 'First'
        email = 'Email'
        active = 'Active'

        # define the look of the output
        output = Output()
        # defining the data headers
        output.header_names = [username, email]
        output.add_item(
            {
                username: user.username,
                email: user.email,
            },
            color_all=Style.bright,
        )
        
        # build the title
        title = " {u.first_name} {u.last_name}".format(u=user)
        if not user.is_active:
            title += " [INACTIVE]"
        title += " "
        output.title = title

        # dump the output as a list of key/value pairs
        output.dump()
예제 #8
0
    def execute(self):

        try:
            user = User.get(self.username)
        except UserError:
            self.logger.error(
                'Could not determine user from: "{u}"'.format(u=self.username))
            raise

        # output headers. reused while defining the look of the output
        username = '******'
        last_name = 'Last'
        first_name = 'First'
        email = 'Email'
        active = 'Active'

        # define the look of the output
        output = Output()
        # defining the data headers
        output.header_names = [username, email]
        output.add_item(
            {
                username: user.username,
                email: user.email,
            },
            color_all=Style.bright,
        )

        # build the title
        title = " {u.first_name} {u.last_name}".format(u=user)
        if not user.is_active:
            title += " [INACTIVE]"
        title += " "
        output.title = title

        # dump the output as a list of key/value pairs
        output.dump()
예제 #9
0
 def user(self):
     """:returns: a User object for the user assigned to the ptask."""
     return User.get(self.user_username)
예제 #10
0
파일: __init__.py 프로젝트: josh-t/dpa-pipe
 def creator(self):
     """:returns: a User object for the creator of this ptask."""
     return User.get(self.creator_username)
예제 #11
0
 def creator(self):
     """:returns: a User object for the creator of this ptask."""
     return User.get(self.creator_username)
예제 #12
0
 def setUp(self):
     """Get a new user object for each test."""
     self.user = User.get(TEST_USERNAME)
예제 #13
0
 def creator(self):
     return User.get(self.creator_username)
예제 #14
0
 def creator(self):
     return User.get(self.creator_username)
예제 #15
0
 def setUp(self):
     """Get a new user object for each test."""
     self.user = User.get(TEST_USERNAME)
예제 #16
0
 def user(self):
     """:returns: a User object for the user assigned to the ptask."""
     return User.get(self.user_username)