Esempio n. 1
0
 def on_set_delete_activated(self, widget, view):
     selection = view.get_selection()
     model, paths = selection.get_selected_rows()
     for path in paths:
         iter = model.get_iter(path)
         id = model[iter][0]
         #
         tarname = make_tarname(model[iter][2])
         tarpath = pathlib.Path(CONFIG['save_location'], tarname)
         target = pathlib.Path(CONFIG['complete_path'], tarname)
         # tarpath = os.path.join(CONFIG['save_location'], tarname)
         if tarpath.is_file():
             try:
                 if target.exists():
                     raise Exception(f'target already exist: {target}')
                 tarpath.replace(target)
                 # shutil.move(tarpath, CONFIG['complete_path'])
                 Sets.delete().where(Sets.id == id).execute()
                 Urls.delete().where(Urls.set_id == id).execute()
                 model.remove(iter)
                 print(target)
             except Exception as e:
                 print(e)
         else:
             Sets.delete().where(Sets.id == id).execute()
             Urls.delete().where(Urls.set_id == id).execute()
             model.remove(iter)
Esempio n. 2
0
 def finish(self, set_iter, row, tarpath):
     set_model[set_iter][4] += 1
     count = set_model[set_iter][5]
     done = set_model[set_iter][4]
     Sets.update(done=done).where(Sets.id == row['set']).execute()
     if done == count:
         set_model.remove(set_iter)
         # move file
         shutil.move(tarpath, CONFIG['complete_path'])
         # clean set in db
         Sets.delete().where(Sets.id == row['set']).execute()
         # register archive database?
     Urls.delete().where(Urls.id == row['id']).execute()