<s> """<STR_LIT>""" <EOL> import urllib2 <EOL> import diamond . collector <EOL> class ResqueWebCollector ( diamond . collector . Collector ) : <EOL> def get_default_config_help ( self ) : <EOL> config_help = super ( ResqueWebCollector , self ) . get_default_config_help ( ) <EOL> config_help . update ( { <EOL> } ) <EOL> return config_help <EOL> def get_default_config ( self ) : <EOL> """<STR_LIT>""" <EOL> config = super ( ResqueWebCollector , self ) . get_default_config ( ) <EOL> config . update ( { <EOL> '<STR_LIT:host>' : '<STR_LIT:localhost>' , <EOL> '<STR_LIT:port>' : <NUM_LIT> , <EOL> '<STR_LIT:path>' : '<STR_LIT>' , <EOL> } ) <EOL> return config <EOL> def collect ( self ) : <EOL> try : <EOL> response = urllib2 . urlopen ( "<STR_LIT>" % ( <EOL> self . config [ '<STR_LIT:host>' ] , int ( self . config [ '<STR_LIT:port>' ] ) ) ) <EOL> except Exception , e : <EOL> self . log . error ( '<STR_LIT>' , e ) <EOL> return { } <EOL> for data in response . read ( ) . split ( "<STR_LIT:\n>" ) : <EOL> if data == "<STR_LIT>" : <EOL> continue <EOL> item , count = data . strip ( ) . split ( "<STR_LIT:=>" ) <EOL> try : <EOL> count = int ( count ) <EOL> ( item , queue ) = item . split ( "<STR_LIT:.>" ) <EOL> if item == "<STR_LIT>" : <EOL> if queue [ - <NUM_LIT:1> ] == "<STR_LIT:+>" : <EOL> self . publish ( "<STR_LIT>" % queue . replace ( "<STR_LIT:+>" , "<STR_LIT>" ) , count ) <EOL> else : <EOL> self . publish ( "<STR_LIT>" % queue , count ) <EOL> else : <EOL> self . publish ( "<STR_LIT>" % queue , count ) <EOL> except Exception , e : <EOL> self . log . error ( '<STR_LIT>' , e ) </s>
