[X2Go-Commits] [pyhoca-gui] 06/71: CVix: start rewrite of CVix-relevant code

git-admin at x2go.org git-admin at x2go.org
Thu Mar 20 00:32:41 CET 2014


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch cvix/2.x
in repository pyhoca-gui.

commit 073d260ea0b829f6be234b33a63d92115631921a
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date:   Wed Feb 5 10:23:48 2014 +0100

    CVix: start rewrite of CVix-relevant code
---
 CVix.py                   |  384 ++-------------------------------------------
 icons/CVix/16x16/CVix.png |  Bin 486 -> 0 bytes
 icons/CVix/22x22/CVix.png |  Bin 554 -> 0 bytes
 img/cvix_about.png        |  Bin 61359 -> 0 bytes
 4 files changed, 16 insertions(+), 368 deletions(-)

diff --git a/CVix.py b/CVix.py
index d605156..337f7b6 100755
--- a/CVix.py
+++ b/CVix.py
@@ -1,390 +1,38 @@
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
-# Copyright (C) 2010-2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-# Copyright (C) 2010-2012 by Dick Kniep <dick.kniep at lindix.nl>
+# Copyright (C) 2010-2013 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# Copyright (C) 2010-2013 by Dick Kniep <dick.kniep at lindix.nl>
 #
 # PyHoca GUI is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
+# it under the terms of the GNU Affero General Public License as published by
 # the Free Software Foundation; either version 3 of the License, or
 # (at your option) any later version.
 #
 # PyHoca GUI is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
+# GNU Affero General Public License for more details.
 #
-# You should have received a copy of the GNU General Public License
+# You should have received a copy of the GNU Affero General Public License
 # along with this program; if not, write to the
 # Free Software Foundation, Inc.,
 # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 
-modules ={}
-
-import os.path
-import subprocess
-import sys
-import wxversion
-
-try:
-    wxversion.select('2.9')
-except: pass
-try:
-    wxversion.select('2.8')
-except: pass
-import wx
-import argparse
-
-import logging, logging.handlers
 import os
-import ConfigParser
-import getpass
-
-import CVix_session_template
-
-from x2go import X2GOCLIENT_OS as _X2GOCLIENT_OS
-from x2go import X2goSessionProfiles
-
-# Python X2Go modules
-from x2go import CURRENT_LOCAL_USER as _CURRENT_LOCAL_USER
-from x2go import X2goLogger as _X2goLogger
-
-# X2Go backends
-
-from pyhoca.wxgui import __VERSION__ as _version
-from pyhoca.wxgui import messages
-from pyhoca.wxgui.basepath import locale_basepath
-from pyhoca.wxgui import PyHocaGUI
+import sys
 
-if _X2GOCLIENT_OS == "Windows":
-    from x2go import X2GoClientXConfig as _X2GoClientXConfig
+from pyhoca.wxgui import *
+from pyhoca.wxgui import __VERSION__
 
 __author__ = "Mike Gabriel, Dick Kniep"
