Commit 7cedde19 by Csók Tamás

fix style to better match pep8, solved some compatibility issues

parent c6d07507
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő program
##
"""
A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő
program
"""
import platform, argparse, sys, time
import platform
import argparse
import sys
import time
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
except ImporError:
pass
##
# Paraméterek átadására használt struktúra
# 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ó
class Struct:
"""
Paraméterek átadására használt struktúra
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ó
"""
pass
##
# Argument parser, argparse modulon alapszik
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("uri", type=str, help="Specific schema handler", nargs='?', default=None)
def parse_arguments():
"""
Argument parser, argparse modulon alapszik
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
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'], default="firefox")
parser.add_argument("-o", "--old", help="Use old interface", action="store_true")
args = parser.parse_args();
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'],
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
# @param args Az args.driver paraméterrel meghatározhatjuk, melyik böngészőt akarjuk használni.
#
"""
Browser inicializálás
Keyword arguments:
@param args -- Az args.driver paraméterrel meghatározhatjuk,
melyik böngészőt akarjuk használni.
"""
def __init__(self, args):
self.args = args
if args.driver == "firefox":
......@@ -52,10 +78,11 @@ class Browser:
self.driver = webdriver.Opera()
self.driver.implicitly_wait(10)
##
# Címtáras beléptetés a parancssorban megadott paraméterek alapján
#
def login(self):
"""
Címtáras beléptetés a parancssorban megadott paraméterek
alapján
"""
driver = self.driver
args = self.args
if args.username is not None:
......@@ -65,13 +92,17 @@ class Browser:
driver.find_element_by_name("j_password").clear()
driver.find_element_by_name("j_password").send_keys(args.password)
if args.username is not None and args.password is not None:
driver.find_element_by_css_selector("input[type='submit']").click()
driver.find_element_by_css_selector(
"input[type='submit']").click()
##
# A régi webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
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()
......@@ -81,23 +112,36 @@ class Browser:
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']")))
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
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
##
# Az új webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def main(self):
"""
Az új 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()
......@@ -107,10 +151,16 @@ class Browser:
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, "#vm-details-pw-eye.icon-eye-close")))
vm.state = driver.find_element_by_css_selector("#vm-details-state > span").text
element = WebDriverWait(driver,7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"#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 = driver.find_element_by_css_selector("#vm-details-connection-string").get_attribute("value").split()
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
if cl[0] == "sshpass":
vm.protocol = "SSH"
vm.user, vm.host = cl[6].split("@")
......@@ -125,27 +175,26 @@ class Browser:
raise
return vm
##
# Főprogram
# 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
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
"""
try:
args = pars_arguments()
args = parse_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.user,vm.password,vm.host,vm.port = \
args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = Browser(args)
try:
if args.old:
......@@ -163,5 +212,7 @@ def main():
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
......@@ -4,7 +4,14 @@
# Távoli klienshez csatlakozás windows OS alól
##
import sys, os, time, subprocess, glob, nxkey, win32crypt, binascii
import time
import os
import subprocess
import glob
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
......
......@@ -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
......@@ -395,7 +395,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 +448,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%"
)
......
#!/usr/bin/python
#!/usr/bin/env 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
##
"""
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:
import os
import sys
import argparse
import errno
import subprocess
import time
from _winreg import *
try:
from collections import *
else:
except ImporError:
from OrderedDict import *
from _winreg import *
##
# Argument parser, based on argparse module
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
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"):
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();
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:
"""
Parameter bypassing 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
#
"""
Registry handling class, makes registry based queries and
manipulations easier.
This class can handle WOW64 based application differently and none
differently (default)
"""
def __init__(self, args = None):
"""Initialise RegistryHandler
Keyword arguments:
@param args -- The arguments that decide how the we should
handle the registry
args.registry -- What base registry should we use
(default: HKLM)
Raises AttributeError if not supported base registry type is
given
args.different -- Whether we handle registry redirection or not
"""
if args is None:
self.args = Struct()
self.args.different = None
......@@ -77,90 +111,139 @@ class RegistryHandler:
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):
"""
Getting a registry open
Keyword arguments:
@return connected_registy -- Reference to the newly opened
registry
"""
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):
def create_registry_from_dict_chain(
self, dict_chain, both = False, architect = KEY_WOW64_64KEY,
needed_rights = KEY_ALL_ACCESS):
""""
Create registry key and value multilevel tree by chained
dictionaries.
Can raise AttributeError if the provided dict chain isn't
correct
Keyword arguments:
@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
"""
if both and architect is KEY_WOW64_64KEY:
self.create_registry_from_dict_chain(dict_chain, False, KEY_WOW64_32KEY, needed_rights)
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):
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)
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))
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)
if my_key == "default":
my_key = None
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)
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):
"""
Getting a registry value by it's key's name
Can raise KeyError if key is not found in the registry
Keyword arguments:
@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 -- 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
"""
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)
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)
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"):
def get_key_values(
self, key_name, subkey_list, subroutine = False,
depth = "subkeys"):
"""
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
Keyword arguments:
@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
[options: key, subkeys, all]
(default: subkeys)
@return results{} -- Dictionary with the subkey_name - value
combinations as keys and values
"""
if depth == "key":
int_depth = 0;
elif depth == "subkeys":
......@@ -174,23 +257,26 @@ class RegistryHandler:
key = key_and_architect[0]
architect = key_and_architect[1]
except KeyError:
#print key_name+" doesn't exist in the registry"
#print "%s doesn't exist in the registry" % key_name
raise LookupError
#print key_name+" found in the registry"
#print "%s found in the registry" % key_name
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():
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]
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"
#print ("%s doesn't exist in this" % subkey_name
# " subkey")
pass
skey.Close()
if not results or len(results) != len(subkey_list):
......@@ -201,34 +287,46 @@ class RegistryHandler:
pass
key.Close()
if len(results) != len(subkey_list):
#print We are missing important variables
#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):
def get_key_value(
self, key_name, subkey_name, subroutine = None, depth = None):
"""
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
Keyword arguments:
@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
"""
try:
if subroutine is None:
return self.get_key_values(key_name, [subkey_name])[subkey_name]
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]
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]
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:
"""
Helper class to get the true ProgramFiles directory.
This class doesn't depend on Phyton or Windows architecture.
"""
@staticmethod
def Is64Windows():
return 'PROGRAMFILES(X86)' in os.environ
......@@ -247,22 +345,31 @@ class DecideArchitecture:
def main():
try:
args = pars_arguments()
args = parse_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)
nx_install_location = handler.get_key_value(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"+
"Uninstall\\nxclient_is1",
"InstallLocation", "key")
print ("NX Client for Windows is found at "
"'%s'" % 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()
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Generating NoMachine NX scrambled key according to https://www.nomachine.com/AR01C00125
##
"""
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:
"""
NXKeyGen class
Creates NoMachine NX scrambled keys
"""
numValidCharList = 85
dummyString = "{{{{"
##
# Initialize the class
# @param password Password that will be scrambled
#
def __init__(self, password):
"""
Initialize the class
Keyword arguments:
@param password -- Password that will be scrambled
"""
self.password = password
##
# Encrypt (scramble) the given password
# @return scrambleString Scrambled version of the original password
#
def getEncrypted(self):
"""
Encrypt (scramble) the given password
Keyword arguments:
@return scrambleString -- Scrambled version of the original
password
"""
return self.scrambleString(self.password)
##
# Valid character list
# @return validcharlist List of the valid characters
#
def getvalidCharList(self, pos):
"""
Valid character list
Keyword arguments:
@return validcharlist -- List of the valid characters
"""
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
......@@ -47,11 +57,13 @@ class NXKeyGen:
]
return validcharlist[pos]
##
# Password encoder
# @return sPass Encoded password
#
def encodePassword(self, p):
"""
Password encoder
Keyword arguments:
@return sPass -- Encoded password
"""
sPass = ":"
sTmp = ""
if not p:
......@@ -64,12 +76,14 @@ class NXKeyGen:
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):
"""
Character position finder
Keyword arguments:
@param c -- Character that needs to be matched if valid
@return i -- Place where the character is in the valid list
"""
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j);
......@@ -78,19 +92,23 @@ class NXKeyGen:
return i
return i
##
# Random valid character getter
# @return char Valid character placed 0-60 in the valid list
#
def getRandomValidCharFromList(self):
"""
Random valid character getter
Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list
"""
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):
"""
Password scrambler
Keyword arguments:
@param s -- Password that needs to be scrambled
@return sRet -- NoMachine NX scrambled password
"""
sRet = ""
if not s:
return s
......@@ -118,10 +136,10 @@ class NXKeyGen:
sRet = sRet + c2
return escape(sRet)
##
# Replace a character at a special position
#
def substr_replace(self,in_str,ch,pos,qt):
"""
Replace a character at a special position
"""
clist = list(in_str)
count = 0;
tmp_str = '';
......@@ -134,7 +152,6 @@ class NXKeyGen:
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
......
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Pywin32 installer for CIRCLE client application
##
"""
Pywin32 installer for CIRCLE client application
"""
import os, sys, subprocess
import os
import sys
import subprocess
from nx_client_installer import DecideArchitecture
##
# Main program
# Install Pywin32 to the computer
#
def main():
"""
Main program
Job:
Install Pywin32 to the computer
"""
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")
subprocess.Popen(
"%s\\no_root_install.bat" % os.path.dirname(
os.path.realpath(__file__)))
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()
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.6.exe").wait()
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).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()
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.7.exe").wait()
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
print "Unsupported Python version is found!"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Windows icon installer for CIRCLE client application
##
"""
Windows icon installer for CIRCLE client application
"""
import os, sys, argparse, subprocess
if sys.hexversion > 0x02070000:
from collections import *
else:
from OrderedDict import *
import os
import argparse
import subprocess
import pythoncom
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
try:
from collections import *
except ImporError:
from OrderedDict import *
##
# 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)
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+
"first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome',
'iexplore', 'opera'])
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"):
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();
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):
"""
Custom protocol register based on RegistryHandler module
Can raise AttributeError on wrongly provided dictionary chain
Keyword arguments:
@param dict_chain -- OrderedDictionary chain of the registry tree
"""
if not isinstance(custom_protocol, OrderedDict):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
......@@ -53,14 +77,18 @@ def custom_protocol_register(custom_protocol):
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()
"""
Main program
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 (
shell.CLSID_ShellLink,
None,
......@@ -75,7 +103,9 @@ def main():
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")
subprocess.call(
"python %s\\nx_client_installer.py" % os.path.dirname(
os.path.realpath(__file__)))
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
shortcut = file(location, 'w')
......@@ -92,27 +122,44 @@ def main():
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)
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_ssh = OrderedDict(
[('ssh', ["default", "URL:ssh Protocol", "URL Protocol", ""]),
('ssh\\URL Protocol', ""),
('ssh\\DefaultIcon', args.location+"cloud.ico"),
('ssh\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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_rdp = OrderedDict(
[('rdp', ["default", "URL:rdp Protocol", "URL Protocol", ""]),
('rdp\\URL Protocol', ""),
('rdp\\DefaultIcon', args.location+"cloud.ico"),
('rdp\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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_nx = OrderedDict(
[('nx', ["default", "URL:nx Protocol", "URL Protocol", ""]),
('nx\\URL Protocol', ""),
('nx\\DefaultIcon', args.location+"cloud.ico"),
('nx\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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!"
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő program
##
"""
A cloudban létrehozott virtuális gépekhez történő kapcsolódást segítő
program
"""
import platform, argparse, sys, time
import platform
import argparse
import sys
import time
try:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
except ImporError:
pass
##
# Paraméterek átadására használt struktúra
# 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ó
class Struct:
"""
Paraméterek átadására használt struktúra
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ó
"""
pass
##
# Argument parser, argparse modulon alapszik
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
parser.add_argument("uri", type=str, help="Specific schema handler", nargs='?', default=None)
def parse_arguments():
"""
Argument parser, argparse modulon alapszik
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"uri", type=str, help="Specific schema handler", nargs='?',
default=None)
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'], default="firefox")
parser.add_argument("-o", "--old", help="Use old interface", action="store_true")
args = parser.parse_args();
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'],
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
# @param args Az args.driver paraméterrel meghatározhatjuk, melyik böngészőt akarjuk használni.
#
"""
Browser inicializálás
Keyword arguments:
@param args -- Az args.driver paraméterrel meghatározhatjuk,
melyik böngészőt akarjuk használni.
"""
def __init__(self, args):
self.args = args
if args.driver == "firefox":
......@@ -52,10 +78,11 @@ class Browser:
self.driver = webdriver.Opera()
self.driver.implicitly_wait(10)
##
# Címtáras beléptetés a parancssorban megadott paraméterek alapján
#
def login(self):
"""
Címtáras beléptetés a parancssorban megadott paraméterek
alapján
"""
driver = self.driver
args = self.args
if args.username is not None:
......@@ -65,13 +92,17 @@ class Browser:
driver.find_element_by_name("j_password").clear()
driver.find_element_by_name("j_password").send_keys(args.password)
if args.username is not None and args.password is not None:
driver.find_element_by_css_selector("input[type='submit']").click()
driver.find_element_by_css_selector(
"input[type='submit']").click()
##
# A régi webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
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()
......@@ -81,23 +112,36 @@ class Browser:
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']")))
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
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
##
# Az új webes felület használata
# @return vm Virtuális gép csatlakozásához szükséges paraméterek
#
def main(self):
"""
Az új 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()
......@@ -107,10 +151,16 @@ class Browser:
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, "#vm-details-pw-eye.icon-eye-close")))
vm.state = driver.find_element_by_css_selector("#vm-details-state > span").text
element = WebDriverWait(driver,7200).until(
EC.presence_of_element_located((
By.CSS_SELECTOR,
"#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 = driver.find_element_by_css_selector("#vm-details-connection-string").get_attribute("value").split()
cl = driver.find_element_by_css_selector(
"#vm-details-connection-string").get_attribute(
"value").split()
if cl[0] == "sshpass":
vm.protocol = "SSH"
vm.user, vm.host = cl[6].split("@")
......@@ -125,27 +175,26 @@ class Browser:
raise
return vm
##
# Főprogram
# 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
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
"""
try:
args = pars_arguments()
args = parse_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.user,vm.password,vm.host,vm.port = \
args.uri.split(':',4)
vm.protocol = vm.protocol.upper()
vm.state = "RUN"
else:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
browser = Browser(args)
try:
if args.old:
......@@ -163,5 +212,7 @@ def main():
connect(vm)
except:
print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__":
main()
......@@ -4,7 +4,14 @@
# Távoli klienshez csatlakozás windows OS alól
##
import sys, os, time, subprocess, glob, nxkey, win32crypt, binascii
import time
import os
import subprocess
import glob
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
......
#!/usr/bin/python
#!/usr/bin/env 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
##
"""
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:
import os
import sys
import argparse
import errno
import subprocess
import time
from _winreg import *
try:
from collections import *
else:
except ImporError:
from OrderedDict import *
from _winreg import *
##
# Argument parser, based on argparse module
# @return args
#
def pars_arguments():
parser = argparse.ArgumentParser();
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
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"):
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();
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:
"""
Parameter bypassing 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
#
"""
Registry handling class, makes registry based queries and
manipulations easier.
This class can handle WOW64 based application differently and none
differently (default)
"""
def __init__(self, args = None):
"""Initialise RegistryHandler
Keyword arguments:
@param args -- The arguments that decide how the we should
handle the registry
args.registry -- What base registry should we use
(default: HKLM)
Raises AttributeError if not supported base registry type is
given
args.different -- Whether we handle registry redirection or not
"""
if args is None:
self.args = Struct()
self.args.different = None
......@@ -77,90 +111,139 @@ class RegistryHandler:
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):
"""
Getting a registry open
Keyword arguments:
@return connected_registy -- Reference to the newly opened
registry
"""
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):
def create_registry_from_dict_chain(
self, dict_chain, both = False, architect = KEY_WOW64_64KEY,
needed_rights = KEY_ALL_ACCESS):
""""
Create registry key and value multilevel tree by chained
dictionaries.
Can raise AttributeError if the provided dict chain isn't
correct
Keyword arguments:
@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
"""
if both and architect is KEY_WOW64_64KEY:
self.create_registry_from_dict_chain(dict_chain, False, KEY_WOW64_32KEY, needed_rights)
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):
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)
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))
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)
if my_key == "default":
my_key = None
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)
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):
"""
Getting a registry value by it's key's name
Can raise KeyError if key is not found in the registry
Keyword arguments:
@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 -- 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
"""
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)
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)
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"):
def get_key_values(
self, key_name, subkey_list, subroutine = False,
depth = "subkeys"):
"""
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
Keyword arguments:
@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
[options: key, subkeys, all]
(default: subkeys)
@return results{} -- Dictionary with the subkey_name - value
combinations as keys and values
"""
if depth == "key":
int_depth = 0;
elif depth == "subkeys":
......@@ -174,23 +257,26 @@ class RegistryHandler:
key = key_and_architect[0]
architect = key_and_architect[1]
except KeyError:
#print key_name+" doesn't exist in the registry"
#print "%s doesn't exist in the registry" % key_name
raise LookupError
#print key_name+" found in the registry"
#print "%s found in the registry" % key_name
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():
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]
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"
#print ("%s doesn't exist in this" % subkey_name
# " subkey")
pass
skey.Close()
if not results or len(results) != len(subkey_list):
......@@ -201,34 +287,46 @@ class RegistryHandler:
pass
key.Close()
if len(results) != len(subkey_list):
#print We are missing important variables
#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):
def get_key_value(
self, key_name, subkey_name, subroutine = None, depth = None):
"""
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
Keyword arguments:
@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
"""
try:
if subroutine is None:
return self.get_key_values(key_name, [subkey_name])[subkey_name]
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]
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]
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:
"""
Helper class to get the true ProgramFiles directory.
This class doesn't depend on Phyton or Windows architecture.
"""
@staticmethod
def Is64Windows():
return 'PROGRAMFILES(X86)' in os.environ
......@@ -247,22 +345,31 @@ class DecideArchitecture:
def main():
try:
args = pars_arguments()
args = parse_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)
nx_install_location = handler.get_key_value(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"+
"Uninstall\\nxclient_is1",
"InstallLocation", "key")
print ("NX Client for Windows is found at "
"'%s'" % 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()
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Generating NoMachine NX scrambled key according to https://www.nomachine.com/AR01C00125
##
"""
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:
"""
NXKeyGen class
Creates NoMachine NX scrambled keys
"""
numValidCharList = 85
dummyString = "{{{{"
##
# Initialize the class
# @param password Password that will be scrambled
#
def __init__(self, password):
"""
Initialize the class
Keyword arguments:
@param password -- Password that will be scrambled
"""
self.password = password
##
# Encrypt (scramble) the given password
# @return scrambleString Scrambled version of the original password
#
def getEncrypted(self):
"""
Encrypt (scramble) the given password
Keyword arguments:
@return scrambleString -- Scrambled version of the original
password
"""
return self.scrambleString(self.password)
##
# Valid character list
# @return validcharlist List of the valid characters
#
def getvalidCharList(self, pos):
"""
Valid character list
Keyword arguments:
@return validcharlist -- List of the valid characters
"""
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
......@@ -47,11 +57,13 @@ class NXKeyGen:
]
return validcharlist[pos]
##
# Password encoder
# @return sPass Encoded password
#
def encodePassword(self, p):
"""
Password encoder
Keyword arguments:
@return sPass -- Encoded password
"""
sPass = ":"
sTmp = ""
if not p:
......@@ -64,12 +76,14 @@ class NXKeyGen:
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):
"""
Character position finder
Keyword arguments:
@param c -- Character that needs to be matched if valid
@return i -- Place where the character is in the valid list
"""
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j);
......@@ -78,19 +92,23 @@ class NXKeyGen:
return i
return i
##
# Random valid character getter
# @return char Valid character placed 0-60 in the valid list
#
def getRandomValidCharFromList(self):
"""
Random valid character getter
Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list
"""
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):
"""
Password scrambler
Keyword arguments:
@param s -- Password that needs to be scrambled
@return sRet -- NoMachine NX scrambled password
"""
sRet = ""
if not s:
return s
......@@ -118,10 +136,10 @@ class NXKeyGen:
sRet = sRet + c2
return escape(sRet)
##
# Replace a character at a special position
#
def substr_replace(self,in_str,ch,pos,qt):
"""
Replace a character at a special position
"""
clist = list(in_str)
count = 0;
tmp_str = '';
......@@ -134,7 +152,6 @@ class NXKeyGen:
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
......
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Pywin32 installer for CIRCLE client application
##
"""
Pywin32 installer for CIRCLE client application
"""
import os, sys, subprocess
import os
import sys
import subprocess
from nx_client_installer import DecideArchitecture
##
# Main program
# Install Pywin32 to the computer
#
def main():
"""
Main program
Job:
Install Pywin32 to the computer
"""
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")
subprocess.Popen(
"%s\\no_root_install.bat" % os.path.dirname(
os.path.realpath(__file__)))
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()
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.6.exe").wait()
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.6.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).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()
subprocess.Popen(
"%s\\x64\\pywin32-%s.win-amd64-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
subprocess.Popen(os.path.dirname(os.path.realpath(__file__))+"\\x86\\pywin32-"+pywin32_version+".win32-py2.7.exe").wait()
subprocess.Popen(
"%s\\x86\\pywin32-%s.win32-py2.7.exe" % (
os.path.dirname(os.path.realpath(__file__)),
pywin32_version)).wait()
else:
print "Unsupported Python version is found!"
if __name__ == "__main__":
main()
\ No newline at end of file
#!/usr/bin/python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
##
# Windows icon installer for CIRCLE client application
##
"""
Windows icon installer for CIRCLE client application
"""
import os, sys, argparse, subprocess
if sys.hexversion > 0x02070000:
from collections import *
else:
from OrderedDict import *
import os
import argparse
import subprocess
import pythoncom
from win32com.shell import shell, shellcon
from nx_client_installer import DecideArchitecture, RegistryHandler, Struct
try:
from collections import *
except ImporError:
from OrderedDict import *
##
# 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)
def parse_arguments():
"""
Argument parser, based on argparse module
Keyword arguments:
@return args -- arguments given by console
"""
parser = argparse.ArgumentParser()
parser.add_argument(
"-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+
"first the proper driver.", type=str, default="firefox",
required=False, choices=['firefox', 'chrome',
'iexplore', 'opera'])
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"):
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();
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):
"""
Custom protocol register based on RegistryHandler module
Can raise AttributeError on wrongly provided dictionary chain
Keyword arguments:
@param dict_chain -- OrderedDictionary chain of the registry tree
"""
if not isinstance(custom_protocol, OrderedDict):
raise AttributeError
print "\t"+custom_protocol.iterkeys().next()
......@@ -53,14 +77,18 @@ def custom_protocol_register(custom_protocol):
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()
"""
Main program
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 (
shell.CLSID_ShellLink,
None,
......@@ -75,7 +103,9 @@ def main():
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")
subprocess.call(
"python %s\\nx_client_installer.py" % os.path.dirname(
os.path.realpath(__file__)))
if args.url:
location = os.path.join(desktop_path, "Cloud GUI.url")
shortcut = file(location, 'w')
......@@ -92,27 +122,44 @@ def main():
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)
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_ssh = OrderedDict(
[('ssh', ["default", "URL:ssh Protocol", "URL Protocol", ""]),
('ssh\\URL Protocol', ""),
('ssh\\DefaultIcon', args.location+"cloud.ico"),
('ssh\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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_rdp = OrderedDict(
[('rdp', ["default", "URL:rdp Protocol", "URL Protocol", ""]),
('rdp\\URL Protocol', ""),
('rdp\\DefaultIcon', args.location+"cloud.ico"),
('rdp\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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_nx = OrderedDict(
[('nx', ["default", "URL:nx Protocol", "URL Protocol", ""]),
('nx\\URL Protocol', ""),
('nx\\DefaultIcon', args.location+"cloud.ico"),
('nx\\shell', {'open': {
'command': "\"python.exe\" \"%s" % 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!"
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