def refresh_device_list(self):
   treeview_backups_model = self.xml.get_widget('treeview_backups').get_model()
   treeview_backups_model.clear()
   known_backups = backup.get_known_backups()
   for t in known_backups:
     uuid = t['uuid']
     paths = backup.get_dev_paths_for_uuid(t['uuid'])
     drive_name = 'UUID: '+ t['uuid']
     for path in paths:
       if 'disk/by-id' in path:
         drive_name = path[path.index('disk/by-id')+11:]
     free_space = util.humanize_bytes(backup.get_free_space(t['uuid']))
     drive_name = backup.get_mount_point_for_uuid(t['uuid']) + ' (%s free)' % free_space
     s = "<b>Drive:</b> %s\n<b>Source:</b> <i>%s</i>:%s\n" % (util.pango_escape(drive_name), util.pango_escape(t['host']), util.pango_escape(t['path']), )
     if backup.is_dev_present(t['uuid']) and backup.get_hostname()==t['host']:
       s += "<b>Status:</b> Drive is ready for backups"
     else:
       if backup.is_dev_present(t['uuid']) and backup.get_hostname()!=t['host']:
         s += "<b>Status:</b> Backup available for export only (was created on another computer)"
       else:
         s += "<b>Status:</b> Drive is unavailable (please attach)"
     if backup.get_device_type(uuid)=='gvfs':
       icon = self.main_window.render_icon(gtk.STOCK_NETWORK, gtk.ICON_SIZE_DIALOG)
     elif backup.get_device_type(uuid)=='local':
       icon = self.main_window.render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_DIALOG)
     else:
       icon = self.main_window.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
     treeview_backups_model.append( (icon, s, backup.is_dev_present(t['uuid']), t['uuid'], t['host'], t['path']) )
   if known_backups:
     treeview_backups_model.append( (self.main_window.render_icon(gtk.STOCK_ADD, gtk.ICON_SIZE_DIALOG), 'Double-click here to create a new backup...', True, None, None, None) )
   else:
     treeview_backups_model.append( (self.main_window.render_icon(gtk.STOCK_ADD, gtk.ICON_SIZE_DIALOG), 'No existing backups found.\nDouble-click here to create a new backup...', True, None, None, None) )
 def refresh_device_list(self):
     treeview_backups_model = self.xml.get_widget(
         'treeview_backups').get_model()
     treeview_backups_model.clear()
     writable_devices = backup.get_writable_devices()
     for uuid in writable_devices:
         path = backup.get_mount_point_for_uuid(uuid)
         if backup.get_device_type(uuid) == 'gvfs':
             icon = self.main_window.render_icon(gtk.STOCK_NETWORK,
                                                 gtk.ICON_SIZE_DIALOG)
         elif backup.get_device_type(uuid) == 'local':
             icon = self.main_window.render_icon(gtk.STOCK_HARDDISK,
                                                 gtk.ICON_SIZE_DIALOG)
         else:
             icon = self.main_window.render_icon(gtk.STOCK_DIALOG_QUESTION,
                                                 gtk.ICON_SIZE_DIALOG)
         free_space = util.humanize_bytes(backup.get_free_space(uuid))
         s = "<b>Drive:</b> %s\n<b>Mount Point:</b> %s\n<b>Free Space:</b> %s" % (
             util.pango_escape(uuid), util.pango_escape(path),
             util.pango_escape(free_space))
         treeview_backups_model.append(
             (icon, s, backup.is_dev_present(uuid), uuid))
     if not writable_devices:
         icon = self.main_window.render_icon(gtk.STOCK_INFO,
                                             gtk.ICON_SIZE_DIALOG)
         s = 'In order to create a backup, Flyback needs a hard drive\nother than the one your computer boots from.\n(preferably external and removable)  Please plug one\ninto a free USB or eSATA port...'
         treeview_backups_model.append((icon, s, False, None))
         self.xml.get_widget('button_new').set_sensitive(False)
     else:
         self.xml.get_widget('button_new').set_sensitive(True)
 def refresh_device_list(self):
     treeview_backups_model = self.xml.get_widget("treeview_backups").get_model()
     treeview_backups_model.clear()
     known_backups = backup.get_known_backups()
     for t in known_backups:
         uuid = t["uuid"]
         paths = backup.get_dev_paths_for_uuid(t["uuid"])
         drive_name = "UUID: " + t["uuid"]
         for path in paths:
             if "disk/by-id" in path:
                 drive_name = path[path.index("disk/by-id") + 11 :]
         free_space = util.humanize_bytes(backup.get_free_space(t["uuid"]))
         drive_name = backup.get_mount_point_for_uuid(t["uuid"]) + " (%s free)" % free_space
         s = "<b>Drive:</b> %s\n<b>Source:</b> <i>%s</i>:%s\n" % (
             util.pango_escape(drive_name),
             util.pango_escape(t["host"]),
             util.pango_escape(t["path"]),
         )
         if backup.is_dev_present(t["uuid"]) and backup.get_hostname() == t["host"]:
             s += "<b>Status:</b> Drive is ready for backups"
         else:
             if backup.is_dev_present(t["uuid"]) and backup.get_hostname() != t["host"]:
                 s += "<b>Status:</b> Backup available for export only (was created on another computer)"
             else:
                 s += "<b>Status:</b> Drive is unavailable (please attach)"
         if backup.get_device_type(uuid) == "gvfs":
             icon = self.main_window.render_icon(gtk.STOCK_NETWORK, gtk.ICON_SIZE_DIALOG)
         elif backup.get_device_type(uuid) == "local":
             icon = self.main_window.render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_DIALOG)
         else:
             icon = self.main_window.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
         treeview_backups_model.append((icon, s, backup.is_dev_present(t["uuid"]), t["uuid"], t["host"], t["path"]))
     if known_backups:
         treeview_backups_model.append(
             (
                 self.main_window.render_icon(gtk.STOCK_ADD, gtk.ICON_SIZE_DIALOG),
                 "Double-click here to create a new backup...",
                 True,
                 None,
                 None,
                 None,
             )
         )
     else:
         treeview_backups_model.append(
             (
                 self.main_window.render_icon(gtk.STOCK_ADD, gtk.ICON_SIZE_DIALOG),
                 "No existing backups found.\nDouble-click here to create a new backup...",
                 True,
                 None,
                 None,
                 None,
             )
         )
    def delete_backup(self, a=None, b=None, c=None):
        treeview_backups_widget = self.xml.get_widget("treeview_backups")
        model, entry = treeview_backups_widget.get_selection().get_selected()
        if entry and model.get_value(entry, 2):
            uuid = model.get_value(entry, 3)
            host = model.get_value(entry, 4)
            path = model.get_value(entry, 5)
            if uuid and host and path:
                title = "Delete Backup?"
                s = "Permanently delete the following backup repository?\n"
                s += "<b>Drive:</b> %s:%s\n<b>Source:</b> <i>%s</i>:%s\n" % (
                    util.pango_escape(uuid),
                    util.pango_escape(backup.get_mount_point_for_uuid(uuid)),
                    util.pango_escape(host),
                    util.pango_escape(path),
                )
                s += "\n<b>This action cannot be undone!</b>"
                md = gtk.MessageDialog(
                    None,
                    gtk.DIALOG_DESTROY_WITH_PARENT,
                    gtk.MESSAGE_WARNING,
                    gtk.BUTTONS_YES_NO,
                    util.pango_escape(title),
                )
                md.format_secondary_markup(s)
                if gtk.RESPONSE_YES == md.run():
                    print "deleting", uuid, host, path

                    gui = self

                    class T(threading.Thread):
                        def run(self):
                            backup.delete_backup(uuid, host, path)
                            gtk.gdk.threads_enter()
                            gui.refresh_device_list()
                            gtk.gdk.threads_leave()

                    T().start()

                md.destroy()
