Пример #1
0
 def handle(self, *app_labels, **options):
     self.defined_count = options['count'] 
     locations = self.get_locations() 
     date_tuple_list = []; ignore_list = []; dirs = {}
     #get stuff in locations 
     for l in locations:
         dirs[l] = os.listdir( l )
     it = iter( dirs.items() )
     for d in it: 
         base = d[0]
         base_contents = d[1] 
         for i in base_contents:
             this_entry = os.path.join(base, i )
             if os.path.isfile( this_entry ):
                 try: 
                     this_size = os.path.getsize( this_entry )
                 except OSError:
                     ignore_list.append( this_entry ) 
             elif os.path.isdir( this_entry ):
                 this_size = get_dir_size( this_entry )
             else:
                 ignore_list.append( this_entry )
                 this_size = 0 
             date_tuple_list.append( (this_entry, this_size ) )
     
     #sort by second element of tuples (date for dir/file) 
     date_tuple_list.sort(key=lambda x: x[1])
     puts(colored.yellow('The following items are not linked in seeding directory'))
     odd = True; counter = self.defined_count
     for f,t in date_tuple_list[-int(self.defined_count):]:
         to_print = "%d: %s %s" % (counter, humanize_bytes(t), f )
         if odd:
             odd = False
             with indent(4, quote=colored.blue('|')):
                 puts(colored.cyan(to_print))
         else:
             odd = True
             with indent(4, quote=colored.blue('|')):
                 puts(colored.yellow(to_print))
         counter = counter - 1
Пример #2
0
 def print_size( self ):
     return utility.humanize_bytes( self.size )
Пример #3
0
 def print_size(self):
     return utility.humanize_bytes(self.size)
Пример #4
0
 def get_real_size( self ):
     try: 
         size = os.path.getsize( self.get_path() )
     except OSError:
         size = 0
     return utility.humanize_bytes( size )
Пример #5
0
 def get_real_size(self):
     try:
         size = os.path.getsize(self.get_path())
     except OSError:
         size = 0
     return utility.humanize_bytes(size)