[X2Go-Commits] [pyhoca-gui] 01/71: CVix: import CVix specific 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 c44a152e90dc3b29c1696f047c67952b7bf2b103
Author: Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
Date: Fri Feb 7 13:38:21 2014 +0100
CVix: import CVix specific code
---
CVix.py | 390 ++++++++++++++++++++++++++++++++++++++++++++
CVix/CVix_initemplate.py | 61 +++++++
CVix/icons/16x16/CVix.png | Bin 0 -> 486 bytes
CVix/icons/22x22/CVix.png | Bin 0 -> 554 bytes
CVix/img/CVix.png | Bin 0 -> 3956205 bytes
CVix/img/cvix_about.png | Bin 0 -> 61359 bytes
CVix/nsis_template_CVix.py | 220 +++++++++++++++++++++++++
CVix/pixmaps/CVix.ico | Bin 0 -> 29686 bytes
setup_CVix.py | 389 +++++++++++++++++++++++++++++++++++++++++++
9 files changed, 1060 insertions(+)
diff --git a/CVix.py b/CVix.py
new file mode 100755
index 0000000..6d568cd
--- /dev/null
+++ b/CVix.py
@@ -0,0 +1,390 @@
+#!/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>
+#
+# 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
+# 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.
+#
+# You should have received a copy of the GNU 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.CVix_initemplate
+
+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
+
+if _X2GOCLIENT_OS == "Windows":
+ from x2go import X2GoClientXConfig as _X2GoClientXConfig
+
+__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.CVix_initemplate.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()
+
+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)
diff --git a/CVix/CVix_initemplate.py b/CVix/CVix_initemplate.py
new file mode 100644
index 0000000..957b883
--- /dev/null
+++ b/CVix/CVix_initemplate.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+SESSION_PROFILE_TEMPLATE = {
+ 'iconvfrom': 'UTF-8',
+ 'height': 600,
+ 'speed': 0,
+ 'setsessiontitle': 0,
+ 'sessiontitle': '',
+ 'width': 800,
+ 'krblogin': False,
+ 'soundsystem': 'pulse',
+ 'autostart': True,
+ 'maxdim': True,
+ 'type': 'auto',
+ 'sndport': 4713,
+ # gets substituted during application start
+ 'sshproxyuser': '{sshproxyuser}',
+ 'usekbd': True,
+ 'autologin': False,
+ 'sound': False,
+ 'rootless': True,
+ # gets substituted during application start
+ 'sshproxyhost': '{sshproxyhost}',
+ 'name': 'CVix',
+ 'iconvto': 'UTF-8',
+ 'sshport': 3389,
+ 'startsoundsystem': False,
+ 'pack': '16m-rgb-%%',
+ 'defsndport': True,
+ 'useiconv': False,
+ 'multidisp': False,
+ # gets substituted during application start
+ 'export': "{local_home}:1;",
+ 'fullscreen': True,
+ 'useexports': True,
+ 'quality': 9,
+ 'xdmcpserver': 'localhost',
+ 'xinerama': 0,
+ 'rdpoptions': '-u X2GO_USER -p X2GO_PASSWORD',
+ 'print': 1,
+ 'usesshproxy': 1,
+ 'sshproxytunnel': 'localhost:53000:localhost:3389',
+ # gets substituted during application start
+ 'sshproxykeyfile': '{sshproxykeyfile}',
+ 'fstunnel': True,
+ 'applications': 'TERMINAL, WWWBROWSER, MAILCLIENT, OFFICE',
+ 'host': 'localhost',
+ 'mimeboxextensions': '',
+ # gets substituted during application start
+ 'user': '{user}',
+ 'key': '',
+ # gets substituted during application start
+ 'icon': '{icon}',
+ 'mimeboxaction': 'OPEN',
+ 'rdpserver': '',
+ 'soundtunnel': 1,
+ 'command': 'startcvix.sh',
+ 'dpi': 96,
+ 'published': False,
+ 'setdpi': False,
+ 'usemimebox': True,
+}
diff --git a/CVix/__init__.py b/CVix/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/CVix/icons/16x16/CVix.png b/CVix/icons/16x16/CVix.png
new file mode 100644
index 0000000..52491ef
Binary files /dev/null and b/CVix/icons/16x16/CVix.png differ
diff --git a/CVix/icons/22x22/CVix.png b/CVix/icons/22x22/CVix.png
new file mode 100644
index 0000000..01717af
Binary files /dev/null and b/CVix/icons/22x22/CVix.png differ
diff --git a/CVix/img/CVix.png b/CVix/img/CVix.png
new file mode 100644
index 0000000..d27b7d5
Binary files /dev/null and b/CVix/img/CVix.png differ
diff --git a/CVix/img/cvix_about.png b/CVix/img/cvix_about.png
new file mode 100644
index 0000000..73fb155
Binary files /dev/null and b/CVix/img/cvix_about.png differ
diff --git a/CVix/nsis_template_CVix.py b/CVix/nsis_template_CVix.py
new file mode 100644
index 0000000..295f0fe
--- /dev/null
+++ b/CVix/nsis_template_CVix.py
@@ -0,0 +1,220 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+NSIS_SCRIPT_TEMPLATE = """
+;{program_name}.nsi
+;
+
+!define VERSION {program_version}
+
+;--------------------------------
+
+; The name of the installer
+Name "{program_name}"
+
+; Sets the title bar text (although NSIS seems to append "Installer")
+Caption "{program_desc}"
+
+!define py2exeOutputDirectory '{output_dir}'
+
+; The file to write
+OutFile "..\\{program_name}_{schema}_${{VERSION}}_win32-setup.exe"
+
+; The default installation directory
+InstallDir $PROGRAMFILES\\{program_name}
+
+; Registry key to check for directory (so if you install again, it will
+; overwrite the old one automatically)
+InstallDirRegKey HKLM "Software\\{program_name}" "Install_Dir"
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel admin
+
+;--------------------------------
+
+; Installer Language Configuration
+
+!include LogicLib.nsh
+
+var LC_MESSAGES
+
+; i18n strings
+var REQUIRED
+var DESKTOP_LINKS
+var STARTMENU_LINKS
+var WITHOUT_PULSEAUDIO
+var GSPRINT
+
+; First is default
+LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Dutch.nlf"
+LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\English.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\French.nlf"
+LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\German.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Korean.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Russian.nlf"
+LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Spanish.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Swedish.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\TradChinese.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\SimpChinese.nlf"
+;LoadLanguageFile "${{NSISDIR}}\\Contrib\\Language files\\Slovak.nlf"
+
+; License data
+; Not exactly translated, but it shows what's needed
+LicenseLangString myLicenseData ${{LANG_DUTCH}} "LICENSE.txt"
+LicenseLangString myLicenseData ${{LANG_ENGLISH}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_FRENCH}} "LICENSE.txt"
+LicenseLangString myLicenseData ${{LANG_GERMAN}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_KOREAN}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_RUSSIAN}} "LICENSE.txt"
+LicenseLangString myLicenseData ${{LANG_SPANISH}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_SWEDISH}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_TRADCHINESE}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_SIMPCHINESE}} "LICENSE.txt"
+;LicenseLangString myLicenseData ${{LANG_SLOVAK}} "LICENSE.txt"
+
+LicenseData $(myLicenseData)
+
+; Set name using the normal interface (Name command)
+LangString Name ${{LANG_DUTCH}} "Dutch"
+LangString Name ${{LANG_ENGLISH}} "English"
+;LangString Name ${{LANG_FRENCH}} "French"
+LangString Name ${{LANG_GERMAN}} "German"
+;LangString Name ${{LANG_KOREAN}} "Korean"
+;LangString Name ${{LANG_RUSSIAN}} "Russian"
+LangString Name ${{LANG_SPANISH}} "Spanish"
+;LangString Name ${{LANG_SWEDISH}} "Swedish"
+;LangString Name ${{LANG_TRADCHINESE}} "Traditional Chinese"
+;LangString Name ${{LANG_SIMPCHINESE}} "Simplified Chinese"
+;LangString Name ${{LANG_SLOVAK}} "Slovak"
+
+Function .onInit
+
+ ;Language selection dialog
+
+ Push ""
+ Push ${{LANG_DUTCH}}
+ Push Dutch
+ Push ${{LANG_ENGLISH}}
+ Push English
+; Push ${{LANG_FRENCH}}
+; Push French
+ Push ${{LANG_GERMAN}}
+ Push German
+; Push ${{LANG_KOREAN}}
+; Push Korean
+; Push ${{LANG_RUSSIAN}}
+; Push Russian
+ Push ${{LANG_SPANISH}}
+ Push Spanish
+; Push ${{LANG_SWEDISH}}
+; Push Swedish
+; Push ${{LANG_TRADCHINESE}}
+; Push "Traditional Chinese"
+; Push ${{LANG_SIMPCHINESE}}
+; Push "Simplified Chinese"
+; Push ${{LANG_SLOVAK}}
+; Push Slovak
+ Push A ; A means auto count languages
+ ; for the auto count to work the first empty push (Push "") must remain
+ LangDLL::LangDialog "Installer Language" "Please select the language of the installer"
+
+ Pop $LANGUAGE
+
+ ${{Switch}} $LANGUAGE
+ ${{Case}} 1031
+ StrCpy $LC_MESSAGES "de"
+ !include "nsis_include\\de.nsi"
+ ${{Break}}
+ ${{Case}} 1033
+ StrCpy $LC_MESSAGES "en"
+ !include "nsis_include\\en.nsi"
+ ${{Break}}
+ ${{Case}} 1043
+ StrCpy $LC_MESSAGES "nl"
+ !include "nsis_include\\nl.nsi"
+ ${{Break}}
+ ${{Case}} 1034
+ StrCpy $LC_MESSAGES "es"
+ !include "nsis_include\\es.nsi"
+ ${{Break}}
+ ${{EndSwitch}}
+
+ StrCmp $LANGUAGE "cancel" 0 +2
+ Abort
+
+FunctionEnd
+
+;--------------------------------
+
+; Pages
+Page license
+Page components
+Page directory
+Page instfiles
+
+UninstPage uninstConfirm
+UninstPage instfiles
+
+;--------------------------------
+
+; The stuff to install
+Section "{program_name} ($REQUIRED)"
+
+ SectionIn RO
+ ; Set output path to the installation directory.
+ SetOutPath "$INSTDIR"
+ File /r /x .svn /x .git "${{py2exeOutputDirectory}}\\*.*"
+
+ ; Write the installation path into the registry
+ WriteRegStr HKLM SOFTWARE\\{program_name} "Install_Dir" "$INSTDIR"
+ WriteRegStr HKLM SOFTWARE\\{program_name} "Path" "$INSTDIR"
+
+
+ ; Write the uninstall keys for Windows
+ WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}" "DisplayName" "{program_name}"
+ WriteRegStr HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}" "UninstallString" '"$INSTDIR\\uninstall.exe"'
+ WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}" "NoModify" 1
+ WriteRegDWORD HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}" "NoRepair" 1
+ WriteUninstaller "uninstall.exe"
+
+SectionEnd
+
+; Optional section (can be disabled by the user)
+Section "$STARTMENU_LINKS"
+
+ CreateDirectory "$SMPROGRAMS\\{program_name}"
+ CreateShortCut "$SMPROGRAMS\\{program_name}\\{program_name}.lnk" "$INSTDIR\\{program_name}.exe" "" "$INSTDIR\\icons\\{program_name}.ico" 0
+ CreateShortCut "$SMPROGRAMS\\{program_name}\\Uninstall.lnk" "$INSTDIR\\uninstall.exe" "" "$INSTDIR\\uninstall.exe" 0
+
+SectionEnd
+
+; Optional section (can be disabled by the user)
+Section "$DESKTOP_LINKS"
+
+ CreateShortCut "$DESKTOP\\{program_name}.lnk" "$INSTDIR\\{program_name}.exe" "" "$INSTDIR\\icons\\{program_name}.ico" 0
+
+SectionEnd
+
+;--------------------------------
+
+; Uninstaller
+
+Section "Uninstall"
+
+ ; Remove registry keys
+ DeleteRegKey HKLM "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{program_name}"
+ DeleteRegKey HKLM SOFTWARE\\{program_name}
+
+ ; Remove files and uninstaller
+ Delete $INSTDIR\\uninstall.exe
+
+ ; Remove shortcuts, if any
+ Delete "$SMPROGRAMS\\{program_name}\\*.*"
+ Delete "$DESKTOP\\{program_name}.lnk"
+
+ ; Remove directories used
+ RMDir "$SMPROGRAMS\\{program_name}"
+ RMDir /r /REBOOTOK $INSTDIR
+
+SectionEnd
+"""
diff --git a/CVix/pixmaps/CVix.ico b/CVix/pixmaps/CVix.ico
new file mode 100644
index 0000000..e410de6
Binary files /dev/null and b/CVix/pixmaps/CVix.ico differ
diff --git a/setup_CVix.py b/setup_CVix.py
new file mode 100755
index 0000000..bec0154
--- /dev/null
+++ b/setup_CVix.py
@@ -0,0 +1,389 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2010-2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+#
+# PyHoca is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# PyHoca 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+# import the PyHoca-GUI
+import sys
+import os
+import shutil
+
+### Create Global variables
+
+mySCHEMA = None
+#SCHEMATA = None
+CUSTOMER_HOST = None
+CUSTOMER_USER = None
+CUSTOMER_KEY = None
+PROGRAM_DESC = None
+PROGRAM_VERSION = '1.2'
+PROGRAM_ICON = None
+PROGRAM_NAME = 'CVix'
+LICENSE = 'AGPLv3+'
+AUTHOR = 'Mike Gabriel, Dick Kniep'
+URL = 'http://www.lindix.org'
+LIBRARY_ZIP = r"lib\shardlib.zip"
+PROGRAM_ICON_MAP2 = ''
+icon_files = []
+customer_files = []
+
+### customize the SCHEMA before running the setup
+
+def datafilelist(installbase, sourcebase):
+ datafileList = []
+ for root, subFolders, files in os.walk(sourcebase):
+ fileList = []
+ for f in files:
+ fileList.append(os.path.join(root, f))
+ datafileList.append((root.replace(sourcebase, installbase), fileList))
+ return datafileList
+
+def _fillGlobals(schema=None):
+ global mySCHEMA
+ global SCHEMATA
+ global CUSTOMER_HOST
+ global CUSTOMER_USER
+ global CUSTOMER_KEY
+ global PROGRAM_DESC
+ global PROGRAM_ICON
+ global PROGRAM_ICON_MAP2
+ global icon_files
+ global customer_files
+ if len(sys.argv) > 2 and schema is None:
+ mySCHEMA = sys.argv[2]
+ del sys.argv[2]
+ elif schema:
+ mySCHEMA = schema
+ else:
+ mySCHEMA = 'autitude' # not relevant......
+
+ SCHEMATA = {
+ 'autitude':'autitude.cvix.nl',
+ 'cvixcoaches':'cvixcoaches.cvix.nl',
+ 'comsupport':'communitysupport.cvix.nl',
+ 'nlwerkt':'nederland-werkt.cvix.nl',
+ 'amarant':'amarant.cvix.nl',
+ 'ambulantehulpverlening':'ambulantehulpverlening.cvix.nl',
+ 'deplannenmakers':'deplannenmakers.cvix.nl',
+ 'emobrain':'emotionalbrain.cvix.nl',
+ 'held':'held.cvix.nl',
+ 'leff':'leff.cvix.nl',
+ 'menea':'menea.cvix.nl',
+ 'meneanew':'meneanew.cvix.nl',
+ 'eega':'eega.cvix.nl',
+ 'reinaerde':'reinaerde.cvix.nl',
+ 'ruimbaan':'ruimbaan.cvix.nl',
+ 'streamcvix':'streamtrajecten.cvix.nl',
+ 'traject':'trajectbv.cvix.nl',
+ 'zorgconcept':'zorgconcept.cvix.nl',
+ 'zzpflevoland':'zzpflevoland.cvix.nl',
+ 'asscoaching':'asscoaching.cvix.nl',
+ 'demo':'demo.cvix.nl',
+ }
+
+ PROGRAM_NAME = 'CVix'
+ if mySCHEMA in SCHEMATA:
+ CUSTOMER_HOST = SCHEMATA[mySCHEMA]
+ else:
+ CUSTOMER_HOST = mySCHEMA + '.cvix.nl'
+ CUSTOMER_USER = CUSTOMER_HOST.split('.')[0]
+ CUSTOMER_KEY = '%s.key' % CUSTOMER_HOST.split('.')[0]
+ f = open(os.path.join(os.getcwd(), PROGRAM_NAME, 'customer'), 'w+')
+ f.write(CUSTOMER_HOST)
+ f.close()
+
+ PROGRAM_DESC = '%s is een terminal server programma aangepast aan het gebruik van CVix door %s' % (PROGRAM_NAME, CUSTOMER_USER)
+ PROGRAM_ICON = "%s/pixmaps/%s.ico" % (PROGRAM_NAME, PROGRAM_NAME)
+ PROGRAM_ICON_MAP2 = "%s\\pixmaps\\%s.ico" % (PROGRAM_NAME, PROGRAM_NAME)
+ icon_files = datafilelist('icons\\PyHoca', r'icons\\PyHoca') + datafilelist('icons\\PyHoca', r'%s\\icons' % PROGRAM_NAME)
+ customer_files = [(PROGRAM_NAME, [r'%s\\keys\\' % PROGRAM_NAME + CUSTOMER_KEY, r'%s\\customer' % PROGRAM_NAME])]
+
+
+#from setuptools import setup, find_packages
+from distutils.core import setup, Command
+import platform
+
+_fillGlobals()
+NSIS_COMPILE = os.path.join(os.environ['ProgramFiles'], 'NSIS', 'makensis.exe')
+# from py2exe.build_exe import py2exe
+from bbfreeze import Freezer
+py2exe = object
+import os, os.path
+import subprocess
+sys.path.append(os.path.normpath('../pyhoca-contrib/mswin/ms-vc-runtime'))
+
+from glob import glob
+
+exec("from %s.nsis_template_%s import NSIS_SCRIPT_TEMPLATE" % (PROGRAM_NAME, PROGRAM_NAME))
+
+#
+# to build .exe file, run on Windows:
+# ,,python setup.py py2exe''
+#
+# to update i18n .mo files (and merge .pot file into .po files) run on Linux:
+# ,,python setup.py build_i18n -m''
+
+cmd_class = {}
+data_files = []
+
+class NSISScript(object):
+
+ def __init__(self, program_name, program_desc, program_version, dist_dir, icon_loc):
+ self.program_name = program_name
+ self.program_desc = program_desc
+ self.program_version = program_version
+ self.dist_dir = dist_dir
+ self.icon_loc = icon_loc
+ self.pathname = "setup_%s.nsi" % self.program_name
+
+ def create(self):
+ contents = NSIS_SCRIPT_TEMPLATE.format(
+ program_name = self.program_name,
+ program_version = self.program_version,
+ program_desc = self.program_desc,
+ output_dir = self.dist_dir,
+ icon_location = os.path.join(self.dist_dir, self.icon_loc),
+ schema = mySCHEMA)
+
+ with open(self.pathname, "w") as outfile:
+ outfile.write(contents)
+
+ def compile(self):
+ subproc = subprocess.Popen(
+ # "/P5" uses realtime priority for the LZMA compression stage.
+ # This can get annoying though.
+ [NSIS_COMPILE, self.pathname, "/P5"], env=os.environ)
+ subproc.communicate()
+
+ retcode = subproc.returncode
+
+ if retcode:
+ raise RuntimeError("NSIS compilation return code: %d" % retcode)
+
+class build_all(Command):
+ user_options = [('all','A','yes')]
+ def initialize_options(self):
+ pass
+ def finalize_options(self):
+ pass
+ def run(self):
+
+ logFile = file('build_all.log','ab')
+
+ for schema, machine in SCHEMATA.items():
+ print "\n\n\n* * * * * * * * * Build environment %s\n\n" % schema
+ _fillGlobals(schema)
+ sys.argv[1] = 'build_installer_bbfreeze'
+ startSetup()
+
+
+class build_installer(object):
+
+ # This class first invokes building the the exe file(s) and then creates an NSIS
+ # installer
+ def __init__(self, dist_dir):
+ self.dist_dir = dist_dir
+
+ def do_build_exe(self):
+ # replace this method with the freezer's build_exe logic
+ pass
+
+ def run(self):
+
+ # clean up dist_dir
+ shutil.rmtree(self.dist_dir, ignore_errors=True)
+ # and recreate a clean one afterwards
+ os.makedirs(self.dist_dir)
+
+ # First, build the exe file
+ self.do_build_exe()
+
+ # Create the installer, using the files py2exe has created.
+ script = NSISScript(
+ PROGRAM_NAME,
+ PROGRAM_DESC,
+ PROGRAM_VERSION,
+ self.dist_dir,
+ os.path.normpath(PROGRAM_ICON)
+ )
+ print "*** creating the NSIS setup script***"
+ script.create()
+ print "*** compiling the NSIS setup script***"
+ script.compile()
+
+class build_installer_bbfreeze(build_installer, Freezer, Command):
+
+ user_options = [
+ ('dist-dir=', 'd',
+ "directory to put final built distributions in (default is dist)"),
+
+ ("excludes=", 'e',
+ "comma-separated list of modules to exclude"),
+ ("includes=", 'i',
+ "comma-separated list of modules to include"),
+ ]
+
+ def __init__(self, *args, **kwargs):
+ Command.__init__(self, *args)
+ build_installer.__init__(self, dist_dir=self.dist_dir)
+
+ def initialize_options(self):
+ self.includes = []
+ self.excludes = []
+ self.packages = []
+ self.compressed = False
+ self.dist_dir = None
+
+ def finalize_options(self):
+ self.includes = fancy_split(self.includes)
+ self.excludes = fancy_split(self.excludes)
+ self.compressed = False
+ if self.dist_dir is None:
+ self.dist_dir = 'dist'
+ self.dist_dir = os.path.abspath(os.path.join(os.getcwd(), self.dist_dir))
+ if not os.path.exists(self.dist_dir):
+ os.makedirs(self.dist_dir)
+
+ def do_build_exe(self):
+ Freezer.__init__(self, self.dist_dir,
+ includes=self.includes,
+ excludes=self.excludes,
+ )
+ self.addScript("CVix.py", gui_only=True)
+ Freezer.__call__(self)
+ if self.distribution.has_data_files():
+ print "*** copy data files ***"
+ install_data = self.reinitialize_command('install_data')
+ install_data.install_dir = self.dist_dir
+ install_data.ensure_finalized()
+ install_data.run()
+
+def fancy_split(strVal, sep=","):
+ # a split which also strips whitespace from the items
+ # passing a list or tuple will return it unchanged
+ if strVal is None:
+ return []
+ if hasattr(strVal, "split"):
+ return [item.strip() for item in strVal.split(sep)]
+ return strVal
+
+
+
+executables = []
+if platform.system() == 'Windows':
+
+ dll_data_files = [("Microsoft.VC90.CRT", glob(r'..\\pyhoca-contrib\\mswin\\ms-vc-runtime\\*.*'))]
+ nxproxy_files = [("nxproxy", glob(r'..\\pyhoca-contrib\\mswin\\nxproxy-mswin\\nxproxy-3.5.0.12\\*.*'))]
+ pulseaudio_files = [("pulseaudio", glob(r'..\\pyhoca-contrib\\mswin\\pulseaudio-mswin\\pulseaudio-1.1\\*.*'))]
+ xserver_files = datafilelist('vcxsrv', r'..\\pyhoca-contrib\\mswin\\vcxsrv-mswin\\vcxsrv-1.14.2.0')
+
+ icon_files = datafilelist('icons\\PyHoca', r'icons\\PyHoca')
+ img_files = [("img", glob(r'img\\*.*'))]
+ i18n_files = datafilelist('mo', r'build\\mo')
+
+ data_files.extend([ ('icons', ["pixmaps\\pyhoca-gui.ico"]), ] +
+ dll_data_files +
+ icon_files +
+ img_files +
+ nxproxy_files +
+ pulseaudio_files +
+ xserver_files +
+ i18n_files
+ )
+
+ cmd_class.update(
+ {
+ "build_with_bbfreeze": build_installer_bbfreeze,
+ }
+ )
+ cmd_class.update({ 'build_exe': cmd_class['build_with_{freezer}'.format(freezer='bbfreeze')] })
+
+elif platform.system() == 'Linux':
+ cmd_class.update(
+ {
+ "build" : build_extra.build_extra,
+ "build_i18n" : build_i18n.build_i18n,
+ "clean": clean_i18n.clean_i18n,
+ }
+ )
+
+ icon_files = datafilelist('{prefix}/share/icons/PyHoca'.format(prefix=sys.prefix), r'icons/PyHoca')
+ img_files = [("{prefix}/share/pyhoca/img".format(prefix=sys.prefix), glob('img/*.*'))]
+ desktop_files = [
+ ('{prefix}/share/applications'.format(prefix=sys.prefix), glob('desktop/*')),
+ ('{prefix}/share/pixmaps'.format(prefix=sys.prefix), glob('pixmaps/*.svg')),
+ ]
+ manpage_files = [
+ ('{prefix}/share/man/man1'.format(prefix=sys.prefix), glob('man/man1/*.1')),
+ ]
+ data_files.extend(icon_files +
+ img_files +
+ desktop_files +
+ manpage_files
+ )
+
+if platform.system() == 'Windows':
+ cmd_options={
+ 'py2exe': {
+ 'includes': ['greenlet', 'gevent.core', 'gevent.ares', 'gevent._semaphore', 'gevent._util', ],
+ 'compressed': 1,
+ 'optimize': 2,
+ },
+ 'build_with_py2exe': {
+ 'includes': ['greenlet', 'gevent.core', 'gevent.ares', 'gevent._semaphore', 'gevent._util', ],
+ 'compressed': 1,
+ 'optimize': 2,
+ },
+ 'build_with_bbfreeze': {
+ 'includes': ['greenlet', 'gevent.core', 'gevent.ares', 'gevent._semaphore', 'gevent._util', 'gevent.resolver_thread', 'gevent.resolver_ares', 'gevent.server', 'gevent.socket', 'gevent.threadpool', 'gevent.select', 'gevent.subprocess', 'distutils.version', 'Crypto', 'Crypto.Random', 'Crypto.Hash', 'Crypto.PublicKey', 'Crypto.PublicKey.DSA', 'Crypto.PublicKey.RSA', 'Crypto.Cipher', 'Crypto.Cipher.AES', 'Crypto.Cipher.ARC4', 'Crypto.Cipher.Blowfish', 'Crypto.Cipher.DES3', 'Crypt [...]
+ 'excludes': ['MSVCR90.dll', 'MSVCP90.dll', ],
+ }
+ }
+ cmd_options.update({ 'build_exe': cmd_options['build_with_{freezer}'.format(freezer='bbfreeze')] })
+
+else:
+ cmd_options={}
+
+def startSetup():
+ setup(
+ name = PROGRAM_NAME,
+ version = PROGRAM_VERSION,
+ description = PROGRAM_DESC,
+ license = LICENSE,
+ author = AUTHOR,
+ url = URL,
+ namespace_packages = [ 'pyhoca', ],
+ packages = [ 'pyhoca.wxgui', ],
+ package_dir = {'': '.'},
+ install_requires = [ 'setuptools', ],
+ cmdclass = cmd_class,
+ windows = [
+ {
+ "script": "pyhoca-gui",
+ "icon_resources": [(0, os.path.normpath(PROGRAM_ICON))],
+ "dest_base": PROGRAM_NAME,
+ },
+ ],
+ data_files=data_files,
+ zipfile = LIBRARY_ZIP,
+ executables = executables,
+ options=cmd_options,
+ )
+
+
+startSetup()
--
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