{"action":"created","comment":{"url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/comments/25495252","id":25495252,"diff_hunk":"@@ -1252,6 +1297,93 @@ def port_val(port_type, value):\n         except:\n             self.ctx.out(\"OMERO.web not installed!\")\n \n+    def get_users_groups(self, args, iadmin):\n+        users = []\n+        groups = []\n+\n+        if args.user_name:\n+            for user_name in args.user_name:\n+                uid, u = self.find_user_by_name(\n+                    iadmin, user_name, fatal=False)\n+                if uid is not None:\n+                    users.append(uid)\n+\n+        if args.user_id:\n+            for user_id in args.user_id:\n+                uid, u = self.find_user_by_id(\n+                    iadmin, user_id, fatal=False)\n+                if uid is not None:\n+                    users.append(uid)\n+\n+        if args.group_name:\n+            for group_name in args.group_name:\n+                gid, g = self.find_group_by_name(\n+                    iadmin, group_name, fatal=False)\n+                if gid is not None:\n+                    groups.append(gid)\n+\n+        if args.group_id:\n+            for group_id in args.group_id:\n+                gid, g = self.find_group_by_id(\n+                    iadmin, group_id, fatal=False)\n+                if gid is not None:\n+                    groups.append(gid)\n+\n+        return users, groups\n+\n+    def email(self, args):\n+        client = self.ctx.conn(args)\n+        iadmin = client.sf.getAdminService()\n+        users, groups = self.get_users_groups(args, iadmin)\n+\n+        if not args.text:\n+            args.text = (\"-\")\n+\n+        text = \" \".join(args.text)\n+        if text == \"-\":\n+            stdin = FileType(\"r\")(\"-\")\n+            text = stdin.read()\n+\n+        req = omero.cmd.SendEmailRequest(\n+            subject=args.subject,\n+            body=text,\n+            userIds=users,\n+            groupIds=groups,\n+            everyone=args.everyone,\n+            inactive=args.inactive)\n+\n+        try:\n+            cb = client.submit(\n+                req, loops=10, ms=500,\n+                failonerror=True, failontimeout=True)\n+        except omero.CmdError, ce:\n+            err = ce.err\n+            if err.name == \"no-body\" and err.parameters:\n+                sb = err.parameters.items()\n+                sb = [\"%s:%s\" % (k, v) for k, v in sb]\n+                sb = \"\\n\".join(sb)\n+                self.ctx.die(12, sb)\n+            self.ctx.die(13, \"Failed to send emails:\\n%s\" % err)\n+\n+        try:\n+            rsp = cb.getResponse()\n+            self.ctx.out(\n+                \"Successfully sent %s of %s emails\" % (\n+                    rsp.success, rsp.total\n+                ))\n+            if rsp.invalidusers:\n+                self.ctx.out(\n+                    \"%s users had no email addresses\" % len(","path":"components/tools/OmeroPy/src/omero/plugins/admin.py","position":154,"original_position":154,"commit_id":"9444161d1c70679f6c9a9f3a2dad1109f4b39666","original_commit_id":"9444161d1c70679f6c9a9f3a2dad1109f4b39666","user":{"login":"mtbc","id":2630707,"avatar_url":"https://avatars.githubusercontent.com/u/2630707?v=3","gravatar_id":"","url":"https://api.github.com/users/mtbc","html_url":"https://github.com/mtbc","followers_url":"https://api.github.com/users/mtbc/followers","following_url":"https://api.github.com/users/mtbc/following{/other_user}","gists_url":"https://api.github.com/users/mtbc/gists{/gist_id}","starred_url":"https://api.github.com/users/mtbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtbc/subscriptions","organizations_url":"https://api.github.com/users/mtbc/orgs","repos_url":"https://api.github.com/users/mtbc/repos","events_url":"https://api.github.com/users/mtbc/events{/privacy}","received_events_url":"https://api.github.com/users/mtbc/received_events","type":"User","site_admin":false},"body":"maybe \"address\" singular?","created_at":"2015-02-27T09:24:42Z","updated_at":"2015-02-27T09:24:42Z","html_url":"https://github.com/openmicroscopy/openmicroscopy/pull/3542#discussion_r25495252","pull_request_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542","_links":{"self":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/comments/25495252"},"html":{"href":"https://github.com/openmicroscopy/openmicroscopy/pull/3542#discussion_r25495252"},"pull_request":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542"}}},"pull_request":{"url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542","id":30147912,"html_url":"https://github.com/openmicroscopy/openmicroscopy/pull/3542","diff_url":"https://github.com/openmicroscopy/openmicroscopy/pull/3542.diff","patch_url":"https://github.com/openmicroscopy/openmicroscopy/pull/3542.patch","issue_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/3542","number":3542,"state":"open","locked":false,"title":"Email cli","user":{"login":"joshmoore","id":88113,"avatar_url":"https://avatars.githubusercontent.com/u/88113?v=3","gravatar_id":"","url":"https://api.github.com/users/joshmoore","html_url":"https://github.com/joshmoore","followers_url":"https://api.github.com/users/joshmoore/followers","following_url":"https://api.github.com/users/joshmoore/following{/other_user}","gists_url":"https://api.github.com/users/joshmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/joshmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshmoore/subscriptions","organizations_url":"https://api.github.com/users/joshmoore/orgs","repos_url":"https://api.github.com/users/joshmoore/repos","events_url":"https://api.github.com/users/joshmoore/events{/privacy}","received_events_url":"https://api.github.com/users/joshmoore/received_events","type":"User","site_admin":false},"body":"Implements a simple `bin/omero admin email` command to make use of @aleksandra-tarkowska's `SendEmailRequest` command. This also slightly changes the behavior of the `everyone` flag, allowing it to be passed when groups & users are passed.\r\n\r\ncc: @sbesson @ximenesuk @pwalczysko @kennethgillen @aleksandra-tarkowska ","created_at":"2015-02-27T08:02:56Z","updated_at":"2015-02-27T09:24:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"443f228f237c47b42b4cfa87e36249acc28c731f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542/commits","review_comments_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542/comments","review_comment_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/comments{/number}","comments_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/3542/comments","statuses_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/statuses/9444161d1c70679f6c9a9f3a2dad1109f4b39666","head":{"label":"joshmoore:email-cli","ref":"email-cli","sha":"9444161d1c70679f6c9a9f3a2dad1109f4b39666","user":{"login":"joshmoore","id":88113,"avatar_url":"https://avatars.githubusercontent.com/u/88113?v=3","gravatar_id":"","url":"https://api.github.com/users/joshmoore","html_url":"https://github.com/joshmoore","followers_url":"https://api.github.com/users/joshmoore/followers","following_url":"https://api.github.com/users/joshmoore/following{/other_user}","gists_url":"https://api.github.com/users/joshmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/joshmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshmoore/subscriptions","organizations_url":"https://api.github.com/users/joshmoore/orgs","repos_url":"https://api.github.com/users/joshmoore/repos","events_url":"https://api.github.com/users/joshmoore/events{/privacy}","received_events_url":"https://api.github.com/users/joshmoore/received_events","type":"User","site_admin":false},"repo":{"id":2347571,"name":"openmicroscopy","full_name":"joshmoore/openmicroscopy","owner":{"login":"joshmoore","id":88113,"avatar_url":"https://avatars.githubusercontent.com/u/88113?v=3","gravatar_id":"","url":"https://api.github.com/users/joshmoore","html_url":"https://github.com/joshmoore","followers_url":"https://api.github.com/users/joshmoore/followers","following_url":"https://api.github.com/users/joshmoore/following{/other_user}","gists_url":"https://api.github.com/users/joshmoore/gists{/gist_id}","starred_url":"https://api.github.com/users/joshmoore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshmoore/subscriptions","organizations_url":"https://api.github.com/users/joshmoore/orgs","repos_url":"https://api.github.com/users/joshmoore/repos","events_url":"https://api.github.com/users/joshmoore/events{/privacy}","received_events_url":"https://api.github.com/users/joshmoore/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/joshmoore/openmicroscopy","description":"OME (Open Microscopy Environment) develops open-source software and data format standards for the storage and manipulation of biological light microscopy data. A joint project between universities, research establishments and industry in Europe and the USA, OME has over 20 active researchers with strong links to the microscopy community. Funded by private and public research grants, OME has been a major force on the international microscopy stage since 2000.","fork":true,"url":"https://api.github.com/repos/joshmoore/openmicroscopy","forks_url":"https://api.github.com/repos/joshmoore/openmicroscopy/forks","keys_url":"https://api.github.com/repos/joshmoore/openmicroscopy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/joshmoore/openmicroscopy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/joshmoore/openmicroscopy/teams","hooks_url":"https://api.github.com/repos/joshmoore/openmicroscopy/hooks","issue_events_url":"https://api.github.com/repos/joshmoore/openmicroscopy/issues/events{/number}","events_url":"https://api.github.com/repos/joshmoore/openmicroscopy/events","assignees_url":"https://api.github.com/repos/joshmoore/openmicroscopy/assignees{/user}","branches_url":"https://api.github.com/repos/joshmoore/openmicroscopy/branches{/branch}","tags_url":"https://api.github.com/repos/joshmoore/openmicroscopy/tags","blobs_url":"https://api.github.com/repos/joshmoore/openmicroscopy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/joshmoore/openmicroscopy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/joshmoore/openmicroscopy/git/refs{/sha}","trees_url":"https://api.github.com/repos/joshmoore/openmicroscopy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/joshmoore/openmicroscopy/statuses/{sha}","languages_url":"https://api.github.com/repos/joshmoore/openmicroscopy/languages","stargazers_url":"https://api.github.com/repos/joshmoore/openmicroscopy/stargazers","contributors_url":"https://api.github.com/repos/joshmoore/openmicroscopy/contributors","subscribers_url":"https://api.github.com/repos/joshmoore/openmicroscopy/subscribers","subscription_url":"https://api.github.com/repos/joshmoore/openmicroscopy/subscription","commits_url":"https://api.github.com/repos/joshmoore/openmicroscopy/commits{/sha}","git_commits_url":"https://api.github.com/repos/joshmoore/openmicroscopy/git/commits{/sha}","comments_url":"https://api.github.com/repos/joshmoore/openmicroscopy/comments{/number}","issue_comment_url":"https://api.github.com/repos/joshmoore/openmicroscopy/issues/comments{/number}","contents_url":"https://api.github.com/repos/joshmoore/openmicroscopy/contents/{+path}","compare_url":"https://api.github.com/repos/joshmoore/openmicroscopy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/joshmoore/openmicroscopy/merges","archive_url":"https://api.github.com/repos/joshmoore/openmicroscopy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/joshmoore/openmicroscopy/downloads","issues_url":"https://api.github.com/repos/joshmoore/openmicroscopy/issues{/number}","pulls_url":"https://api.github.com/repos/joshmoore/openmicroscopy/pulls{/number}","milestones_url":"https://api.github.com/repos/joshmoore/openmicroscopy/milestones{/number}","notifications_url":"https://api.github.com/repos/joshmoore/openmicroscopy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/joshmoore/openmicroscopy/labels{/name}","releases_url":"https://api.github.com/repos/joshmoore/openmicroscopy/releases{/id}","created_at":"2011-09-08T09:53:15Z","updated_at":"2014-06-25T08:25:48Z","pushed_at":"2015-02-27T08:01:24Z","git_url":"git://github.com/joshmoore/openmicroscopy.git","ssh_url":"git@github.com:joshmoore/openmicroscopy.git","clone_url":"https://github.com/joshmoore/openmicroscopy.git","svn_url":"https://github.com/joshmoore/openmicroscopy","homepage":"http://www.openmicroscopy.org","size":1986925,"stargazers_count":4,"watchers_count":4,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":4,"default_branch":"omero43-ice34"}},"base":{"label":"openmicroscopy:develop","ref":"develop","sha":"b3e668cc904de81499a7676a5fb64335be4926ac","user":{"login":"openmicroscopy","id":975861,"avatar_url":"https://avatars.githubusercontent.com/u/975861?v=3","gravatar_id":"","url":"https://api.github.com/users/openmicroscopy","html_url":"https://github.com/openmicroscopy","followers_url":"https://api.github.com/users/openmicroscopy/followers","following_url":"https://api.github.com/users/openmicroscopy/following{/other_user}","gists_url":"https://api.github.com/users/openmicroscopy/gists{/gist_id}","starred_url":"https://api.github.com/users/openmicroscopy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openmicroscopy/subscriptions","organizations_url":"https://api.github.com/users/openmicroscopy/orgs","repos_url":"https://api.github.com/users/openmicroscopy/repos","events_url":"https://api.github.com/users/openmicroscopy/events{/privacy}","received_events_url":"https://api.github.com/users/openmicroscopy/received_events","type":"Organization","site_admin":false},"repo":{"id":2228226,"name":"openmicroscopy","full_name":"openmicroscopy/openmicroscopy","owner":{"login":"openmicroscopy","id":975861,"avatar_url":"https://avatars.githubusercontent.com/u/975861?v=3","gravatar_id":"","url":"https://api.github.com/users/openmicroscopy","html_url":"https://github.com/openmicroscopy","followers_url":"https://api.github.com/users/openmicroscopy/followers","following_url":"https://api.github.com/users/openmicroscopy/following{/other_user}","gists_url":"https://api.github.com/users/openmicroscopy/gists{/gist_id}","starred_url":"https://api.github.com/users/openmicroscopy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openmicroscopy/subscriptions","organizations_url":"https://api.github.com/users/openmicroscopy/orgs","repos_url":"https://api.github.com/users/openmicroscopy/repos","events_url":"https://api.github.com/users/openmicroscopy/events{/privacy}","received_events_url":"https://api.github.com/users/openmicroscopy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/openmicroscopy/openmicroscopy","description":"OME (Open Microscopy Environment) develops open-source software and data format standards for the storage and manipulation of biological light microscopy data. A joint project between universities, research establishments and industry in Europe and the USA, OME has over 20 active researchers with strong links to the microscopy community. Funded by private and public research grants, OME has been a major force on the international microscopy stage since 2000.","fork":false,"url":"https://api.github.com/repos/openmicroscopy/openmicroscopy","forks_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/forks","keys_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/teams","hooks_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/hooks","issue_events_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/events{/number}","events_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/events","assignees_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/assignees{/user}","branches_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/branches{/branch}","tags_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/tags","blobs_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/git/refs{/sha}","trees_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/statuses/{sha}","languages_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/languages","stargazers_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/stargazers","contributors_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/contributors","subscribers_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/subscribers","subscription_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/subscription","commits_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/commits{/sha}","git_commits_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/git/commits{/sha}","comments_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/comments{/number}","issue_comment_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/comments{/number}","contents_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/contents/{+path}","compare_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/merges","archive_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/downloads","issues_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues{/number}","pulls_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls{/number}","milestones_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/milestones{/number}","notifications_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/labels{/name}","releases_url":"https://api.github.com/repos/openmicroscopy/openmicroscopy/releases{/id}","created_at":"2011-08-18T14:26:02Z","updated_at":"2015-02-27T09:11:18Z","pushed_at":"2015-02-27T09:11:18Z","git_url":"git://github.com/openmicroscopy/openmicroscopy.git","ssh_url":"git@github.com:openmicroscopy/openmicroscopy.git","clone_url":"https://github.com/openmicroscopy/openmicroscopy.git","svn_url":"https://github.com/openmicroscopy/openmicroscopy","homepage":"http://www.openmicroscopy.org","size":2150477,"stargazers_count":65,"watchers_count":65,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":63,"mirror_url":null,"open_issues_count":32,"forks":63,"open_issues":32,"watchers":65,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542"},"html":{"href":"https://github.com/openmicroscopy/openmicroscopy/pull/3542"},"issue":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/3542"},"comments":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/issues/3542/comments"},"review_comments":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542/comments"},"review_comment":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/pulls/3542/commits"},"statuses":{"href":"https://api.github.com/repos/openmicroscopy/openmicroscopy/statuses/9444161d1c70679f6c9a9f3a2dad1109f4b39666"}}}}