source: epoptes/trunk/fuentes/epoptes/ui/remote_assistance.py @ 295

Last change on this file since 295 was 295, checked in by mabarracus, 3 years ago

copy trusty epoptes code

File size: 2.4 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3
4###########################################################################
5# Remote assistance.
6#
7# Copyright (C) 2010 Alkis Georgopoulos <alkisg@gmail.com>
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FINESS FOR A PARTICULAR PURPOSE.  See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program.  If not, see <http://www.gnu.org/licenses/>.
21#
22# On Debian GNU/Linux systems, the complete text of the GNU General
23# Public License can be found in `/usr/share/common-licenses/GPL".
24###########################################################################
25
26import gtk
27import pygtk
28import subprocess
29
30class RemoteAssistance:
31    def __init__(self):
32        self.wTree = gtk.Builder()
33        self.wTree.add_from_file('remote_assistance.ui')
34        self.wTree.connect_signals(self)
35        self.get = self.wTree.get_object
36   
37    def run(self):   
38        dlg = self.get('remote_assistance_dialog')
39        if self.get('sb_assist_port').get_value() == 0:
40            self.get('sb_assist_port').set_value(5500)
41        reply = dlg.run()
42        if reply == 1:
43            ip = self.get('rem_assist_ip').get_text().strip()
44            port = self.get('sb_assist_port').get_value()
45            if self.get('cb_assist_type').get_active() == 1:
46                # Unfortunately double quoting is needed when a parameter
47                # contains spaces. That might change in the future,
48                # see http://www.sudo.ws/sudo/bugs/show_bug.cgi?id=413
49                # Fortunately, sh -c 'ls' works even if the quotes there are
50                # wrong. :)
51                subprocess.Popen(['sh', '-c', ("""TERM=xterm socat """ +
52                    """SYSTEM:"sleep 1; exec screen -xRR ra",pty,stderr """ +
53                    """tcp:%s:%d & exec xterm -e screen -l -S ra""") %
54                    (ip, port)])
55            else:
56                subprocess.Popen(['./epoptes-remote-assistance', "%s:%d" % (ip, port)])
57        dlg.destroy()
Note: See TracBrowser for help on using the repository browser.