def checkSmtp(): """ Make a connection socket test into STMP server. Return status code of SocketType.connect_ex(). """ try : S = SocketType() S.settimeout(2) smtpStatus = S.connect_ex( ( settings.SNAFU['smtp-server'],settings.SNAFU['smtp-port']) ) S.close() except (error,gaierror), e : smtpStatus = e return smtpStatus
def is_on(self): """ Make a connection socket test. """ from urlparse import urlsplit S = SocketType() S.settimeout(2) errno = S.connect_ex((urlsplit(settings.SNAFU['glpi-url']).netloc, 80)) S.close() if errno < 0 : return False return True