Commit 72b0e56f by Csók Tamás

Working windows parametrizable installer

parent 59aa364c
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
try:
from _abcoll import KeysView, ValuesView, ItemsView
except ImportError:
pass
class OrderedDict(dict):
'Dictionary that remembers insertion order'
# An inherited dict maps keys to values.
# The inherited dict provides __getitem__, __len__, __contains__, and get.
# The remaining methods are order-aware.
# Big-O running times for all methods are the same as for regular dictionaries.
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
# Each link is stored as a list of length three: [PREV, NEXT, KEY].
def __init__(self, *args, **kwds):
'''Initialize an ordered dictionary. Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.
'''
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.__root
except AttributeError:
self.__root = root = [] # sentinel node
root[:] = [root, root, None]
self.__map = {}
self.__update(*args, **kwds)
def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
if key not in self:
root = self.__root
last = root[0]
last[1] = root[0] = self.__map[key] = [last, root, key]
dict_setitem(self, key, value)
def __delitem__(self, key, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
dict_delitem(self, key)
link_prev, link_next, key = self.__map.pop(key)
link_prev[1] = link_next
link_next[0] = link_prev
def __iter__(self):
'od.__iter__() <==> iter(od)'
root = self.__root
curr = root[1]
while curr is not root:
yield curr[2]
curr = curr[1]
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
root = self.__root
curr = root[0]
while curr is not root:
yield curr[2]
curr = curr[0]
def clear(self):
'od.clear() -> None. Remove all items from od.'
try:
for node in self.__map.itervalues():
del node[:]
root = self.__root
root[:] = [root, root, None]
self.__map.clear()
except AttributeError:
pass
dict.clear(self)
def popitem(self, last=True):
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
'''
if not self:
raise KeyError('dictionary is empty')
root = self.__root
if last:
link = root[0]
link_prev = link[0]
link_prev[1] = root
root[0] = link_prev
else:
link = root[1]
link_next = link[1]
root[1] = link_next
link_next[0] = root
key = link[2]
del self.__map[key]
value = dict.pop(self, key)
return key, value
# -- the following methods do not depend on the internal structure --
def keys(self):
'od.keys() -> list of keys in od'
return list(self)
def values(self):
'od.values() -> list of values in od'
return [self[key] for key in self]
def items(self):
'od.items() -> list of (key, value) pairs in od'
return [(key, self[key]) for key in self]
def iterkeys(self):
'od.iterkeys() -> an iterator over the keys in od'
return iter(self)
def itervalues(self):
'od.itervalues -> an iterator over the values in od'
for k in self:
yield self[k]
def iteritems(self):
'od.iteritems -> an iterator over the (key, value) items in od'
for k in self:
yield (k, self[k])
def update(*args, **kwds):
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does: for k, v in E: od[k] = v
In either case, this is followed by: for k, v in F.items(): od[k] = v
'''
if len(args) > 2:
raise TypeError('update() takes at most 2 positional '
'arguments (%d given)' % (len(args),))
elif not args:
raise TypeError('update() takes at least 1 argument (0 given)')
self = args[0]
# Make progressively weaker assumptions about "other"
other = ()
if len(args) == 2:
other = args[1]
if isinstance(other, dict):
for key in other:
self[key] = other[key]
elif hasattr(other, 'keys'):
for key in other.keys():
self[key] = other[key]
else:
for key, value in other:
self[key] = value
for key, value in kwds.items():
self[key] = value
__update = update # let subclasses override update without breaking __init__
__marker = object()
def pop(self, key, default=__marker):
'''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
if key in self:
result = self[key]
del self[key]
return result
if default is self.__marker:
raise KeyError(key)
return default
def setdefault(self, key, default=None):
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
if key in self:
return self[key]
self[key] = default
return default
def __repr__(self, _repr_running={}):
'od.__repr__() <==> repr(od)'
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'
_repr_running[call_key] = 1
try:
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
finally:
del _repr_running[call_key]
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def copy(self):
'od.copy() -> a shallow copy of od'
return self.__class__(self)
@classmethod
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).
'''
d = cls()
for key in iterable:
d[key] = value
return d
def __eq__(self, other):
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
'''
if isinstance(other, OrderedDict):
return len(self)==len(other) and self.items() == other.items()
return dict.__eq__(self, other)
def __ne__(self, other):
return not self == other
# -- the following methods are only used in Python 2.7 --
def viewkeys(self):
"od.viewkeys() -> a set-like object providing a view on od's keys"
return KeysView(self)
def viewvalues(self):
"od.viewvalues() -> an object providing a view on od's values"
return ValuesView(self)
def viewitems(self):
"od.viewitems() -> a set-like object providing a view on od's items"
return ItemsView(self)
\ No newline at end of file
......@@ -3,7 +3,7 @@ Encoding=UTF-8
Version=0.2
Type=Application
Name=Cloud GUI
Comment=Tool to use IK Cloud
Comment=Tool to use CIRCLE Cloud
Exec=cloud2 %u
Icon=/usr/share/icons/cloud.svg
Terminal=true
......
......@@ -162,6 +162,6 @@ def main():
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
except:
pass
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
......@@ -4,6 +4,7 @@
# Távoli klienshez csatlakozás windows OS alól
##
import sys, os, time, subprocess, glob, nxkey, win32crypt, binascii
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
......@@ -14,6 +15,65 @@
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
pass
if vm.protocol == "SSH":
arguments = "-ssh -P %s -pw %s %s@%s" % (vm.port, vm.password, vm.user, vm.host)
subprocess.Popen("putty.exe "+arguments, shell = True)
elif vm.protocol == "NX":
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False
server = "\"Server host\" value=\"%s\"" % vm.host
port = "\"Server port\" value=\"%s\"" % vm.port
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if server in file and port in file:
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"), str(int(time.time()*1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted()
config = NX_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
elif vm.protocol == "RDP":
listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp"
found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if full_address in file and user in file:
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\", str(int(time.time()*1000)), ".rdp")
password = binascii.hexlify(win32crypt.CryptProtectData(u"%s" % vm.password,u'psw',None,None,None,0))
config = RPD_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
<option key="Remember password" value="true" />
<option key="Resolution" value="fullscreen" />
<option key="Server host" value="%(HOST)s" />
<option key="Server port" value="%(PORT)s" />
<option key="Session" value="unix" />
</group>
<group name="Login" >
<option key="Auth" value="%(PASSWORD)s" />
<option key="Guest Mode" value="false" />
<option key="Login Method" value="nx" />
<option key="User" value="%(USERNAME)s" />
</group>
</NXClientSettings>"""
RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s
password 51:b:%(PASSWORD)s"""
\ No newline at end of file
@echo off
cls
setLocal EnableDelayedExpansion
@echo Starting CIRCLE Client install script
@echo.
rem Get the running directory for later ease of use
SET running_directory=%~dp0
rem Set where this file will install the rest of the files
SET "install_location=%ProgramFiles%\CIRCLE"
call :SUB_ARCHITECTURE architecture
rem Decide whether python 2.x is installed or not
SET "python_registry="
:PHYTON_CHECK
SET index=-1
:loop
SET /a index+=1
IF %index% GTR 7 (
if "!architecture!"=="64" (
if "%python_registry%"=="" (
SET "python_registry=Wow6432Node\"
GOTO PHYTON_CHECK
) else (
GOTO NOPYTHON
)
) else (
GOTO NOPYTHON
)
)
SET version=2.%index%
SET @query="hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%"
reg>nul query %@query% 2>nul
IF ERRORLEVEL 1 GOTO loop
IF ERRORLEVEL 0 GOTO HASPYTHON
GOTO NOPYTHON
rem No 2.x Python is installed
:NOPYTHON
@echo No 2.x Python is detected on the system.
if "!architecture!"=="64" (
@echo 64 bit system detected, commencing the install
start /WAIT %running_directory%python-2.7.7.amd64.msi
GOTO NOWHASPYTHON
)
if "!architecture!"=="32" (
@echo 32 bit system detected, commencing the install
start /WAIT %running_directory%python-2.7.7.msi
GOTO NOWHASPYTHON
)
GOTO ERR
rem Subroutine to decide whether it is 32 or 64 bit
:SUB_ARCHITECTURE
rem Decide what architecture the system is using
if /i %processor_architecture%==AMD64 (
SET %1=64
GOTO END
)
if /i %PROCESSOR_ARCHITEW6432%==AMD64 (
SET %1=64
GOTO END
)
if /i %processor_architecture%==x86 (
SET %1=32
GOTO END
)
GOTO ERR
rem Error within the installation
:ERR
@echo Unsupported architecture! Please install files manually
@echo Please visit: https://www.python.org/downloads/
@echo Please visit: http://www.mozilla.org/en/firefox/new/
pause
GOTO END
rem The install program closed. Check whether the Phyton installation was successful
:NOWHASPYTHON
@echo Phyton install finished, rechecking registry
GOTO PHYTON_CHECK
rem We have Phyton but let's check if it's in the PATH
:HASPYTHON
@echo %version% Phyton is found, checking PATH variable
rem Check Phyton install path
set install_path=
for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%\InstallPath"') do (
set install_path=%%b
)
set test=%install_path:~0,-1%
call %running_directory%inPath test && (@echo %test% is already in PATH) || (call %running_directory%addPath test & setx PATH "%PATH%;%test%" /m & @echo %test% set to PATH)
set test=%install_path%Scripts
call %running_directory%inPath test && (@echo %test% is already in PATH) || (call %running_directory%addPath test & setx PATH "%PATH%;%test%" /m & @echo %test% set to PATH)
GOTO PIP_CHECK
rem Check whether PIP is installed or not
:PIP_CHECK
@echo.
@echo Checking if PIP is installed
IF EXIST %install_path%Scripts/PIP.exe GOTO PIP_VERSION_CHECK
@echo No PIP found, commencing PIP install
call phyton %running_directory%get-pip.py
rem Try to update the PIP
:PIP_VERSION_CHECK
@echo PIP is found
@echo Checking whether the latest PIP is installed
call python -m pip install --upgrade pip
SET "pip_program=selenium"
GOTO PIP_PACKAGE_CHECK
rem Check if the PIP package is installed or not
:PIP_PACKAGE_CHECK
@echo.
@echo Check whether !pip_program! is installed
for /f "tokens=1,2 delims===" %%a in ('call python -m pip freeze') do (
if "%%a"=="!pip_program!" (
@echo %%b !pip_program! is found
GOTO PIP_PACKAGE_UPDATE
)
)
@echo No !pip_program! version is found, commencing install
GOTO PIP_PACKAGE_INSTALL
rem Try to install the PIP package via PIP
:PIP_PACKAGE_INSTALL
@echo Installing !pip_program!
call python -m pip install !pip_program!
goto CHECK_PACKAGE_LIST
rem Try to update Selenium
:PIP_PACKAGE_UPDATE
@echo Trying to update !pip_program!
call python -m pip install --upgrade !pip_program!
goto CHECK_PACKAGE_LIST
:CHECK_PACKAGE_LIST
if "!pip_program!"=="selenium" (
set "pip_program=winshell"
goto PIP_PACKAGE_CHECK
)
goto CHECK_BROWSER
rem Get installed browsers
:CHECK_BROWSER
set browserToUse=None
@echo.
@echo Checking installed browsers
rem For 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
rem For 32 bit systems
if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
set count=1
for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
rem Extracting browser name from icon path
set "browser=%%B"
rem Removing \DefaultIcon] string
set "browser=!browser:\DefaultIcon]=!"
rem Get the browser name
for %%P in ("!browser!") do (
call :SUB_PRINTBROWSER %%~nP
)
)
GOTO CHECK_BROWSER_TO_USE
rem Subroutine to print installed browsers
:SUB_PRINTBROWSER
set subBrowser=%*
CALL :UCase subBrowser upperBrowser
if "%upperBrowser%"=="FIREFOX" (
@echo !count!. %upperBrowser% ^(Recommended^) ^- will be used
set "browserToUse=firefox"
) else (
@echo !count!. %upperBrowser%
)
set /a count+=1
GOTO END
rem Determine which Selenium driver to use
:CHECK_BROWSER_TO_USE
if "!browserToUse!"=="None" (
@echo Decide whitch browser to use
@echo Checking which one is the Default browser
START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do (
set "default=%%B"
rem removing double slashes
set "default=!default:\\=\!"
rem removing end slash
set "default=!default:~0,-1!"
rem get the name
for %%D in ("!default!") do (
call :SUB_DEFAULTBROWSER %%~nD
)
)
del /Q /F "%Temp%\BROW5.reg"
)
) else (
rem Registry location depends of the architecture
if "!architecture!"=="64" (
set "browser_architect=Wow6432Node\"
set "architecture_name=x64"
) else (
if "!architecture!"=="32" (
set "browser_architect="
set "architecture_name=x86"
) else (
GOTO ERR
)
)
rem Registry names for the different browsers out there
if "!browserToUse!"=="firefox" (
set "browser_path_name=FIREFOX.EXE"
set "selenium_driver_name="
)
if "!browserToUse!"=="chrome" (
set "browser_path_name=Google Chrome"
set "selenium_driver_name=chromedriver.exe"
)
if "!browserToUse!"=="iexplore" (
set "browser_path_name=IEXPLORE.EXE"
set "selenium_driver_name=IEDriverServer.exe"
)
rem Opera have to versions (in the registry) Opera and OperaStable, we try to Stable first
if "!browserToUse!"=="opera" (
set "browser_path_name=OperaStable"
set "selenium_driver_name="
)
set "browser_path="
@echo Check if !browserToUse!.exe is in PATH
:get_browser_path
set browser_path=
set query="hklm\SOFTWARE\%browser_architect%Clients\StartMenuInternet\%browser_path_name%\shell\open\command"
reg>nul query %query% 2>nul
if ERRORLEVEL 1 (
if "%browser_path%"=="" (
if "%browser_architect%"=="" (
rem If the Stable failed check out the simple Opera
if "%browser_path_name%"=="OperaStable" (
SET "browser_path_name=Opera"
SET "browser_architect=Wow6432Node\"
goto get_browser_path
)
@echo Location not found^^! Please add !browserToUse!.exe to PATH manually
pause
) else (
set "browser_architect="
goto get_browser_path
)
)
)
rem Get the installation path for the selected browser
for /f "tokens=2,*" %%a in ('reg query %query%') do (
set browser_path=%%b
)
set browser_path=%browser_path:"=%
call :Split "%browser_path%" test
set myTest=!test:~0,-1!
rem Set that path in the PATH environment variable
call %running_directory%inPath myTest && (@echo !myTest! is already in PATH) || (call %running_directory%addPath myTest & setx PATH "%PATH%;!myTest!" /m & @echo !myTest! set to PATH)
if NOT "!selenium_driver_name!"=="" (
@echo Installing the !browserToUse! Selenium driver
xcopy>nul "%running_directory%%architecture_name%^\%selenium_driver_name%" "!test!" /y
if ERRORLEVEL 0 (
@echo Done
) else (
@echo Error^^! Please copy the ^'chromedriver.exe^' to ^'!test!^' manually
)
)
rem For the Opera we need to install the selenium standalone jar
if "!browserToUse!"=="opera" (
SET "standalone_version=selenium-server-standalone-2.42.2.jar"
@echo Installing the Selenium server stand alone JAR
xcopy>nul "%running_directory%!standalone_version!" "!test!"
if ERRORLEVEL 0 (
@echo Done
rem And set it in the SELENIUM_SERVER_JAR environment variable
@echo Setting the SELENIUM_SERVER_JAR environment variable
setx SELENIUM_SERVER_JAR "!myTest!^\!standalone_version!" /m
@echo SELENIUM_SERVER_JAR set to ^'!myTest!^\!standalone_version!^'
) else (
@echo Error^^! Please copy the ^'%standalone_version%^' to ^'!test!^' manually
)
)
GOTO FIN
)
GOTO ERR
rem Finish up the install
:FIN
rem Create folder if needed and set it to PATH
@echo Checking wheter ^'%install_location%^\^' exists already
call %running_directory%inPath install_location && (@echo !install_location! is already in PATH) || (call %running_directory%addPath install_location & setx PATH "%PATH%;!install_location!" /m & @echo !install_location! set to PATH)
if not exist "%install_location%\" (
mkdir "%install_location%"
)
rem Copy the files to the folder
@echo Copying files to ^'%install_location%^'
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%cloud.ico" "%install_location%\" /y
@echo Done
@echo.
@echo Starting the phyton installation script
call python %running_directory%win_install.py ^-d !browserToUse! ^-l "%install_location%\\"
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
GOTO END
rem Subroutine to decide which Selenium driver to use
:SUB_DEFAULTBROWSER
set defBrowser=%*
CALL :LCase defBrowser lowerFound
if "%lowerFound%"=="launcher" (
set "lowerFound=opera"
)
@echo %lowerFound% is the default browser
set browserToUse=%lowerFound%
GOTO END
:LCase
:UCase
:: Converts to upper/lower case variable contents
:: Syntax: CALL :UCase _VAR1 _VAR2
:: Syntax: CALL :LCase _VAR1 _VAR2
:: _VAR1 = Variable NAME whose VALUE is to be converted to upper/lower case
:: _VAR2 = NAME of variable to hold the converted value
:: Note: Use variable NAMES in the CALL, not values (pass "by reference")
SET _UCase=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
SET _LCase=a b c d e f g h i j k l m n o p q r s t u v w x y z
SET _Lib_UCase_Tmp=!%1!
IF /I "%0"==":UCase" SET _Abet=%_UCase%
IF /I "%0"==":LCase" SET _Abet=%_LCase%
FOR %%Z IN (%_Abet%) DO SET _Lib_UCase_Tmp=!_Lib_UCase_Tmp:%%Z=%%Z!
SET %2=%_Lib_UCase_Tmp%
GOTO END
rem Subroutine to get the exact path out from a file location, but strip the file name
:Split
SET %2=%~dp1
GOTO END
:END
\ No newline at end of file
......@@ -4,9 +4,9 @@ sudo apt-get install sshpass python-pip remmina-plugin-nx remmina-plugin-rdp xdg
sudo pip install selenium
if [ "$(uname -m)" == 'x86_64' ]; then
sudo cp remminapasswd64 /usr/local/bin/remminapasswd
sudo cp x64/remminapasswd /usr/local/bin/remminapasswd
else
sudo cp remminapasswd32 /usr/local/bin/remminapasswd
sudo cp x86/remminapasswd /usr/local/bin/remminapasswd
fi
sudo chmod +x /usr/local/bin/remminapasswd
sudo cp cloud2 /usr/local/bin/
......
@echo off
cls
setLocal EnableDelayedExpansion
@echo Starting CIRCLE Client install script
@echo.
rem Get the running directory for later ease of use
SET running_directory=%~dp0
rem Set where this file will install the rest of the files
SET "install_location=%APPDATA%\CIRCLE"
rem Set whether we want output info on screen or not
IF NOT "%1"=="" (
SET "output_on_screen=%1"
) else (
SET "output_on_screen=False"
)
rem Set whether we want to install selenium or not
IF NOT "%2"=="" (
SET "install_selenium=%2"
) else (
SET "install_selenium=False"
)
rem Set which website should the icon point to
SET "website="
IF NOT "%3"=="" (
IF "%install_selenium%"=="False" (
SET site=%3
SET site=!site:"=!
SET "website= -t ^"!site!^""
)
)
:BatchCheckElevated
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
IF NOT "!output_on_screen!"=="False" (
@echo Elevated rights recived from UAC
)
:--------------------------------------
rem Start the installation script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client install script
@echo.
)
call :SUB_ARCHITECTURE architecture
rem Decide whether python 2.x is installed or not
SET "python_registry="
:PHYTON_CHECK
SET index=-1
:PYTHON_CHECK
SET index=8
:loop
SET /a index+=1
IF %index% GTR 7 (
SET /a index-=1
IF %index% LSS 6 (
if "!architecture!"=="64" (
if "%python_registry%"=="" (
SET "python_registry=Wow6432Node\"
GOTO PHYTON_CHECK
GOTO PYTHON_CHECK
) else (
GOTO NOPYTHON
)
......@@ -34,17 +86,23 @@ SET index=-1
IF ERRORLEVEL 0 GOTO HASPYTHON
GOTO NOPYTHON
rem No 2.x Python is installed
rem No 2.6+ Python is installed
:NOPYTHON
@echo No 2.x Python is detected on the system.
IF NOT "!output_on_screen!"=="False" (
@echo No 2.6^+ Python is detected on the system.
)
if "!architecture!"=="64" (
@echo 64 bit system detected, commencing the install
start /WAIT %running_directory%python-2.7.7.amd64.msi
IF NOT "!output_on_screen!"=="False" (
@echo 64 bit system detected, commencing the install
)
start /WAIT %running_directory%x64^\python-2.7.7.amd64.msi
GOTO NOWHASPYTHON
)
if "!architecture!"=="32" (
@echo 32 bit system detected, commencing the install
start /WAIT %running_directory%python-2.7.7.msi
IF NOT "!output_on_screen!"=="False" (
@echo 32 bit system detected, commencing the install
)
start /WAIT %running_directory%x86^\python-2.7.7.msi
GOTO NOWHASPYTHON
)
GOTO ERR
......@@ -52,15 +110,15 @@ rem No 2.x Python is installed
rem Subroutine to decide whether it is 32 or 64 bit
:SUB_ARCHITECTURE
rem Decide what architecture the system is using
if /i %processor_architecture%==AMD64 (
if /i "%processor_architecture%"=="AMD64" (
SET %1=64
GOTO END
)
if /i %PROCESSOR_ARCHITEW6432%==AMD64 (
if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" (
SET %1=64
GOTO END
)
if /i %processor_architecture%==x86 (
if /i "%processor_architecture%"=="x86" (
SET %1=32
GOTO END
)
......@@ -68,71 +126,117 @@ rem No 2.x Python is installed
rem Error within the installation
:ERR
@echo Unsupported architecture! Please install files manually
@echo Please visit: https://www.python.org/downloads/
@echo Please visit: http://www.mozilla.org/en/firefox/new/
pause
IF NOT "!output_on_screen!"=="False" (
@echo Unsupported architecture! Please install files manually
@echo Please visit: https://www.python.org/downloads/
@echo Please visit: http://www.mozilla.org/en/firefox/new/
pause
)
GOTO END
rem The install program closed. Check whether the Phyton installation was successful
rem The install program closed. Check whether the Python installation was successful
:NOWHASPYTHON
@echo Phyton install finished, rechecking registry
GOTO PHYTON_CHECK
SET version=2.7
IF NOT "!output_on_screen!"=="False" (
@echo Python install finished, rechecking registry
)
GOTO UACPrompt
rem We have Phyton but let's check if it's in the PATH
rem We have Python but let's check if it's in the PATH
:HASPYTHON
@echo %version% Phyton is found, checking PATH variable
rem Check Phyton install path
IF NOT "!output_on_screen!"=="False" (
@echo %version% Python is found, checking PATH variable
)
rem Check Python install path
set install_path=
for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%\InstallPath"') do (
set install_path=%%b
)
set test=%install_path:~0,-1%
call %running_directory%inPath test && (@echo %test% is already in PATH) || (call %running_directory%addPath test & setx PATH "%PATH%;%test%" & @echo %test% set to local PATH)
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to local PATH))
set test=%install_path%Scripts
call %running_directory%inPath test && (@echo %test% is already in PATH) || (call %running_directory%addPath test & setx PATH "%PATH%;%test%" & @echo %test% set to local PATH)
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to local PATH))
GOTO PIP_CHECK
rem Check whether PIP is installed or not
:PIP_CHECK
@echo.
@echo Checking if PIP is installed
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Checking if PIP is installed
)
IF EXIST %install_path%Scripts/PIP.exe GOTO PIP_VERSION_CHECK
@echo No PIP found, commencing PIP install
call phyton %running_directory%get-pip.py
IF NOT "!output_on_screen!"=="False" (
@echo No PIP found, commencing PIP install
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%get-pip.py
) else (
call python %running_directory%get-pip.py >nul 2>&1
)
rem Try to update the PIP
:PIP_VERSION_CHECK
@echo PIP is found
@echo Checking whether the latest PIP is installed
call python -m pip install --upgrade pip
SET "pip_program=selenium"
IF NOT "!output_on_screen!"=="False" (
@echo PIP is found
@echo Checking whether the latest PIP is installed
)
IF NOT "!output_on_screen!"=="False" (
call python -m pip install --upgrade pip
) else (
call python -m pip install --upgrade pip >nul 2>&1
)
IF "%install_selenium%"=="False" (
SET "pip_program=winshell"
) else (
SET "pip_program=selenium"
)
GOTO PIP_PACKAGE_CHECK
rem Check if the PIP package is installed or not
rem Check if the PIP package is installed or not
:PIP_PACKAGE_CHECK
@echo.
@echo Check whether !pip_program! is installed
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Check whether !pip_program! is installed
)
for /f "tokens=1,2 delims===" %%a in ('call python -m pip freeze') do (
if "%%a"=="!pip_program!" (
@echo %%b !pip_program! is found
GOTO PIP_PACKAGE_UPDATE
IF NOT "!output_on_screen!"=="False" (
@echo %%b !pip_program! is found
)
rem pywin32 cannot be installed or updated via pip
if "!pip_program!"=="pywin32" goto CHECK_PACKAGE_LIST
GOTO PIP_PACKAGE_UPDATE
)
)
@echo No !pip_program! version is found, commencing install
IF NOT "!output_on_screen!"=="False" (
@echo No !pip_program! version is found, commencing install
)
GOTO PIP_PACKAGE_INSTALL
rem Try to install the PIP package via PIP
:PIP_PACKAGE_INSTALL
@echo Installing !pip_program!
call python -m pip install !pip_program!
IF NOT "!output_on_screen!"=="False" (
@echo Installing !pip_program!
)
if "!pip_program!"=="pywin32" (
call python %running_directory%pywin_installer.py
) else (
IF NOT "!output_on_screen!"=="False" (
call python -m pip install !pip_program!
) else (
call python -m pip install !pip_program! >nul 2>&1
)
)
goto CHECK_PACKAGE_LIST
rem Try to update Selenium
:PIP_PACKAGE_UPDATE
@echo Trying to update !pip_program!
call python -m pip install --upgrade !pip_program!
IF NOT "!output_on_screen!"=="False" (
@echo Trying to update !pip_program!
call python -m pip install --upgrade !pip_program!
) else (
call python -m pip install --upgrade !pip_program! >nul 2>&1
)
goto CHECK_PACKAGE_LIST
:CHECK_PACKAGE_LIST
......@@ -140,14 +244,23 @@ rem No 2.x Python is installed
set "pip_program=winshell"
goto PIP_PACKAGE_CHECK
)
goto CHECK_BROWSER
if "!pip_program!"=="winshell" (
set "pip_program=pywin32"
goto PIP_PACKAGE_CHECK
)
if NOT "%install_selenium%"=="False" (
goto CHECK_BROWSER
) else (
goto FIN
)
rem Get installed browsers
:CHECK_BROWSER
set browserToUse=None
@echo.
@echo Checking installed browsers
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Checking installed browsers
)
rem For 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
rem For 32 bit systems
......@@ -170,10 +283,16 @@ rem Subroutine to print installed browsers
set subBrowser=%*
CALL :UCase subBrowser upperBrowser
if "%upperBrowser%"=="FIREFOX" (
@echo !count!. %upperBrowser% ^(Recommended^) ^- will be used
set "browserToUse=firefox"
IF NOT "!output_on_screen!"=="False" (
@echo !count!. %upperBrowser% ^(Recommended^) ^- will be used
)
if NOT "%install_selenium%"=="False" (
SET "browserToUse=firefox"
)
) else (
@echo !count!. %upperBrowser%
IF NOT "!output_on_screen!"=="False" (
@echo !count!. %upperBrowser%
)
)
set /a count+=1
GOTO END
......@@ -181,8 +300,10 @@ GOTO END
rem Determine which Selenium driver to use
:CHECK_BROWSER_TO_USE
if "!browserToUse!"=="None" (
IF NOT "!output_on_screen!"=="False" (
@echo Decide whitch browser to use
@echo Checking which one is the Default browser
)
START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do (
set "default=%%B"
......@@ -229,7 +350,9 @@ if "!browserToUse!"=="None" (
set "selenium_driver_name="
)
set "browser_path="
@echo Check if !browserToUse!.exe is in PATH
IF NOT "!output_on_screen!"=="False" (
@echo Check if !browserToUse!.exe is in PATH
)
:get_browser_path
set browser_path=
set query="hklm\SOFTWARE\%browser_architect%Clients\StartMenuInternet\%browser_path_name%\shell\open\command"
......@@ -243,8 +366,11 @@ if "!browserToUse!"=="None" (
SET "browser_architect=Wow6432Node\"
goto get_browser_path
)
@echo Location not found^^! Please add !browserToUse!.exe to PATH manually
pause
IF NOT "!output_on_screen!"=="False" (
@echo Location not found^^! Please add !browserToUse!.exe to PATH manually
pause
)
goto install_driver
) else (
set "browser_architect="
goto get_browser_path
......@@ -259,29 +385,47 @@ if "!browserToUse!"=="None" (
call :Split "%browser_path%" test
set myTest=!test:~0,-1!
rem Set that path in the PATH environment variable
call %running_directory%inPath myTest && (@echo !myTest! is already in PATH) || (call %running_directory%addPath myTest & setx PATH "%PATH%;!myTest!" & @echo !myTest! set to local PATH)
if NOT "!selenium_driver_name!"=="" (
@echo Installing the !browserToUse! Selenium driver
xcopy>nul "%running_directory%%architecture_name%^\%selenium_driver_name%" "!install_location!\" /y
if ERRORLEVEL 0 (
@echo Done
) else (
@echo Error^^! Please copy the ^'chromedriver.exe^' to ^'!install_location!^\^' manually
call %running_directory%inPath myTest && (IF NOT "!output_on_screen!"=="False" ( @echo !myTest! is already in PATH)) || (call %running_directory%addPath myTest & setx>nul PATH "%PATH%;!myTest!" & IF NOT "!output_on_screen!"=="False" ( @echo !myTest! set to local PATH) )
:install_driver
IF NOT "%install_selenium%"=="False" (
if NOT "!selenium_driver_name!"=="" (
@echo Installing the !browserToUse! Selenium driver
xcopy>nul "%running_directory%%architecture_name%^\%selenium_driver_name%" "!install_location!\" /y
if ERRORLEVEL 0 (
IF NOT "!output_on_screen!"=="False" (
@echo Done
)
) else (
IF NOT "!output_on_screen!"=="False" (
@echo Error^^! Please copy the ^'chromedriver.exe^' to ^'!install_location!^\^' manually
)
)
)
)
rem For the Opera we need to install the selenium standalone jar
if "!browserToUse!"=="opera" (
SET "standalone_version=selenium-server-standalone-2.42.2.jar"
@echo Installing the Selenium server stand alone JAR
xcopy>nul "%running_directory%!standalone_version!" "!install_location!\"
if ERRORLEVEL 0 (
@echo Done
rem And set it in the SELENIUM_SERVER_JAR environment variable
@echo Setting the SELENIUM_SERVER_JAR environment variable
setx SELENIUM_SERVER_JAR "!install_location!^\!standalone_version!"
@echo local SELENIUM_SERVER_JAR set to ^'!install_location!^\!standalone_version!^'
) else (
@echo Error^^! Please copy the ^'%standalone_version%^' to ^'!test!^' manually
rem For the Opera we need to install the selenium standalone jar
if "!browserToUse!"=="opera" (
SET "standalone_version=selenium-server-standalone-2.42.2.jar"
IF NOT "!output_on_screen!"=="False" (
@echo Installing the Selenium server stand alone JAR
)
xcopy>nul "%running_directory%!standalone_version!" "!install_location!\"
if ERRORLEVEL 0 (
IF NOT "!output_on_screen!"=="False" (
@echo Done
)
rem And set it in the SELENIUM_SERVER_JAR environment variable
IF NOT "!output_on_screen!"=="False" (
@echo Setting the SELENIUM_SERVER_JAR environment variable
)
setx>nul SELENIUM_SERVER_JAR "!install_location!^\!standalone_version!"
IF NOT "!output_on_screen!"=="False" (
@echo local SELENIUM_SERVER_JAR set to ^'!install_location!^\!standalone_version!^'
)
) else (
IF NOT "!output_on_screen!"=="False" (
@echo Error^^! Please copy the ^'%standalone_version%^' to ^'!test!^' manually
)
)
)
)
GOTO FIN
......@@ -291,24 +435,52 @@ GOTO ERR
rem Finish up the install
:FIN
rem Create folder if needed and set it to PATH
@echo Checking wheter ^'%install_location%^\^' exists already
call %running_directory%inPath install_location && (@echo !install_location! is already in PATH) || (call %running_directory%addPath install_location & setx PATH "%PATH%;!install_location!" & @echo !install_location! set to local PATH)
IF NOT "!output_on_screen!"=="False" (
@echo Checking wheter ^'%install_location%^\^' exists already
)
call %running_directory%inPath install_location && (IF NOT "!output_on_screen!"=="False" ( @echo !install_location! is already in PATH)) || (call %running_directory%addPath install_location & setx>nul PATH "%PATH%;!install_location!" & IF NOT "!output_on_screen!"=="False" ( @echo !install_location! set to local PATH))
if not exist "%install_location%\" (
mkdir "%install_location%"
)
if not exist "%install_location%\.rdp\" (
mkdir "%install_location%\.rdp"
)
rem Copy the files to the folder
@echo Copying files to ^'%install_location%^'
IF NOT "!output_on_screen!"=="False" (
@echo Copying files to ^'%install_location%^'
)
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%nxkey.py" "%install_location%\" /y
xcopy>nul "%running_directory%OrderedDict.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud.ico" "%install_location%\" /y
@echo Done
@echo.
@echo Starting the phyton installation script
call python %running_directory%win_install.py ^-d !browserToUse! ^-l "%install_location%\\"
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
xcopy>nul "%running_directory%putty.exe" "%install_location%\" /y
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo.
)
IF "%install_selenium%"=="False" (
SET "create_url_icon= -u"
) else (
SET "create_url_icon="
)
IF NOT "!output_on_screen!"=="False" (
@echo Starting the python installation script
)
if NOT "!browserToUse!"=="" (
SET "selenium_driver= -d !browserToUse!"
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website!
) else (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website! >nul 2>&1
)
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
)
GOTO END
rem Subroutine to decide which Selenium driver to use
......@@ -318,7 +490,9 @@ CALL :LCase defBrowser lowerFound
if "%lowerFound%"=="launcher" (
set "lowerFound=opera"
)
@echo %lowerFound% is the default browser
IF NOT "!output_on_screen!"=="False" (
@echo %lowerFound% is the default browser
)
set browserToUse=%lowerFound%
GOTO END
......
#!/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
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Generating NoMachine NX scrambled key according to https://www.nomachine.com/AR01C00125
##
import sys
import random
import re
from xml.sax.saxutils import escape
##
# NXKeyGen class
# Creates NoMachine NX scrambled keys
#
class NXKeyGen:
numValidCharList = 85
dummyString = "{{{{"
##
# Initialize the class
# @param password Password that will be scrambled
#
def __init__(self, password):
self.password = password
##
# Encrypt (scramble) the given password
# @return scrambleString Scrambled version of the original password
#
def getEncrypted(self):
return self.scrambleString(self.password)
##
# Valid character list
# @return validcharlist List of the valid characters
#
def getvalidCharList(self, pos):
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}"
]
return validcharlist[pos]
##
# Password encoder
# @return sPass Encoded password
#
def encodePassword(self, p):
sPass = ":"
sTmp = ""
if not p:
return ""
for i in range(len(p)):
c = p[i:i+1]
a = ord(c)
sTmp = str( a + i + 1) + ":"
sPass += sTmp
sTmp = ""
return sPass
##
# Character position finder
# @param c Character that needs to be matched if valid
# @return i Place where the character is in the valid list
#
def findCharInList(self, c):
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j);
if randchar == c:
i = j
return i
return i
##
# Random valid character getter
# @return char Valid character placed 0-60 in the valid list
#
def getRandomValidCharFromList(self):
return self.getvalidCharList(random.randint(0,60))
##
# Password scrambler
# @param s Password that needs to be scrambled
# @return sRet NoMachine NX scrambled password
#
def scrambleString(self, s):
sRet = ""
if not s:
return s
strp = self.encodePassword(s)
if len(strp) < 32:
sRet += self.dummyString
for iR in reversed(range(len(strp))):
sRet += strp[iR:iR+1]
if len(sRet) < 32:
sRet += self.dummyString
app = self.getRandomValidCharFromList()
k = ord(app)
l = k + len(sRet) - 2
sRet = app + sRet
for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1]
j = self.findCharInList(app2)
if j == -1:
return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList
car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet,car,i1,1)
c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c)
sRet = sRet + c2
return escape(sRet)
##
# Replace a character at a special position
#
def substr_replace(self,in_str,ch,pos,qt):
clist = list(in_str)
count = 0;
tmp_str = '';
for key in clist:
if count != pos:
tmp_str += key
else:
tmp_str += ch
count = count+1
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
print NXPass.getEncrypted()
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Pywin32 installer for CIRCLE client application
##
import os, sys, subprocess
from nx_client_installer import DecideArchitecture
##
# Main program
# Install Pywin32 to the computer
#
def main():
if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\no_root_install.bat")
sys.exit(1)
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if DecideArchitecture.Is64Windows():
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x64\\pywin32-"+pywin32_version+".win-amd64-py2.6.exe").wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.6.exe").wait()
elif sys.hexversion < 0x02080000:
if DecideArchitecture.Is64Windows():
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x64\\pywin32-"+pywin32_version+".win-amd64-py2.7.exe").wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.7.exe").wait()
else:
print "Unsupported Python version is found!"
if __name__ == "__main__":
main()
\ No newline at end of file
@echo off
cls
setLocal EnableDelayedExpansion
rem Set whether we want output info on screen or not
IF NOT "%1"=="" (
SET "output_on_screen=%1"
) else (
SET "output_on_screen=False"
)
rem Starting the uninstall script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client uninstall script
@echo.
)
rem Get the running directory for later ease of use
SET running_directory=%~dp0
rem Set where this file will install the rest of the files
SET "install_location=%APPDATA%\CIRCLE"
if not exist "%install_location%\" (
SET "install_location=%ProgramFiles%\CIRCLE"
)
if not exist "%install_location%\" (
IF NOT "!output_on_screen!"=="False" (
@echo Installation direcory not found^^! Please delete ^'CIRCLE^' direcory manually
pause
)
goto end
)
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
@echo Done
pause
) else (
call python %running_directory%win_install.py ^-r >nul 2>&1
)
:end
\ No newline at end of file
......@@ -2,52 +2,117 @@
# -*- coding: utf-8 -*-
##
# Windows installer helper for CIRCLE client application
# Windows icon installer for CIRCLE client application
##
import os, sys, argparse
import os, sys, argparse, subprocess
if sys.hexversion > 0x02070000:
from collections import *
else:
from OrderedDict import *
import pythoncom
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
##
# Argument parser, argparse modulon alapszik
# Argument parser, based on argparse module
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'iexplore', 'opera'], default="firefox")
parser.add_argument("-l", "--location", help="Location of the client files in the system", default=os.getenv('ProgramFiles')+"\\CIRCLE\\")
type=str, choices=['firefox', 'chrome', 'iexplore', 'opera'], default="firefox", required=False)
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, required=False)
parser.add_argument("-r", "--remove", help="Remove installed files instead of creating them", action="store_true", required=False)
parser.add_argument("-u", "--url", help="Whether we installed and we want to use selenium or not", action="store_true", required=False)
parser.add_argument("-t", "--target", help="If this is an URL icon, where should it point", default="https://pc3.szgt.uni-miskolc.hu/", required=False)
args = parser.parse_args();
return args
##
# Custom protocol register based on RegistryHandler module
# Can raise AttributeError on wrongly provided dictionary chain
# @param dict_chain OrderedDictionary chain of the registry tree
#
def custom_protocol_register(custom_protocol):
if not isinstance(custom_protocol, OrderedDict):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
try:
custom_arguments = Struct()
custom_arguments.registry = "HKCR"
handler = RegistryHandler(custom_arguments)
handler.create_registry_from_dict_chain(custom_protocol, True)
print "\t\tDone!"
except:
raise
##
# Main program
# read the parameters
# create a proper icon with the proper driver
# call the nx_client_installer
def main():
try:
args = pars_arguments()
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
shortcut.SetPath (args.location+"cloud.py")
if args.driver == "chrome":
shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore":
shortcut.SetArguments("-d ie")
elif args.driver == "opera":
shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)
persist_file.Save (os.path.join (desktop_path, "Cloud GUI.lnk"), 0)
if args.remove:
location =os.path.join(desktop_path, "Cloud GUI")
if os.path.isfile("%s%s" % (location, ".lnk")):
os.remove("%s%s" % (location, ".lnk"))
if os.path.isfile("%s%s" % (location, ".url")):
os.remove("%s%s" % (location, ".url"))
else:
subprocess.call("python "+os.path.dirname(os.path.realpath(__file__))+"\\nx_client_installer.py")
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
shortcut = file(location, 'w')
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL='+args.target)
shortcut.close()
else:
shortcut.SetPath (args.location+"cloud.py")
if args.driver == "chrome":
shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore":
shortcut.SetArguments("-d ie")
elif args.driver == "opera":
shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)
persist_file.Save (os.path.join (desktop_path, "Cloud GUI.lnk"), 0)
print "Icon successfully created on desktop"
print "Creating custom URL protocol handlers"
try:
custom_ssh = OrderedDict([('ssh', "URL:CIRCLE-SSH Protocol"), ('ssh\\URL Protocol', ""),\
('ssh\\DefaultIcon', args.location+"cloud.ico"),\
('ssh\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_ssh)
custom_rdp = OrderedDict([('rdp', "URL:CIRCLE-RDP Protocol"), ('rdp\\URL Protocol', ""),\
('rdp\\DefaultIcon', args.location+"cloud.ico"),\
('rdp\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_rdp)
custom_nx = OrderedDict([('nx', "URL:CIRCLE-NX Protocol"), ('nx\\URL Protocol', ""),\
('nx\\DefaultIcon', args.location+"cloud.ico"),\
('nx\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_nx)
except:
print "Error! URL Protocol handler installation aborted!"
except:
pass
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/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
#!/bin/bash
sudo rm -f /usr/local/bin/remminapasswd
sudo rm -f /usr/local/bin/cloud2
sudo rm -f /usr/local/bin/cloud.py
sudo rm -f /usr/local/bin/cloud_connect_from_linux.py
sudo rm -f /usr/share/icons/cloud.svg
rm -f $(xdg-user-dir DESKTOP)/cloud.desktop
\ No newline at end of file
@echo off
:addPath pathVar /B
::
:: Safely appends the path contained within variable pathVar to the end
:: of PATH if and only if the path does not already exist within PATH.
::
:: If the case insensitive /B option is specified, then the path is
:: inserted into the front (Beginning) of PATH instead.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings are
:: considered a match if they are logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
:: Before appending the pathVar path, all double quotes are stripped, and
:: then the path is enclosed in double quotes if and only if the path
:: contains at least one semicolon.
::
:: addPath aborts with ERRORLEVEL 2 if pathVar is missing or undefined
:: or if PATH is undefined.
::
::------------------------------------------------------------------------
::
:: Error checking
if "%~1"=="" exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Determine if function was called while delayed expansion was enabled
setlocal
set "NotDelayed=!"
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set "var=%path:"=""%"
set "var=%var:^=^^%"
set "var=%var:&=^&%"
set "var=%var:|=^|%"
set "var=%var:<=^<%"
set "var=%var:>=^>%"
set "var=%var:;=^;^;%"
set var=%var:""="%
set "var=%var:"=""Q%"
set "var=%var:;;="S"S%"
set "var=%var:^;^;=;%"
set "var=%var:""="%"
setlocal EnableDelayedExpansion
set "var=!var:"Q=!"
set "var=!var:"S"S=";"!"
::
:: Remove quotes from pathVar and abort if it becomes empty
set "new=!%~1:"^=!"
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo("!new!"|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& set "abs=1" || set "abs=0"
::
:: For each path in PATH, check if path is fully qualified and then
:: do proper comparison with pathVar. Exit if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in ("!new!\") do for %%B in ("!var!") do (
if "!!"=="" setlocal disableDelayedExpansion
for %%C in ("%%~B\") do (
echo(%%B|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& (if %abs%==1 if /i "%%~sA"=="%%~sC" exit /b 0) ^
|| (if %abs%==0 if /i %%A==%%C exit /b 0)
)
)
::
:: Build the modified PATH, enclosing the added path in quotes
:: only if it contains ;
setlocal enableDelayedExpansion
if "!new:;=!" neq "!new!" set new="!new!"
if /i "%~2"=="/B" (set "rtn=!new!;!path!") else set "rtn=!path!;!new!"
::
:: rtn now contains the modified PATH. We need to safely pass the
:: value accross the ENDLOCAL barrier
::
:: Make rtn safe for assignment using normal expansion by replacing
:: % and " with not yet defined FOR variables
set "rtn=!rtn:%%=%%A!"
set "rtn=!rtn:"=%%B!"
::
:: Escape ^ and ! if function was called while delayed expansion was enabled.
:: The trailing ! in the second assignment is critical and must not be removed.
if not defined NotDelayed set "rtn=!rtn:^=^^^^!"
if not defined NotDelayed set "rtn=%rtn:!=^^^!%" !
::
:: Pass the rtn value accross the ENDLOCAL barrier using FOR variables to
:: restore the % and " characters. Again the trailing ! is critical.
for /f "usebackq tokens=1,2" %%A in ('%%^ ^"') do (
endlocal & endlocal & endlocal & endlocal & endlocal
set "path=%rtn%" !
)
exit /b 0
\ No newline at end of file
@echo off
:inPath pathVar
::
:: Tests if the path stored within variable pathVar exists within PATH.
::
:: The result is returned as the ERRORLEVEL:
:: 0 if the pathVar path is found in PATH.
:: 1 if the pathVar path is not found in PATH.
:: 2 if pathVar is missing or undefined or if PATH is undefined.
::
:: If the pathVar path is fully qualified, then it is logically compared
:: to each fully qualified path within PATH. The path strings don't have
:: to match exactly, they just need to be logically equivalent.
::
:: If the pathVar path is relative, then it is strictly compared to each
:: relative path within PATH. Case differences and double quotes are
:: ignored, but otherwise the path strings must match exactly.
::
::------------------------------------------------------------------------
::
:: Error checking
if "%~1"=="" exit /b 2
if not defined %~1 exit /b 2
if not defined path exit /b 2
::
:: Prepare to safely parse PATH into individual paths
setlocal DisableDelayedExpansion
set "var=%path:"=""%"
set "var=%var:^=^^%"
set "var=%var:&=^&%"
set "var=%var:|=^|%"
set "var=%var:<=^<%"
set "var=%var:>=^>%"
set "var=%var:;=^;^;%"
set var=%var:""="%
set "var=%var:"=""Q%"
set "var=%var:;;="S"S%"
set "var=%var:^;^;=;%"
set "var=%var:""="%"
setlocal EnableDelayedExpansion
set "var=!var:"Q=!"
set "var=!var:"S"S=";"!"
::
:: Remove quotes from pathVar and abort if it becomes empty
set "new=!%~1:"=!"
if not defined new exit /b 2
::
:: Determine if pathVar is fully qualified
echo("!new!"|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& set "abs=1" || set "abs=0"
::
:: For each path in PATH, check if path is fully qualified and then do
:: proper comparison with pathVar.
:: Exit with ERRORLEVEL 0 if a match is found.
:: Delayed expansion must be disabled when expanding FOR variables
:: just in case the value contains !
for %%A in ("!new!\") do for %%B in ("!var!") do (
if "!!"=="" endlocal
for %%C in ("%%~B\") do (
echo(%%B|findstr /i /r /c:^"^^\"[a-zA-Z]:[\\/][^\\/]" ^
/c:^"^^\"[\\][\\]" >nul ^
&& (if %abs%==1 if /i "%%~sA"=="%%~sC" exit /b 0) ^
|| (if %abs%==0 if /i "%%~A"=="%%~C" exit /b 0)
)
)
:: No match was found so exit with ERRORLEVEL 1
exit /b 1
\ No newline at end of file
@echo off
cls
setLocal EnableDelayedExpansion
rem Get the running directory for later ease of use
SET running_directory=%~dp0
rem Set where this file will install the rest of the files
SET "install_location=%APPDATA%\CIRCLE"
rem Set whether we want output info on screen or not
IF NOT "%1"=="" (
SET "output_on_screen=%1"
) else (
SET "output_on_screen=False"
)
rem Set whether we want to install selenium or not
IF NOT "%2"=="" (
SET "install_selenium=%2"
) else (
SET "install_selenium=False"
)
rem Set which website should the icon point to
SET "website="
IF NOT "%3"=="" (
IF "%install_selenium%"=="False" (
SET site=%3
SET site=!site:"=!
SET "website= -t ^"!site!^""
)
)
:BatchCheckElevated
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
echo Requesting administrative privileges...
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
IF NOT "!output_on_screen!"=="False" (
@echo Elevated rights recived from UAC
)
:--------------------------------------
rem Start the installation script
IF NOT "!output_on_screen!"=="False" (
@echo Starting CIRCLE Client install script
@echo.
)
call :SUB_ARCHITECTURE architecture
rem Decide whether python 2.x is installed or not
SET "python_registry="
:PYTHON_CHECK
SET index=8
:loop
SET /a index-=1
IF %index% LSS 6 (
if "!architecture!"=="64" (
if "%python_registry%"=="" (
SET "python_registry=Wow6432Node\"
GOTO PYTHON_CHECK
) else (
GOTO NOPYTHON
)
) else (
GOTO NOPYTHON
)
)
SET version=2.%index%
SET @query="hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%"
reg>nul query %@query% 2>nul
IF ERRORLEVEL 1 GOTO loop
IF ERRORLEVEL 0 GOTO HASPYTHON
GOTO NOPYTHON
rem No 2.6+ Python is installed
:NOPYTHON
IF NOT "!output_on_screen!"=="False" (
@echo No 2.6^+ Python is detected on the system.
)
if "!architecture!"=="64" (
IF NOT "!output_on_screen!"=="False" (
@echo 64 bit system detected, commencing the install
)
start /WAIT %running_directory%x64^\python-2.7.7.amd64.msi
GOTO NOWHASPYTHON
)
if "!architecture!"=="32" (
IF NOT "!output_on_screen!"=="False" (
@echo 32 bit system detected, commencing the install
)
start /WAIT %running_directory%x86^\python-2.7.7.msi
GOTO NOWHASPYTHON
)
GOTO ERR
rem Subroutine to decide whether it is 32 or 64 bit
:SUB_ARCHITECTURE
rem Decide what architecture the system is using
if /i "%processor_architecture%"=="AMD64" (
SET %1=64
GOTO END
)
if /i "%PROCESSOR_ARCHITEW6432%"=="AMD64" (
SET %1=64
GOTO END
)
if /i "%processor_architecture%"=="x86" (
SET %1=32
GOTO END
)
GOTO ERR
rem Error within the installation
:ERR
IF NOT "!output_on_screen!"=="False" (
@echo Unsupported architecture! Please install files manually
@echo Please visit: https://www.python.org/downloads/
@echo Please visit: http://www.mozilla.org/en/firefox/new/
pause
)
GOTO END
rem The install program closed. Check whether the Python installation was successful
:NOWHASPYTHON
SET version=2.7
IF NOT "!output_on_screen!"=="False" (
@echo Python install finished, rechecking registry
)
GOTO UACPrompt
rem We have Python but let's check if it's in the PATH
:HASPYTHON
IF NOT "!output_on_screen!"=="False" (
@echo %version% Python is found, checking PATH variable
)
rem Check Python install path
set install_path=
for /f "tokens=2,*" %%a in ('reg query "hklm\SOFTWARE\%python_registry%Python\PythonCore\%version%\InstallPath"') do (
set install_path=%%b
)
set test=%install_path:~0,-1%
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to local PATH))
set test=%install_path%Scripts
call %running_directory%inPath test && (IF NOT "!output_on_screen!"=="False" (@echo %test% is already in PATH)) || (call %running_directory%addPath test & setx>nul PATH "%PATH%;%test%" & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to local PATH))
GOTO PIP_CHECK
rem Check whether PIP is installed or not
:PIP_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Checking if PIP is installed
)
IF EXIST %install_path%Scripts/PIP.exe GOTO PIP_VERSION_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo No PIP found, commencing PIP install
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%get-pip.py
) else (
call python %running_directory%get-pip.py >nul 2>&1
)
rem Try to update the PIP
:PIP_VERSION_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo PIP is found
@echo Checking whether the latest PIP is installed
)
IF NOT "!output_on_screen!"=="False" (
call python -m pip install --upgrade pip
) else (
call python -m pip install --upgrade pip >nul 2>&1
)
IF "%install_selenium%"=="False" (
SET "pip_program=winshell"
) else (
SET "pip_program=selenium"
)
GOTO PIP_PACKAGE_CHECK
rem Check if the PIP package is installed or not
:PIP_PACKAGE_CHECK
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Check whether !pip_program! is installed
)
for /f "tokens=1,2 delims===" %%a in ('call python -m pip freeze') do (
if "%%a"=="!pip_program!" (
IF NOT "!output_on_screen!"=="False" (
@echo %%b !pip_program! is found
)
rem pywin32 cannot be installed or updated via pip
if "!pip_program!"=="pywin32" goto CHECK_PACKAGE_LIST
GOTO PIP_PACKAGE_UPDATE
)
)
IF NOT "!output_on_screen!"=="False" (
@echo No !pip_program! version is found, commencing install
)
GOTO PIP_PACKAGE_INSTALL
rem Try to install the PIP package via PIP
:PIP_PACKAGE_INSTALL
IF NOT "!output_on_screen!"=="False" (
@echo Installing !pip_program!
)
if "!pip_program!"=="pywin32" (
call python %running_directory%pywin_installer.py
) else (
IF NOT "!output_on_screen!"=="False" (
call python -m pip install !pip_program!
) else (
call python -m pip install !pip_program! >nul 2>&1
)
)
goto CHECK_PACKAGE_LIST
rem Try to update Selenium
:PIP_PACKAGE_UPDATE
IF NOT "!output_on_screen!"=="False" (
@echo Trying to update !pip_program!
call python -m pip install --upgrade !pip_program!
) else (
call python -m pip install --upgrade !pip_program! >nul 2>&1
)
goto CHECK_PACKAGE_LIST
:CHECK_PACKAGE_LIST
if "!pip_program!"=="selenium" (
set "pip_program=winshell"
goto PIP_PACKAGE_CHECK
)
if "!pip_program!"=="winshell" (
set "pip_program=pywin32"
goto PIP_PACKAGE_CHECK
)
if NOT "%install_selenium%"=="False" (
goto CHECK_BROWSER
) else (
goto FIN
)
rem Get installed browsers
:CHECK_BROWSER
set browserToUse=None
IF NOT "!output_on_screen!"=="False" (
@echo.
@echo Checking installed browsers
)
rem For 64 bit systems
START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Clients\StartMenuInternet
rem For 32 bit systems
if not exist "%Temp%\BROW3.reg" START /W REGEDIT /E "%Temp%\BROW3.reg" HKEY_LOCAL_MACHINE\SOFTWARE\Clients\StartMenuInternet
set count=1
for /f "tokens=*" %%B in ('type "%Temp%\BROW3.reg" ^| findstr /E "DefaultIcon]"') do (
rem Extracting browser name from icon path
set "browser=%%B"
rem Removing \DefaultIcon] string
set "browser=!browser:\DefaultIcon]=!"
rem Get the browser name
for %%P in ("!browser!") do (
call :SUB_PRINTBROWSER %%~nP
)
)
GOTO CHECK_BROWSER_TO_USE
rem Subroutine to print installed browsers
:SUB_PRINTBROWSER
set subBrowser=%*
CALL :UCase subBrowser upperBrowser
if "%upperBrowser%"=="FIREFOX" (
IF NOT "!output_on_screen!"=="False" (
@echo !count!. %upperBrowser% ^(Recommended^) ^- will be used
)
if NOT "%install_selenium%"=="False" (
SET "browserToUse=firefox"
)
) else (
IF NOT "!output_on_screen!"=="False" (
@echo !count!. %upperBrowser%
)
)
set /a count+=1
GOTO END
rem Determine which Selenium driver to use
:CHECK_BROWSER_TO_USE
if "!browserToUse!"=="None" (
IF NOT "!output_on_screen!"=="False" (
@echo Decide whitch browser to use
@echo Checking which one is the Default browser
)
START /W REGEDIT /E "%Temp%\BROW5.reg" HKEY_CLASSES_ROOT\http\shell\open\command
for /f tokens^=3^ delims^=^" %%B in ('type "%Temp%\BROW5.reg" ^| find "@"') do (
set "default=%%B"
rem removing double slashes
set "default=!default:\\=\!"
rem removing end slash
set "default=!default:~0,-1!"
rem get the name
for %%D in ("!default!") do (
call :SUB_DEFAULTBROWSER %%~nD
)
)
del /Q /F "%Temp%\BROW5.reg"
)
) else (
rem Registry location depends of the architecture
if "!architecture!"=="64" (
set "browser_architect=Wow6432Node\"
set "architecture_name=x64"
) else (
if "!architecture!"=="32" (
set "browser_architect="
set "architecture_name=x86"
) else (
GOTO ERR
)
)
rem Registry names for the different browsers out there
if "!browserToUse!"=="firefox" (
set "browser_path_name=FIREFOX.EXE"
set "selenium_driver_name="
)
if "!browserToUse!"=="chrome" (
set "browser_path_name=Google Chrome"
set "selenium_driver_name=chromedriver.exe"
)
if "!browserToUse!"=="iexplore" (
set "browser_path_name=IEXPLORE.EXE"
set "selenium_driver_name=IEDriverServer.exe"
)
rem Opera have to versions (in the registry) Opera and OperaStable, we try to Stable first
if "!browserToUse!"=="opera" (
set "browser_path_name=OperaStable"
set "selenium_driver_name="
)
set "browser_path="
IF NOT "!output_on_screen!"=="False" (
@echo Check if !browserToUse!.exe is in PATH
)
:get_browser_path
set browser_path=
set query="hklm\SOFTWARE\%browser_architect%Clients\StartMenuInternet\%browser_path_name%\shell\open\command"
reg>nul query %query% 2>nul
if ERRORLEVEL 1 (
if "%browser_path%"=="" (
if "%browser_architect%"=="" (
rem If the Stable failed check out the simple Opera
if "%browser_path_name%"=="OperaStable" (
SET "browser_path_name=Opera"
SET "browser_architect=Wow6432Node\"
goto get_browser_path
)
IF NOT "!output_on_screen!"=="False" (
@echo Location not found^^! Please add !browserToUse!.exe to PATH manually
pause
)
goto install_driver
) else (
set "browser_architect="
goto get_browser_path
)
)
)
rem Get the installation path for the selected browser
for /f "tokens=2,*" %%a in ('reg query %query%') do (
set browser_path=%%b
)
set browser_path=%browser_path:"=%
call :Split "%browser_path%" test
set myTest=!test:~0,-1!
rem Set that path in the PATH environment variable
call %running_directory%inPath myTest && (IF NOT "!output_on_screen!"=="False" ( @echo !myTest! is already in PATH)) || (call %running_directory%addPath myTest & setx>nul PATH "%PATH%;!myTest!" & IF NOT "!output_on_screen!"=="False" ( @echo !myTest! set to local PATH) )
:install_driver
IF NOT "%install_selenium%"=="False" (
if NOT "!selenium_driver_name!"=="" (
@echo Installing the !browserToUse! Selenium driver
xcopy>nul "%running_directory%%architecture_name%^\%selenium_driver_name%" "!install_location!\" /y
if ERRORLEVEL 0 (
IF NOT "!output_on_screen!"=="False" (
@echo Done
)
) else (
IF NOT "!output_on_screen!"=="False" (
@echo Error^^! Please copy the ^'chromedriver.exe^' to ^'!install_location!^\^' manually
)
)
)
rem For the Opera we need to install the selenium standalone jar
if "!browserToUse!"=="opera" (
SET "standalone_version=selenium-server-standalone-2.42.2.jar"
IF NOT "!output_on_screen!"=="False" (
@echo Installing the Selenium server stand alone JAR
)
xcopy>nul "%running_directory%!standalone_version!" "!install_location!\"
if ERRORLEVEL 0 (
IF NOT "!output_on_screen!"=="False" (
@echo Done
)
rem And set it in the SELENIUM_SERVER_JAR environment variable
IF NOT "!output_on_screen!"=="False" (
@echo Setting the SELENIUM_SERVER_JAR environment variable
)
setx>nul SELENIUM_SERVER_JAR "!install_location!^\!standalone_version!"
IF NOT "!output_on_screen!"=="False" (
@echo local SELENIUM_SERVER_JAR set to ^'!install_location!^\!standalone_version!^'
)
) else (
IF NOT "!output_on_screen!"=="False" (
@echo Error^^! Please copy the ^'%standalone_version%^' to ^'!test!^' manually
)
)
)
)
GOTO FIN
)
GOTO ERR
rem Finish up the install
:FIN
rem Create folder if needed and set it to PATH
IF NOT "!output_on_screen!"=="False" (
@echo Checking wheter ^'%install_location%^\^' exists already
)
call %running_directory%inPath install_location && (IF NOT "!output_on_screen!"=="False" ( @echo !install_location! is already in PATH)) || (call %running_directory%addPath install_location & setx>nul PATH "%PATH%;!install_location!" & IF NOT "!output_on_screen!"=="False" ( @echo !install_location! set to local PATH))
if not exist "%install_location%\" (
mkdir "%install_location%"
)
if not exist "%install_location%\.rdp\" (
mkdir "%install_location%\.rdp"
)
rem Copy the files to the folder
IF NOT "!output_on_screen!"=="False" (
@echo Copying files to ^'%install_location%^'
)
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%nxkey.py" "%install_location%\" /y
xcopy>nul "%running_directory%OrderedDict.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud.ico" "%install_location%\" /y
xcopy>nul "%running_directory%putty.exe" "%install_location%\" /y
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo.
)
IF "%install_selenium%"=="False" (
SET "create_url_icon= -u"
) else (
SET "create_url_icon="
)
IF NOT "!output_on_screen!"=="False" (
@echo Starting the python installation script
)
if NOT "!browserToUse!"=="" (
SET "selenium_driver= -d !browserToUse!"
)
IF NOT "!output_on_screen!"=="False" (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website!
) else (
call python %running_directory%win_install.py!selenium_driver! ^-l "%install_location%\\"!create_url_icon!!website! >nul 2>&1
)
IF NOT "!output_on_screen!"=="False" (
@echo Done
@echo Installation complete
@echo Press any key to close this installer
pause
)
GOTO END
rem Subroutine to decide which Selenium driver to use
:SUB_DEFAULTBROWSER
set defBrowser=%*
CALL :LCase defBrowser lowerFound
if "%lowerFound%"=="launcher" (
set "lowerFound=opera"
)
IF NOT "!output_on_screen!"=="False" (
@echo %lowerFound% is the default browser
)
set browserToUse=%lowerFound%
GOTO END
:LCase
:UCase
:: Converts to upper/lower case variable contents
:: Syntax: CALL :UCase _VAR1 _VAR2
:: Syntax: CALL :LCase _VAR1 _VAR2
:: _VAR1 = Variable NAME whose VALUE is to be converted to upper/lower case
:: _VAR2 = NAME of variable to hold the converted value
:: Note: Use variable NAMES in the CALL, not values (pass "by reference")
SET _UCase=A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
SET _LCase=a b c d e f g h i j k l m n o p q r s t u v w x y z
SET _Lib_UCase_Tmp=!%1!
IF /I "%0"==":UCase" SET _Abet=%_UCase%
IF /I "%0"==":LCase" SET _Abet=%_LCase%
FOR %%Z IN (%_Abet%) DO SET _Lib_UCase_Tmp=!_Lib_UCase_Tmp:%%Z=%%Z!
SET %2=%_Lib_UCase_Tmp%
GOTO END
rem Subroutine to get the exact path out from a file location, but strip the file name
:Split
SET %2=%~dp1
GOTO END
:END
\ No newline at end of file
[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>
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates.
try:
from thread import get_ident as _get_ident
except ImportError:
from dummy_thread import get_ident as _get_ident
try:
from _abcoll import KeysView, ValuesView, ItemsView
except ImportError:
pass
class OrderedDict(dict):
'Dictionary that remembers insertion order'
# An inherited dict maps keys to values.
# The inherited dict provides __getitem__, __len__, __contains__, and get.
# The remaining methods are order-aware.
# Big-O running times for all methods are the same as for regular dictionaries.
# The internal self.__map dictionary maps keys to links in a doubly linked list.
# The circular doubly linked list starts and ends with a sentinel element.
# The sentinel element never gets deleted (this simplifies the algorithm).
# Each link is stored as a list of length three: [PREV, NEXT, KEY].
def __init__(self, *args, **kwds):
'''Initialize an ordered dictionary. Signature is the same as for
regular dictionaries, but keyword arguments are not recommended
because their insertion order is arbitrary.
'''
if len(args) > 1:
raise TypeError('expected at most 1 arguments, got %d' % len(args))
try:
self.__root
except AttributeError:
self.__root = root = [] # sentinel node
root[:] = [root, root, None]
self.__map = {}
self.__update(*args, **kwds)
def __setitem__(self, key, value, dict_setitem=dict.__setitem__):
'od.__setitem__(i, y) <==> od[i]=y'
# Setting a new item creates a new link which goes at the end of the linked
# list, and the inherited dictionary is updated with the new key/value pair.
if key not in self:
root = self.__root
last = root[0]
last[1] = root[0] = self.__map[key] = [last, root, key]
dict_setitem(self, key, value)
def __delitem__(self, key, dict_delitem=dict.__delitem__):
'od.__delitem__(y) <==> del od[y]'
# Deleting an existing item uses self.__map to find the link which is
# then removed by updating the links in the predecessor and successor nodes.
dict_delitem(self, key)
link_prev, link_next, key = self.__map.pop(key)
link_prev[1] = link_next
link_next[0] = link_prev
def __iter__(self):
'od.__iter__() <==> iter(od)'
root = self.__root
curr = root[1]
while curr is not root:
yield curr[2]
curr = curr[1]
def __reversed__(self):
'od.__reversed__() <==> reversed(od)'
root = self.__root
curr = root[0]
while curr is not root:
yield curr[2]
curr = curr[0]
def clear(self):
'od.clear() -> None. Remove all items from od.'
try:
for node in self.__map.itervalues():
del node[:]
root = self.__root
root[:] = [root, root, None]
self.__map.clear()
except AttributeError:
pass
dict.clear(self)
def popitem(self, last=True):
'''od.popitem() -> (k, v), return and remove a (key, value) pair.
Pairs are returned in LIFO order if last is true or FIFO order if false.
'''
if not self:
raise KeyError('dictionary is empty')
root = self.__root
if last:
link = root[0]
link_prev = link[0]
link_prev[1] = root
root[0] = link_prev
else:
link = root[1]
link_next = link[1]
root[1] = link_next
link_next[0] = root
key = link[2]
del self.__map[key]
value = dict.pop(self, key)
return key, value
# -- the following methods do not depend on the internal structure --
def keys(self):
'od.keys() -> list of keys in od'
return list(self)
def values(self):
'od.values() -> list of values in od'
return [self[key] for key in self]
def items(self):
'od.items() -> list of (key, value) pairs in od'
return [(key, self[key]) for key in self]
def iterkeys(self):
'od.iterkeys() -> an iterator over the keys in od'
return iter(self)
def itervalues(self):
'od.itervalues -> an iterator over the values in od'
for k in self:
yield self[k]
def iteritems(self):
'od.iteritems -> an iterator over the (key, value) items in od'
for k in self:
yield (k, self[k])
def update(*args, **kwds):
'''od.update(E, **F) -> None. Update od from dict/iterable E and F.
If E is a dict instance, does: for k in E: od[k] = E[k]
If E has a .keys() method, does: for k in E.keys(): od[k] = E[k]
Or if E is an iterable of items, does: for k, v in E: od[k] = v
In either case, this is followed by: for k, v in F.items(): od[k] = v
'''
if len(args) > 2:
raise TypeError('update() takes at most 2 positional '
'arguments (%d given)' % (len(args),))
elif not args:
raise TypeError('update() takes at least 1 argument (0 given)')
self = args[0]
# Make progressively weaker assumptions about "other"
other = ()
if len(args) == 2:
other = args[1]
if isinstance(other, dict):
for key in other:
self[key] = other[key]
elif hasattr(other, 'keys'):
for key in other.keys():
self[key] = other[key]
else:
for key, value in other:
self[key] = value
for key, value in kwds.items():
self[key] = value
__update = update # let subclasses override update without breaking __init__
__marker = object()
def pop(self, key, default=__marker):
'''od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
If key is not found, d is returned if given, otherwise KeyError is raised.
'''
if key in self:
result = self[key]
del self[key]
return result
if default is self.__marker:
raise KeyError(key)
return default
def setdefault(self, key, default=None):
'od.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od'
if key in self:
return self[key]
self[key] = default
return default
def __repr__(self, _repr_running={}):
'od.__repr__() <==> repr(od)'
call_key = id(self), _get_ident()
if call_key in _repr_running:
return '...'
_repr_running[call_key] = 1
try:
if not self:
return '%s()' % (self.__class__.__name__,)
return '%s(%r)' % (self.__class__.__name__, self.items())
finally:
del _repr_running[call_key]
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
inst_dict = vars(self).copy()
for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict:
return (self.__class__, (items,), inst_dict)
return self.__class__, (items,)
def copy(self):
'od.copy() -> a shallow copy of od'
return self.__class__(self)
@classmethod
def fromkeys(cls, iterable, value=None):
'''OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
and values equal to v (which defaults to None).
'''
d = cls()
for key in iterable:
d[key] = value
return d
def __eq__(self, other):
'''od.__eq__(y) <==> od==y. Comparison to another OD is order-sensitive
while comparison to a regular mapping is order-insensitive.
'''
if isinstance(other, OrderedDict):
return len(self)==len(other) and self.items() == other.items()
return dict.__eq__(self, other)
def __ne__(self, other):
return not self == other
# -- the following methods are only used in Python 2.7 --
def viewkeys(self):
"od.viewkeys() -> a set-like object providing a view on od's keys"
return KeysView(self)
def viewvalues(self):
"od.viewvalues() -> an object providing a view on od's values"
return ValuesView(self)
def viewitems(self):
"od.viewitems() -> a set-like object providing a view on od's items"
return ItemsView(self)
\ No newline at end of file
......@@ -34,7 +34,7 @@ def pars_arguments():
parser.add_argument("-u", "--username", type=str)
parser.add_argument("-p", "--password", type=str)
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'ie', 'opera', 'safari'], default="firefox")
type=str, choices=['firefox', 'chrome', 'ie', 'opera'], default="firefox")
parser.add_argument("-o", "--old", help="Use old interface", action="store_true")
args = parser.parse_args();
return args
......@@ -54,8 +54,6 @@ class Browser:
self.driver = webdriver.Ie()
elif args.driver == "opera":
self.driver = webdriver.Opera()
elif args.driver == "safari":
self.driver = webdriver.Safari()
self.driver.implicitly_wait(10)
##
......@@ -96,6 +94,7 @@ class Browser:
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
##
......@@ -127,6 +126,7 @@ class Browser:
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
##
......@@ -138,25 +138,30 @@ class Browser:
# kapcsolódunk a klienshez
def main():
args = pars_arguments()
if args.uri is not None:
vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
if args.old:
vm = browser.old_main()
else:
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
try:
args = pars_arguments()
if args.uri is not None:
vm = Struct()
vm.protocol, vm.user, vm.password, vm.host, vm.port = args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
browser = Browser(args)
try:
if args.old:
vm = browser.old_main()
else:
vm = browser.main()
browser.driver.quit()
except:
raise
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
from cloud_connect_from_windows import connect
if vm.state.upper()[:3] in ("FUT", "RUN"):
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
......@@ -4,6 +4,7 @@
# Távoli klienshez csatlakozás windows OS alól
##
import sys, os, time, subprocess, glob, nxkey, win32crypt, binascii
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
......@@ -14,6 +15,65 @@
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
pass
if vm.protocol == "SSH":
arguments = "-ssh -P %s -pw %s %s@%s" % (vm.port, vm.password, vm.user, vm.host)
subprocess.Popen("putty.exe "+arguments, shell = True)
elif vm.protocol == "NX":
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False
server = "\"Server host\" value=\"%s\"" % vm.host
port = "\"Server port\" value=\"%s\"" % vm.port
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if server in file and port in file:
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"), str(int(time.time()*1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted()
config = NX_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
elif vm.protocol == "RDP":
listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp"
found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir):
with open(config_file) as f:
file = f.read()
if full_address in file and user in file:
found = True
break
if not found:
config_file = "%s%s%s" % (os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\", str(int(time.time()*1000)), ".rdp")
password = binascii.hexlify(win32crypt.CryptProtectData(u"%s" % vm.password,u'psw',None,None,None,0))
config = RPD_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port}
f = open(config_file, 'w')
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
<option key="Remember password" value="true" />
<option key="Resolution" value="fullscreen" />
<option key="Server host" value="%(HOST)s" />
<option key="Server port" value="%(PORT)s" />
<option key="Session" value="unix" />
</group>
<group name="Login" >
<option key="Auth" value="%(PASSWORD)s" />
<option key="Guest Mode" value="false" />
<option key="Login Method" value="nx" />
<option key="User" value="%(USERNAME)s" />
</group>
</NXClientSettings>"""
RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s
password 51:b:%(PASSWORD)s"""
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Generating NoMachine NX scrambled key according to https://www.nomachine.com/AR01C00125
##
import sys
import random
import re
from xml.sax.saxutils import escape
##
# NXKeyGen class
# Creates NoMachine NX scrambled keys
#
class NXKeyGen:
numValidCharList = 85
dummyString = "{{{{"
##
# Initialize the class
# @param password Password that will be scrambled
#
def __init__(self, password):
self.password = password
##
# Encrypt (scramble) the given password
# @return scrambleString Scrambled version of the original password
#
def getEncrypted(self):
return self.scrambleString(self.password)
##
# Valid character list
# @return validcharlist List of the valid characters
#
def getvalidCharList(self, pos):
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}"
]
return validcharlist[pos]
##
# Password encoder
# @return sPass Encoded password
#
def encodePassword(self, p):
sPass = ":"
sTmp = ""
if not p:
return ""
for i in range(len(p)):
c = p[i:i+1]
a = ord(c)
sTmp = str( a + i + 1) + ":"
sPass += sTmp
sTmp = ""
return sPass
##
# Character position finder
# @param c Character that needs to be matched if valid
# @return i Place where the character is in the valid list
#
def findCharInList(self, c):
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j);
if randchar == c:
i = j
return i
return i
##
# Random valid character getter
# @return char Valid character placed 0-60 in the valid list
#
def getRandomValidCharFromList(self):
return self.getvalidCharList(random.randint(0,60))
##
# Password scrambler
# @param s Password that needs to be scrambled
# @return sRet NoMachine NX scrambled password
#
def scrambleString(self, s):
sRet = ""
if not s:
return s
strp = self.encodePassword(s)
if len(strp) < 32:
sRet += self.dummyString
for iR in reversed(range(len(strp))):
sRet += strp[iR:iR+1]
if len(sRet) < 32:
sRet += self.dummyString
app = self.getRandomValidCharFromList()
k = ord(app)
l = k + len(sRet) - 2
sRet = app + sRet
for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1]
j = self.findCharInList(app2)
if j == -1:
return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList
car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet,car,i1,1)
c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c)
sRet = sRet + c2
return escape(sRet)
##
# Replace a character at a special position
#
def substr_replace(self,in_str,ch,pos,qt):
clist = list(in_str)
count = 0;
tmp_str = '';
for key in clist:
if count != pos:
tmp_str += key
else:
tmp_str += ch
count = count+1
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
print NXPass.getEncrypted()
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Pywin32 installer for CIRCLE client application
##
import os, sys, subprocess
from nx_client_installer import DecideArchitecture
##
# Main program
# Install Pywin32 to the computer
#
def main():
if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\no_root_install.bat")
sys.exit(1)
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if DecideArchitecture.Is64Windows():
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x64\\pywin32-"+pywin32_version+".win-amd64-py2.6.exe").wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.6.exe").wait()
elif sys.hexversion < 0x02080000:
if DecideArchitecture.Is64Windows():
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x64\\pywin32-"+pywin32_version+".win-amd64-py2.7.exe").wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.7.exe").wait()
else:
print "Unsupported Python version is found!"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/usr/bin/python
# -*- coding: utf-8 -*-
##
# Windows icon installer for CIRCLE client application
##
import os, sys, argparse, subprocess
if sys.hexversion > 0x02070000:
from collections import *
else:
from OrderedDict import *
import pythoncom
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
##
# Argument parser, based on argparse module
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("-d", "--driver", help="Select webdriver. Aside from Firefox, you have to install first the proper driver.", \
type=str, choices=['firefox', 'chrome', 'iexplore', 'opera'], default="firefox", required=False)
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, required=False)
parser.add_argument("-r", "--remove", help="Remove installed files instead of creating them", action="store_true", required=False)
parser.add_argument("-u", "--url", help="Whether we installed and we want to use selenium or not", action="store_true", required=False)
parser.add_argument("-t", "--target", help="If this is an URL icon, where should it point", default="https://pc3.szgt.uni-miskolc.hu/", required=False)
args = parser.parse_args();
return args
##
# Custom protocol register based on RegistryHandler module
# Can raise AttributeError on wrongly provided dictionary chain
# @param dict_chain OrderedDictionary chain of the registry tree
#
def custom_protocol_register(custom_protocol):
if not isinstance(custom_protocol, OrderedDict):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
try:
custom_arguments = Struct()
custom_arguments.registry = "HKCR"
handler = RegistryHandler(custom_arguments)
handler.create_registry_from_dict_chain(custom_protocol, True)
print "\t\tDone!"
except:
raise
##
# Main program
# read the parameters
# create a proper icon with the proper driver
# call the nx_client_installer
def main():
try:
args = pars_arguments()
shortcut = pythoncom.CoCreateInstance (
shell.CLSID_ShellLink,
None,
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove:
location =os.path.join(desktop_path, "Cloud GUI")
if os.path.isfile("%s%s" % (location, ".lnk")):
os.remove("%s%s" % (location, ".lnk"))
if os.path.isfile("%s%s" % (location, ".url")):
os.remove("%s%s" % (location, ".url"))
else:
subprocess.call("python "+os.path.dirname(os.path.realpath(__file__))+"\\nx_client_installer.py")
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
shortcut = file(location, 'w')
shortcut.write('[InternetShortcut]\n')
shortcut.write('URL='+args.target)
shortcut.close()
else:
shortcut.SetPath (args.location+"cloud.py")
if args.driver == "chrome":
shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore":
shortcut.SetArguments("-d ie")
elif args.driver == "opera":
shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface (pythoncom.IID_IPersistFile)
persist_file.Save (os.path.join (desktop_path, "Cloud GUI.lnk"), 0)
print "Icon successfully created on desktop"
print "Creating custom URL protocol handlers"
try:
custom_ssh = OrderedDict([('ssh', "URL:CIRCLE-SSH Protocol"), ('ssh\\URL Protocol', ""),\
('ssh\\DefaultIcon', args.location+"cloud.ico"),\
('ssh\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_ssh)
custom_rdp = OrderedDict([('rdp', "URL:CIRCLE-RDP Protocol"), ('rdp\\URL Protocol', ""),\
('rdp\\DefaultIcon', args.location+"cloud.ico"),\
('rdp\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_rdp)
custom_nx = OrderedDict([('nx', "URL:CIRCLE-NX Protocol"), ('nx\\URL Protocol', ""),\
('nx\\DefaultIcon', args.location+"cloud.ico"),\
('nx\\shell', {'open': {'command': "\"python.exe\" \""+args.location+"cloud.py\" \"%1\""}})])
custom_protocol_register(custom_nx)
except:
print "Error! URL Protocol handler installation aborted!"
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