Пример #1
0
    def save_settings(self):
        """Helper function for on_imi_file_quit_activate."""
        sel_group = self.gstore.get_path(self.get_selected_group()[0])[0]
        self.gstore.remove(
            self.gstore.get_iter(self.default_group_ref.get_path()))
        config.save_groups(config.expand_filename('groups.json'), self.gstore)
        settings = config.settings
        if not settings.has_section('GUI'):
            settings.add_section('GUI')

        settings.set('GUI', 'selected_group', str(sel_group))
        settings.set('GUI', 'show_real_names', str(self.show_real_names))
        settings.set('GUI', 'thumbshots_width', str(self.ts_width))
        config.write_ini_file(config.expand_filename('settings'), settings)
Пример #2
0
 def broadcast_screen(self, fullscreen=''):
     """Helper function for on_imi_broadcasts_broadcast_screen*_activate."""
     if self.vncserver is None:
         pwdfile = config.expand_filename('vncpasswd')
         pwd = ''.join(
             random.sample(string.ascii_letters + string.digits, 8))
         subprocess.call(['x11vnc', '-storepasswd', pwd, pwdfile])
         file = open(pwdfile, 'rb')
         pwd = file.read()
         file.close()
         self.vncserver_port = self.find_unused_port()
         self.vncserver_pwd = ''.join('\\%o' % c for c in pwd)
         self.vncserver = subprocess.Popen([
             'x11vnc', '-noshm', '-nopw', '-quiet', '-viewonly', '-shared',
             '-forever', '-nolookup', '-24to32', '-threads', '-rfbport',
             str(self.vncserver_port), '-rfbauth', pwdfile
         ])
     # Running `xdg-screensaver reset` as root doesn't reset the D.E.
     # screensaver, so send the reset command to both epoptes processes
     self.exec_on_selected_clients(['reset_screensaver'],
                                   mode=EM_SYSTEM_AND_SESSION)
     self.exec_on_selected_clients([
         "receive_broadcast", self.vncserver_port, self.vncserver_pwd,
         fullscreen
     ],
                                   mode=EM_SYSTEM_OR_SESSION)
Пример #3
0
    def run(self):
        """Show the dialog, then hide it so that it may be reused.
        Return the command.
        """
        reply = self.dialog.run()
        if reply == 1:
            result = self.ent_command.get_text().strip()
            if result in config.history:
                config.history.remove(result)
            config.history.insert(0, result)
            config.write_plain_file(
                config.expand_filename('history'), config.history)
        else:
            result = ''
        self.dialog.hide()

        return result
Пример #4
0
    def run(self):
        """Show the dialog, then hide it so that it may be reused.
        Return (text, title, markup).
        """
        reply = self.dialog.run()
        if reply == 1:
            text = self.txv_message.get_buffer().props.text
            title = self.ent_title.get_text().strip()
            use_markup = self.chb_markup.get_active()
            result = (text, title, use_markup)
            config.settings.set('GUI', 'messages_default_title', title)
            config.settings.set('GUI', 'messages_use_markup', str(use_markup))
            config.write_ini_file(config.expand_filename('settings'),
                                  config.settings)
        else:
            result = ()
        self.dialog.hide()

        return result
