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 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 [Bitbucket] 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 initialize(self): section_name = self.config_section or self.name print "Initializing " + self.name + " project." import idli.config as cfg for (name, help) in self.init_names: cfg.set_config_value(section_name, name, self.args.__dict__[name], global_val=False) cfg.set_config_value("project", "type", self.name, global_val=False) print "Wrote configuration to " + cfg.local_config_filename()
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 get_backend_or_fail(backend_name=None): try: backend_name = backend_name or cfg.get_config_value("project", "type").lower() return backend_list[backend_name] except cfg.IdliMissingConfigException as e: print( "Could not find idli configuration file. Run 'idli init' in the project root directory." ) sys.exit(0) except KeyError as e: print("No such backend '" + cfg.get_config_value("project", "type") + ". Check the configuration file " + cfg.local_config_filename() + " for errors.") sys.exit(0) except Exception as e: print("Failed: " + str(e)) sys.exit(0)
def run(self): self.backend.initialize() print "Configuration written to " + config.local_config_filename()
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 [Bitbucket] 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 __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))
CONFIG_SECTION = "Trac" def catch_socket_errors(func): 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)) 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): config_section = CONFIG_SECTION name = "trac" init_names = [ ("server", "URL of trac server."), ("path", "Name of repository") ] config_names = [("user", "Trac username"), ("password", "Trac login password.") ] def __init__(self, args):
def run(self): self.backend.initialize() print("Configuration written to " + config.local_config_filename())
__add_items_to_parser(backend.init_names, init_parser) backend_list[backend.name] = backend def __add_items_to_parser(items, parser): if items.__class__ == dict: for (cmd, help) in items.iteritems(): parser.add_argument(cmd, help=help) if items.__class__ == list: for (cmd, help) in items: parser.add_argument(cmd, help=help) def get_backend_or_fail(backend_name = None): try: backend_name = backend_name or cfg.get_config_value("project", "type").lower() return backend_list[backend_name] except cfg.IdliMissingConfigException, e: print "Could not find idli configuration file. Run 'idli init' in the project root directory." sys.exit(0) except KeyError, e: print "No such backend '" + cfg.get_config_value("project", "type") + ". Check the configuration file " + cfg.local_config_filename() + " for errors." sys.exit(0) except Exception, e: print "Failed: " + str(e) sys.exit(0) register_backend(github.GithubBackend) register_backend(trac.TracBackend) register_backend(redmine.RedmineBackend)
def get_backend_or_fail(backend_name = None): try: backend_name = backend_name or cfg.get_config_value("project", "type").lower() return backend_list[backend_name] except cfg.IdliMissingConfigException as e: print("Could not find idli configuration file. Run 'idli init' in the project root directory.") sys.exit(0) except KeyError as e: print("No such backend '" + cfg.get_config_value("project", "type") + ". Check the configuration file " + cfg.local_config_filename() + " for errors.") sys.exit(0) except Exception as e: print("Failed: " + str(e)) sys.exit(0)
+ 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): config_section = CONFIG_SECTION name = "trac" init_names = [("server", "URL of trac server."), ("path", "Name of repository")] config_names = [("user", "Trac username"), ("password", "Trac login password.")]
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 instructions here to install it:\nhttp://trac-hacks.org/wiki/XmlRpcPlugin\n\n"+str(e))
if items.__class__ == dict: for (cmd, help) in items.iteritems(): parser.add_argument(cmd, help=help) if items.__class__ == list: for (cmd, help) in items: parser.add_argument(cmd, help=help) def get_backend_or_fail(backend_name=None): try: backend_name = backend_name or cfg.get_config_value("project", "type").lower() return backend_list[backend_name] except cfg.IdliMissingConfigException, e: print "Could not find idli configuration file. Run 'idli init' in the project root directory." sys.exit(0) except KeyError, e: print "No such backend '" + cfg.get_config_value( "project", "type" ) + ". Check the configuration file " + cfg.local_config_filename( ) + " for errors." sys.exit(0) except Exception, e: print "Failed: " + str(e) sys.exit(0) register_backend(github.GithubBackend) register_backend(trac.TracBackend) register_backend(redmine.RedmineBackend)