Пример #1
0
    def __init__(self, parent):
        """Default constructor.
        """
        _gladefile = Util.get_resource_file('sbackup-restore.glade')

        _wdgt_lst = [
            'restoreDialog', 'txt_title', 'txt_content', 'button_cancel',
            'button_close', 'restore_progressbar'
        ]

        _hdls = ['_on_button_close_clicked']

        _top_win_name = 'restoreDialog'
        GladeWindow.__init__(self,
                             gladefile=_gladefile,
                             widget_list=_wdgt_lst,
                             handlers=_hdls,
                             root=_top_win_name,
                             parent=parent,
                             pull_down_dict=None)
        self.set_top_window(self.widgets[_top_win_name])
        self.top_window.set_icon_from_file(\
                                    Util.get_resource_file("sbackup-restore.png"))

        ProgressbarMixin.__init__(self, self.widgets['restore_progressbar'])
        self.__mode = None
        self.__source = None
        self.__dirname = None

        self._init_pulse()
Пример #2
0
    def __init__(self, parent=None):
        GladeWindow.__init__(self,
                             gladefile=Util.get_resource_file(
                                 gtk_rsrc.RESTOREGUI_GLADEFILE),
                             widget_list=gtk_rsrc.get_restoregui_widgets(),
                             handlers=gtk_rsrc.get_restoregui_handlers(),
                             root=gtk_rsrc.RESTOREGUI_TOPWINDOW,
                             parent=parent,
                             pull_down_dict=None)
        self.set_top_window(self.widgets[gtk_rsrc.RESTOREGUI_TOPWINDOW])
        Gtk.Window.set_default_icon_from_file(
            Util.get_resource_file(constants.RESTORE_ICON_FILENAME))

        # setup progress bar
        ProgressbarMixin.__init__(self, self.widgets['progressbar'])
        self._init_pulse()

        self.logger = LogFactory.getLogger(level=10)
        self.config = self.__get_configuration()
        self.__default_destination_path = self.config.get_destination_path()

        self.currentSnp = None
        self.currentsbdict = None
        self.currSnpFilesInfos = None
        self.restoreman = None
        self.snpman = None
        self.target = None
        self.__fam_target_hdl = fam.get_fam_target_handler_facade_instance()
        self.__fop = fam.get_file_operations_facade_instance()

        # tree stores
        self.snplisttreestore = Gtk.TreeStore(str, str)
        self.flisttreestore = Gtk.TreeStore(str, str)
        self.flisttreesort = Gtk.TreeModelSort(self.flisttreestore)
        self.historylisttreestore = Gtk.TreeStore(str)
        self.__init_treeviews()

        self.widgets['snpdetails'].set_sensitive(False)

        self.__context_id = None
        self.__init_statusbar()

        # firstly initialize destination with target of default profile
        self._defaultdest_active = True
        self.widgets['defaultradiob'].set_active(True)
        self._apply_defaultradiob_state()
        self.widgets['defaultfolderlabel'].set_text(_("n.a."))
        self._defaultdest_active = True
        GObject.idle_add(self.__set_destination,
                         self.__default_destination_path)

        self.__restore_dialog = RestoreDialog(parent=self)
Пример #3
0
    def _launch_indicator(self):
        """
        environ: the Gnome-session environ is accessable for root and the
                 user who owns the session.
        :note: import D-Bus related modules only if using D-Bus is enabled
        """
        print("Attempt to launch indicator application (status icon).")
        _path_to_app = get_resource_file(constants.INDICATORAPP_FILE)

        session_env = system.get_session_environment()
        if session_env is None:
            print(
                "No desktop session found. Indicator application is not started."
            )
        else:
            _cmd = [_path_to_app]
            if self.__options_given.legacy_appindicator is True:
                _cmd.append("--legacy")

            if not system.is_superuser():
                if system.get_user_from_uid() != session_env["USER"]:
                    _cmd = None
                    print("Unable to launch indicator application as current user.\n"\
                          "You must own current desktop session.")

            if _cmd is None:
                print("Unable to launch indicator application")
            else:
                pid = system.exec_command_async(args=_cmd, env=session_env)
                print("Indicator application started (PID: %s)" % pid)
                time.sleep(constants.INDICATOR_LAUNCH_PAUSE_SECONDS)
Пример #4
0
 def __init_ctrls(self):
     self._build_menu()
     self._show_showdialogs_menuitem()
     self._indicator.set_from_file(
         util.get_resource_file(constants.DEFAULT_ICON_FILENAME))
     self._indicator.connect('popup-menu', self.on_popup_menu)
     self._indicator.set_blinking(False)
     self._indicator.set_visible(True)
 def _launch_dbusservice(self):
     """Launches the DBus service and establishes a placeholder
     connection in order to keep the service alive as long as this
     application is running. Call `finalize` to close the
     connection properly when terminating the application.
     """
     dbus_launcher = get_resource_file(constants.DBUSSERVICE_FILE)
     system.exec_command_async(args=[dbus_launcher, "start"])
     time.sleep(DBUS_COMMUNICATE_PAUSE_SECONDS)
