<s> from ajenti . api import * <EOL> from ajenti . api . sensors import * <EOL> from ajenti . plugins . main . api import SectionPlugin <EOL> from ajenti . ui import * <EOL> from ajenti . ui . binder import Binder <EOL> from api import * <EOL> @ plugin <EOL> class NetworkPlugin ( SectionPlugin ) : <EOL> platforms = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def init ( self ) : <EOL> self . title = _ ( '<STR_LIT>' ) <EOL> self . icon = '<STR_LIT>' <EOL> self . category = _ ( '<STR_LIT>' ) <EOL> self . net_config = INetworkConfig . get ( ) <EOL> self . append ( self . ui . inflate ( '<STR_LIT>' ) ) <EOL> def post_interface_bind ( o , c , i , u ) : <EOL> i . add_bits ( self . ui ) <EOL> for bit in i . bits : <EOL> u . find ( '<STR_LIT>' ) . append ( self . ui . create ( <EOL> '<STR_LIT>' , <EOL> children = [ bit ] , <EOL> title = bit . title , <EOL> ) ) <EOL> u . find ( '<STR_LIT>' ) . on ( '<STR_LIT>' , self . on_up , i ) <EOL> u . find ( '<STR_LIT>' ) . on ( '<STR_LIT>' , self . on_down , i ) <EOL> u . find ( '<STR_LIT>' ) . on ( '<STR_LIT>' , self . on_restart , i ) <EOL> u . find ( '<STR_LIT>' ) . text = self . net_config . get_ip ( i ) <EOL> def post_interface_update ( o , c , i , u ) : <EOL> for bit in i . bits : <EOL> bit . apply ( ) <EOL> self . find ( '<STR_LIT>' ) . post_item_bind = post_interface_bind <EOL> self . find ( '<STR_LIT>' ) . post_item_update = post_interface_update <EOL> self . binder = Binder ( None , self ) <EOL> def on_page_load ( self ) : <EOL> self . refresh ( ) <EOL> def refresh ( self ) : <EOL> self . net_config . rescan ( ) <EOL> sensor = Sensor . find ( '<STR_LIT>' ) <EOL> for i in self . net_config . interface_list : <EOL> i . tx , i . rx = sensor . value ( i . name ) <EOL> self . binder . setup ( self . net_config ) . populate ( ) <EOL> return <EOL> def on_up ( self , iface = None ) : <EOL> self . save ( ) <EOL> self . net_config . up ( iface ) <EOL> self . refresh ( ) <EOL> def on_down ( self , iface = None ) : <EOL> self . save ( ) <EOL> self . net_config . down ( iface ) <EOL> self . refresh ( ) <EOL> def on_restart ( self , iface = None ) : <EOL> self . save ( ) <EOL> self . on_down ( iface ) <EOL> self . on_up ( iface ) <EOL> @ on ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def save ( self ) : <EOL> self . binder . update ( ) <EOL> self . net_config . save ( ) <EOL> self . refresh ( ) <EOL> self . context . notify ( '<STR_LIT:info>' , _ ( '<STR_LIT>' ) ) </s>
