Exemplo n.º 1
0
 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) )
Exemplo n.º 2
0
 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,
             )
         )
Exemplo n.º 3
0
def run_backup(uuid, path):
  host = backup.get_hostname()
  if backup.test_backup_assertions(uuid, host, path):
    print '---=== starting backup:', uuid, path, '===---'
    try: backup.backup(uuid, host, path)
    except: traceback.print_exc()
  else:
    print '---=== skipped backup:', uuid, path, '===---'
Exemplo n.º 4
0
def run_backup(uuid, path):
    host = backup.get_hostname()
    if backup.test_backup_assertions(uuid, host, path):
        print '---=== starting backup:', uuid, path, '===---'
        try:
            backup.backup(uuid, host, path)
        except:
            traceback.print_exc()
    else:
        print '---=== skipped backup:', uuid, path, '===---'
Exemplo n.º 5
0
 def init_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:
     uuid = model.get_value(entry, 3)
     host = backup.get_hostname()
     path = self.xml.get_widget('filechooserbutton').get_current_folder()
     print 'opening... drive:%s'%uuid, 'host:%s'%host, 'path:%s'%path
     backup.init_backup(uuid, host, path)
     self.register_gui( manage_backup_gui.GUI(self.register_gui, self.unregister_gui, uuid, host, path) )
     self.close()
   else:
     s = 'No Drive Selected'
     md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, s)
     md.format_secondary_markup('You must select a drive from the list...')
     md.run()
     md.destroy()
Exemplo n.º 6
0
 def init_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:
         uuid = model.get_value(entry, 3)
         host = backup.get_hostname()
         path = self.xml.get_widget(
             'filechooserbutton').get_current_folder()
         print 'opening... drive:%s' % uuid, 'host:%s' % host, 'path:%s' % path
         backup.init_backup(uuid, host, path)
         self.register_gui(
             manage_backup_gui.GUI(self.register_gui, self.unregister_gui,
                                   uuid, host, path))
         self.close()
     else:
         s = 'No Drive Selected'
         md = gtk.MessageDialog(None, gtk.DIALOG_DESTROY_WITH_PARENT,
                                gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE, s)
         md.format_secondary_markup(
             'You must select a drive from the list...')
         md.run()
         md.destroy()