Пример #6
0
    def __init__(self, indicator_hdl):
        if not isinstance(indicator_hdl, SBackupdIndicatorHandler):
            raise TypeError(
                "Parameter of type `SBackupdIndicatorHandler` expected.")

        SBackupdIndicatorBase.__init__(self, indicator_hdl)

        self.logger = LogFactory.getLogger()
        self._indicator = gtk.StatusIcon()

        PyNotifyMixin.__init__(self,
                               logger=self.logger,
                               iconfile=util.get_resource_file(
                                   constants.NOTIFICATION_ICON_FILENAME),
                               trayicon=self._indicator)

        self.__init_ctrls()
Пример #7
0
def show_about_dialog(set_transient_for = None):
    _icon_file = util.get_resource_file(constants.DEFAULT_ICON_FILENAME)
    about = Gtk.AboutDialog()
    about.set_name(Infos.NAME)
    about.set_version(Infos.VERSION)
    about.set_comments(Infos.DESCRIPTION)
    if set_transient_for is not None:
        about.set_transient_for(set_transient_for)
    about.set_copyright(Infos.COPYRIGHT)
    about.set_translator_credits(Infos.TRANSLATORS)
    about.set_authors(Infos.AUTHORS)
    if not system.is_superuser():
        about.set_website(Infos.WEBSITE)
    about.set_logo(GdkPixbuf.Pixbuf.new_from_file(_icon_file))
    about.set_icon_from_file(_icon_file)
    about.run()
    about.destroy()
Пример #8
0
    def __init__(self, indicator_hdl):
        if not isinstance(indicator_hdl, SBackupdIndicatorHandler):
            raise TypeError(
                "Parameter of type `SBackupdIndicatorHandler` expected.")

        SBackupdIndicatorBase.__init__(self, indicator_hdl)

        self.logger = LogFactory.getLogger()
        self._indicator = appindicator.Indicator(
            constants.INDICATORAPP_NAME, constants.INDICATOR_ACTIVE_ICON,
            appindicator.CATEGORY_APPLICATION_STATUS)

        PyNotifyMixin.__init__(self,
                               logger=self.logger,
                               iconfile=util.get_resource_file(
                                   constants.NOTIFICATION_ICON_FILENAME),
                               trayicon=None)

        self.__init_ctrls()
Пример #9
0
def msgdialog(message_str,
              msgtype,
              parent,
              boxtitle="",
              buttons=gtk.BUTTONS_CLOSE,
              headline_str="",
              secmsg_str=""):
    """Creates und displays a modal dialog box. Main purpose is
    displaying of error messages.
    
    Do not use markup for the strings.
    
    @param message_format: error message to show
    @type message_format: String
    
    @todo: Add proper escaping before markup is applied to the headlline.
    """
    # in compliance with Gnome HIG a 'Close' button instead of 'OK' is used

    dialog = gtk.MessageDialog(parent=parent,
                               type=msgtype,
                               flags=gtk.DIALOG_MODAL
                               | gtk.DIALOG_DESTROY_WITH_PARENT,
                               buttons=buttons)

    icon_file = util.get_resource_file(constants.DEFAULT_ICON_FILENAME)
    dialog.set_icon_from_file(icon_file)

    if boxtitle.strip() != "":
        dialog.set_title(boxtitle)

    _hdl = headline_str.strip(" \n\t")
    if _hdl != "":
        _hdl = "<b>%s</b>\n\n" % glib.markup_escape_text(_hdl)
    _msg = "%s%s" % (_hdl, glib.markup_escape_text(message_str))
    dialog.set_markup(_msg)

    # an optional secondary message is added
    _sec = secmsg_str.strip(" \n\t")
    if _sec != "":
        _sec = "<small>%s</small>" % (glib.markup_escape_text(_sec))
        dialog.format_secondary_markup(_sec)
    return dialog
Пример #10
0
 def cancel_backup(self):
     res = True
     pid = self._backup_dbus_obj.get_backup_pid()
     self.logger.info(_("PID of backup process being canceled: %s") % pid)
     if pid != constants.PID_UNKNOWN:
         term_script = util.get_resource_file(constants.TERMINATE_FILE)
         _ret = system.exec_command_returncode([term_script, str(pid)])
         if _ret != 0:
             self.logger.info(
                 _("Unable to send signal to process %s") % pid)
             self.logger.info(
                 _("Sending signal using gksu to process %s") % pid)
             descr = _("Cancel Backup")
             _ret = system.exec_command_returncode(
                 ["gksu", "--description", descr, term_script,
                  str(pid)])
             if _ret != 0:
                 self.logger.warning(
                     _("Sending signal using gksu to process %s failed") %
                     pid)
                 res = False
     else:
         res = False
     return res
Пример #11
0
try:
    from gi.repository import Gtk
    from gi.repository import Gdk
except ImportError:
    print(
        "Failed to load Python GTK bindings. Please check your installation.")
    sys.exit(1)
try:
    import gnomevfs
except ImportError:
    import gnome.vfs as gnomevfs

from sbackup.ui import misc
sys.excepthook = misc.except_hook_threaded

_LEGACY_RESTOREGUI_GLADE = Util.get_resource_file(
    'sbackup-legacy-restore.glade')


class SRestore:
    def __init__(self):
        pass

    def restore(self, backup, spath, dpath=None):
        """
        Restore one file or directory from the backup tdir with name
        spath to dpath (or to its old location).
        All existing files must be moved to a "*.before_restore_$time" files.
        """

        if not dpath:
            dpath = spath