Commit 9174ec20 by Csók Tamás

client: upgrades in the setup process, plus more logical layout of the code

parent 79e79460
......@@ -162,9 +162,9 @@ IF NOT "!output_on_screen!"=="False" (
goto loop
) else (
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))
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%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to 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))
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%" /m & IF NOT "!output_on_screen!"=="False" ( @echo %test% set to PATH))
)
GOTO PIP_CHECK
......@@ -195,12 +195,11 @@ IF NOT "!output_on_screen!"=="False" (
) else (
call python -m pip install --upgrade pip >nul 2>&1
)
IF "%install_selenium%"=="False" (
SET "pip_program=winshell"
) else (
SET "pip_program=selenium"
SET "pip_program=requirements.txt"
IF NOT "!output_on_screen!"=="False" (
@echo Installing python modules
)
GOTO PIP_PACKAGE_CHECK
GOTO PIP_PACKAGE_INSTALL
rem Check if the PIP package is installed or not
:PIP_PACKAGE_CHECK
......@@ -213,9 +212,7 @@ IF NOT "!output_on_screen!"=="False" (
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
GOTO CHECK_PACKAGE_LIST
)
)
IF NOT "!output_on_screen!"=="False" (
......@@ -223,38 +220,21 @@ IF NOT "!output_on_screen!"=="False" (
)
GOTO PIP_PACKAGE_INSTALL
rem Try to install the PIP package via PIP
rem Try to install the PIP packages 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!
call python -m pip install -r requirements.txt
) else (
call python -m pip install !pip_program! >nul 2>&1
call python -m pip install -r requirements.txt >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" (
if "!pip_program!"=="requirements.txt" (
set "pip_program=pywin32"
goto PIP_PACKAGE_CHECK
)
......@@ -395,7 +375,7 @@ 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 && (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) )
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!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !myTest! set to PATH) )
:install_driver
IF NOT "%install_selenium%"=="False" (
if NOT "!selenium_driver_name!"=="" (
......@@ -448,7 +428,7 @@ 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))
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!" /m & IF NOT "!output_on_screen!"=="False" ( @echo !install_location! set to PATH))
if not exist "%install_location%\" (
mkdir "%install_location%"
)
......@@ -462,7 +442,7 @@ IF NOT "!output_on_screen!"=="False" (
xcopy>nul "%running_directory%cloud.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud_connect_from_windows.py" "%install_location%\" /y
xcopy>nul "%running_directory%win_install.py" "%install_location%\" /y
xcopy>nul "%running_directory%nx_client_installer.py" "%install_location%\" /y
xcopy>nul "%running_directory%windowsclasses.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
......
......@@ -2,6 +2,9 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
#define MyAppName "CIRCLE Client"
#define MyAppProgramInfo "Visit the CIRCLE"
#define MyAppProgram "Cloud GUI.url"
#define MyAppDir "{userappdata}\CIRCLE"
#define MyAppVersion "1.0"
#define MyAppPublisher "BME IK, IIT, VIK"
#define MyAppURL "http://cloud.bme.hu/"
......@@ -79,4 +82,5 @@ Filename: "{app}\uninstall.bat"; Parameters: "True"; Flags: waituntilterminated
[Icons]
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{group}\{#MyAppProgramInfo}"; Filename: "{#MyAppDir}\{#MyAppProgram}"; IconFilename: "{#MyAppDir}\cloud.ico"
......@@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
"""
A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő
program
Main program of the Client written for CIRCLE Cloud.
The Client job is to help the ease of use of the cloud system.
"""
import platform
......@@ -21,22 +21,22 @@ except ImporError:
class Struct:
"""
Paraméterek átadására használt struktúra
A struct used for parameter passing
Keyword arguments:
state -- A virtuális gép állapota, azt figyeljük, hogy fut-e
protocol -- SSH, NX és RDP lehetséges
host -- A virtuális gép címe
port -- Ezen a porton csatlakozunk a virtuális géphez
user -- Csatlakozáshoz használt név
password -- Csatlakozáshoz használt jelszó
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH, NX and RDP possible
host -- Address of the Virtual Computer
port -- The port where we can access the Virtual Computer
user -- Username used for the connection
password -- Password used for the connection
"""
pass
def parse_arguments():
"""
Argument parser, argparse modulon alapszik
Argument parser, based on the argparse module
Keyword arguments:
@return args -- arguments given by console
......@@ -53,18 +53,16 @@ def parse_arguments():
"first the proper driver.", 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
class Browser:
"""
Browser inicializálás
Browser initialisation
Keyword arguments:
@param args -- Az args.driver paraméterrel meghatározhatjuk,
melyik böngészőt akarjuk használni.
@param args -- args.driver tells us which installed browser
we want to use with selenium.
"""
def __init__(self, args):
self.args = args
......@@ -80,8 +78,7 @@ class Browser:
def login(self):
"""
Címtáras beléptetés a parancssorban megadott paraméterek
alapján
Eduid login based on the given console arguments
"""
driver = self.driver
args = self.args
......@@ -95,59 +92,21 @@ class Browser:
driver.find_element_by_css_selector(
"input[type='submit']").click()
def old_main(self):
"""
A régi webes felület használata
Keyword arguments:
@return vm -- Virtuális gép csatlakozásához szükséges
paraméterek
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://cloud.ik.bme.hu/info/")
driver.find_element_by_css_selector("a[href*='/login/']").click()
self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver, 7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"input.hidden-password.shown[type='text']")))
vm.password = element.get_attribute("value")
vm.state = driver.find_element_by_css_selector(
"#state > div > p").text
vm.protocol = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(1) > td").text
vm.host,vm.port = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(2) > td").text.split(':')
vm.user = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(4) > td").text
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
def main(self):
"""
Az új webes felület használata
Use of the https://cloud.bme.hu/
Keyword arguments:
@return vm -- Virtuális gép csatlakozásához szükséges
paraméterek
@return vm -- Necessarily parameters to connect
to the Virtual Machine
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://pc3.szgt.uni-miskolc.hu/")
#driver.find_element_by_css_selector("a[href*='/login/']").click()
#self.login()
driver.get("https://cloud.bme.hu/")
# driver.find_element_by_css_selector("a[href*='/login/']").click()
# self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
......@@ -157,7 +116,7 @@ class Browser:
"#vm-details-pw-eye.fa.fa-eye-slash")))
vm.state = driver.find_element_by_css_selector(
"#vm-details-state > span").text
#cl: connection string converted to list
# cl: connection string converted to list
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
......@@ -177,14 +136,7 @@ class Browser:
def main():
"""
Főprogram
Job:
beolvassuk a paramétereket
megnyitjuk a kiválasztott böngészőben a weboldalt
bejelentkezünk a címtárba
kiválasztjuk a futtatni kívánt klienst
kapcsolódunk a klienshez
Main program
"""
try:
args = parse_arguments()
......@@ -196,14 +148,8 @@ def main():
vm.state = "RUN"
else:
browser = Browser(args)
try:
if args.old:
vm = browser.old_main()
else:
vm = browser.main()
browser.driver.quit()
except:
raise
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
......@@ -212,7 +158,7 @@ def main():
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás windows OS alól
##
"""
Configuration of the Windows specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs.
"""
import time
import os
......@@ -12,16 +15,19 @@ import win32crypt
import binascii
import nxkey
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH, NX and RDP possible
vm.host -- Address of the Virtual Computer
vm.port -- The port where we can access the Virtual Computer
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
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)
......@@ -63,7 +69,8 @@ def connect(vm):
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
......
......@@ -195,12 +195,11 @@ IF NOT "!output_on_screen!"=="False" (
) else (
call python -m pip install --upgrade pip >nul 2>&1
)
IF "%install_selenium%"=="False" (
SET "pip_program=winshell"
) else (
SET "pip_program=selenium"
SET "pip_program=requirements.txt"
IF NOT "!output_on_screen!"=="False" (
@echo Installing python modules
)
GOTO PIP_PACKAGE_CHECK
GOTO PIP_PACKAGE_INSTALL
rem Check if the PIP package is installed or not
:PIP_PACKAGE_CHECK
......@@ -213,9 +212,7 @@ IF NOT "!output_on_screen!"=="False" (
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
GOTO CHECK_PACKAGE_LIST
)
)
IF NOT "!output_on_screen!"=="False" (
......@@ -223,38 +220,21 @@ IF NOT "!output_on_screen!"=="False" (
)
GOTO PIP_PACKAGE_INSTALL
rem Try to install the PIP package via PIP
rem Try to install the PIP packages 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!
call python -m pip install -r requirements.txt
) else (
call python -m pip install !pip_program! >nul 2>&1
call python -m pip install -r requirements.txt >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" (
if "!pip_program!"=="requirements.txt" (
set "pip_program=pywin32"
goto PIP_PACKAGE_CHECK
)
......@@ -462,7 +442,7 @@ IF NOT "!output_on_screen!"=="False" (
xcopy>nul "%running_directory%cloud.py" "%install_location%\" /y
xcopy>nul "%running_directory%cloud_connect_from_windows.py" "%install_location%\" /y
xcopy>nul "%running_directory%win_install.py" "%install_location%\" /y
xcopy>nul "%running_directory%nx_client_installer.py" "%install_location%\" /y
xcopy>nul "%running_directory%windowsclasses.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
......
......@@ -8,7 +8,7 @@ Pywin32 installer for CIRCLE client application
import os
import sys
import subprocess
from nx_client_installer import DecideArchitecture
import windowsclasses
def main():
......@@ -27,7 +27,7 @@ def main():
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if DecideArchitecture.Is64Windows():
if windowsclasses.DecideArchitecture.Is64Windows():
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
......@@ -38,7 +38,7 @@ def main():
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
elif sys.hexversion < 0x02080000:
if DecideArchitecture.Is64Windows():
if windowsclasses.DecideArchitecture.Is64Windows():
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
......
winshell==0.6
\ No newline at end of file
......@@ -9,11 +9,12 @@ import os
import argparse
import subprocess
import pythoncom
import shutil
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
import windowsclasses
try:
from collections import *
except ImporError:
except ImportError:
from OrderedDict import *
......@@ -32,10 +33,12 @@ def parse_arguments():
"first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome',
'iexplore', 'opera'])
if DecideArchitecture.Is64Windows():
local_default = DecideArchitecture.GetProgramFiles64()+"\\CIRCLE\\"
if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\")
else:
local_default = DecideArchitecture.GetProgramFiles32()+"\\CIRCLE\\"
local_default = (windowsclasses.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\\"
......@@ -53,7 +56,7 @@ def parse_arguments():
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)
default="https://cloud.bme.hu/", required=False)
args = parser.parse_args()
return args
......@@ -69,9 +72,9 @@ def custom_protocol_register(custom_protocol):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
try:
custom_arguments = Struct()
custom_arguments = windowsclasses.Struct()
custom_arguments.registry = "HKCR"
handler = RegistryHandler(custom_arguments)
handler = windowsclasses.RegistryHandler(custom_arguments)
handler.create_registry_from_dict_chain(custom_protocol, True)
print "\t\tDone!"
except:
......@@ -79,14 +82,14 @@ def custom_protocol_register(custom_protocol):
def main():
"""
Main program
"""
Main program
Jobs:
read the parameters
create a proper icon with the proper driver (or delete)
call the nx_client_installer
"""
Jobs:
read the parameters
create a proper icon with the proper driver (or delete)
call the nx_client_installer
"""
try:
args = parse_arguments()
shortcut = pythoncom.CoCreateInstance (
......@@ -95,9 +98,10 @@ def main():
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
desktop_path = shell.SHGetFolderPath (
0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove:
location =os.path.join(desktop_path, "Cloud GUI")
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")):
......@@ -126,9 +130,10 @@ def main():
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)
location = os.path.join(desktop_path, "Cloud GUI.lnk")
persist_file.Save(location, 0)
print "Icon successfully created on desktop"
shutil.copy(location, args.location)
print "Creating custom URL protocol handlers"
try:
custom_ssh = OrderedDict(
......
......@@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
"""
A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő
program
Main program of the Client written for CIRCLE Cloud.
The Client job is to help the ease of use of the cloud system.
"""
import platform
......@@ -21,22 +21,22 @@ except ImporError:
class Struct:
"""
Paraméterek átadására használt struktúra
A struct used for parameter passing
Keyword arguments:
state -- A virtuális gép állapota, azt figyeljük, hogy fut-e
protocol -- SSH, NX és RDP lehetséges
host -- A virtuális gép címe
port -- Ezen a porton csatlakozunk a virtuális géphez
user -- Csatlakozáshoz használt név
password -- Csatlakozáshoz használt jelszó
state -- State of the Virtual Computer (running, etc..)
protocol -- SSH, NX and RDP possible
host -- Address of the Virtual Computer
port -- The port where we can access the Virtual Computer
user -- Username used for the connection
password -- Password used for the connection
"""
pass
def parse_arguments():
"""
Argument parser, argparse modulon alapszik
Argument parser, based on the argparse module
Keyword arguments:
@return args -- arguments given by console
......@@ -53,18 +53,16 @@ def parse_arguments():
"first the proper driver.", 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
class Browser:
"""
Browser inicializálás
Browser initialisation
Keyword arguments:
@param args -- Az args.driver paraméterrel meghatározhatjuk,
melyik böngészőt akarjuk használni.
@param args -- args.driver tells us which installed browser
we want to use with selenium.
"""
def __init__(self, args):
self.args = args
......@@ -80,8 +78,7 @@ class Browser:
def login(self):
"""
Címtáras beléptetés a parancssorban megadott paraméterek
alapján
Eduid login based on the given console arguments
"""
driver = self.driver
args = self.args
......@@ -95,59 +92,21 @@ class Browser:
driver.find_element_by_css_selector(
"input[type='submit']").click()
def old_main(self):
"""
A régi webes felület használata
Keyword arguments:
@return vm -- Virtuális gép csatlakozásához szükséges
paraméterek
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://cloud.ik.bme.hu/info/")
driver.find_element_by_css_selector("a[href*='/login/']").click()
self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
element = WebDriverWait(driver, 7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"input.hidden-password.shown[type='text']")))
vm.password = element.get_attribute("value")
vm.state = driver.find_element_by_css_selector(
"#state > div > p").text
vm.protocol = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(1) > td").text
vm.host,vm.port = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(2) > td").text.split(':')
vm.user = driver.find_element_by_css_selector(
"#vm-credentials > div > table > tbody > "+
"tr:nth-child(4) > td").text
driver.find_element_by_css_selector("a[href*='/logout/']").click()
except:
print "Browser session timed out!"
raise
return vm
def main(self):
"""
Az új webes felület használata
Use of the https://cloud.bme.hu/
Keyword arguments:
@return vm -- Virtuális gép csatlakozásához szükséges
paraméterek
@return vm -- Necessarily parameters to connect
to the Virtual Machine
"""
vm = Struct()
driver = self.driver
driver.maximize_window()
driver.get("https://pc3.szgt.uni-miskolc.hu/")
#driver.find_element_by_css_selector("a[href*='/login/']").click()
#self.login()
driver.get("https://cloud.bme.hu/")
# driver.find_element_by_css_selector("a[href*='/login/']").click()
# self.login()
vm.state, vm.protocol = "", "NONE"
try:
while vm.state.upper()[:3] not in ("FUT", "RUN"):
......@@ -157,7 +116,7 @@ class Browser:
"#vm-details-pw-eye.fa.fa-eye-slash")))
vm.state = driver.find_element_by_css_selector(
"#vm-details-state > span").text
#cl: connection string converted to list
# cl: connection string converted to list
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
......@@ -177,14 +136,7 @@ class Browser:
def main():
"""
Főprogram
Job:
beolvassuk a paramétereket
megnyitjuk a kiválasztott böngészőben a weboldalt
bejelentkezünk a címtárba
kiválasztjuk a futtatni kívánt klienst
kapcsolódunk a klienshez
Main program
"""
try:
args = parse_arguments()
......@@ -196,14 +148,8 @@ def main():
vm.state = "RUN"
else:
browser = Browser(args)
try:
if args.old:
vm = browser.old_main()
else:
vm = browser.main()
browser.driver.quit()
except:
raise
vm = browser.main()
browser.driver.quit()
if platform.system() == "Linux":
from cloud_connect_from_linux import connect
elif platform.system() == "Windows":
......@@ -212,7 +158,7 @@ def main():
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Távoli klienshez csatlakozás windows OS alól
##
"""
Configuration of the Windows specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs.
"""
import time
import os
......@@ -12,16 +15,19 @@ import win32crypt
import binascii
import nxkey
##
# A távoli klienshez csatlakozás valósítja majd meg windows alól
# @param vm Paraméterek a csatlakozáshoz
# vm.protocol SSH, NX és RDP lehetséges
# vm.host A virtuális gép címe
# vm.port Ezen a porton csatlakozunk a virtuális géphez
# vm.user Csatlakozáshoz használt név
# vm.password Csatlakozáshoz használt jelszó
#
def connect(vm):
"""
Handles to connection to the Virtual Machines from the local
machine
Keyword arguments:
vm.protocol -- SSH, NX and RDP possible
vm.host -- Address of the Virtual Computer
vm.port -- The port where we can access the Virtual Computer
vm.user -- Username used for the connection
vm.password -- Password used for the connection
"""
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)
......@@ -63,7 +69,8 @@ def connect(vm):
f.write(config)
f.close()
subprocess.Popen(config_file, shell = True)
NX_template = """<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="General" >
......
......@@ -8,7 +8,7 @@ Pywin32 installer for CIRCLE client application
import os
import sys
import subprocess
from nx_client_installer import DecideArchitecture
import windowsclasses
def main():
......@@ -27,7 +27,7 @@ def main():
else:
pywin32_version = str(219)
if sys.hexversion < 0x02070000:
if DecideArchitecture.Is64Windows():
if windowsclasses.DecideArchitecture.Is64Windows():
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
......@@ -38,7 +38,7 @@ def main():
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
elif sys.hexversion < 0x02080000:
if DecideArchitecture.Is64Windows():
if windowsclasses.DecideArchitecture.Is64Windows():
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
......
......@@ -9,11 +9,12 @@ import os
import argparse
import subprocess
import pythoncom
import shutil
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
import windowsclasses
try:
from collections import *
except ImporError:
except ImportError:
from OrderedDict import *
......@@ -32,10 +33,12 @@ def parse_arguments():
"first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome',
'iexplore', 'opera'])
if DecideArchitecture.Is64Windows():
local_default = DecideArchitecture.GetProgramFiles64()+"\\CIRCLE\\"
if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\")
else:
local_default = DecideArchitecture.GetProgramFiles32()+"\\CIRCLE\\"
local_default = (windowsclasses.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\\"
......@@ -53,7 +56,7 @@ def parse_arguments():
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)
default="https://cloud.bme.hu/", required=False)
args = parser.parse_args()
return args
......@@ -69,9 +72,9 @@ def custom_protocol_register(custom_protocol):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
try:
custom_arguments = Struct()
custom_arguments = windowsclasses.Struct()
custom_arguments.registry = "HKCR"
handler = RegistryHandler(custom_arguments)
handler = windowsclasses.RegistryHandler(custom_arguments)
handler.create_registry_from_dict_chain(custom_protocol, True)
print "\t\tDone!"
except:
......@@ -79,14 +82,14 @@ def custom_protocol_register(custom_protocol):
def main():
"""
Main program
"""
Main program
Jobs:
read the parameters
create a proper icon with the proper driver (or delete)
call the nx_client_installer
"""
Jobs:
read the parameters
create a proper icon with the proper driver (or delete)
call the nx_client_installer
"""
try:
args = parse_arguments()
shortcut = pythoncom.CoCreateInstance (
......@@ -95,9 +98,10 @@ def main():
pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink
)
desktop_path = shell.SHGetFolderPath (0, shellcon.CSIDL_DESKTOP, 0, 0)
desktop_path = shell.SHGetFolderPath (
0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove:
location =os.path.join(desktop_path, "Cloud GUI")
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")):
......@@ -126,9 +130,10 @@ def main():
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)
location = os.path.join(desktop_path, "Cloud GUI.lnk")
persist_file.Save(location, 0)
print "Icon successfully created on desktop"
shutil.copy(location, args.location)
print "Creating custom URL protocol handlers"
try:
custom_ssh = OrderedDict(
......
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