from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable import os import subprocess from uds.forward import forward # @UnresolvedImport from uds import tools # @UnresolvedImport import six forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22) if forwardThread.status == 2: raise Exception('Unable to open tunnel') tools.addTaskToWait(forwardThread) keyFile = tools.saveTempFile('''{m.key}''') theFile = '''{m.xf}'''.format(export='c:\\:1;', keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port) filename = tools.saveTempFile(theFile) x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient' executable = tools.findApp('x2goclient.exe', [x2goPath]) if executable is None: raise Exception('''<p>You must have installed latest X2GO Client in default program file folder in order to connect to this UDS service.</p> <p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>''') subprocess.Popen([executable, '--session-conf={{}}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts'])
<p>You can get it from <a href="{}static/other/CoRD.pkg">this link</a></p> </li> </ul> <p>If both apps are installed, Remote Desktop Connection will be used as first option</p> '''.format(sp['this_server'])) # @UndefinedVariable forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 3389, waitTime=sp['tunWait']) # @UndefinedVariable address = '127.0.0.1:{}'.format(port) if forwardThread.status == 2: raise Exception('Unable to open tunnel') else: if executable == msrdc: theFile = sp['as_file'].format(address=address) # @UndefinedVariable filename = tools.saveTempFile(theFile) tools.addFileToUnlink(filename) try: if sp['password'] != '': # @UndefinedVariable subprocess.call( [ 'security', 'add-generic-password', '-w', sp['password'], # @UndefinedVariable '-U', '-a', sp['usernameWithDomain'], # @UndefinedVariable '-s', 'Remote Desktop Connection 2 Password for 127.0.0.1'.format(port), '-T', '/Applications/Remote Desktop Connection.app', ] )
# This is a template # Saved as .py for easier editing from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index from PyQt4 import QtCore, QtGui # @UnusedImport import subprocess import os from uds import tools # @UnresolvedImport cmd = "/Applications/OpenNX/OpenNX.app/Contents/MacOS/OpenNXapp" if os.path.isfile(cmd) is False: raise Exception( """<p>You need to have installed Open NX Client in order to connect to this UDS service.</p> <p>Please, install appropriate package for your system from <a href="http://www.opennx.net/">here</a>.</p> """ ) filename = tools.saveTempFile("""{r.as_file}""") tools.addTaskToWait(subprocess.Popen([cmd, "--session={{}}".format(filename), "--autologin", "--killerrors"])) tools.addFileToUnlink(filename)
# pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index import subprocess import os import urllib from uds import tools # @UnresolvedImport import six theFile = '''{m.r.as_file}''' # First, try to locate Remote Desktop Connection (version 2, from Microsoft website, not the app store one) filename = tools.saveTempFile(theFile) msrdc = '/Applications/Remote Desktop Connection.app/Contents/MacOS/Remote Desktop Connection' cord = "/Applications/CoRD.app/Contents/MacOS/CoRD" if os.path.isfile(msrdc): executable = msrdc elif os.path.isfile(cord): executable = cord else: executable = None def onExit(): import subprocess # @Reimport subprocess.call( [
# This is a template # Saved as .py for easier editing from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module import subprocess from uds import tools # @UnresolvedImport try: cmd = tools.findApp('nxclient', ['/usr/NX/bin/']) if cmd is None: raise Exception() except Exception: raise Exception('''<p>You need to have installed NX Client version 3.5 in order to connect to this UDS service.</p> <p>Please, install appropriate package for your system.</p> ''') filename = tools.saveTempFile('''{r.as_file}''') tools.addTaskToWait(subprocess.Popen([cmd, '--session', filename])) tools.addFileToUnlink(filename)
try: thePass = six.binary_type("""{m.password}""".encode('UTF-16LE')) password = win32crypt.CryptProtectData(thePass, None, None, None, None, 0x01).encode('hex') except Exception: logger.info('Cannot encrypt for user, trying for machine') password = win32crypt.CryptProtectData(thePass, None, None, None, None, 0x05).encode('hex') try: key = wreg.OpenKey( wreg.HKEY_CURRENT_USER, 'Software\Microsoft\Terminal Server Client\LocalDevices', 0, wreg.KEY_SET_VALUE) # @UndefinedVariable wreg.SetValueEx(key, '{m.ip}', 0, wreg.REG_DWORD, 255) # @UndefinedVariable wreg.CloseKey(key) # @UndefinedVariable except Exception as e: logger.warn('Exception fixing redirection dialog: %s', e) # The password must be encoded, to be included in a .rdp file, as 'UTF-16LE' before protecting (CtrpyProtectData) it in order to work with mstsc theFile = '''{m.r.as_file}'''.format(password=password) filename = tools.saveTempFile(theFile) executable = tools.findApp('mstsc.exe') subprocess.Popen([executable, filename]) tools.addFileToUnlink(filename) # QtGui.QMessageBox.critical(parent, 'Notice', filename + ", " + executable, QtGui.QMessageBox.Ok)
# This is a template # Saved as .py for easier editing from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module, too-many-format-args, undefined-variable, invalid-sequence-index import subprocess import os from uds import tools # @UnresolvedImport cmd = '/Applications/OpenNX/OpenNX.app/Contents/MacOS/OpenNXapp' if os.path.isfile(cmd) is False: raise Exception( '''<p>You need to have installed Open NX Client in order to connect to this UDS service.</p> <p>Please, install appropriate package for your system from <a href="http://www.opennx.net/">here</a>.</p> ''') filename = tools.saveTempFile('''{r.as_file}''') tools.addTaskToWait( subprocess.Popen([ cmd, '--session={{}}'.format(filename), '--autologin', '--killerrors' ])) tools.addFileToUnlink(filename)
from os.path import expanduser from uds import tools # @UnresolvedImport import six forwardThread, port = forward('{m.tunHost}', '{m.tunPort}', '{m.tunUser}', '{m.tunPass}', '{m.ip}', 22) if forwardThread.status == 2: raise Exception('Unable to open tunnel') tools.addTaskToWait(forwardThread) home = expanduser('~').replace('\\', '\\\\') + '#1;' keyFile = tools.saveTempFile('''{m.key}''') theFile = '''{m.xf}'''.format(export=home, keyFile=keyFile.replace('\\', '/'), ip='127.0.0.1', port=port) filename = tools.saveTempFile(theFile) x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient' executable = tools.findApp('x2goclient.exe', [x2goPath]) if executable is None: raise Exception( '''<p>You must have installed latest X2GO Client in default program file folder in order to connect to this UDS service.</p> <p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>''' ) subprocess.Popen([
# This is a template # Saved as .py for easier editing # from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module import os import subprocess from os.path import expanduser from uds import tools # @UnresolvedImport home = expanduser('~').replace('\\', '\\\\') + '#1;' keyFile = tools.saveTempFile(sp['key']) # On windows, the separator beween active and not is "#" theFile = sp['xf'].format(export='c:\\\\#1;', keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) filename = tools.saveTempFile(theFile) x2goPath = os.environ['PROGRAMFILES(X86)'] + '\\x2goclient' executable = tools.findApp('x2goclient.exe', [x2goPath]) if executable is None: raise Exception( '''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p> <p>You can download it for windows from <a href="http://wiki.x2go.org/doku.php">X2Go Site</a>.</p>''' ) # C:\Program Files (x86)\\x2goclient>x2goclient.exe --session-conf=c:/temp/sessions --session=UDS/test-session --close-disconnect --hide --no-menu subprocess.Popen([
</li> </ul> <p>If both apps are installed, Remote Desktop Connection will be used as first option</p> '''.format(sp['this_server'])) # @UndefinedVariable forwardThread, port = forward(sp['tunHost'], sp['tunPort'], sp['tunUser'], sp['tunPass'], sp['ip'], 3389, sp['tunWait']) # @UndefinedVariable address = '127.0.0.1:{}'.format(port) if forwardThread.status == 2: raise Exception('Unable to open tunnel') else: theFile = '''{m.r.as_file}'''.format( address='127.0.0.1:{{}}'.format(port) ) filename = tools.saveTempFile(theFile) tools.addFileToUnlink(filename) if executable == msrdc: try: filename = tools.saveTempFile(sp['as_file'].format(address=address)) # @UndefinedVariable tools.addFileToUnlink(filename) if sp['password'] != '': # @UndefinedVariable subprocess.call( [ 'security', 'add-generic-password', '-w', sp['password'], # @UndefinedVariable '-U', '-a', sp['usernameWithDomain'], # @UndefinedVariable '-s', 'Remote Desktop Connection 2 Password for 127.0.0.1'.format(port),
# This is a template # Saved as .py for easier editing from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module, undefined-variable import subprocess from uds import tools # type: ignore try: cmd = tools.findApp('nxclient', ['/usr/NX/bin/']) if cmd is None: raise Exception() except Exception: raise Exception( '''<p>You need to have installed NX Client version 3.5 in order to connect to this UDS service.</p> <p>Please, install appropriate package for your system.</p> ''') filename = tools.saveTempFile(sp['as_file']) # type: ignore tools.addTaskToWait(subprocess.Popen([cmd, '--session', filename])) tools.addFileToUnlink(filename)
] ) if executable is None: raise Exception('''<p><b>Microsoft Remote Desktop Connection not found</b></p> <p>In order to connect to UDS RDP Sessions, you need to have at least one of the following:<p> <ul> <li> <p><b>CoRD</b> (A bit unstable from 10.7 onwards)</p> <p>You can get it from <a href="{}static/other/CoRD.pkg">this link</a></p> </li> </ul> <p>If both apps are installed, Remote Desktop Connection will be used as first option</p>'''.format(sp['this_server'])) # @UndefinedVariable elif executable == msrdc: try: filename = tools.saveTempFile(sp['as_file']) # @UndefinedVariable if sp['password'] != '': # @UndefinedVariable subprocess.call( [ 'security', 'add-generic-password', '-w', sp['password'], # @UndefinedVariable '-U', '-a', sp['usernameWithDomain'], # @UndefinedVariable '-s', 'Remote Desktop Connection 2 Password for {}'.format(sp['ip']), # @UndefinedVariable '-T', '/Applications/Remote Desktop Connection.app', ] ) tools.addExecBeforeExit(onExit) # Call and wait for exit tools.addTaskToWait(subprocess.Popen([executable, filename]))
# This is a template # Saved as .py for easier editing from __future__ import unicode_literals # pylint: disable=import-error, no-name-in-module import subprocess from os.path import expanduser from uds import tools # type: ignore home = expanduser('~') + ':1;/media:1;' keyFile = tools.saveTempFile(sp['key']) # type: ignore theFile = sp['xf'].format(export=home, keyFile=keyFile.replace('\\', '/'), ip=sp['ip'], port=sp['port']) # type: ignore filename = tools.saveTempFile(theFile) # HOME=[temporal folder, where we create a .x2goclient folder and a sessions inside] pyhoca-cli -P UDS/test-session executable = tools.findApp('x2goclient') if executable is None: raise Exception('''<p>You must have installed latest X2GO Client in order to connect to this UDS service.</p> <p>Please, install the required packages for your platform</p>''') subprocess.Popen([executable, '--session-conf={}'.format(filename), '--session=UDS/connect', '--close-disconnect', '--hide', '--no-menu', '--add-to-known-hosts']) # tools.addFileToUnlink(filename) # tools.addFileToUnlink(keyFile)