Exemplo n.º 1
0
 def __wrapped(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except socket.gaierror as e:
         raise idli.IdliException(
             "Error connecting to trac server " + trac_server_url() +
             ".\nCheck your config file and make sure the path is correct: "
             + cfg.local_config_filename() + ".\n\n" + str(e))
     except socket.error as e:
         raise idli.IdliException(
             "Error connecting to trac server " + trac_server_url() +
             ".\nCheck your config file and make sure the path is correct: "
             + cfg.local_config_filename() + ".\n\n" + str(e))
     except xmlrpc.client.Fault as e:
         if e.faultCode == 403:
             raise idli.IdliException(
                 "Trac's permissions are not set correctly. Run\n $ trac-admin TRACDIR permission add authenticated XML_RPC\nto enable XML_RPC permissions (which are required by idli)."
             )
         else:
             raise idli.IdliException(
                 "Error connecting to trac server " + trac_server_url() +
                 ".\nCheck your config file and make sure the path is correct: "
                 + cfg.local_config_filename() + ".\n\n" + str(e))
     except xmlrpc.client.ProtocolError as e:
         raise idli.IdliException(
             "Protocol error. This probably means that the XmlRpc plugin for trac is not enabled. Follow the inunicodeuctions here to install it:\nhttp://trac-hacks.org/wiki/XmlRpcPlugin\n\n"
             + str(e))
Exemplo n.º 2
0
 def wrapped_func(self, *args, **kwargs):
     try:
         return func(self, *args, **kwargs)
     except cfg.IdliMissingConfigException as e:
         raise idli.IdliException(
             "You must configure idli for Bitbucket first. Run 'idli configure Bitbucket' for options."
         )
Exemplo n.º 3
0
 def wrapped_func(self, *args, **kwargs):
     try:
         return func(self, *args, **kwargs)
     except cfg.IdliMissingConfigException, e:
         raise idli.IdliException(
             "You must configure idli for github first. Run 'idli configure github' for options."
         )
Exemplo n.º 4
0
 def __validate_repo(self):
     test_url = github_base_api_url + "repos/show/" + self.repo_owner() + "/" + self.repo()
     try:
         result = json.loads(urllib.request.urlopen(test_url).read())
         return result["repository"]
     except urllib.error.HTTPError as e:
         raise idli.IdliException("Can not find repository " + self.repo() + " on github.")
Exemplo n.º 5
0
 def tag_issue(self, issue_id, tags, remove_tags=False):
     for t in tags:
         url = self.__add_label_url(issue_id, t, remove_tags)
         result = json.loads(self.__url_request(url))
         if (not (t in result['labels'])) and (not remove_tags):
             raise idli.IdliException("Failed to add tag to issue " + str(issue_id) + ". The issue list may be in an inconsistent state.")
     return self.get_issue(issue_id)
Exemplo n.º 6
0
 def get_title_body(self):
     title = self.args.title or ""
     body = self.args.body or ""
     if (title == "" or body == ""):
         title, body, exit_status = util.get_title_body_from_editor(title, body, prefix='idli-add-issue')
         if (exit_status != 0):
             raise idli.IdliException("Operation cancelled.")
     return title, body
Exemplo n.º 7
0
 def __wrapped(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except socket.gaierror, e:
         raise idli.IdliException(
             "Error connecting to trac server " + trac_server_url() +
             ".\nCheck your config file and make sure the path is correct: "
             + cfg.local_config_filename() + ".\n\n" + unicode(e))
Exemplo n.º 8
0
 def __validate_user(self):
     test_url = github_base_api_url + "user/show/" + self.repo_owner()
     try:
         result = json.loads(urllib2.urlopen(test_url).read())
         return result["user"]
     except urllib2.HTTPError, e:
         raise idli.IdliException("Can not find user " + self.repo_owner() +
                                  " on github.")
Exemplo n.º 9
0
 def __validate_user(self):
     test_url = self.url(endpoint='users', component='{account_name}')
     try:
         result = json.loads(urllib.request.urlopen(test_url).read())
         return result['user']
     except urllib.error.HTTPError as e:
         raise idli.IdliException("Can not find user " + self.repo_owner() +
                                  " on github.")
Exemplo n.º 10
0
 def __validate_repo(self):
     test_url = self.url(endpoint='repositories',
                         component='{account_name}/{repo_slug}')
     try:
         result = json.loads(urllib.request.urlopen(test_url).read())
         return result['repository']
     except urllib.error.HTTPError as e:
         raise idli.IdliException("Can not find repository " + self.repo() +
                                  " on github.")
Exemplo n.º 11
0
 def assign_issue(self, issue_id, user, message):
     actions = self.ticket_api().getActions(issue_id)
     if ('reassign' in [a[0] for a in actions]):
         ticket = self.ticket_api().update(int(issue_id), message, {
             'owner': user,
             'status': 'assigned'
         })
         return self.__convert_issue(ticket)
     raise idli.IdliException("Failed to assign ticket.")
Exemplo n.º 12
0
 def wrapped_func(self, *args, **kwargs):
     try:
         return func(self, *args, **kwargs)
     except HttpRequestException as e:
         if (e.status_code == 401):
             raise idli.IdliException("Authentication failed.\n\nCheck your idli configuration. The most likely cause is incorrect values for 'user' or 'password' variables in the [Github] section of the configuration files:\n    " + cfg.local_config_filename() + "\n    " + cfg.global_config_filename() + ".\n\nMake sure you check both files - the values in " + cfg.local_config_filename() + " will override the values in " + cfg.global_config_filename() + "." + "\n\n" + str(e))
         if (e.status_code == 404):
             self.validate()
         raise e
Exemplo n.º 13
0
 def resolve_issue(self, issue_id, status="closed", message=None):
     actions = self.ticket_api().getActions(issue_id)
     if ('resolve' in [a[0] for a in actions]):
         ticket = self.ticket_api().update(int(issue_id), message, {
             'status': 'fixed',
             'action': 'resolve'
         })
         return self.__convert_issue(ticket)
     raise idli.IdliException("Can not resolve issue " + issue_id +
                              ". Perhaps it is already resolved?")
Exemplo n.º 14
0
 def tag_issue(self, issue_id, tags, remove_tags=False):
     logging.debug('tag_issue')
     raise idli.IdliNotImplementedException('Tagging not supported')
     for t in tags:
         url = self.__add_label_url(issue_id, t, remove_tags)
         result = self.__url_request(url)
         if (not (t in result['labels'])) and (not remove_tags):
             raise idli.IdliException(
                 "Failed to add tag to issue " + str(issue_id) +
                 ". The issue list may be in an inconsistent state.")
     return self.get_issue(issue_id)
Exemplo n.º 15
0
 def run(self):
     message = self.args.message
     if (message is None):
         message, exit_status = util.get_string_from_editor("Please resolve this issue.", prefix='idli-assign-')
         if (exit_status != 0):
             raise idli.IdliException("Operation cancelled.")
     issue = self.backend.assign_issue(self.args.id, user=self.args.user, message = message)
     issue, comments = self.backend.get_issue(self.args.id)
     print("Issue " + self.args.id + " assigned to " + str(self.args.user))
     print()
     util.print_issue(issue, comments)
Exemplo n.º 16
0
 def run(self):
     message = self.args.message
     message = self.args.message
     if (message is None):
         message, exit_status = util.get_string_from_editor("Issue resolved.\n# More details go here.", prefix='idli-resolve-')
         if (exit_status != 0):
             raise idli.IdliException("Operation cancelled.")
     issue = self.backend.resolve_issue(self.args.id, status = self.args.state, message = message)
     issue, comments = self.backend.get_issue(self.args.id)
     print("Issue state changed to " + str(self.args.state))
     print()
     util.print_issue(issue, comments)
Exemplo n.º 17
0
 def get_issue(self, issue_id, get_comments=True):
     issue_url = github_base_api_url + "issues/show/" + self.repo_owner(
     ) + "/" + self.repo() + "/" + issue_id
     comment_url = github_base_api_url + "issues/comments/" + self.repo_owner(
     ) + "/" + self.repo() + "/" + issue_id
     try:
         issue_as_json = json.loads(self.__url_request(issue_url))
         comments_as_json = json.loads(self.__url_request(comment_url))
     except urllib2.HTTPError, e:
         self.validate()
         raise idli.IdliException("Could not find issue with id '" +
                                  issue_id + "'")
Exemplo n.º 18
0
 def run(self):
     issue = self.backend.get_issue(self.args.id) # Will raise error message if issue cannot be found
     message = self.args.body
     if (message is None):
         message, exit_status = util.get_string_from_editor("# Type your comment here.", prefix='idli-comment-')
         if (exit_status != 0):
             raise idli.IdliException("Operation cancelled.")
     self.backend.add_comment(self.args.id, message)
     print("Comment added!")
     print()
     issue, comments = self.backend.get_issue(self.args.id)
     util.print_issue(issue, comments)
Exemplo n.º 19
0
    def run(self):
        issue, comments = self.backend.get_issue(self.args.id) # This will raise an error if the issue does not exist.
        tags = [t for t in (self.args.tags).split(",") if t] # Remove empty tags

        if self.args.remove: #If user asked to remove nonexistent tag, raise an error.
            for t in tags:
                if not (t in issue.tags):
                    raise idli.IdliException("The issue " + str(self.args.id) + " does not have the tag " + t + ". No action performed. Tags available: " + ", ".join(issue.tags))
                tags = [t for t in tags if not (t in issue.tags)]

        #Now actually tag the issue.
        self.backend.tag_issue(self.args.id, tags, self.args.remove)
        issue,comments = self.backend.get_issue(self.args.id)
        util.print_issue(issue, comments)
Exemplo n.º 20
0
    def get_issue(self, issue_id, get_comments=True):
        issue_url = github_base_api_url + "issues/show/" + self.repo_owner() + "/" + self.repo() + "/" + issue_id
        comment_url = github_base_api_url + "issues/comments/" + self.repo_owner() + "/" + self.repo() + "/" + issue_id
        try:
            issue_as_json = json.loads(self.__url_request(issue_url))
            comments_as_json = json.loads(self.__url_request(comment_url))
        except urllib.error.HTTPError as e:
            self.validate()
            raise idli.IdliException("Could not find issue with id '" + issue_id + "'")

        js_issue = issue_as_json["issue"]
        date = self.__parse_date(js_issue["created_at"])
        issue = self.__parse_issue(issue_as_json["issue"])
        comments_list = comments_as_json["comments"]
        comment_result = []
        for c in comments_list:
            comment_result.append(self.__parse_comment(issue, c))
        return (issue, comment_result)
Exemplo n.º 21
0
    def get_issue(self, issue_id, get_comments=True):
        logging.debug('get_issue, issue_id: %s', issue_id)
        issue_url = self.url(component='{issue_id}', issue_id=issue_id)
        comment_url = self.url(component='{issue_id}/comments',
                               issue_id=issue_id)
        try:
            issue_as_json = self.__url_request('get', issue_url)
            comments_as_json = self.__url_request('get', comment_url)
        except urllib2.HTTPError as e:
            self.validate()
            raise idli.IdliException("Could not find issue with id '" +
                                     issue_id + "'")

        issue = self.__parse_issue(issue_as_json)
        comments = []
        for c in comments_as_json:
            comments.append(self.__parse_comment(issue, c))
        return (issue, comments)
Exemplo n.º 22
0
 def wrapped_func(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except HttpRequestException, e:
         raise idli.IdliException("Could not connect to github. Error: " +
                                  unicode(e))
Exemplo n.º 23
0
        try:
            return func(*args, **kwargs)
        except socket.gaierror, e:
            raise idli.IdliException(
                "Error connecting to trac server " + trac_server_url() +
                ".\nCheck your config file and make sure the path is correct: "
                + cfg.local_config_filename() + ".\n\n" + unicode(e))
        except socket.error, e:
            raise idli.IdliException(
                "Error connecting to trac server " + trac_server_url() +
                ".\nCheck your config file and make sure the path is correct: "
                + cfg.local_config_filename() + ".\n\n" + unicode(e))
        except xmlrpclib.Fault, e:
            if e.faultCode == 403:
                raise idli.IdliException(
                    "Trac's permissions are not set correctly. Run\n $ trac-admin TRACDIR permission add authenticated XML_RPC\nto enable XML_RPC permissions (which are required by idli)."
                )
            else:
                raise idli.IdliException(
                    "Error connecting to trac server " + trac_server_url() +
                    ".\nCheck your config file and make sure the path is correct: "
                    + cfg.local_config_filename() + ".\n\n" + unicode(e))
        except xmlrpclib.ProtocolError, e:
            raise idli.IdliException(
                "Protocol error. This probably means that the XmlRpc plugin for trac is not enabled. Follow the inunicodeuctions here to install it:\nhttp://trac-hacks.org/wiki/XmlRpcPlugin\n\n"
                + unicode(e))

    return __wrapped


class TracBackend(idli.Backend):
Exemplo n.º 24
0
 def wrapped_func(*args, **kwargs):
     try:
         return func(*args, **kwargs)
     except HttpRequestException as e:
         raise idli.IdliException(
             "Could not connect to Bitbucket. Error: " + str(e))