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))
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." )
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." )
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.")
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)
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
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))
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.")
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.")
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.")
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.")
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
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?")
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)
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)
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)
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 + "'")
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)
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)
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)
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)
def wrapped_func(*args, **kwargs): try: return func(*args, **kwargs) except HttpRequestException, e: raise idli.IdliException("Could not connect to github. Error: " + unicode(e))
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):
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))