Пример #5
0
    def __init__(self):
        # Initialization of general-purpose variables
        self.about = None
        self.benchmark = None
        self.client_information = None
        self.current_macs = subprocess.Popen(
            [
                'sh', '-c', r"""ip -oneline -family inet link show | """
                r"""sed -n '/.*ether[[:space:]]*\([[:xdigit:]:]*\).*/"""
                r"""{s//\1/;y/abcdef-/ABCDEF:/;p;}';"""
                r"""echo $LTSP_CLIENT_MAC"""
            ],
            stdout=subprocess.PIPE).communicate()[0].split()
        self.current_thumbshots = dict()
        self.daemon = None
        self.displayed_compatibility_warning = False
        self.exec_command = None
        self.imagetypes = {
            'thin': GdkPixbuf.Pixbuf.new_from_file('images/thin.svg'),
            'fat': GdkPixbuf.Pixbuf.new_from_file('images/fat.svg'),
            'standalone':
            GdkPixbuf.Pixbuf.new_from_file('images/standalone.svg'),
            'offline': GdkPixbuf.Pixbuf.new_from_file('images/offline.svg')
        }
        self.labels_order = (1, 0)
        self.notify_queue = NotifyQueue(
            'Epoptes', '/usr/share/icons/hicolor/scalable/apps/epoptes.svg')
        self.send_message = None
        self.show_real_names = config.settings.getboolean('GUI',
                                                          'show_real_names',
                                                          fallback=False)
        # Thumbshot width and height. Good width defaults are multiples of 16,
        # so that the height is an integer in both 16/9 and 4/3 aspect ratios.
        self.ts_width = config.settings.getint('GUI',
                                               'thumbshots_width',
                                               fallback=128)
        self.ts_height = int(self.ts_width / (4 / 3))
        self.uid = os.getuid()
        self.vncserver = None
        self.vncserver_port = None
        self.vncserver_pwd = None
        self.vncviewer = None
        self.vncviewer_port = None

        self.builder = Gtk.Builder()
        self.builder.add_from_file('epoptes.ui')
        self.get = self.builder.get_object
        # Hide the remote assistance menuitem if epoptes-client isn't installed
        if not os.path.isfile(
                '/usr/share/epoptes-client/remote_assistance.py'):
            self.get('mi_remote_assistance').set_property('visible', False)
            self.get('smi_help_remote_support').set_property('visible', False)
        self.mnu_add_to_group = self.get('mnu_add_to_group')
        self.mni_add_to_group = self.get('mni_add_to_group')
        self.gstore = Gtk.ListStore(str, object, bool)
        self.trv_groups = self.get('trv_groups')
        self.trv_groups.set_model(self.gstore)
        self.mainwin = self.get('wnd_main')
        self.cstore = Gtk.ListStore(str, GdkPixbuf.Pixbuf, object, str)
        self.icv_clients = self.get('icv_clients')
        self.set_labels_order(1, 0, None)
        self.icv_clients.set_model(self.cstore)
        self.icv_clients.set_pixbuf_column(C_PIXBUF)
        self.icv_clients.set_text_column(C_LABEL)
        self.cstore.set_sort_column_id(C_LABEL, Gtk.SortType.ASCENDING)
        self.on_icv_clients_selection_changed(None)
        self.icv_clients.enable_model_drag_source(
            Gdk.ModifierType.BUTTON1_MASK,
            [Gtk.TargetEntry.new("add", Gtk.TargetFlags.SAME_APP, 0)],
            Gdk.DragAction.COPY)
        self.trv_groups.enable_model_drag_dest(
            [("add", Gtk.TargetFlags.SAME_APP, 0)], Gdk.DragAction.COPY)
        self.default_group = structs.Group(
            '<b>' + _('Detected clients') + '</b>', {})
        default_iter = self.gstore.append(
            [self.default_group.name, self.default_group, False])
        self.default_group_ref = Gtk.TreeRowReference.new(
            self.gstore, self.gstore.get_path(default_iter))
        # Connect glade handlers with the callback functions
        self.builder.connect_signals(self)
        self.trv_groups.get_selection().select_path(
            self.default_group_ref.get_path())
        self.get('adj_icon_size').set_value(self.ts_width)
        _saved_clients, groups = config.read_groups(
            config.expand_filename('groups.json'))
        if groups:
            self.mni_add_to_group.set_sensitive(True)
        for group in groups:
            self.gstore.append([group.name, group, True])
            mitem = Gtk.MenuItem(label=group.name)
            mitem.show()
            mitem.connect('activate',
                          self.on_imi_clients_add_to_group_activate, group)
            self.mnu_add_to_group.append(mitem)
        self.fill_icon_view(self.get_selected_group()[1])
        self.trv_groups.get_selection().select_path(
            config.settings.getint('GUI', 'selected_group', fallback=0))
        mitem = self.get(
            config.settings.get('GUI',
                                'label',
                                fallback='rmi_labels_host_user'))
        if not mitem:
            mitem = self.get('rmi_labels_host_user')
        mitem.set_active(True)
        self.get('cmi_show_real_names').set_active(self.show_real_names)
        self.mainwin.set_sensitive(False)