<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def postgres_version_to_int(pg_version):
 """Convert the server_version to integer 90503 90313 100001 Traceback (most recent call last):
 PostgresException: 'Invalid PostgreSQL version format: X.Y or X.Y.Z is accepted: 10' Traceback (most recent call last):
 PostgresException: 'Invalid PostgreSQL version format: X.Y or X.Y.Z is accepted: 9.6' Traceback (most recent call last):
 PostgresException: 'Invalid PostgreSQL version: a.b.c' """


        try:
            components = list(map(int, pg_version.split('.')))
        except ValueError:
            raise PostgresException('Invalid PostgreSQL version: {0}'.format(pg_version))

        if len(components) < 2 or len(components) == 2 and components[0] < 10 or len(components) > 3:
            raise PostgresException('Invalid PostgreSQL version format: X.Y or X.Y.Z is accepted: {0}'
                                    .format(pg_version))

        if len(components) == 2:
            # new style verion numbers, i.e. 10.1 becomes 100001
            components.insert(1, 0)

        return int(''.join('{0:02d}'.format(c) for c in components))