-__version__ = _version
-
-PROG_NAME = os.path.basename(sys.argv[0]).replace('.exe', '').replace('.py', '')
-PROG_PID  = os.getpid()
-
-# version information
-VERSION=_version
-VERSION_TEXT="""
-%s[%s] - an X2Go GUI client written in Python
-----------------------------------------------------------------------
-developed by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
-sponsored by Dick Kniep <dick.kniep at lindix.nl> (2010-2012)
-
-VERSION: %s
-
-""" % (PROG_NAME, PROG_PID, VERSION)
-
-
-if _X2GOCLIENT_OS == 'Windows':
-    import _winreg
-
-SESSIONDIR = '.x2goclient'
-
-ProgramFiles = None
-if hasattr(sys, 'frozen') and sys.frozen in ("windows_exe", "console_exe"):
-    class Win32_Logging(object):
-
-        softspace = 0
-        _fname = os.path.join(os.environ['AppData'], PROG_NAME, '%s.log' % PROG_NAME)
-        _file = None
-
-        def __init__(self, filemode='a'):
-            self._filemode = filemode
-
-        def write(self, text, **kwargs):
-            if self._file is None:
-                try:
-                    try:
-                        os.mkdir(os.path.dirname(self._fname))
-                    except:
-                        pass
-                    self._file = open(self._fname, self._filemode)
-                except:
-                    pass
-            else:
-                self._file.write(text)
-                self._file.flush()
-
-        def flush(self):
-            if self._file is not None:
-                self._file.flush()
-
-    sys.stdout = Win32_Logging(filemode='w+')
-    sys.stderr = Win32_Logging(filemode='a')
-    del Win32_Logging
-
-    try:
-        OK = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,'SOFTWARE\\CVix')
-    except WindowsError:
-        m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='ALREADY_RUNNING', msg='CVix niet opgeslagen in register, waarschijnlijk is de installatie niet gelukt.', title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-        m.ShowModal()
-        sys.exit(1)
-
-    ProgramFiles, Regtype = _winreg.QueryValueEx(OK, 'Install_Dir')
-
-import gevent
-import gevent.monkey
-gevent.monkey.patch_all()
-import gettext
-
-
-if _X2GOCLIENT_OS in ('Linux', 'Mac'):
-    import setproctitle
-    setproctitle.setproctitle(PROG_NAME)
-
-if sys.argv[0].startswith('./') or sys.argv[0].startswith('python') or sys.argv[1] == '--debug' or (os.environ.has_key('PYHOCAGUI_DEVELOPMENT') and os.environ['PYHOCAGUI_DEVELOPMENT'] == '1'):
-    sys.path.insert(0, os.getcwd())
-    os.environ['PYHOCAGUI_DEVELOPMENT'] = '1'
-    ProgramFiles = os.getcwd()
-    print '### PyHoca-GUI running in development mode ###'
-
-if not ProgramFiles:
-    ProgramFiles = '/Program Files/%s' % PROG_NAME
-
-f = open(os.path.join('CVix_customer'), 'r')
-CUSTOMER_HOST = f.read().replace('\n', '').replace('\r', '')
-f.close()
-CUSTOMER_USER = CUSTOMER_HOST.split('.')[0]
-CUSTOMER_KEY = 'CVix/keys/%s.key' % CUSTOMER_USER
-
-if _X2GOCLIENT_OS == 'Windows':
-    from pyhoca.wxgui.basepath import nxproxy_binary
-    os.environ.update({'NXPROXY_BINARY': nxproxy_binary, })
-
-def check_running():
-    if _X2GOCLIENT_OS  in ('Linux', 'Mac'):
-        p = subprocess.Popen(['ps', '-A'], stdout=subprocess.PIPE)
-        psA_out = p.communicate()
-        return psA_out[0].count(PROG_NAME) > 1
-    elif _X2GOCLIENT_OS == 'Windows':
-        import wmi
-        w = wmi.WMI()
-        _p_names = []
-        for process in w.Win32_Process():
-            _p_names.append(process.Name)
-        return len([ _p_name for _p_name in _p_names if _p_name == PROG_NAME]) > 1
-
-def configFile(ProgramFiles):
-
-    bdir = os.path.join(os.path.normpath(os.path.expanduser('~')), SESSIONDIR)
-    sessionFile = os.path.join(bdir, 'sessions')
-
-    session_profiles = X2goSessionProfiles(config_files=[sessionFile])
-
-    found = False
-    if 'CVix' in session_profiles.profile_names:
-        found = True
-
-    if not found:
-
-        profile_config = CVix_session_template.SESSION_PROFILE_TEMPLATE
-        customized_config = {
-            'sshproxyhost': '{hostname}'.format(hostname=CUSTOMER_HOST),
-            'sshproxyport': 3389,
-            'sshproxyuser': CUSTOMER_USER,
-            'sshproxykeyfile': os.path.join(ProgramFiles, CUSTOMER_KEY),
-            'icon': os.path.join(ProgramFiles, 'CVix', 'pixmaps', 'CVix.ico'),
-            'user': getpass.getuser(),
-        }
-        profile_config['export'] = profile_config['export'].format(local_home=os.path.normpath(os.path.expanduser('~')))
-        profile_config.update(customized_config)
-
-        session_profiles.add_profile(profile_id=None, **profile_config)
-
-        session_profiles.write_user_config = True
-        session_profiles.write()
-
-
-class args:
-    def __init__(self, session_profile='CVix', debug=True, quiet=False, libdebug=True, libdebug_sftpxfer=True, version=False,
-                 remember_username=True, non_interactive=True, auto_connect=False, show_profile_metatypes=False, single_session_profile=False,
-                 tray_icon='CVix', tray_icon_connecting=None, add_to_known_hosts=True,
-                 restricted_trayicon=False, start_on_connect=False, exit_on_disconnect=False, resume_newest_on_connect=True, resume_oldest_on_connect=False,
-                 resume_all_on_connect=False, disconnect_on_suspend=False, disconnect_on_terminate=False,
-                 splash_image=None, disable_splash=True, disable_options=False,
-                 disable_printingprefs=False, disable_profilemanager=False, disable_notifications=False, display=None, logon_window_position=None,
-                 published_applications_no_submenus=10, lang='nl', backend_controlsession=None, backend_terminalsession=None, backend_serversessioninfo=None,
-                 backend_serversessionlist=None, backend_proxy=None, backend_sessionprofiles=None, backend_clientsettings=None, backend_clientprinting=None,
-                 start_xserver=True, preferred_xserver=None, start_pulseaudio=False, client_rootdir=None, sessions_rootdir=None, ssh_rootdir=None,about_image='cvix_about.png'):
-        self.start_xserver = start_xserver
-        self.client_rootdir = client_rootdir
-        self.sessions_rootdir = sessions_rootdir
-        self.ssh_rootdir = ssh_rootdir
-        self.preferred_xserver = preferred_xserver
-        self.start_pulseaudio = start_pulseaudio
-        self.session_profile = session_profile
-        self.add_to_known_hosts = add_to_known_hosts
-        self.debug = debug
-        self.quiet = quiet
-        self.libdebug = libdebug
-        self.libdebug_sftpxfer = libdebug_sftpxfer
-        self.version = version
-        self.remember_username = remember_username
-        self.non_interactive = non_interactive
-        self.auto_connect = auto_connect
-        self.show_profile_metatypes = show_profile_metatypes
-        self.single_session_profile = single_session_profile
-        self.tray_icon = tray_icon
-        self.tray_icon_connecting = tray_icon_connecting
-        self.restricted_trayicon = restricted_trayicon
-        self.start_on_connect = start_on_connect
-        self.exit_on_disconnect = exit_on_disconnect
-        self.resume_newest_on_connect = resume_newest_on_connect
-        self.resume_oldest_on_connect = resume_oldest_on_connect
-        self.resume_all_on_connect = resume_all_on_connect
-        self.disconnect_on_suspend = disconnect_on_suspend
-        self.disconnect_on_terminate = disconnect_on_terminate
-        self.splash_image = splash_image
-        self.disable_splash = disable_splash
-        self.disable_options = disable_options
-        self.disable_printingprefs = disable_printingprefs
-        self.disable_profilemanager = disable_profilemanager
-        self.disable_notifications = disable_notifications
-        self.display = display
-        self.logon_window_position = logon_window_position
-        self.published_applications_no_submenus = published_applications_no_submenus
-        self.lang = lang
-        self.backend_controlsession = backend_controlsession
-        self.backend_terminalsession = backend_terminalsession
-        self.backend_serversessioninfo = backend_serversessioninfo
-        self.backend_serversessionlist = backend_serversessionlist
-        self.backend_proxy = backend_proxy
-        self.backend_sessionprofiles = backend_sessionprofiles
-        self.backend_clientsettings = backend_clientsettings
-        self.backend_clientprinting =  backend_clientprinting
-        self.about_image = about_image
-
-def processArgs(debug, libdebug):
-    global DEBUG
-    global print_action_args
-
-    a = args(debug=debug, libdebug=libdebug)
-    logger = _X2goLogger(tag='CVix')
-    liblogger = _X2goLogger()
-
-    if a.debug:
-        logger.set_loglevel_debug()
-
-    if a.libdebug:
-        liblogger.set_loglevel_debug()
-
-    if a.quiet:
-        logger.set_loglevel_quiet()
-        liblogger.set_loglevel_quiet()
-
-    if a.libdebug_sftpxfer:
-        liblogger.enable_debug_sftpxfer()
-
-    if a.single_session_profile and a.session_profile is None:
-        m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='SINGLESESSIONS', msg='The --single-session-profile option requires naming of a specific session profile!', title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-        m.ShowModal()
-        sys.exit(1)
-
-    if a.non_interactive:
-        if a.session_profile is None:
-            m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='SINGLESESSIONS', msg='In non-interactive mode you have to use the --session-profile option (or -P) to specify a certain session profile name!', title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-            m.ShowModal()
-            sys.exit(1)
-        a.restricted_trayicon = True
-        a.auto_connect = True
-        a.start_on_connect = True
-        a.resume_all_on_connect = True
-        a.exit_on_disconnect = True
-        a.disconnect_on_suspend = True
-        a.disconnect_on_terminate = True
-        a.single_session_profile = True
-
-    if a.non_interactive and (a.resume_newest_on_connect or a.resume_oldest_on_connect):
-        # allow override...
-        a.resume_all_on_connect = False
-
-    if _X2GOCLIENT_OS == "Windows":
-        _x = _X2GoClientXConfig()
-        _known_xservers = _x.known_xservers
-        _installed_xservers = _x.installed_xservers
-
-        if _X2GOCLIENT_OS == 'Windows' and a.preferred_xserver:
-            if a.preferred_xserver not in _installed_xservers:
-                m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='SINGLESESSIONS', msg='Xserver ,,%s\'\' is not installed on your Windows system' % a.preferred_xserver, title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-                m.ShowModal()
-                sys.exit(1)
-            a.start_xserver = a.preferred_xserver
-
-        if _X2GOCLIENT_OS == 'Windows' and a.start_xserver and a.display:
-                m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='SINGLESESSIONS', msg='You can tell PyHoca-GUI to handle XServer startup and then specify a DISPLAY environment variable!', title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-                m.ShowModal()
-                sys.exit(1)
-
-    if a.display:
-        os.environ.update({'DISPLAY': a.display})
-    else:
-        if _X2GOCLIENT_OS == 'Windows' and not a.start_xserver:
-            os.environ.update({'DISPLAY': 'localhost:0'})
-
-    if a.client_rootdir:
-        a.backend_sessionprofiles='FILE'
-        a.backend_clientsettings='FILE'
-        a.backend_clientprinting='FILE'
-
-    return a, logger, liblogger
-
-def startCVix(loglevel):
-    """
-    Deze functie zorgt er voor dat bij verschillende mensen die gebruik 
-    maken van dezelfde computer en verschillende accounts hebben,
-    de directory met de juiste instellingen gekopieerd wordt naar 
-    de nieuwe gebruiker. Tevens geeft het info indien er een probleem met
-    opstarten.
-    """
-    libdbg = dbg = False
-    if loglevel in ('--debug', '-D'):
-        libdbg = dbg = True
-
-    a, logger, liblogger = processArgs(debug=dbg, libdebug=libdbg)
-
-    print 'Programma %s' % ProgramFiles
-    if ProgramFiles is None:
-        logger.error('CVix gevonden in register, maar de installatiedirectory niet gevonden')
-        sys.exit(1)
-    configFile(ProgramFiles)
-
-    if _X2GOCLIENT_OS == 'Windows':
-        print 'Locale basepath = ' + locale_basepath
-        print 'languages = ' + a.lang
-        if a.lang:
-            lang = gettext.translation('pyhoca-gui', localedir=locale_basepath, languages=[a.lang], )
-        else:
-            lang = gettext.translation('pyhoca-gui', localedir=locale_basepath, languages=['en'], )
-        lang.install(unicode=True)
-    else:
-        gettext.install('pyhoca-gui', localedir=locale_basepath, unicode=True)
-
-    if check_running(): 
-        sys.stderr.write("\n###############################\n### %s: already running for user %s\n###############################\n" % (PROG_NAME, _CURRENT_LOCAL_USER))
-        m = messages.PyHoca_MessageWindow_Ok(wx.App(), shortmsg='ALREADY_RUNNING', title=u'PyHoca-GUI (%s)...' % VERSION, icon='pyhoca-trayicon')
-        m.ShowModal()
-
-    try:
-        thisPyHocaGUI = PyHocaGUI(a, logger, liblogger, version=VERSION, appname='CVix')
-        thisPyHocaGUI.MainLoop()
-    except KeyboardInterrupt:
-        thisPyHocaGUI.WakeUpIdle()
-        thisPyHocaGUI.ExitMainLoop()
-    except SystemExit:
-        thisPyHocaGUI.WakeUpIdle()
-        thisPyHocaGUI.ExitMainLoop()
+__version__ = 2.0
 
 if __name__ == '__main__':