Exemple #5
0
 def refresh_device_list(self):
   treeview_backups_model = self.xml.get_widget('treeview_backups').get_model()
   treeview_backups_model.clear()
   writable_devices = backup.get_writable_devices()
   for uuid in writable_devices:
     path = backup.get_mount_point_for_uuid(uuid)
     if backup.get_device_type(uuid)=='gvfs':
       icon = self.main_window.render_icon(gtk.STOCK_NETWORK, gtk.ICON_SIZE_DIALOG)
     elif backup.get_device_type(uuid)=='local':
       icon = self.main_window.render_icon(gtk.STOCK_HARDDISK, gtk.ICON_SIZE_DIALOG)
     else:
       icon = self.main_window.render_icon(gtk.STOCK_DIALOG_QUESTION, gtk.ICON_SIZE_DIALOG)
     free_space = util.humanize_bytes(backup.get_free_space(uuid))
     s = "<b>Drive:</b> %s\n<b>Mount Point:</b> %s\n<b>Free Space:</b> %s" % (util.pango_escape(uuid), util.pango_escape(path), util.pango_escape(free_space))
     treeview_backups_model.append( (icon, s, backup.is_dev_present(uuid), uuid) )
   if not writable_devices:
     icon = self.main_window.render_icon(gtk.STOCK_INFO, gtk.ICON_SIZE_DIALOG)
     s = 'In order to create a backup, Flyback needs a hard drive\nother than the one your computer boots from.\n(preferably external and removable)  Please plug one\ninto a free USB or eSATA port...'
     treeview_backups_model.append( (icon, s, False, None) )
     self.xml.get_widget('button_new').set_sensitive(False)
   else:
     self.xml.get_widget('button_new').set_sensitive(True)
  def delete_backup(self,a=None,b=None,c=None):
    treeview_backups_widget = self.xml.get_widget('treeview_backups')
    model, entry = treeview_backups_widget.get_selection().get_selected()
    if entry and model.get_value(entry, 2):
      uuid = model.get_value(entry, 3)
      host = model.get_value(entry, 4)
      path = model.get_value(entry, 5)
      if uuid and host and path:
        title = 'Delete Backup?'
        s = "Permanently delete the following backup repository?\n"
        s += "<b>Drive:</b> %s:%s\n<b>Source:</b> <i>%s</i>:%s\n" % (util.pango_escape(uuid), util.pango_escape(backup.get_mount_point_for_uuid(uuid)), util.pango_escape(host), util.pango_escape(path), )
        s += '\n<b>This action cannot be undone!</b>'
        md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO, util.pango_escape(title))
        md.format_secondary_markup(s)
        if gtk.RESPONSE_YES==md.run():
          print 'deleting',uuid,host,path

          gui = self
          class T(threading.Thread):
            def run(self):
              backup.delete_backup(uuid, host, path)
              gtk.gdk.threads_enter()
              gui.refresh_device_list()
              gtk.gdk.threads_leave()
          T().start()

        md.destroy()