mirror of
https://github.com/dkmstr/openuds.git
synced 2025-01-06 13:17:54 +03:00
Moving gui variables to snake_case
This commit is contained in:
parent
cd737c4b5f
commit
ce888a6013
@ -277,9 +277,9 @@ class Dispatcher(View):
|
||||
modfinder.dynamically_load_and_register_packages(
|
||||
Dispatcher.registerClass,
|
||||
Handler,
|
||||
modName=modName,
|
||||
module_name=modName,
|
||||
checker=checker,
|
||||
packageName='methods',
|
||||
package_name='methods',
|
||||
)
|
||||
|
||||
Dispatcher.initialize()
|
||||
|
@ -102,6 +102,7 @@ class Module(abc.ABC, UserInterface, Environmentable, Serializable):
|
||||
__slots__ = ['_uuid']
|
||||
# Import variable indicating this module is a base class not a real module
|
||||
# Note that Module is not a real module, but a base class for all modules so is_base is not used on this class
|
||||
# This means that is_base is set as a default here, but not checked for Module NEVER (but for subclasses)
|
||||
is_base: typing.ClassVar[bool] = False
|
||||
|
||||
# Types
|
||||
|
@ -40,6 +40,7 @@ import typing
|
||||
import collections.abc
|
||||
|
||||
from django.conf import settings
|
||||
from requests import get
|
||||
|
||||
from uds.core import module
|
||||
|
||||
@ -65,19 +66,19 @@ def get_urlpatterns_from_modules() -> list[typing.Any]:
|
||||
if not patterns:
|
||||
logger.debug('Looking for patterns')
|
||||
try:
|
||||
modName = 'uds.dispatchers'
|
||||
pkgpath = os.path.dirname(typing.cast(str, sys.modules[modName].__file__))
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
fullModName = f'{modName}.{name}.urls'
|
||||
module_name = 'uds.dispatchers'
|
||||
package_path = os.path.dirname(typing.cast(str, sys.modules[module_name].__file__))
|
||||
for _, name, _ in pkgutil.iter_modules([package_path]):
|
||||
module_fullname = f'{module_name}.{name}.urls'
|
||||
try:
|
||||
mod = importlib.import_module(fullModName)
|
||||
mod = importlib.import_module(module_fullname)
|
||||
urlpatterns: list[typing.Any] = getattr(mod, 'urlpatterns')
|
||||
logger.debug('Loaded mod %s, url %s', mod, urlpatterns)
|
||||
# Append patters from mod
|
||||
for up in urlpatterns:
|
||||
patterns.append(up)
|
||||
except Exception:
|
||||
logger.error('No patterns found in %s', fullModName)
|
||||
logger.error('No patterns found in %s', module_fullname)
|
||||
except Exception:
|
||||
logger.exception('Processing dispatchers loading')
|
||||
|
||||
@ -86,7 +87,7 @@ def get_urlpatterns_from_modules() -> list[typing.Any]:
|
||||
return patterns
|
||||
|
||||
|
||||
def import_modules(mod_name: str, *, package_name: typing.Optional[str] = None) -> None:
|
||||
def import_modules(module_name: str, *, package_name: typing.Optional[str] = None) -> None:
|
||||
"""Dinamycally import children of package
|
||||
|
||||
Args:
|
||||
@ -95,24 +96,24 @@ def import_modules(mod_name: str, *, package_name: typing.Optional[str] = None)
|
||||
|
||||
Notes:
|
||||
This function is used to dinamycally import all submodules inside a submodule (with optional package name).
|
||||
|
||||
|
||||
"""
|
||||
# Dinamycally import children of this package.
|
||||
pkgpath = os.path.dirname(typing.cast(str, sys.modules[mod_name].__file__))
|
||||
package_path = os.path.dirname(typing.cast(str, sys.modules[module_name].__file__))
|
||||
if package_name: # Append package name to path and module name
|
||||
pkgpath = os.path.join(pkgpath, package_name)
|
||||
mod_name = f'{mod_name}.{package_name}'
|
||||
package_path = os.path.join(package_path, package_name)
|
||||
module_name = f'{module_name}.{package_name}'
|
||||
|
||||
logger.info('* Importing modules from %s', pkgpath)
|
||||
for _, name, _ in pkgutil.iter_modules([pkgpath]):
|
||||
logger.info('* Importing modules from %s', package_path)
|
||||
for _, name, _ in pkgutil.iter_modules([package_path]):
|
||||
try:
|
||||
logger.info(' - Importing module %s.%s ', mod_name, name)
|
||||
importlib.import_module('.' + name, mod_name) # import module
|
||||
logger.info(' - Importing module %s.%s ', module_name, name)
|
||||
importlib.import_module('.' + name, module_name) # import module
|
||||
except Exception as e:
|
||||
if settings.DEBUG:
|
||||
logger.exception('***** Error importing module %s.%s: %s *****', mod_name, name, e)
|
||||
logger.error(' - Error importing module %s.%s: %s', mod_name, name, e)
|
||||
logger.info('* Done importing modules from %s', pkgpath)
|
||||
logger.exception('***** Error importing module %s.%s: %s *****', module_name, name, e)
|
||||
logger.error(' - Error importing module %s.%s: %s', module_name, name, e)
|
||||
logger.info('* Done importing modules from %s', package_path)
|
||||
|
||||
importlib.invalidate_caches()
|
||||
|
||||
@ -120,18 +121,18 @@ def import_modules(mod_name: str, *, package_name: typing.Optional[str] = None)
|
||||
def dynamically_load_and_register_packages(
|
||||
adder: collections.abc.Callable[[type[V]], None],
|
||||
type_: type[V],
|
||||
modName: str,
|
||||
module_name: str,
|
||||
*,
|
||||
packageName: typing.Optional[str] = None,
|
||||
package_name: typing.Optional[str] = None,
|
||||
checker: typing.Optional[collections.abc.Callable[[type[V]], bool]] = None,
|
||||
) -> None:
|
||||
''' Loads all packages from a given package that are subclasses of the given type
|
||||
'''Loads all packages from a given package that are subclasses of the given type
|
||||
|
||||
Args:
|
||||
adder (collections.abc.Callable[[type[V]], None]): Function to use to add the objects, must support "insert" method
|
||||
type_ (type[V]): Type of the objects to load
|
||||
modName (str): Name of the package to load
|
||||
packageName (str, optional): Name of the package inside the module to import. Defaults to None. If None, the module itself is imported
|
||||
module_name (str): Name of the package to load
|
||||
package_name (str, optional): Name of the package inside the module to import. Defaults to None. If None, the module itself is imported
|
||||
checker (collections.abc.Callable[[type[V]], bool], optional): Function to use to check if the class is registrable. Defaults to None.
|
||||
|
||||
Notes:
|
||||
@ -143,7 +144,7 @@ def dynamically_load_and_register_packages(
|
||||
return cls.__name__.startswith('MyClass')
|
||||
'''
|
||||
# Ensures all modules under modName (and optionally packageName) are imported
|
||||
import_modules(modName, package_name=packageName)
|
||||
import_modules(module_name, package_name=package_name)
|
||||
|
||||
checkFnc = checker or (lambda x: True)
|
||||
|
||||
@ -167,25 +168,33 @@ def dynamically_load_and_register_packages(
|
||||
logger.exception('***** Error registering %s.%s: %s *****', cls.__module__, cls.__name__, e)
|
||||
logger.error(' - Error registering %s.%s: %s', cls.__module__, cls.__name__, e)
|
||||
|
||||
logger.info('* Start registering %s', modName)
|
||||
logger.info('* Start registering %s', module_name)
|
||||
process(type_.__subclasses__())
|
||||
logger.info('* Done Registering %s', modName)
|
||||
logger.info('* Done Registering %s', module_name)
|
||||
|
||||
|
||||
def dynamically_load_and_register_modules(
|
||||
factory: 'ModuleFactory[T]',
|
||||
type_: type[T],
|
||||
modName: str,
|
||||
module_name: str,
|
||||
) -> None:
|
||||
''' Loads and registers all modules from a given package that are subclasses of the given type
|
||||
'''Loads and registers all modules from a given package that are subclasses of the given type
|
||||
|
||||
This is an specialisation of dynamicLoadAndRegisterPackages that uses a ModuleFactory to register the modules
|
||||
|
||||
Args:
|
||||
factory (ModuleFactory): Factory to use to create the objects, must support "insert" method
|
||||
type_ (type[T]): Type of the objects to load
|
||||
modName (str): Name of the package to load
|
||||
module_name (str): Name of the package to load
|
||||
'''
|
||||
|
||||
def checker(cls: type[T]) -> bool:
|
||||
# Will receive all classes that are subclasses of type_
|
||||
return not cls.is_base
|
||||
|
||||
dynamically_load_and_register_packages(
|
||||
factory.insert, type_, modName, checker=lambda x: not x.is_base
|
||||
factory.insert,
|
||||
type_,
|
||||
module_name,
|
||||
checker=checker,
|
||||
)
|
||||
|
@ -64,13 +64,13 @@ class SPICETransport(BaseSpiceTransport):
|
||||
# useEmptyCreds = BaseSpiceTransport.useEmptyCreds
|
||||
# fixedName = BaseSpiceTransport.fixedName
|
||||
# fixedPassword = BaseSpiceTransport.fixedPassword
|
||||
serverCertificate = BaseSpiceTransport.serverCertificate
|
||||
fullScreen = BaseSpiceTransport.fullScreen
|
||||
usbShare = BaseSpiceTransport.usbShare
|
||||
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
|
||||
smartCardRedirect = BaseSpiceTransport.smartCardRedirect
|
||||
sslConnection = BaseSpiceTransport.SSLConnection
|
||||
overridedProxy = BaseSpiceTransport.overridedProxy
|
||||
server_certificate = BaseSpiceTransport.server_certificate
|
||||
fullscreen = BaseSpiceTransport.fullscreen
|
||||
allow_usb_redirection = BaseSpiceTransport.allow_usb_redirection
|
||||
allow_usb_redirection_new_plugs = BaseSpiceTransport.allow_usb_redirection_new_plugs
|
||||
allow_usb_redirection_new_plugs = BaseSpiceTransport.allow_smartcards
|
||||
allow_usb_redirection_new_plugs = BaseSpiceTransport.ssl_connection
|
||||
overrided_proxy = BaseSpiceTransport.overrided_proxy
|
||||
|
||||
def get_transport_script(
|
||||
self,
|
||||
@ -101,16 +101,16 @@ class SPICETransport(BaseSpiceTransport):
|
||||
port,
|
||||
secure_port,
|
||||
con['ticket']['value'],
|
||||
con.get('ca', self.serverCertificate.value.strip()),
|
||||
con.get('ca', self.server_certificate.value.strip()),
|
||||
con['cert_subject'],
|
||||
fullscreen=self.fullScreen.as_bool(),
|
||||
fullscreen=self.fullscreen.as_bool(),
|
||||
)
|
||||
r.proxy = self.overridedProxy.value.strip() or con.get('proxy', None)
|
||||
r.proxy = self.overrided_proxy.value.strip() or con.get('proxy', None)
|
||||
|
||||
r.usb_auto_share = self.usbShare.as_bool()
|
||||
r.new_usb_auto_share = self.autoNewUsbShare.as_bool()
|
||||
r.smartcard = self.smartCardRedirect.as_bool()
|
||||
r.ssl_connection = self.sslConnection.as_bool()
|
||||
r.usb_auto_share = self.allow_usb_redirection.as_bool()
|
||||
r.new_usb_auto_share = self.allow_usb_redirection_new_plugs.as_bool()
|
||||
r.smartcard = self.allow_usb_redirection_new_plugs.as_bool()
|
||||
r.ssl_connection = self.allow_usb_redirection_new_plugs.as_bool()
|
||||
|
||||
# if sso: # If SSO requested, and when supported by platform
|
||||
# userServiceInstance.desktopLogin(user, password, '')
|
||||
|
@ -58,25 +58,28 @@ class BaseSpiceTransport(transports.Transport):
|
||||
icon_file = 'spice.png'
|
||||
protocol = types.transports.Protocol.SPICE
|
||||
|
||||
useEmptyCreds = gui.CheckBoxField(
|
||||
force_empty_creds = gui.CheckBoxField(
|
||||
order=1,
|
||||
label=_('Empty credentials'),
|
||||
tooltip=_('If checked, the credentials used to connect will be emtpy'),
|
||||
tab=types.ui.Tab.CREDENTIALS,
|
||||
stored_field_name='useEmptyCreds',
|
||||
)
|
||||
fixedName = gui.TextField(
|
||||
forced_username = gui.TextField(
|
||||
order=2,
|
||||
label=_('Username'),
|
||||
tooltip=_('If not empty, this username will be always used as credential'),
|
||||
tab=types.ui.Tab.CREDENTIALS,
|
||||
stored_field_name='fixedName',
|
||||
)
|
||||
fixedPassword = gui.PasswordField(
|
||||
forced_password = gui.PasswordField(
|
||||
order=3,
|
||||
label=_('Password'),
|
||||
tooltip=_('If not empty, this password will be always used as credential'),
|
||||
tab=types.ui.Tab.CREDENTIALS,
|
||||
stored_field_name='fixedPassword',
|
||||
)
|
||||
serverCertificate = gui.TextField(
|
||||
server_certificate = gui.TextField(
|
||||
order=4,
|
||||
length=4096,
|
||||
lines=4,
|
||||
@ -85,43 +88,49 @@ class BaseSpiceTransport(transports.Transport):
|
||||
'Server certificate (public), can be found on your ovirt engine, probably at /etc/pki/ovirt-engine/certs/ca.der (Use the contents of this file).'
|
||||
),
|
||||
required=False,
|
||||
stored_field_name='serverCertificate',
|
||||
)
|
||||
fullScreen = gui.CheckBoxField(
|
||||
fullscreen = gui.CheckBoxField(
|
||||
order=5,
|
||||
label=_('Fullscreen Mode'),
|
||||
tooltip=_('If checked, viewer will be shown on fullscreen mode-'),
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='fullScreen',
|
||||
)
|
||||
smartCardRedirect = gui.CheckBoxField(
|
||||
allow_smartcards = gui.CheckBoxField(
|
||||
order=6,
|
||||
label=_('Smartcard Redirect'),
|
||||
tooltip=_('If checked, SPICE protocol will allow smartcard redirection.'),
|
||||
default=False,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='smartCardRedirect',
|
||||
)
|
||||
usbShare = gui.CheckBoxField(
|
||||
allow_usb_redirection = gui.CheckBoxField(
|
||||
order=7,
|
||||
label=_('Enable USB'),
|
||||
tooltip=_('If checked, USB redirection will be allowed.'),
|
||||
default=False,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='usbShare',
|
||||
)
|
||||
autoNewUsbShare = gui.CheckBoxField(
|
||||
allow_usb_redirection_new_plugs = gui.CheckBoxField(
|
||||
order=8,
|
||||
label=_('New USB Auto Sharing'),
|
||||
tooltip=_('Auto-redirect USB devices when plugged in.'),
|
||||
default=False,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='autoNewUsbShare',
|
||||
)
|
||||
SSLConnection = gui.CheckBoxField(
|
||||
ssl_connection = gui.CheckBoxField(
|
||||
order=9,
|
||||
label=_('SSL Connection'),
|
||||
tooltip=_('If checked, SPICE protocol will allow SSL connections.'),
|
||||
default=True,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='SSLConnection',
|
||||
)
|
||||
|
||||
overridedProxy = gui.TextField(
|
||||
overrided_proxy = gui.TextField(
|
||||
order=10,
|
||||
label=_('Override Proxy'),
|
||||
tooltip=_(
|
||||
@ -130,16 +139,7 @@ class BaseSpiceTransport(transports.Transport):
|
||||
required=False,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
pattern=types.ui.FieldPatternType.URL,
|
||||
)
|
||||
|
||||
overridedProxy = gui.TextField(
|
||||
order=10,
|
||||
label=_('Override Proxy'),
|
||||
tooltip=_(
|
||||
'If not empty, this proxy will be used to connect to the service instead of the one provided by the hypervisor. Format: http://host:port'
|
||||
),
|
||||
required=False,
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='overridedProxy',
|
||||
)
|
||||
|
||||
def is_ip_allowed(self, userService: 'models.UserService', ip: str) -> bool:
|
||||
@ -202,13 +202,13 @@ class BaseSpiceTransport(transports.Transport):
|
||||
) -> types.connections.ConnectionData:
|
||||
username = user.get_username_for_auth()
|
||||
|
||||
if self.fixedName.value:
|
||||
username = self.fixedName.value
|
||||
if self.forced_username.value:
|
||||
username = self.forced_username.value
|
||||
|
||||
if self.fixedPassword.value:
|
||||
password = self.fixedPassword.value
|
||||
if self.forced_password.value:
|
||||
password = self.forced_password.value
|
||||
|
||||
if self.useEmptyCreds.as_bool():
|
||||
if self.force_empty_creds.as_bool():
|
||||
username, password = '', ''
|
||||
|
||||
# Fix username/password acording to os manager
|
||||
|
@ -66,9 +66,9 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
group = types.transports.Grouping.TUNNELED
|
||||
|
||||
tunnel = fields.tunnel_field()
|
||||
tunnelWait = fields.tunnel_wait_time()
|
||||
tunnel_wait = fields.tunnel_wait_time()
|
||||
|
||||
verifyCertificate = gui.CheckBoxField(
|
||||
verify_certificate = gui.CheckBoxField(
|
||||
label=_('Force SSL certificate verification'),
|
||||
order=23,
|
||||
tooltip=_(
|
||||
@ -76,14 +76,15 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
),
|
||||
default=False,
|
||||
tab=types.ui.Tab.TUNNEL,
|
||||
stored_field_name='verifyCertificate',
|
||||
)
|
||||
|
||||
serverCertificate = BaseSpiceTransport.serverCertificate
|
||||
fullScreen = BaseSpiceTransport.fullScreen
|
||||
usbShare = BaseSpiceTransport.usbShare
|
||||
autoNewUsbShare = BaseSpiceTransport.autoNewUsbShare
|
||||
smartCardRedirect = BaseSpiceTransport.smartCardRedirect
|
||||
sslConnection = BaseSpiceTransport.SSLConnection
|
||||
server_certificate = BaseSpiceTransport.server_certificate
|
||||
fullscreen = BaseSpiceTransport.fullscreen
|
||||
allow_usb_redirection = BaseSpiceTransport.allow_usb_redirection
|
||||
allow_usb_redirection_new_plugs = BaseSpiceTransport.allow_usb_redirection_new_plugs
|
||||
allow_smartcards = BaseSpiceTransport.allow_smartcards
|
||||
ssl_connection = BaseSpiceTransport.ssl_connection
|
||||
|
||||
def initialize(self, values: 'Module.ValuesType'):
|
||||
if values:
|
||||
@ -128,7 +129,7 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
ticket = TicketStore.create_for_tunnel(
|
||||
userService=userService,
|
||||
port=int(con['port']),
|
||||
validity=self.tunnelWait.num() + 60, # Ticket overtime
|
||||
validity=self.tunnel_wait.num() + 60, # Ticket overtime
|
||||
)
|
||||
|
||||
if con['secure_port']:
|
||||
@ -136,7 +137,7 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
userService=userService,
|
||||
port=int(con['secure_port']),
|
||||
host=con['address'],
|
||||
validity=self.tunnelWait.num() + 60, # Ticket overtime
|
||||
validity=self.tunnel_wait.num() + 60, # Ticket overtime
|
||||
)
|
||||
|
||||
r = RemoteViewerFile(
|
||||
@ -144,15 +145,15 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
'{port}',
|
||||
'{secure_port}',
|
||||
con['ticket']['value'], # This is secure ticket from kvm, not UDS ticket
|
||||
con.get('ca', self.serverCertificate.value.strip()),
|
||||
con.get('ca', self.server_certificate.value.strip()),
|
||||
con['cert_subject'],
|
||||
fullscreen=self.fullScreen.as_bool(),
|
||||
fullscreen=self.fullscreen.as_bool(),
|
||||
)
|
||||
|
||||
r.usb_auto_share = self.usbShare.as_bool()
|
||||
r.new_usb_auto_share = self.autoNewUsbShare.as_bool()
|
||||
r.smartcard = self.smartCardRedirect.as_bool()
|
||||
r.ssl_connection = self.sslConnection.as_bool()
|
||||
r.usb_auto_share = self.allow_usb_redirection.as_bool()
|
||||
r.new_usb_auto_share = self.allow_usb_redirection_new_plugs.as_bool()
|
||||
r.smartcard = self.allow_smartcards.as_bool()
|
||||
r.ssl_connection = self.ssl_connection.as_bool()
|
||||
|
||||
# if sso: # If SSO requested, and when supported by platform
|
||||
# userServiceInstance.desktopLogin(user, password, '')
|
||||
@ -162,8 +163,8 @@ class TSPICETransport(BaseSpiceTransport):
|
||||
'as_file_ns': r.as_file_ns,
|
||||
'tunHost': tunHost,
|
||||
'tunPort': tunPort,
|
||||
'tunWait': self.tunnelWait.num(),
|
||||
'tunChk': self.verifyCertificate.as_bool(),
|
||||
'tunWait': self.tunnel_wait.num(),
|
||||
'tunChk': self.verify_certificate.as_bool(),
|
||||
'ticket': ticket,
|
||||
'ticket_secure': ticket_secure,
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class TestTransport(transports.Transport):
|
||||
protocol = types.transports.Protocol.OTHER
|
||||
group = types.transports.Grouping.DIRECT
|
||||
|
||||
testURL = gui.TextField(
|
||||
test_url = gui.TextField(
|
||||
label=_('URL Pattern'),
|
||||
order=1,
|
||||
tooltip=_('URL Pattern to open (i.e. https://_IP_/test?user=_USER_'),
|
||||
@ -72,7 +72,7 @@ class TestTransport(transports.Transport):
|
||||
required=True,
|
||||
)
|
||||
|
||||
forceNewWindow = gui.CheckBoxField(
|
||||
force_new_window = gui.CheckBoxField(
|
||||
label=_('Force new HTML Window'),
|
||||
order=91,
|
||||
tooltip=_(
|
||||
@ -87,8 +87,8 @@ class TestTransport(transports.Transport):
|
||||
return
|
||||
# Strip spaces
|
||||
if not (
|
||||
self.testURL.value.startswith('http://')
|
||||
or self.testURL.value.startswith('https://')
|
||||
self.test_url.value.startswith('http://')
|
||||
or self.test_url.value.startswith('https://')
|
||||
):
|
||||
raise exceptions.validation.ValidationError(
|
||||
_('The url must be http or https')
|
||||
@ -114,11 +114,11 @@ class TestTransport(transports.Transport):
|
||||
username: str = user.get_username_for_auth()
|
||||
username, password = userService.process_user_password(username, password)
|
||||
|
||||
url = self.testURL.value.replace('_IP_', ip).replace('_USER_', username)
|
||||
url = self.test_url.value.replace('_IP_', ip).replace('_USER_', username)
|
||||
|
||||
onw = (
|
||||
'&o_n_w={}'.format(hash(transport.name))
|
||||
if self.forceNewWindow.as_bool()
|
||||
if self.force_new_window.as_bool()
|
||||
else ''
|
||||
)
|
||||
return str("{}{}".format(url, onw))
|
||||
|
@ -59,22 +59,22 @@ class X2GOTransport(BaseX2GOTransport):
|
||||
type_type = 'X2GOTransport'
|
||||
type_description = _('X2Go access (Experimental). Direct connection.')
|
||||
|
||||
fixedName = BaseX2GOTransport.fixedName
|
||||
screenSize = BaseX2GOTransport.screenSize
|
||||
desktopType = BaseX2GOTransport.desktopType
|
||||
customCmd = BaseX2GOTransport.customCmd
|
||||
fixed_name = BaseX2GOTransport.fixed_name
|
||||
screen_size = BaseX2GOTransport.screen_size
|
||||
desktop_type = BaseX2GOTransport.desktop_type
|
||||
custom_cmd = BaseX2GOTransport.custom_cmd
|
||||
sound = BaseX2GOTransport.sound
|
||||
exports = BaseX2GOTransport.exports
|
||||
speed = BaseX2GOTransport.speed
|
||||
|
||||
soundType = BaseX2GOTransport.soundType
|
||||
keyboardLayout = BaseX2GOTransport.keyboardLayout
|
||||
sound_type = BaseX2GOTransport.sound_type
|
||||
keyboard_layout = BaseX2GOTransport.keyboard_layout
|
||||
pack = BaseX2GOTransport.pack
|
||||
quality = BaseX2GOTransport.quality
|
||||
|
||||
def get_transport_script( # pylint: disable=too-many-locals
|
||||
self,
|
||||
userService: 'models.UserService',
|
||||
userservice: 'models.UserService',
|
||||
transport: 'models.Transport',
|
||||
ip: str,
|
||||
os: 'types.os.DetectedOsInfo',
|
||||
@ -82,15 +82,15 @@ class X2GOTransport(BaseX2GOTransport):
|
||||
password: str,
|
||||
request: 'ExtendedHttpRequestWithUser',
|
||||
) -> 'types.transports.TransportScript':
|
||||
ci = self.get_connection_info(userService, user, password)
|
||||
ci = self.get_connection_info(userservice, user, password)
|
||||
|
||||
priv, pub = self.getAndPushKey(ci.username, userService)
|
||||
priv, pub = self.getAndPushKey(ci.username, userservice)
|
||||
|
||||
width, height = self.getScreenSize()
|
||||
rootless = False
|
||||
desktop = self.desktopType.value
|
||||
desktop = self.desktop_type.value
|
||||
if desktop == "UDSVAPP":
|
||||
desktop = "/usr/bin/udsvapp " + self.customCmd.value
|
||||
desktop = "/usr/bin/udsvapp " + self.custom_cmd.value
|
||||
rootless = True
|
||||
|
||||
xf = x2go_file.getTemplate(
|
||||
@ -113,5 +113,5 @@ class X2GOTransport(BaseX2GOTransport):
|
||||
return self.get_script(os.os.os_name(), 'direct', sp)
|
||||
except Exception:
|
||||
return super().get_transport_script(
|
||||
userService, transport, ip, os, user, password, request
|
||||
userservice, transport, ip, os, user, password, request
|
||||
)
|
||||
|
@ -68,14 +68,15 @@ class BaseX2GOTransport(transports.Transport):
|
||||
protocol = types.transports.Protocol.X2GO
|
||||
supported_oss = (types.os.KnownOS.LINUX, types.os.KnownOS.WINDOWS)
|
||||
|
||||
fixedName = gui.TextField(
|
||||
fixed_name = gui.TextField(
|
||||
order=2,
|
||||
label=_('Username'),
|
||||
tooltip=_('If not empty, this username will be always used as credential'),
|
||||
tab=types.ui.Tab.CREDENTIALS,
|
||||
stored_field_name='fixedName',
|
||||
)
|
||||
|
||||
screenSize = gui.ChoiceField(
|
||||
screen_size = gui.ChoiceField(
|
||||
label=_('Screen size'),
|
||||
order=10,
|
||||
tooltip=_('Screen size'),
|
||||
@ -89,9 +90,10 @@ class BaseX2GOTransport(transports.Transport):
|
||||
{'id': CommonPrefs.SZ_FULLSCREEN, 'text': gettext_lazy('Full Screen')},
|
||||
],
|
||||
tab=types.ui.Tab.PARAMETERS,
|
||||
stored_field_name='screenSize',
|
||||
)
|
||||
|
||||
desktopType = gui.ChoiceField(
|
||||
desktop_type = gui.ChoiceField(
|
||||
label=_('Desktop'),
|
||||
order=11,
|
||||
tooltip=_('Desktop session'),
|
||||
@ -107,15 +109,17 @@ class BaseX2GOTransport(transports.Transport):
|
||||
{'id': 'UDSVAPP', 'text': 'UDS vAPP'},
|
||||
],
|
||||
tab=types.ui.Tab.PARAMETERS,
|
||||
stored_field_name='desktopType',
|
||||
)
|
||||
|
||||
customCmd = gui.TextField(
|
||||
custom_cmd = gui.TextField(
|
||||
order=12,
|
||||
label=_('vAPP'),
|
||||
tooltip=_(
|
||||
'If UDS vAPP is selected as "Desktop", the FULL PATH of the app to be executed. If UDS vAPP is not selected, this field will be ignored.'
|
||||
),
|
||||
tab=types.ui.Tab.PARAMETERS,
|
||||
stored_field_name='customCmd',
|
||||
)
|
||||
|
||||
sound = gui.CheckBoxField(
|
||||
@ -149,7 +153,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
tab=types.ui.Tab.PARAMETERS,
|
||||
)
|
||||
|
||||
soundType = gui.ChoiceField(
|
||||
sound_type = gui.ChoiceField(
|
||||
label=_('Sound'),
|
||||
order=30,
|
||||
tooltip=_('Sound server'),
|
||||
@ -159,14 +163,16 @@ class BaseX2GOTransport(transports.Transport):
|
||||
{'id': 'esd', 'text': 'ESD'},
|
||||
],
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='soundType',
|
||||
)
|
||||
|
||||
keyboardLayout = gui.TextField(
|
||||
keyboard_layout = gui.TextField(
|
||||
label=_('Keyboard'),
|
||||
order=31,
|
||||
tooltip=_('Keyboard layout (es, us, fr, ...). Empty value means autodetect.'),
|
||||
default='',
|
||||
tab=types.ui.Tab.ADVANCED,
|
||||
stored_field_name='keyboardLayout',
|
||||
)
|
||||
# 'nopack', '8', '64', '256', '512', '4k', '32k', '64k', '256k', '2m', '16m'
|
||||
# '256-rdp', '256-rdp-compressed', '32k-rdp', '32k-rdp-compressed', '64k-rdp'
|
||||
@ -217,7 +223,7 @@ class BaseX2GOTransport(transports.Transport):
|
||||
return ready == 'Y'
|
||||
|
||||
def getScreenSize(self) -> tuple[int, int]:
|
||||
return CommonPrefs.get_wh(self.screenSize.value)
|
||||
return CommonPrefs.get_wh(self.screen_size.value)
|
||||
|
||||
def processed_username(self, userService: 'models.UserService', user: 'models.User') -> str:
|
||||
v = self.process_user_password(userService, user, '')
|
||||
@ -239,8 +245,8 @@ class BaseX2GOTransport(transports.Transport):
|
||||
|
||||
services_type_provided = service.get_type().services_type_provided
|
||||
|
||||
if self.fixedName.value != '':
|
||||
username = self.fixedName.value
|
||||
if self.fixed_name.value != '':
|
||||
username = self.fixed_name.value
|
||||
|
||||
# Fix username/password acording to os manager
|
||||
username, password = userService.process_user_password(username, password)
|
||||
|
@ -68,26 +68,27 @@ class TX2GOTransport(BaseX2GOTransport):
|
||||
group = types.transports.Grouping.TUNNELED
|
||||
|
||||
tunnel = fields.tunnel_field()
|
||||
tunnelWait = fields.tunnel_wait_time()
|
||||
tunnel_wait = fields.tunnel_wait_time()
|
||||
|
||||
verifyCertificate = gui.CheckBoxField(
|
||||
verify_certificate = gui.CheckBoxField(
|
||||
label=_('Force SSL certificate verification'),
|
||||
order=23,
|
||||
tooltip=_('If enabled, the certificate of tunnel server will be verified (recommended).'),
|
||||
default=False,
|
||||
tab=types.ui.Tab.TUNNEL,
|
||||
stored_field_name='verifyCertificate',
|
||||
)
|
||||
|
||||
fixedName = BaseX2GOTransport.fixedName
|
||||
screenSize = BaseX2GOTransport.screenSize
|
||||
desktopType = BaseX2GOTransport.desktopType
|
||||
customCmd = BaseX2GOTransport.customCmd
|
||||
fixed_name = BaseX2GOTransport.fixed_name
|
||||
screen_size = BaseX2GOTransport.screen_size
|
||||
desktop_type = BaseX2GOTransport.desktop_type
|
||||
custom_cmd = BaseX2GOTransport.custom_cmd
|
||||
sound = BaseX2GOTransport.sound
|
||||
exports = BaseX2GOTransport.exports
|
||||
speed = BaseX2GOTransport.speed
|
||||
|
||||
soundType = BaseX2GOTransport.soundType
|
||||
keyboardLayout = BaseX2GOTransport.keyboardLayout
|
||||
sound_type = BaseX2GOTransport.sound_type
|
||||
keyboard_layout = BaseX2GOTransport.keyboard_layout
|
||||
pack = BaseX2GOTransport.pack
|
||||
quality = BaseX2GOTransport.quality
|
||||
|
||||
@ -112,9 +113,9 @@ class TX2GOTransport(BaseX2GOTransport):
|
||||
width, height = self.getScreenSize()
|
||||
|
||||
rootless = False
|
||||
desktop = self.desktopType.value
|
||||
desktop = self.desktop_type.value
|
||||
if desktop == "UDSVAPP":
|
||||
desktop = "/usr/bin/udsvapp " + self.customCmd.value
|
||||
desktop = "/usr/bin/udsvapp " + self.custom_cmd.value
|
||||
rootless = True
|
||||
|
||||
xf = x2go_file.getTemplate(
|
||||
@ -134,7 +135,7 @@ class TX2GOTransport(BaseX2GOTransport):
|
||||
ticket = TicketStore.create_for_tunnel(
|
||||
userService=userService,
|
||||
port=22,
|
||||
validity=self.tunnelWait.num() + 60, # Ticket overtime
|
||||
validity=self.tunnel_wait.num() + 60, # Ticket overtime
|
||||
)
|
||||
|
||||
tunnelFields = fields.get_tunnel_from_field(self.tunnel)
|
||||
@ -143,8 +144,8 @@ class TX2GOTransport(BaseX2GOTransport):
|
||||
sp = {
|
||||
'tunHost': tunHost,
|
||||
'tunPort': tunPort,
|
||||
'tunWait': self.tunnelWait.num(),
|
||||
'tunChk': self.verifyCertificate.as_bool(),
|
||||
'tunWait': self.tunnel_wait.num(),
|
||||
'tunChk': self.verify_certificate.as_bool(),
|
||||
'ticket': ticket,
|
||||
'key': priv,
|
||||
'xf': xf,
|
||||
|
Loading…
Reference in New Issue
Block a user