-# debug options...
-    mainPath = os.path.normpath(os.path.dirname(sys.argv[0]))
-    os.chdir(mainPath)
-    global DEBUG
-    global print_action_args
-    ldb = None
-    if len(sys.argv) > 1:
-        ldb = sys.argv[1]
-
-    startCVix(ldb)
+    app = PyHocaGUI_Launcher()
+    app.setup_progname('CVix')
+    app.setup_version(__version__)
+    app.setup_consolelog()
+    app.setup_process()
+    app.setup_devmode()
+    app.main()
diff --git a/icons/CVix/16x16/CVix.png b/icons/CVix/16x16/CVix.png
deleted file mode 100644
index 52491ef..0000000
Binary files a/icons/CVix/16x16/CVix.png and /dev/null differ
diff --git a/icons/CVix/22x22/CVix.png b/icons/CVix/22x22/CVix.png
deleted file mode 100644
index 01717af..0000000
Binary files a/icons/CVix/22x22/CVix.png and /dev/null differ
diff --git a/img/cvix_about.png b/img/cvix_about.png
deleted file mode 100644
index 73fb155..0000000
Binary files a/img/cvix_about.png and /dev/null differ

--
Alioth's /srv/git/_hooks_/post-receive-email on /srv/git/code.x2go.org/pyhoca-gui.git



More information about the x2go-commits mailing list