<s> """<STR_LIT>""" <EOL> import dns . resolver <EOL> import socket <EOL> class Py3status : <EOL> """<STR_LIT:U+0020>""" <EOL> domain = '<STR_LIT>' <EOL> lifetime = <NUM_LIT> <EOL> nameservers = '<STR_LIT>' <EOL> resolvers = '<STR_LIT>' <EOL> def ns_checker ( self , i3s_output_list , i3s_config ) : <EOL> response = { '<STR_LIT>' : '<STR_LIT>' } <EOL> counter = <NUM_LIT:0> <EOL> error = False <EOL> nameservers = [ ] <EOL> if not isinstance ( self . nameservers , list ) : <EOL> self . nameservers = self . nameservers . split ( '<STR_LIT:U+002C>' ) <EOL> if not isinstance ( self . resolvers , list ) : <EOL> self . resolvers = self . resolvers . split ( '<STR_LIT:U+002C>' ) <EOL> my_resolver = dns . resolver . Resolver ( ) <EOL> my_resolver . lifetime = self . lifetime <EOL> if self . resolvers : <EOL> my_resolver . nameservers = self . resolvers <EOL> my_ns = my_resolver . query ( self . domain , '<STR_LIT>' ) <EOL> for ns in my_ns : <EOL> nameservers . append ( str ( socket . gethostbyname ( str ( ns ) ) ) ) <EOL> for ns in self . nameservers : <EOL> nameservers . append ( str ( ns ) ) <EOL> for ns in nameservers : <EOL> my_resolver . nameservers = [ ns ] <EOL> counter += <NUM_LIT:1> <EOL> try : <EOL> my_resolver . query ( self . domain , '<STR_LIT:A>' ) <EOL> except : <EOL> error = True <EOL> if error : <EOL> response [ '<STR_LIT>' ] = str ( counter ) + '<STR_LIT>' <EOL> response [ '<STR_LIT>' ] = i3s_config [ '<STR_LIT>' ] <EOL> else : <EOL> response [ '<STR_LIT>' ] = str ( counter ) + '<STR_LIT>' <EOL> response [ '<STR_LIT>' ] = i3s_config [ '<STR_LIT>' ] <EOL> return response <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> """<STR_LIT>""" <EOL> from time import sleep <EOL> x = Py3status ( ) <EOL> config = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> while True : <EOL> print ( x . ns_checker ( [ ] , config ) ) <EOL> sleep ( <NUM_LIT:1> ) </s>
