Exemplo n.º 1
0
 def move_dirs(self):
     try:
         dst = self.args[0].lower()
     except IndexError:
         raise OrganizerExceptions.CommandLineArgumentException(
             'Must Enter a destination argument.')
     if dst == 'local':
         sourcePath = '/Users/agreen/.stage/finished/organized/'
         #destinationPath = '/Volumes/Echo/.p/finished/'
         destinationPath = '/Volumes/Papa/.p/'
     elif dst == 'p':
         sourcePath = '/Volumes/Echo/.p/'
         destinationPath = '/Volumes/Papa/.p/'
     elif dst == 'papa':
         sourcePath = '/Volumes/Papa/.organized/'
         destinationPath = '/Volumes/Papa/.p/'
     else:
         message = 'Error: ' + dst + ' not a recognized destination. Enter either local or p as destination'
         raise OrganizerExceptions.UnknownArgumentExeption(message)
     start = time.time()
     mover = DirectoryMover(sourcePath, destinationPath)
     mover.move_dirs()
     mover._del_empty_dirs()
     mover.save_recently_moved_names()
     end = time.time()
     minutes = (end - start) / 60.
     print('move directories took: %.2f' % minutes, 'minutes')
     return None
Exemplo n.º 2
0
 def add_file(self, balance_file):
     try:
         index_info = self._insertion_index(balance_file.file_name)
     except OrganizerExceptions.NoValueInListException as e:
         print(e)
     destination_path = os.path.join(self.root_path, balance_file.file_name)
     # TODO Add error handling in case moving dirs fails when handling is added to DirectoryMover
     dir_mover = DirectoryMover(balance_file.path, destination_path)
     dir_mover.move_single_dir(dir_mover.src_path, dir_mover.dst_path)
     if not index_info[self._constants.has_file]:
         print('inserting:', balance_file.file_name, 'into:',
               self.root_path)
         self.files.insert(index_info[self._constants.file_index],
                           balance_file.file_name)
     self.used_space += balance_file.size
     return None
Exemplo n.º 3
0
 def move_dirs(self):
     try:
         dst = self.args[0].lower()
     except IndexError:
         raise OrganizerExceptions.CommandLineArgumentException('Must Enter a destination argument.')
     if dst == 'local':
         sourcePath = '/Users/agreen/.stage/finished/organized/'
         #destinationPath = '/Volumes/Echo/.p/finished/'
         destinationPath = '/Volumes/Papa/.p/'
     elif dst == 'p':
         sourcePath = '/Volumes/Echo/.p/'
         destinationPath = '/Volumes/Papa/.p/'
     elif dst == 'papa':
         sourcePath = '/Volumes/Papa/.organized/'
         destinationPath = '/Volumes/Papa/.p/'
     else:
         message = 'Error: ' + dst + ' not a recognized destination. Enter either local or p as destination'
         raise OrganizerExceptions.UnknownArgumentExeption(message)
     start = time.time()
     mover = DirectoryMover(sourcePath, destinationPath)
     mover.move_dirs()
     mover._del_empty_dirs()
     mover.save_recently_moved_names()
     end = time.time()
     minutes = (end - start)/60.
     print('move directories took: %.2f' % minutes, 'minutes')
     return None