<s> import logging <EOL> import subprocess <EOL> from django . core . validators import MinValueValidator , MaxValueValidator <EOL> from django . db import models <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from freenasUI import choices <EOL> from freenasUI . freeadmin . models import Model , UserField , PathField <EOL> from freenasUI . middleware . notifier import notifier <EOL> from freenasUI . storage . models import Disk <EOL> log = logging . getLogger ( '<STR_LIT>' ) <EOL> class CronJob ( Model ) : <EOL> cron_user = UserField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) <EOL> ) <EOL> cron_command = models . TextField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_description = models . CharField ( <EOL> max_length = <NUM_LIT:200> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> ) <EOL> cron_minute = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_hour = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_daymonth = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_month = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = '<STR_LIT:*>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_dayweek = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> cron_stdout = models . BooleanField ( <EOL> default = True , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> ) <EOL> cron_stderr = models . BooleanField ( <EOL> default = False , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> ) <EOL> cron_enabled = models . BooleanField ( <EOL> default = True , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> ordering = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> def __unicode__ ( self ) : <EOL> if self . cron_description : <EOL> return self . cron_description <EOL> return u"<STR_LIT>" % ( self . id , self . cron_user ) <EOL> def get_human_minute ( self ) : <EOL> if self . cron_minute == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . cron_minute . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . cron_minute . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . cron_minute <EOL> def get_human_hour ( self ) : <EOL> if self . cron_hour == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . cron_hour . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . cron_hour . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . cron_hour <EOL> def get_human_daymonth ( self ) : <EOL> if self . cron_daymonth == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . cron_daymonth . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . cron_daymonth . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . cron_daymonth <EOL> def get_human_month ( self ) : <EOL> months = self . cron_month . split ( "<STR_LIT:U+002C>" ) <EOL> if len ( months ) == <NUM_LIT:12> or self . cron_month == '<STR_LIT:*>' : <EOL> return _ ( "<STR_LIT>" ) <EOL> mchoices = dict ( choices . MONTHS_CHOICES ) <EOL> labels = [ ] <EOL> for m in months : <EOL> labels . append ( unicode ( mchoices [ m ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def get_human_dayweek ( self ) : <EOL> weeks = self . cron_dayweek . split ( '<STR_LIT:U+002C>' ) <EOL> if len ( weeks ) == <NUM_LIT:7> or self . cron_dayweek == '<STR_LIT:*>' : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:1> , <NUM_LIT:6> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:6> , <NUM_LIT:8> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> wchoices = dict ( choices . WEEKDAYS_CHOICES ) <EOL> labels = [ ] <EOL> for w in weeks : <EOL> labels . append ( unicode ( wchoices [ str ( w ) ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def commandline ( self ) : <EOL> line = self . cron_command <EOL> if self . cron_stdout : <EOL> line += '<STR_LIT>' <EOL> if self . cron_stderr : <EOL> line += '<STR_LIT>' <EOL> else : <EOL> line += '<STR_LIT>' <EOL> return line <EOL> def run ( self ) : <EOL> proc = subprocess . Popen ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , str ( self . id ) , <EOL> ] ) <EOL> proc . communicate ( ) <EOL> def delete ( self ) : <EOL> super ( CronJob , self ) . delete ( ) <EOL> try : <EOL> notifier ( ) . restart ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> class InitShutdown ( Model ) : <EOL> ini_type = models . CharField ( <EOL> choices = ( <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ) , <EOL> default = '<STR_LIT>' , <EOL> max_length = <NUM_LIT:15> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> ini_command = models . CharField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> ) <EOL> ini_script = PathField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> filesonly = True , <EOL> dirsonly = False , <EOL> blank = True , <EOL> ) <EOL> ini_when = models . CharField ( <EOL> choices = ( <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , _ ( '<STR_LIT>' ) ) , <EOL> ) , <EOL> max_length = <NUM_LIT:15> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> def __unicode__ ( self ) : <EOL> if self . ini_type == '<STR_LIT>' : <EOL> name = self . ini_command <EOL> else : <EOL> name = self . ini_script <EOL> return u"<STR_LIT>" % ( <EOL> self . get_ini_when_display ( ) , <EOL> name , <EOL> ) <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> class FreeAdmin : <EOL> icon_model = u"<STR_LIT>" <EOL> icon_object = u"<STR_LIT>" <EOL> icon_add = u"<STR_LIT>" <EOL> icon_view = u"<STR_LIT>" <EOL> menu_child_of = '<STR_LIT>' <EOL> class Rsync ( Model ) : <EOL> rsync_path = PathField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> abspath = False , <EOL> ) <EOL> rsync_remotehost = models . CharField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> ) <EOL> rsync_remoteport = models . SmallIntegerField ( <EOL> default = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> validators = [ MinValueValidator ( <NUM_LIT:1> ) , MaxValueValidator ( <NUM_LIT> ) ] , <EOL> ) <EOL> rsync_mode = models . CharField ( <EOL> max_length = <NUM_LIT:20> , <EOL> choices = choices . RSYNC_MODE_CHOICES , <EOL> default = '<STR_LIT>' , <EOL> ) <EOL> rsync_remotemodule = models . CharField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> rsync_remotepath = models . CharField ( <EOL> max_length = <NUM_LIT:255> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> rsync_direction = models . CharField ( <EOL> max_length = <NUM_LIT:10> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> default = '<STR_LIT>' , <EOL> choices = choices . RSYNC_DIRECTION , <EOL> ) <EOL> rsync_desc = models . CharField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> ) <EOL> rsync_minute = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> ) <EOL> rsync_hour = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> ) <EOL> rsync_daymonth = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) , <EOL> ) <EOL> rsync_month = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = '<STR_LIT:*>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> rsync_dayweek = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = "<STR_LIT:*>" , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> rsync_user = UserField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> rsync_recursive = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = True , <EOL> ) <EOL> rsync_times = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = True , <EOL> ) <EOL> rsync_compress = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = True , <EOL> ) <EOL> rsync_archive = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = False , <EOL> ) <EOL> rsync_delete = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> ) , <EOL> default = False , <EOL> ) <EOL> rsync_quiet = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = False , <EOL> ) <EOL> rsync_preserveperm = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> default = False , <EOL> ) <EOL> rsync_preserveattr = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> ) , <EOL> default = False , <EOL> ) <EOL> rsync_delayupdates = models . BooleanField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = True , <EOL> ) <EOL> rsync_extra = models . TextField ( <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> blank = True <EOL> ) <EOL> rsync_enabled = models . BooleanField ( <EOL> default = True , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> ordering = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> def __unicode__ ( self ) : <EOL> if self . rsync_desc : <EOL> return self . rsync_desc <EOL> elif self . rsync_mode == '<STR_LIT>' : <EOL> return self . rsync_remotemodule <EOL> else : <EOL> return self . rsync_remotepath <EOL> def get_human_minute ( self ) : <EOL> if self . rsync_minute == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . rsync_minute . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . rsync_minute . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . rsync_minute <EOL> def get_human_hour ( self ) : <EOL> if self . rsync_hour == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . rsync_hour . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . rsync_hour . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . rsync_hour <EOL> def get_human_daymonth ( self ) : <EOL> if self . rsync_daymonth == '<STR_LIT:*>' : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . rsync_daymonth . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . rsync_daymonth . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . rsync_daymonth <EOL> def get_human_month ( self ) : <EOL> months = self . rsync_month . split ( '<STR_LIT:U+002C>' ) <EOL> if len ( months ) == <NUM_LIT:12> or self . rsync_month == '<STR_LIT:*>' : <EOL> return _ ( "<STR_LIT>" ) <EOL> mchoices = dict ( choices . MONTHS_CHOICES ) <EOL> labels = [ ] <EOL> for m in months : <EOL> labels . append ( unicode ( mchoices [ m ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def get_human_dayweek ( self ) : <EOL> weeks = self . rsync_dayweek . split ( '<STR_LIT:U+002C>' ) <EOL> if len ( weeks ) == <NUM_LIT:7> or self . rsync_dayweek == '<STR_LIT:*>' : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:1> , <NUM_LIT:6> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:6> , <NUM_LIT:8> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> wchoices = dict ( choices . WEEKDAYS_CHOICES ) <EOL> labels = [ ] <EOL> for w in weeks : <EOL> labels . append ( unicode ( wchoices [ str ( w ) ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def commandline ( self ) : <EOL> line = '<STR_LIT>' % ( <EOL> self . rsync_path <EOL> ) <EOL> if self . rsync_recursive : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_times : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_compress : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_archive : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_preserveperm : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_preserveattr : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_delete : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_delayupdates : <EOL> line += '<STR_LIT>' <EOL> if self . rsync_extra : <EOL> line += '<STR_LIT>' % self . rsync_extra <EOL> if '<STR_LIT:@>' in self . rsync_remotehost : <EOL> remote = self . rsync_remotehost <EOL> else : <EOL> remote = '<STR_LIT>' % ( <EOL> self . rsync_user , <EOL> self . rsync_remotehost , <EOL> ) <EOL> if self . rsync_mode == '<STR_LIT>' : <EOL> if self . rsync_direction == '<STR_LIT>' : <EOL> line += '<STR_LIT>' % ( <EOL> self . rsync_path , <EOL> remote , <EOL> self . rsync_remotemodule , <EOL> ) <EOL> else : <EOL> line += '<STR_LIT>' % ( <EOL> remote , <EOL> self . rsync_remotemodule , <EOL> self . rsync_path , <EOL> ) <EOL> else : <EOL> line += ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> ) % ( <EOL> self . rsync_remoteport <EOL> ) <EOL> if self . rsync_direction == '<STR_LIT>' : <EOL> line += '<STR_LIT>' % ( <EOL> self . rsync_path , <EOL> remote , <EOL> self . rsync_remotepath , <EOL> ) <EOL> else : <EOL> line += '<STR_LIT>' % ( <EOL> remote , <EOL> self . rsync_remotepath , <EOL> self . rsync_path , <EOL> ) <EOL> if self . rsync_quiet : <EOL> line += '<STR_LIT>' <EOL> return line <EOL> def run ( self ) : <EOL> proc = subprocess . Popen ( [ <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , str ( self . id ) , <EOL> ] ) <EOL> proc . communicate ( ) <EOL> def delete ( self ) : <EOL> super ( Rsync , self ) . delete ( ) <EOL> try : <EOL> notifier ( ) . restart ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> class SMARTTest ( Model ) : <EOL> smarttest_disks = models . ManyToManyField ( <EOL> Disk , <EOL> limit_choices_to = { '<STR_LIT>' : True } , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> smarttest_type = models . CharField ( <EOL> choices = choices . SMART_TEST , <EOL> max_length = <NUM_LIT:2> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> smarttest_desc = models . CharField ( <EOL> max_length = <NUM_LIT> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> blank = True , <EOL> ) <EOL> smarttest_hour = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = '<STR_LIT:*>' , <EOL> ) <EOL> smarttest_daymonth = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> help_text = _ ( "<STR_LIT>" ) , <EOL> default = '<STR_LIT:*>' , <EOL> ) <EOL> smarttest_month = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = '<STR_LIT:*>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> smarttest_dayweek = models . CharField ( <EOL> max_length = <NUM_LIT:100> , <EOL> default = '<STR_LIT:*>' , <EOL> verbose_name = _ ( "<STR_LIT>" ) , <EOL> ) <EOL> def get_human_hour ( self ) : <EOL> if self . smarttest_hour in ( '<STR_LIT:..>' , '<STR_LIT:*>' ) : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . smarttest_hour . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . smarttest_hour . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . smarttest_hour <EOL> def get_human_daymonth ( self ) : <EOL> if self . smarttest_daymonth in ( '<STR_LIT:..>' , '<STR_LIT:*>' ) : <EOL> return _ ( u'<STR_LIT>' ) <EOL> elif self . smarttest_daymonth . startswith ( '<STR_LIT>' ) : <EOL> return _ ( u'<STR_LIT>' ) . format ( <EOL> self . smarttest_daymonth . split ( '<STR_LIT>' ) [ <NUM_LIT:1> ] ) <EOL> else : <EOL> return self . smarttest_daymonth <EOL> def get_human_month ( self ) : <EOL> months = self . smarttest_month . split ( '<STR_LIT:U+002C>' ) <EOL> if len ( months ) == <NUM_LIT:12> or self . smarttest_month == '<STR_LIT:*>' : <EOL> return _ ( "<STR_LIT>" ) <EOL> mchoices = dict ( choices . MONTHS_CHOICES ) <EOL> labels = [ ] <EOL> for m in months : <EOL> labels . append ( unicode ( mchoices [ m ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def get_human_dayweek ( self ) : <EOL> weeks = self . smarttest_dayweek . split ( '<STR_LIT:U+002C>' ) <EOL> if len ( weeks ) == <NUM_LIT:7> : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:1> , <NUM_LIT:6> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> if weeks == map ( str , xrange ( <NUM_LIT:6> , <NUM_LIT:8> ) ) : <EOL> return _ ( '<STR_LIT>' ) <EOL> wchoices = dict ( choices . WEEKDAYS_CHOICES ) <EOL> labels = [ ] <EOL> for w in weeks : <EOL> labels . append ( unicode ( wchoices [ str ( w ) ] ) ) <EOL> return '<STR_LIT:U+002CU+0020>' . join ( labels ) <EOL> def __unicode__ ( self ) : <EOL> if self . smarttest_disks . count ( ) > <NUM_LIT:3> : <EOL> disks = [ d . disk_name for d in self . smarttest_disks . all ( ) [ : <NUM_LIT:3> ] ] <EOL> disks = '<STR_LIT:U+002CU+0020>' . join ( disks ) + '<STR_LIT>' <EOL> else : <EOL> disks = [ d . disk_name for d in self . smarttest_disks . all ( ) ] <EOL> disks = '<STR_LIT:U+002CU+0020>' . join ( disks ) <EOL> return "<STR_LIT>" % ( <EOL> self . get_smarttest_type_display ( ) , <EOL> disks <EOL> ) <EOL> def delete ( self ) : <EOL> super ( SMARTTest , self ) . delete ( ) <EOL> try : <EOL> notifier ( ) . restart ( "<STR_LIT>" ) <EOL> except : <EOL> pass <EOL> class Meta : <EOL> verbose_name = _ ( "<STR_LIT>" ) <EOL> verbose_name_plural = _ ( "<STR_LIT>" ) <EOL> ordering = [ "<STR_LIT>" ] </s>
