Commit e5887644 by Csók Tamás

Working setup and uninstall.exe

parent 72b0e56f
[Desktop Entry]
Encoding=UTF-8
Version=0.2
Type=Application
Name=Cloud GUI
Comment=Tool to use CIRCLE Cloud
Exec=cloud2 %u
Icon=/usr/share/icons/cloud.svg
Terminal=true
MimeType=x-scheme-handler/rdp;x-scheme-handler/nx;x-scheme-handler/ssh;
Categories=Utility;Application;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32px"
height="32px"
id="svg4113"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="cloud.svg"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/laborclient/cloudgui/cloud.png"
inkscape:export-xdpi="180"
inkscape:export-ydpi="180">
<defs
id="defs4115">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3034"
id="radialGradient6745"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.91098464,-0.68941106,-0.52931253,-0.699431,40.047884,602.97172)"
cx="391.42856"
cy="287.43375"
fx="391.42856"
fy="287.43375"
r="145.96571" />
<linearGradient
inkscape:collect="always"
id="linearGradient3034">
<stop
style="stop-color:#aaccee;stop-opacity:1;"
offset="0"
id="stop3036" />
<stop
style="stop-color:#aaccee;stop-opacity:0;"
offset="1"
id="stop3038" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3024"
id="radialGradient6747"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.80253714,-0.60679623,0.29834416,0.39458642,-154.50478,207.30449)"
cx="318.85928"
cy="314.71725"
fx="318.85928"
fy="314.71725"
r="145.96571" />
<linearGradient
inkscape:collect="always"
id="linearGradient3024">
<stop
style="stop-color:#b3defd;stop-opacity:0.5"
offset="0"
id="stop3026" />
<stop
style="stop-color:#b3defd;stop-opacity:0;"
offset="1"
id="stop3028" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3050"
id="radialGradient6749"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
cx="292.64816"
cy="299.75269"
fx="292.64816"
fy="299.75269"
r="145.96571" />
<linearGradient
id="linearGradient3050"
inkscape:collect="always">
<stop
id="stop3052"
offset="0"
style="stop-color:#b3defd;stop-opacity:0.5" />
<stop
id="stop3054"
offset="1"
style="stop-color:#b3defd;stop-opacity:0.7" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3034"
id="radialGradient7457"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.91098464,-0.68941106,-0.52931253,-0.699431,40.047884,602.97172)"
cx="391.42856"
cy="287.43375"
fx="391.42856"
fy="287.43375"
r="145.96571" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3024"
id="radialGradient7459"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.80253714,-0.60679623,0.29834416,0.39458642,-154.50478,207.30449)"
cx="318.85928"
cy="314.71725"
fx="318.85928"
fy="314.71725"
r="145.96571" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3050"
id="radialGradient7461"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
cx="292.64816"
cy="299.75269"
fx="292.64816"
fy="299.75269"
r="145.96571" />
<radialGradient
r="145.96571"
fy="299.75269"
fx="292.64816"
cy="299.75269"
cx="292.64816"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
gradientUnits="userSpaceOnUse"
id="radialGradient4111"
xlink:href="#linearGradient3050"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9180417"
inkscape:cx="6.6070506"
inkscape:cy="11.63422"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="950"
inkscape:window-height="1061"
inkscape:window-x="0"
inkscape:window-y="17"
inkscape:window-maximized="0" />
<metadata
id="metadata4118">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g6661"
transform="matrix(0.10449644,0,0,0.10449644,-9.9531247,2.8799027)"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325">
<path
style="fill:url(#radialGradient7457);fill-opacity:1;stroke:none"
d="m 256.14524,59.11126 c 24.62625,2.347316 49.86777,32.49978 53.75856,51.16324 8.62329,-27.43498 50.34441,-17.171137 59.85333,-0.71968 6.65814,11.5193 48.45788,5.51236 28.44657,28.00035 24.27442,15.34513 20.8571,65.07012 -42.70377,65.95822 l -176.71875,0 c -42.76196,-1.07615 -51.32274,-8.1926 -57.875,-33.40625 -5.53769,-21.30947 22.49377,-78.5932 62.40625,-64.25 11.6223,-24.03732 44.1151,-49.483183 72.83281,-46.74588 z"
id="path6663"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acscccsca" />
<path
sodipodi:nodetypes="acacccsca"
inkscape:connector-curvature="0"
id="path6665"
d="M 276.48862,56.4684 C 249.95136,55.91176 211.62085,77.96818 207.73006,96.63164 199.10677,69.19666 174.15148,70.8254 157.87673,77.91196 c -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
style="fill:url(#radialGradient7459);fill-opacity:1;stroke:none" />
<path
style="fill:url(#radialGradient4111);fill-opacity:1;stroke:none"
d="m 255.98862,62.9684 c -26.53726,-0.55664 -64.86777,21.49978 -68.75856,40.16324 -8.62329,-27.43498 -33.57858,-25.80624 -49.85333,-18.71968 -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
id="path6667"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acacccsca" />
</g>
<g
transform="matrix(0.10449644,0,0,0.10449644,-9.9531247,2.8799027)"
id="g7143"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325">
<path
sodipodi:nodetypes="acscccsca"
inkscape:connector-curvature="0"
id="path7145"
d="m 256.14524,59.11126 c 24.62625,2.347316 49.86777,32.49978 53.75856,51.16324 8.62329,-27.43498 50.34441,-17.171137 59.85333,-0.71968 6.65814,11.5193 48.45788,5.51236 28.44657,28.00035 24.27442,15.34513 20.8571,65.07012 -42.70377,65.95822 l -176.71875,0 c -42.76196,-1.07615 -51.32274,-8.1926 -57.875,-33.40625 -5.53769,-21.30947 22.49377,-78.5932 62.40625,-64.25 11.6223,-24.03732 44.1151,-49.483183 72.83281,-46.74588 z"
style="fill:url(#radialGradient6745);fill-opacity:1;stroke:none" />
<path
style="fill:url(#radialGradient6747);fill-opacity:1;stroke:none"
d="M 276.48862,56.4684 C 249.95136,55.91176 211.62085,77.96818 207.73006,96.63164 199.10677,69.19666 174.15148,70.8254 157.87673,77.91196 c -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
id="path7147"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acacccsca" />
<path
sodipodi:nodetypes="acacccsca"
inkscape:connector-curvature="0"
id="path7149"
d="m 255.98862,62.9684 c -26.53726,-0.55664 -64.86777,21.49978 -68.75856,40.16324 -8.62329,-27.43498 -33.57858,-25.80624 -49.85333,-18.71968 -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
style="fill:url(#radialGradient6749);fill-opacity:1;stroke:none" />
</g>
<path
style="color:#000000;fill:#023397;fill-opacity:1;fill-rule:nonzero;stroke:#013397;stroke-width:0.94207054;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 1.5063263,16.860746 C 0.4156576,11.32735 5.5426162,6.5060803 9.4930905,12.794092 12.390583,10.362512 18.261384,5.4751042 21.924479,10.356943 c 4.63917,5.709372 8.828435,2.091553 9.150998,7.200829 1.718965,7.440276 -8.53632,6.237142 -13.058126,7.023742 -5.243812,-0.597269 -11.6068286,1.83668 -16.0931921,-1.584416 -2.83679016,-2.868664 0.4677062,-8.372045 -0.256227,-3.038949 1.6721659,5.015472 8.2408874,3.367343 12.1150121,3.959711 4.986922,-0.85089 11.314427,1.082767 15.334753,-2.286781 2.765266,-4.396332 1.928251,-6.112638 -6.005384,-8.869924 C 20.710434,8.941212 14.735657,9.414075 11.152431,12.552675 6.4967083,13.692321 4.221964,7.4719519 2.0955523,15.655441 l -0.2846878,0.607473 z"
id="path7850"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccc"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325" />
</g>
</svg>
#!/usr/bin/python
import cloud
if __name__ == '__main__':
try:
cloud.main()
finally:
pass
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás linux OS alól
##
import sys, os, time, subprocess, glob
##
# A távoli klienshez csatlakozás valósítja meg
# NX és RDP esetén a remmina programot hívja meg. Ha a remmina-ban még nem szerepel
# a kliens, a program elkészíti az indításhoz szükséges profilt.
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
if vm.protocol == "SSH":
command = "sshpass -p %s ssh -p %s -o StrictHostKeyChecking=no %s@%s" % (vm.password, vm.port, vm.user, vm.host)
subprocess.call(command, shell=True)
elif vm.protocol in ("NX", "RDP"):
server = "%s:%s" % (vm.host, vm.port)
listdir = os.path.expanduser("~/.remmina/*.remmina")
found = False
for config_file in glob.glob(listdir):
with open(config_file) as f:
if server in f.read():
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.expanduser("~/.remmina/"), str(int(time.time()*1000)), ".remmina")
password = subprocess.check_output(["remminapasswd", vm.password])
f = open(config_file, 'w')
if vm.protocol == "NX":
f.write(NX_template)
else:
f.write(RDP_template)
f.write("name=%s:%s\nprotocol=%s\nserver=%s\nusername=%s\npassword=%s\n" % (vm.protocol, server, vm.protocol, server, vm.user, password))
f.close()
subprocess.call(["remmina", "-c", config_file])
NX_template = """[remmina]
ssh_auth=0
quality=2
disableencryption=0
ssh_charset=
ssh_privatekey=
resolution=
group=
ssh_loopback=0
exec=
ssh_username=
ssh_server=
ssh_enabled=0
nx_privatekey=
showcursor=0
disableclipboard=0
window_maximize=1
viewmode=4
"""
RDP_template = """[remmina]
disableclipboard=0
ssh_auth=0
clientname=
quality=2
ssh_charset=
ssh_privatekey=
console=0
resolution=
group=
ssh_loopback=0
shareprinter=0
ssh_username=
ssh_server=
security=
execpath=
sound=off
exec=
ssh_enabled=0
sharefolder=
domain=
colordepth=24
window_maximize=1
viewmode=4
"""
#!/bin/bash
sudo apt-get install sshpass python-pip remmina-plugin-nx remmina-plugin-rdp xdg-user-dirs
sudo pip install selenium
if [ "$(uname -m)" == 'x86_64' ]; then
sudo cp x64/remminapasswd /usr/local/bin/remminapasswd
else
sudo cp x86/remminapasswd /usr/local/bin/remminapasswd
fi
sudo chmod +x /usr/local/bin/remminapasswd
sudo cp cloud2 /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud2
sudo cp cloud.py /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud.py
sudo cp cloud_connect_from_linux.py /usr/local/bin/
sudo chmod +x /usr/local/bin/cloud_connect_from_linux.py
sudo cp cloud.svg /usr/share/icons/
sudo cp cloud.desktop /usr/share/applications
sudo chmod +x /usr/share/applications/cloud.desktop
sudo update-desktop-database
cp cloud.desktop $(xdg-user-dir DESKTOP)
chmod +x $(xdg-user-dir DESKTOP)/cloud.desktop
remmina
\ No newline at end of file
......@@ -54,6 +54,7 @@ if '%errorlevel%' NEQ '0' (
@echo Elevated rights recived from UAC
)
:--------------------------------------
rem Start the installation script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client install script
......@@ -84,6 +85,7 @@ SET index=8
reg>nul query %@query% 2>nul
IF ERRORLEVEL 1 GOTO loop
IF ERRORLEVEL 0 GOTO HASPYTHON
pause
GOTO NOPYTHON
rem No 2.6+ Python is installed
......@@ -451,6 +453,8 @@ IF NOT "!output_on_screen!"=="False" (
)
xcopy>nul "%running_directory%cloud.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud_connect_from_windows.py" "%install_location%\" /y
xcopy>nul "%running_directory%win_install.py" "%install_location%\" /y
xcopy>nul "%running_directory%nx_client_installer.py" "%install_location%\" /y
xcopy>nul "%running_directory%nxkey.py" "%install_location%\" /y
xcopy>nul "%running_directory%OrderedDict.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud.ico" "%install_location%\" /y
......@@ -478,8 +482,6 @@ IF NOT "!output_on_screen!"=="False" (
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
)
GOTO END
......
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "CIRCLE Client"
#define MyAppVersion "1.0"
#define MyAppPublisher "BME IK, IIT, VIK"
#define MyAppURL "http://cloud.bme.hu/"
[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{86EFCEF4-69E1-4AE5-BF33-30FE7117F45D}
ExtraDiskSpaceRequired=2097140
PrivilegesRequired=poweruser
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={localappdata}\CIRCLE
DisableDirPage=yes
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename=setup
SetupIconFile=C:\Users\Godhak\Desktop\client\dist\cloud.ico
UninstallIconFile=C:\Users\Godhak\Desktop\client\dist\cloud.ico
Compression=lzma
SolidCompression=yes
[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "hungarian"; MessagesFile: "compiler:Languages\Hungarian.isl"
[Files]
; "installer" folder contains every necessary files except the uninstall.bat
Source: "installer\*"; DestDir: "{tmp}"; Flags: ignoreversion recursesubdirs createallsubdirs
; "uninstaller" folder contains ONLY the uninstall.bat
Source: "uninstaller\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files
[Code]
procedure CurPageChanged(CurPageID: Integer);
var
ErrorCode: Integer;
show_stuff: String;
install_selenium: String;
page: String;
command: String;
OldState: Boolean;
begin
show_stuff := 'True';
install_selenium := 'False';
page := 'https://pc3.szgt.uni-miskolc.hu/'
command := show_stuff + ' ' + install_selenium + ' ' + AddQuotes(page)
case CurPageID of
wpFinished:
begin
if IsWin64 then
begin
OldState := EnableFsRedirection(False);
end;
try
Exec(ExpandConstant('{cmd}'), '/C '+AddQuotes(ExpandConstant('{tmp}\install.bat'))+ ' ' + command, '', SW_SHOW, ewWaitUntilTerminated, ErrorCode);
finally
if IsWin64 then
begin
EnableFsRedirection(OldState);
end;
end;
end;
end;
end;
[UninstallRun]
Filename: "{app}\uninstall.bat"; Parameters: "True"; Flags: waituntilterminated runascurrentuser shellexec
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
......@@ -54,6 +54,7 @@ if '%errorlevel%' NEQ '0' (
@echo Elevated rights recived from UAC
)
:--------------------------------------
rem Start the installation script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client install script
......@@ -84,6 +85,7 @@ SET index=8
reg>nul query %@query% 2>nul
IF ERRORLEVEL 1 GOTO loop
IF ERRORLEVEL 0 GOTO HASPYTHON
pause
GOTO NOPYTHON
rem No 2.6+ Python is installed
......@@ -451,6 +453,8 @@ IF NOT "!output_on_screen!"=="False" (
)
xcopy>nul "%running_directory%cloud.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud_connect_from_windows.py" "%install_location%\" /y
xcopy>nul "%running_directory%win_install.py" "%install_location%\" /y
xcopy>nul "%running_directory%nx_client_installer.py" "%install_location%\" /y
xcopy>nul "%running_directory%nxkey.py" "%install_location%\" /y
xcopy>nul "%running_directory%OrderedDict.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud.ico" "%install_location%\" /y
......@@ -478,8 +482,6 @@ IF NOT "!output_on_screen!"=="False" (
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
)
GOTO END
......
......@@ -59,7 +59,7 @@ def custom_protocol_register(custom_protocol):
# create a proper icon with the proper driver
# call the nx_client_installer
def main():
try:
#try:
args = pars_arguments()
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
......@@ -112,7 +112,7 @@ def main():
custom_protocol_register(custom_nx)
except:
print "Error! URL Protocol handler installation aborted!"
except:
print "Unknown error occurred! Please contact the developers!"
#except:
# print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
\ No newline at end of file
......@@ -28,17 +28,18 @@ if not exist "%install_location%\" (
)
IF NOT "!output_on_screen!"=="False" (
@echo Installation direcory found at ^'%install_location%^'
@echo Removing files
)
rem Delete files and directory
rd>nul /q/s %install_location% 2>nul
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo Removing desktop icon
call python %running_directory%win_install.py ^-r
call python "%install_location%\win_install.py" ^-r
@echo Done
pause
@echo Removing files
) else (
call python %running_directory%win_install.py ^-r >nul 2>&1
call python "%install_location%\win_install.py" ^-r >nul 2>&1
)
rd>nul /q/s %install_location% 2>nul
IF NOT "!output_on_screen!"=="False" (
@echo Done
)
:end
\ No newline at end of file
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# NX Client for Windows installer with RegistryHandler and DecideArchitecture classes
# Checks whether NX Client for Windows is installed in the system, the classes used for this
# process are used for other operations too
##
import os, sys, argparse, errno, subprocess, time
if sys.hexversion > 0x02070000:
from collections import *
else:
from OrderedDict import *
from _winreg import *
##
# Argument parser, based on argparse module
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
if DecideArchitecture.Is64Windows():
local_default = DecideArchitecture.GetProgramFiles64()+"\\CIRCLE\\"
else:
local_default = DecideArchitecture.GetProgramFiles32()+"\\CIRCLE\\"
if not os.path.exists(local_default[:-1]) and os.path.exists(os.environ['APPDATA']+"\\CIRCLE"):
local_default = os.environ['APPDATA']+"\\CIRCLE\\"
parser.add_argument("-l", "--location", help="Location of the client files in the system", default=local_default)
parser.add_argument("-g", "--global", help="Whether we want to edit registry globally or just locally", action="store_true")
parser.add_argument("-d", "--different", help="Only handle the architecture specific registry area", action="store_true")
parser.add_argument("-r", "--registry", help="Which HKEY_* const registry type the program should use", \
type=str, choices=['HKLM', 'HKCR', 'HKCU', 'HKU', 'HKPD', 'HKCC'], default="HKLM")
args = parser.parse_args();
return args
##
# Parameter bypassing struct
#
class Struct:
pass
##
# Registry handling class, makes registry based queries and manipulations easier
# This class can handle WOW64 based application differently and none differently (default)
#
class RegistryHandler:
##
# Initialise RegistryHandler
# @param args The args.registry tells us what registry we need to handle
#
def __init__(self, args = None):
if args is None:
self.args = Struct()
self.args.different = None
self.args.registry = None
else:
if not hasattr(args, 'different'):
args.different = None
if not hasattr(args, 'registry'):
args.registry = None
self.args = args
if self.args.different is None:
self.args.different = False
if self.args.registry is None or self.args.registry == "HKLM":
self.args.registry = HKEY_LOCAL_MACHINE
elif self.args.registry == "HKCR":
self.args.registry = HKEY_CLASSES_ROOT
elif self.args.registry == "HKCU":
self.args.registry = HKEY_CURRENT_USER
elif self.args.registry == "HKU":
self.args.registry = HKEY_USERS
elif self.args.registry == "HKPD":
self.args.registry = HKEY_PERFORMANCE_DATA
elif self.args.registry == "HKCC":
self.args.registry = HKEY_CURRENT_CONFIG
else:
#print "Non supported registry type"
raise AttributeError
##
# Getting a registry open
# @return connected_registy The registry which we successfully opened
#
def connect_registry(self):
return ConnectRegistry(None,self.args.registry)
##
# Create registry key and value multilevel tree by simple chained dictionaries
# Can raise AttributeError if the provided dict chain isn't correct
# @param key_value_chain The dict chain containing all the information
# @param both Whether create the registry in WOW64 node too
# @param architect The current registry view (only change it if we want to fill the
# WOW6432 registry only [both = False], on x64 windows)
# @param needed_rights SAM rights to access the key
#
def create_registry_from_dict_chain(self, dict_chain, both = False, architect = KEY_WOW64_64KEY, needed_rights = KEY_ALL_ACCESS):
if both and architect is KEY_WOW64_64KEY:
self.create_registry_from_dict_chain(dict_chain, False, KEY_WOW64_32KEY, needed_rights)
if not DecideArchitecture.Is64Windows():
architect = 0
connected_registy = self.connect_registry()
if isinstance(dict_chain, dict) or isinstance(dict_chain, OrderedDict):
for key, value in dict_chain.iteritems():
if isinstance(value, dict) or isinstance(value, OrderedDict):
temp_dict = OrderedDict()
for my_key, my_value in value.iteritems():
temp_dict[key+"\\"+my_key] = my_value
self.create_registry_from_dict_chain(temp_dict, False, architect, needed_rights)
else:
if isinstance(value, list):
if len(value)%2 != 0:
#print "Not enough member in the list"
raise AttributeError
else:
new_key = CreateKeyEx(connected_registy, key, 0, needed_rights | architect)
temp_dict = OrderedDict(value[i:i+2] for i in range(0, len(value), 2))
for my_key, my_value in temp_dict.iteritems():
SetValueEx(new_key,my_key,0, REG_SZ, my_value)
else:
new_key = CreateKeyEx(connected_registy, key, 0, needed_rights | architect)
SetValueEx(new_key,None,0, REG_SZ, value)
else:
print "The provided attribute wasn't a dictionary chain"
raise AttributeError
##
# Getting a registry value by it's key's name
# Can raise KeyError if key is not found in the registry
# @param key_name The specific key name of which value we are interested in
# @param needed_rights SAM rights to access the key
# @return [key, architect]
# key: The reference to the opened key handler
# architect: 0 for x86
# KEY_WOW64_32KEY or KEY_WOW64_64KEY depending where we found the key on x64
#
def get_key(self, key_name, needed_rights = KEY_ALL_ACCESS):
connected_registy = self.connect_registry()
architect = 0
if DecideArchitecture.Is64Windows():
architect = KEY_WOW64_64KEY
try:
key = OpenKey(connected_registy, key_name, 0, needed_rights | architect)
except WindowsError:
if DecideArchitecture.Is64Windows() and not self.args.different:
try:
architect = KEY_WOW64_32KEY
key = OpenKey(connected_registy, key_name, 0, needed_rights | architect)
except WindowsError:
raise KeyError
else:
raise KeyError
return [key, architect]
##
# Getting registry subkeys value by it's key's name and subkeys name
# Can raise LookupError exception if there are missing data
# Can raise AttributeError exception if depth attribute is wrong
# @param key_name The specific key name of which subkey's we are interested in
# @param subkey_list List containing all the subkeys names which values we are interested in
# @param subroutine Whether suppress exception about not having enough results or not - default False
# @param depth How depth the search should go for (key, subkeys, all) - default: subkeys
# @return results{} Dictionary with the subkey_name - value combinations as keys and values
#
def get_key_values(self, key_name, subkey_list, subroutine = False, depth = "subkeys"):
if depth == "key":
int_depth = 0;
elif depth == "subkeys":
int_depth = 1;
elif depth == "all":
int_depth = 2;
else:
raise AttributeError
try:
key_and_architect = self.get_key(key_name)
key = key_and_architect[0]
architect = key_and_architect[1]
except KeyError:
#print key_name+" doesn't exist in the registry"
raise LookupError
#print key_name+" found in the registry"
results = {}
if int_depth >= 1:
for i in xrange(0, QueryInfoKey(key)[0]-1):
skey_name = EnumKey(key, i)
skey = OpenKey(key, skey_name, 0, KEY_ALL_ACCESS | architect)
if int_depth == 2 and QueryInfoKey(skey)[0] > 0:
for key, value in self.get_key_values(skey_name, subkey_list, True, depth).iteritems():
results[key] = value
for subkey_name in subkey_list:
try:
results[subkey_name] = QueryValueEx(skey, subkey_name)[0]
except OSError as e:
if e.errno == errno.ENOENT:
#print subkey_name+" doesn't exist in this subkey"
pass
skey.Close()
if not results or len(results) != len(subkey_list):
for subkey_name in subkey_list:
try:
results[subkey_name] = QueryValueEx(key, subkey_name)[0]
except OSError as e:
pass
key.Close()
if len(results) != len(subkey_list):
#print We are missing important variables
raise LookupError
return results
##
# This is a wrapper for the get_key_values to be easier to use for single subkeys
# Getting registry subkey value by it's key's name and subkey name
# @param key_name The specific key name of which subkey's we are interested in
# @param subkey_name The specific subkey name which value we are interested in
# @param subroutine can be found at: get_key_values
# @param depth can be found at: get_key_values
# @return value Value of the specific subkey
#
def get_key_value(self, key_name, subkey_name, subroutine = None, depth = None):
try:
if subroutine is None:
return self.get_key_values(key_name, [subkey_name])[subkey_name]
elif depth is None:
return self.get_key_values(key_name, [subkey_name], subroutine)[subkey_name]
else:
return self.get_key_values(key_name, [subkey_name], subroutine, depth)[subkey_name]
except:
raise
##
# Helper class to get the true ProgramFiles directory.
# This class doesn't depend on Phyton or Windows architecture.
#
class DecideArchitecture:
@staticmethod
def Is64Windows():
return 'PROGRAMFILES(X86)' in os.environ
@staticmethod
def GetProgramFiles32():
if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMFILES(X86)']
else:
return os.environ['PROGRAMFILES']
@staticmethod
def GetProgramFiles64():
if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMW6432']
else:
return None
def main():
try:
args = pars_arguments()
nx_install_location = None
while nx_install_location is None:
print "Checking whether NX Client for Windows is installed"
handler = RegistryHandler()
try:
nx_install_location = handler.get_key_value("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\nxclient_is1", "InstallLocation", "key")
print "NX Client for Windows is found at '"+nx_install_location+"'"
process = subprocess.Popen("%s\\nxclient.exe" % nx_install_location)
time.sleep(2)
process.terminate()
except:
print "NX Client for Windows isn't installed on the system."
print "\tCommencing the install"
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\nxclient-3.5.0-9.exe").wait()
except:
pass
if __name__ == "__main__":
main()
\ No newline at end of file
......@@ -59,7 +59,7 @@ def custom_protocol_register(custom_protocol):
# create a proper icon with the proper driver
# call the nx_client_installer
def main():
try:
#try:
args = pars_arguments()
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
......@@ -112,7 +112,7 @@ def main():
custom_protocol_register(custom_nx)
except:
print "Error! URL Protocol handler installation aborted!"
except:
print "Unknown error occurred! Please contact the developers!"
#except:
# print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment