def check_hostname(hostname):
    """Returns a list of reasons why the hostname is invalid."""
    errors = []
    for result in validation.check_hostname(misc.utf8(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            errors.append('hostname_error_length')
        elif result == validation.HOSTNAME_BADCHAR:
            errors.append('hostname_error_badchar')
        elif result == validation.HOSTNAME_BADHYPHEN:
            errors.append('hostname_error_badhyphen')
        elif result == validation.HOSTNAME_BADDOTS:
            errors.append('hostname_error_baddots')
    return errors
def check_hostname(hostname):
    """Returns a newline separated string of reasons why the hostname is
    invalid."""
    # TODO: i18n
    e = []
    for result in validation.check_hostname(unicode(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            e.append("El nombre de host debe tener entre 1 y 63 carácteres.")
        elif result == validation.HOSTNAME_BADCHAR:
            e.append("El nombre de host solo puede contener letras, números, guiones, "
                     "y puntos.")
        elif result == validation.HOSTNAME_BADHYPHEN:
            e.append("El nombre de host no puede empezar o terminar con un guión.")
        elif result == validation.HOSTNAME_BADDOTS:
            e.append('El nombre de host no puede empezar o terminar con un punto, '
                     'o contener la secuencia "..".')
    return "\n".join(e)
예제 #3
0
def check_hostname(hostname):
    """Returns a newline separated string of reasons why the hostname is
    invalid."""
    # TODO: i18n
    e = []
    for result in validation.check_hostname(unicode(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            e.append("The hostname must be between 1 and 63 characters long.")
        elif result == validation.HOSTNAME_BADCHAR:
            e.append("The hostname may only contain letters, digits, hyphens, "
                     "and dots.")
        elif result == validation.HOSTNAME_BADHYPHEN:
            e.append("The hostname may not start or end with a hyphen.")
        elif result == validation.HOSTNAME_BADDOTS:
            e.append('The hostname may not start or end with a dot, '
                     'or contain the sequence "..".')
    return "\n".join(e)
def check_hostname(hostname):
    """Returns a newline separated string of reasons why the hostname is
    invalid."""
    # TODO: i18n
    e = []
    for result in validation.check_hostname(unicode(hostname)):
        if result == validation.HOSTNAME_LENGTH:
            e.append("The hostname must be between 1 and 63 characters long.")
        elif result == validation.HOSTNAME_BADCHAR:
            e.append("The hostname may only contain letters, digits, hyphens, "
                     "and dots.")
        elif result == validation.HOSTNAME_BADHYPHEN:
            e.append("The hostname may not start or end with a hyphen.")
        elif result == validation.HOSTNAME_BADDOTS:
            e.append('The hostname may not start or end with a dot, '
                     'or contain the sequence "..".')
    return "\n".join(e)
예제 #5
0
def check_hostname(hostname):
    """Returns a newline separated string of reasons why the hostname is
    invalid."""
    # TODO: i18n
    e = []
    # Ahem.  We can cheat here by inserting newlines where needed.  Hopefully
    # by the time we translate this, GTK+ will have decent layout management.
    for result in validation.check_hostname(hostname.decode('utf-8')):
        if result == validation.HOSTNAME_LENGTH:
            e.append("Must be between 1 and 63 characters long.")
        elif result == validation.HOSTNAME_BADCHAR:
            e.append("May only contain letters, digits,\nhyphens, and dots.")
        elif result == validation.HOSTNAME_BADHYPHEN:
            e.append("May not start or end with a hyphen.")
        elif result == validation.HOSTNAME_BADDOTS:
            e.append('May not start or end with a dot,\n'
                     'or contain the sequence "..".')
    return "\n".join(e)
예제 #6
0
 def run(self):
     error_msg = ['\n']
     error = 0
     for result in validation.check_hostname(self.info['hostname']):
         if result == validation.HOSTNAME_LENGTH:
             error_msg.append("· hostname wrong length (allowed between 3 and 18 chars).\n")
             error = 1
         elif result == validation.HOSTNAME_WHITESPACE:
             error_msg.append("· hostname contains white spaces (they're not allowed).\n")
             error = 1
     if error == 1:
         self.show_error(''.join(error_msg))
     if '/' not in self.info['mountpoints'].values():
          error_msg.append("· mountpoint must start with '/').\n")
          error = 1
     if error == 1:
         self.show_error(''.join(error_msg))
     self.progress_loop()
     self.clean_up()
     return 10 # reboot
예제 #7
0
 def run(self):
     error_msg = ['\n']
     error = 0
     for result in validation.check_hostname(self.info['hostname']):
         if result == validation.HOSTNAME_LENGTH:
             error_msg.append(
                 "· hostname wrong length (allowed between 3 and 18 chars).\n"
             )
             error = 1
         elif result == validation.HOSTNAME_WHITESPACE:
             error_msg.append(
                 "· hostname contains white spaces (they're not allowed).\n"
             )
             error = 1
     if error == 1:
         self.show_error(''.join(error_msg))
     if '/' not in self.info['mountpoints'].values():
         error_msg.append("· mountpoint must start with '/').\n")
         error = 1
     if error == 1:
         self.show_error(''.join(error_msg))
     self.progress_loop()
     self.clean_up()
     return 10  # reboot