1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-13 13:17:54 +03:00

* Moved some more values to consts

* Fixed bugs on references on UserInterface
* Added a new tests for internal data to userService
This commit is contained in:
Adolfo Gómez García 2023-08-31 17:41:16 +02:00
parent 412f1e36b4
commit 66090e181d
No known key found for this signature in database
GPG Key ID: DD1ABF20724CDA23
45 changed files with 328 additions and 189 deletions

View File

@ -34,10 +34,9 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
# We use commit/rollback
from ...utils.test import UDSTestCase
from uds.core.ui.user_interface import gui, UDSB, UDSK
import time
from django.conf import settings
from uds.core.util import ensure
class GuiTest(UDSTestCase):
def test_globals(self):
@ -79,10 +78,10 @@ class GuiTest(UDSTestCase):
# 1. Empty list
# 2.- single string
# 3.- A list of strings
self.assertEqual(gui.convertToList([]), [])
self.assertEqual(gui.convertToList('aaaa'), ['aaaa'])
self.assertEqual(gui.convertToList(['a', 'b']), ['a', 'b'])
self.assertEqual(gui.convertToList(1), ['1'])
self.assertEqual(ensure.is_list([]), [])
self.assertEqual(ensure.is_list('aaaa'), ['aaaa'])
self.assertEqual(ensure.is_list(['a', 'b']), ['a', 'b'])
self.assertEqual(ensure.is_list(1), [1])
def test_choice_image(self) -> None:
# id, text, and base64 image
@ -93,8 +92,8 @@ class GuiTest(UDSTestCase):
def test_to_bool(self) -> None:
for val in ('true', 'True', 'TRUE', 'yes', 'Yes', 'YES', '1'):
self.assertTrue(gui.toBool(val), 'Failed to convert {} to True'.format(val))
self.assertTrue(gui.toBool(val), f'Failed to convert "{val}" to True')
for val in ('false', 'False', 'FALSE', 'no', 'No', 'NO', '0'):
self.assertFalse(
gui.toBool(val), 'Failed to convert {} to False'.format(val)
gui.toBool(val), f'Failed to convert "{val}" to False'
)

View File

@ -0,0 +1,108 @@
# -*- coding: utf-8 -*-
#
# Copyright (c) 2022 Virtual Cable S.L.U.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of Virtual Cable S.L.U. nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
import typing
# We use commit/rollback
from ...utils.test import UDSTestCase
from uds.core import types, consts
from uds.core.ui.user_interface import gui
from ...fixtures.user_interface import TestingUserInterface, DEFAULTS
logger = logging.getLogger(__name__)
class UserinterfaceTestInternalData(UDSTestCase):
def test_data(self):
# This test is to ensure that old serialized data can be loaded
# This data is from a
ui = TestingUserInterface()
self.assertEqual(ui.str_field.value, DEFAULTS['str_field'])
self.assertEqual(ui.str_auto_field.value, DEFAULTS['str_auto_field'])
self.assertEqual(ui.num_field.value, DEFAULTS['num_field'])
self.assertEqual(ui.password_field.value, DEFAULTS['password_field'])
self.assertEqual(ui.hidden_field.value, DEFAULTS['hidden_field'])
self.assertEqual(ui.choice_field.value, DEFAULTS['choice_field'])
self.assertEqual(ui.multi_choice_field.value, DEFAULTS['multi_choice_field'])
self.assertEqual(ui.editable_list_field.value, DEFAULTS['editable_list_field'])
self.assertEqual(ui.checkbox_field.value, DEFAULTS['checkbox_field'])
self.assertEqual(ui.image_choice_field.value, DEFAULTS['image_choice_field'])
self.assertEqual(ui.image_field.value, DEFAULTS['image_field'])
self.assertEqual(ui.date_field.value, DEFAULTS['date_field'])
self.assertEqual(ui.info_field.value, DEFAULTS['info_field'])
# Ensure references are fine
self.assertEqual(ui.str_field.value, ui._gui['str_field'].value)
self.assertEqual(ui.str_auto_field.value, ui._gui['str_auto_field'].value)
self.assertEqual(ui.num_field.value, ui._gui['num_field'].value)
self.assertEqual(ui.password_field.value, ui._gui['password_field'].value)
self.assertEqual(ui.hidden_field.value, ui._gui['hidden_field'].value)
self.assertEqual(ui.choice_field.value, ui._gui['choice_field'].value)
self.assertEqual(ui.multi_choice_field.value, ui._gui['multi_choice_field'].value)
self.assertEqual(ui.editable_list_field.value, ui._gui['editable_list_field'].value)
self.assertEqual(ui.checkbox_field.value, ui._gui['checkbox_field'].value)
self.assertEqual(ui.image_choice_field.value, ui._gui['image_choice_field'].value)
self.assertEqual(ui.image_field.value, ui._gui['image_field'].value)
self.assertEqual(ui.date_field.value, ui._gui['date_field'].value)
self.assertEqual(ui.info_field.value, ui._gui['info_field'].value)
# Modify values, and recheck references
ui.str_field.value = 'New value'
self.assertEqual(ui.str_field.value, ui._gui['str_field'].value)
ui.str_auto_field.value = 'New value'
self.assertEqual(ui.str_auto_field.value, ui._gui['str_auto_field'].value)
ui.num_field.value = 100
self.assertEqual(ui.num_field.value, ui._gui['num_field'].value)
ui.password_field.value = 'New value'
self.assertEqual(ui.password_field.value, ui._gui['password_field'].value)
ui.hidden_field.value = 'New value'
self.assertEqual(ui.hidden_field.value, ui._gui['hidden_field'].value)
ui.choice_field.value = 'New value'
self.assertEqual(ui.choice_field.value, ui._gui['choice_field'].value)
ui.multi_choice_field.value = ['New value', 'New value 2']
self.assertEqual(ui.multi_choice_field.value, ui._gui['multi_choice_field'].value)
ui.editable_list_field.value = ['New value', 'New value 2']
self.assertEqual(ui.editable_list_field.value, ui._gui['editable_list_field'].value)
ui.checkbox_field.value = False
self.assertEqual(ui.checkbox_field.value, ui._gui['checkbox_field'].value)
ui.image_choice_field.value = 'New value'
self.assertEqual(ui.image_choice_field.value, ui._gui['image_choice_field'].value)
ui.image_field.value = 'New value'
self.assertEqual(ui.image_field.value, ui._gui['image_field'].value)
ui.date_field.value = '2001-01-01'
self.assertEqual(ui.date_field.value, ui._gui['date_field'].value)
ui.info_field.value = 'New value'
self.assertEqual(ui.info_field.value, ui._gui['info_field'].value)

View File

@ -37,7 +37,7 @@ import typing
# We use commit/rollback
from ...utils.test import UDSTestCase
from uds.core import types
from uds.core import types, consts
from uds.core.ui.user_interface import gui
from ...fixtures.user_interface import TestingUserInterface, DEFAULTS
@ -85,7 +85,7 @@ def oldSerializeForm(ui) -> bytes:
# logger.debug('Field {} is a dummy field and will not be serialized')
continue
if v.isType(types.ui.FieldType.EDITABLE_LIST) or v.isType(
types.ui.FieldType.MULTI_CHOICE
types.ui.FieldType.MULTICHOICE
):
# logger.debug('Serializing value {0}'.format(v.value))
val = MULTIVALUE_FIELD + pickle.dumps(v.value, protocol=0)
@ -100,9 +100,9 @@ def oldSerializeForm(ui) -> bytes:
else:
val = v.value.encode('utf8')
if val is True:
val = gui.TRUE.encode('utf8')
val = consts.TRUE_STR.encode('utf8')
elif val is False:
val = gui.FALSE.encode('utf8')
val = consts.FALSE_STR.encode('utf8')
arr.append(k.encode('utf8') + NAME_VALUE_SEPARATOR + val)
logger.debug('Arr, >>%s<<', arr)
@ -154,7 +154,7 @@ class UserinterfaceTest(UDSTestCase):
data = oldSerializeForm(ui)
ui2 = TestingUserInterface()
ui2.oldDeserializeForm(data)
self.assertEqual(ui, ui2)
self.ensure_values_fine(ui2)

View File

@ -33,7 +33,7 @@ import datetime
from uds.core.ui.user_interface import UserInterface, gui
DEFAULTS = {
DEFAULTS: typing.Dict[str, typing.Union[str, int, typing.List[str]]] = {
'str_field': 'Default value text',
'str_auto_field': 'Default value auto',
'num_field': 50,
@ -101,7 +101,7 @@ class TestingUserInterface(UserInterface):
order=5,
tooltip='This is a multi choice field',
required=True,
default=DEFAULTS['multi_choice_field'],
default=typing.cast(typing.List[str], DEFAULTS['multi_choice_field']),
choices=['Value 1', 'Value 2', 'Value 3'],
)
editable_list_field = gui.EditableListField(
@ -140,6 +140,10 @@ class TestingUserInterface(UserInterface):
required=True,
default=DEFAULTS['date_field'],
)
info_field = gui.InfoField(
label='title',
default=DEFAULTS['info_field'],
)
# Equals operator, to speed up tests writing

View File

@ -36,7 +36,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import auths, types
from uds.core import auths, types, consts
from uds.core.ui import gui
from uds.core.util import net
@ -49,7 +49,7 @@ if typing.TYPE_CHECKING:
class IPAuth(auths.Authenticator):
acceptProxy = gui.CheckBoxField(
label=_('Accept proxy'),
default=gui.FALSE,
default=consts.FALSE_STR,
order=50,
tooltip=_(
'If checked, requests via proxy will get FORWARDED ip address'

View File

@ -55,9 +55,7 @@ MAC_UNKNOWN: typing.Final[str] = '00:00:00:00:00:00'
SERVER_DEFAULT_LISTEN_PORT: typing.Final[int] = 43910
# REST Related constants
OK: typing.Final[
str
] = 'ok' # Constant to be returned when result is just "operation complete successfully"
OK: typing.Final[str] = 'ok' # Constant to be returned when result is just "operation complete successfully"
# Maximum number of failures before blocking on REST API
ALLOWED_FAILS: typing.Final[int] = 5
@ -66,3 +64,25 @@ ALLOWED_FAILS: typing.Final[int] = 5
USER_AGENT: typing.Final[str] = f'UDS/{VERSION}'
COMMS_TIMEOUT: typing.Final[int] = 5 # Timeout for communications with servers
MIN_SERVER_VERSION: typing.Final[str] = '4.0.0'
# For conversion to boolean
BOOL_TRUE_VALUES: typing.Final[typing.Set[typing.Union[bool, str, bytes, int]]] = {
True,
'TRUE',
'True',
b'true',
b'True',
b'TRUE',
1,
'1',
b'1',
'true',
'YES',
'Yes',
'yes',
'ENABLED',
'Enabled',
'enabled',
}
TRUE_STR: typing.Final[str] = 'true'
FALSE_STR: typing.Final[str] = 'false'

View File

@ -30,19 +30,18 @@
"""
Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import sys
import os.path
import codecs
import logging
import os.path
import sys
import typing
from django.utils.translation import gettext as _
from uds.core.ui.user_interface import UserInterface
from .serializable import Serializable
from .environment import Environment, Environmentable
from .serializable import Serializable
logger = logging.getLogger(__name__)

View File

@ -33,9 +33,7 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
import logging
import typing
from uds.core.module import Module
from uds.core.environment import Environment
from uds.core import module, environment, consts
from uds.core.util import log
from uds.core.ui import gui
@ -47,7 +45,7 @@ if typing.TYPE_CHECKING:
logger = logging.getLogger(__name__)
class ServiceProvider(Module):
class ServiceProvider(module.Module):
"""
Base Service Provider Class.
@ -149,8 +147,8 @@ class ServiceProvider(Module):
def __init__(
self,
environment: Environment,
values: 'Module.ValuesType' = None,
environment: environment.Environment,
values: 'module.Module.ValuesType' = None,
uuid: typing.Optional[str] = None,
):
"""
@ -163,7 +161,7 @@ class ServiceProvider(Module):
super().__init__(environment, values, uuid=uuid)
self.initialize(values)
def initialize(self, values: 'Module.ValuesType') -> None:
def initialize(self, values: 'module.Module.ValuesType') -> None:
"""
This method will be invoked from __init__ constructor.
This is provided so you don't have to provide your own __init__ method,
@ -214,7 +212,7 @@ class ServiceProvider(Module):
val = self.ignoreLimits = False
val = getattr(val, 'value', val)
return val is True or val == gui.TRUE
return val is True or val == consts.TRUE_STR
def doLog(self, level: log.LogLevel, message: str) -> None:
"""

View File

@ -68,7 +68,7 @@ class FieldType(enum.StrEnum):
PASSWORD = 'password' # nosec: this is not a password
HIDDEN = 'hidden'
CHOICE = 'choice'
MULTI_CHOICE = 'multichoice'
MULTICHOICE = 'multichoice'
EDITABLE_LIST = 'editlist'
CHECKBOX = 'checkbox'
IMAGE_CHOICE = 'imgchoice'
@ -115,7 +115,7 @@ class ChoiceType(typing.TypedDict):
text: str
ChoicesType = typing.Union[typing.Callable[[], typing.List[ChoiceType]], typing.List[ChoiceType]]
ChoicesType = typing.Union[typing.Callable[[], typing.Iterable[ChoiceType]], typing.Iterable[ChoiceType]]
@dataclasses.dataclass

View File

@ -45,7 +45,7 @@ import abc
from django.utils.translation import gettext as _
from uds.core import exceptions, types
from uds.core import consts, exceptions, types
from uds.core.managers.crypto import UDSK, CryptoManager
from uds.core.util import serializer, validators, ensure
from uds.core.util.decorators import deprecatedClassValue
@ -108,11 +108,6 @@ class gui:
],
]
# : True string value
TRUE: typing.ClassVar[str] = 'true'
# : False string value
FALSE: typing.ClassVar[str] = 'false'
# : For backward compatibility, will be removed in future versions
# For now, will log a warning if used
@deprecatedClassValue('types.ui.Tab.ADVANCED')
@ -168,7 +163,7 @@ class gui:
@staticmethod
def convertToChoices(
vals: typing.Union[
typing.Iterable[typing.Union[str, typing.Dict[str, str]]],
typing.Iterable[typing.Union[str, types.ui.ChoiceType]],
typing.Dict[str, str],
None,
]
@ -187,7 +182,7 @@ class gui:
return vals
# Helper to convert an item to a dict
def choiceFromValue(val: typing.Union[str, int, typing.Dict[str, str]]) -> 'types.ui.ChoiceType':
def choiceFromValue(val: typing.Union[str, int, types.ui.ChoiceType]) -> 'types.ui.ChoiceType':
if isinstance(val, dict):
if 'id' not in val or 'text' not in val:
raise ValueError(f'Invalid choice dict: {val}')
@ -230,7 +225,7 @@ class gui:
Returns:
True if the string is "true" (case insensitive), False else.
"""
return value in (True, 'True', b'true', b'True', 1, '1', b'1', gui.TRUE)
return value in consts.BOOL_TRUE_VALUES
@staticmethod
def fromBool(bol: bool) -> str:
@ -245,8 +240,8 @@ class gui:
"true" if bol evals to True, "false" if don't.
"""
if bol:
return gui.TRUE
return gui.FALSE
return consts.TRUE_STR
return consts.FALSE_STR
# Classes
@ -460,7 +455,7 @@ class gui:
return str(self.value)
def __repr__(self):
return repr(self._data)
return f'{self.__class__.__name__}: {repr(self._data)}'
class TextField(InputField):
"""
@ -584,7 +579,7 @@ class gui:
self._data.choices = gui.convertToChoices(kwargs.get('choices', []))
def setChoices(self, values: typing.Iterable[typing.Union[str, typing.Dict[str, str]]]):
def setChoices(self, values: typing.Iterable[typing.Union[str, types.ui.ChoiceType]]):
"""
Set the values for this choice field
"""
@ -921,7 +916,7 @@ class gui:
if fills['callbackName'] not in gui.callbacks:
gui.callbacks[fills['callbackName']] = fnc
def setChoices(self, values: typing.Iterable[typing.Union[str, typing.Dict[str, str]]]):
def setChoices(self, values: typing.Iterable[typing.Union[str, types.ui.ChoiceType]]):
"""
Set the values for this choice field
"""
@ -942,7 +937,7 @@ class gui:
self._data.choices = gui.convertToChoices(kwargs.get('choices', []))
def setChoices(self, values: typing.Iterable[typing.Union[str, typing.Dict[str, str]]]):
def setChoices(self, values: typing.Iterable[typing.Union[str, types.ui.ChoiceType]]):
"""
Set the values for this choice field
"""
@ -977,29 +972,42 @@ class gui:
readonly = False, rows = 5, order = 8,
tooltip = _('Datastores where to put incrementals'),
required = True,
values = [ {'id': '0', 'text': 'datastore0' },
choices = [ {'id': '0', 'text': 'datastore0' },
{'id': '1', 'text': 'datastore1' } ]
)
"""
def __init__(self, **kwargs):
super().__init__(**kwargs, type=types.ui.FieldType.MULTI_CHOICE)
if 'values' in kwargs:
caller = inspect.stack()[1]
logger.warning(
'Field %s: "values" parameter is deprecated, use "choices" instead. Called from %s:%s',
kwargs.get('label', ''),
caller.filename,
caller.lineno,
)
kwargs['choices'] = kwargs['values']
def __init__(
self,
label: str = '',
readonly: bool = False,
rows: typing.Optional[int] = None,
order: int = 0,
tooltip: str = '',
required: bool = False,
choices: typing.Union[
typing.Iterable[typing.Union[str, types.ui.ChoiceType]],
typing.Dict[str, str],
None,
] = None,
tab: typing.Optional[typing.Union[str, types.ui.Tab]] = None,
default: typing.Union[str, typing.Iterable[str]] = '',
):
super().__init__(
label=label,
readonly=readonly,
order=order,
tooltip=tooltip,
required=required,
tab=tab,
type=types.ui.FieldType.MULTICHOICE,
default=default,
)
if kwargs.get('choices') and isinstance(kwargs.get('choices'), dict):
kwargs['choices'] = gui.convertToChoices(kwargs['choices'])
self._data.rows = kwargs.get('rows', -1)
self._data.choices = gui.convertToChoices(kwargs.get('choices', []))
self._data.rows = rows
self._data.choices = gui.convertToChoices(choices or [])
def setChoices(self, values: typing.Iterable[typing.Union[str, typing.Dict[str, str]]]):
def setChoices(self, values: typing.Iterable[typing.Union[str, types.ui.ChoiceType]]):
"""
Set the values for this choice field
"""
@ -1085,8 +1093,9 @@ class UserInterfaceType(type):
# (we will update references on class 'self' to the new copy)
for attrName, attr in namespace.items():
if isinstance(attr, gui.InputField):
# Ensure we have a copy of the data, so we can modify it without affecting others
attr._data = copy.deepcopy(attr._data)
_gui[attrName] = attr
_gui[attrName]._data = copy.deepcopy(attr._data)
newClassDict[attrName] = attr
newClassDict['_base_gui'] = _gui
@ -1132,8 +1141,10 @@ class UserInterface(metaclass=UserInterfaceType):
# If a field has a callable on defined attributes(value, default, choices)
# update the reference to the new copy
for _, val in self._gui.items(): # And refresh self references to them
# cast _data to dict, so we can check for deveral values
for key, val in self._gui.items(): # And refresh self references to them
setattr(self, key, val) # Reference to self._gui[key]
# Check for "callable" fields and update them if needed
for field in ['choices', 'value', 'default']: # ['value', 'default']:
logger.debug('Checking field %s', field)
attr = getattr(val._data, field, None)
@ -1200,7 +1211,7 @@ class UserInterface(metaclass=UserInterfaceType):
for k, v in self._gui.items():
if v.isType(types.ui.FieldType.EDITABLE_LIST):
dic[k] = ensure.is_list(v.value)
elif v.isType(types.ui.FieldType.MULTI_CHOICE):
elif v.isType(types.ui.FieldType.MULTICHOICE):
dic[k] = gui.convertToChoices(v.value)
else:
dic[k] = v.value
@ -1233,9 +1244,9 @@ class UserInterface(metaclass=UserInterfaceType):
),
types.ui.FieldType.HIDDEN: (lambda x: None if not x.isSerializable() else x.value),
types.ui.FieldType.CHOICE: lambda x: x.value,
types.ui.FieldType.MULTI_CHOICE: lambda x: codecs.encode(serialize(x.value), 'base64').decode(),
types.ui.FieldType.MULTICHOICE: lambda x: codecs.encode(serialize(x.value), 'base64').decode(),
types.ui.FieldType.EDITABLE_LIST: lambda x: codecs.encode(serialize(x.value), 'base64').decode(),
types.ui.FieldType.CHECKBOX: lambda x: gui.TRUE if x.isTrue() else gui.FALSE,
types.ui.FieldType.CHECKBOX: lambda x: consts.TRUE_STR if x.isTrue() else consts.FALSE_STR,
types.ui.FieldType.IMAGE_CHOICE: lambda x: x.value,
types.ui.FieldType.IMAGE: lambda x: x.value,
types.ui.FieldType.DATE: lambda x: x.value,
@ -1305,7 +1316,7 @@ class UserInterface(metaclass=UserInterfaceType):
),
types.ui.FieldType.HIDDEN: lambda x: None,
types.ui.FieldType.CHOICE: lambda x: x,
types.ui.FieldType.MULTI_CHOICE: lambda x: deserialize(codecs.decode(x.encode(), 'base64')),
types.ui.FieldType.MULTICHOICE: lambda x: deserialize(codecs.decode(x.encode(), 'base64')),
types.ui.FieldType.EDITABLE_LIST: lambda x: deserialize(codecs.decode(x.encode(), 'base64')),
types.ui.FieldType.CHECKBOX: lambda x: x,
types.ui.FieldType.IMAGE_CHOICE: lambda x: x,

View File

@ -34,7 +34,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import mfas, types
from uds.core import mfas, types, consts
from uds.core.ui import gui
if typing.TYPE_CHECKING:
@ -55,7 +55,7 @@ class SampleMFA(mfas.MFA):
order=90,
tooltip=_('This is a useless field, for sample and testing pourposes'),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
def initialize(self, values: 'Module.ValuesType') -> None:

View File

@ -75,8 +75,7 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
import logging
import typing
from uds.core import services, types
from uds.core.environment import Environment
from uds.core import services, consts
from uds.core.ui import gui
from . import _migrator
@ -95,15 +94,15 @@ class RDSProvider(services.ServiceProvider):
# Gui
ipList = gui.EditableListField()
serverCheck = gui.CheckBoxField(default=gui.FALSE)
serverCheck = gui.CheckBoxField(default=consts.FALSE_STR)
# User mapping, classical
useUserMapping = gui.CheckBoxField(default=gui.FALSE)
useUserMapping = gui.CheckBoxField(default=consts.FALSE_STR)
userMap = gui.EditableListField()
userPass = gui.PasswordField()
# User creating, new
useUserCreation = gui.CheckBoxField(default=gui.FALSE)
useUserCreation = gui.CheckBoxField(default=consts.FALSE_STR)
adHost = gui.TextField()
adPort = gui.NumericField(default='636')
adUsersDn = gui.TextField()

View File

@ -31,7 +31,7 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
import logging
from uds.core.ui import gui
from uds.core import transports
from uds.core import transports, consts
from . import _migrator
@ -60,7 +60,7 @@ class HTML5RDPTransport(transports.Transport):
wallpaper = gui.CheckBoxField()
desktopComp = gui.CheckBoxField()
smooth = gui.CheckBoxField()
enableAudio = gui.CheckBoxField(default=gui.TRUE)
enableAudio = gui.CheckBoxField(default=consts.TRUE_STR)
enableAudioInput = gui.CheckBoxField()
enablePrinting = gui.CheckBoxField()
enableFileSharing = gui.ChoiceField(default='false')
@ -70,7 +70,7 @@ class HTML5RDPTransport(transports.Transport):
ticketValidity = gui.NumericField(default='60')
forceNewWindow = gui.ChoiceField(default=gui.FALSE)
forceNewWindow = gui.ChoiceField(default=consts.FALSE_STR)
security = gui.ChoiceField(default='any')
rdpPort = gui.NumericField(default='3389')

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -56,7 +56,7 @@ class HTML5RDSTransport(transports.Transport):
wallpaper = gui.CheckBoxField()
desktopComp = gui.CheckBoxField()
smooth = gui.CheckBoxField()
enableAudio = gui.CheckBoxField(default=gui.TRUE)
enableAudio = gui.CheckBoxField(default=consts.TRUE_STR)
enableAudioInput = gui.CheckBoxField()
enablePrinting = gui.CheckBoxField()
enableFileSharing = gui.ChoiceField(default='false')
@ -64,7 +64,7 @@ class HTML5RDSTransport(transports.Transport):
serverLayout = gui.ChoiceField(default='-')
ticketValidity = gui.NumericField(default='60')
forceNewWindow = gui.ChoiceField(default=gui.FALSE)
forceNewWindow = gui.ChoiceField(default=consts.FALSE_STR)
security = gui.ChoiceField(default='any')
rdpPort = gui.NumericField(default='3389')

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -54,7 +54,7 @@ class HTML5SSHTransport(transports.Transport):
sshHostKey = gui.TextField()
serverKeepAlive = gui.NumericField(default='30')
ticketValidity = gui.NumericField(default='60')
forceNewWindow = gui.ChoiceField(default=gui.FALSE)
forceNewWindow = gui.ChoiceField(default=consts.FALSE_STR)
# This value is the new "tunnel server"
# Old guacamoleserver value will be stored also on database, but will be ignored

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -57,7 +57,7 @@ class HTML5VNCTransport(transports.Transport):
cursor = gui.CheckBoxField()
readOnly = gui.CheckBoxField()
ticketValidity = gui.NumericField(default='60')
forceNewWindow = gui.ChoiceField(default=gui.FALSE)
forceNewWindow = gui.ChoiceField(default=consts.FALSE_STR)
# This value is the new "tunnel server"
# Old guacamoleserver value will be stored also on database, but will be ignored

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -50,7 +50,7 @@ class NICEDCVTunnelTransport(transports.Transport):
tunnelServer = gui.TextField()
tunnelWait = gui.NumericField(default='60')
verifyCertificate = gui.CheckBoxField(default=gui.TRUE)
verifyCertificate = gui.CheckBoxField(default=consts.TRUE_STR)
useEmptyCreds = gui.CheckBoxField()
fixedName = gui.TextField()
fixedPassword = gui.PasswordField()

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -49,7 +49,7 @@ class TSNoMachineTransport(transports.Transport):
tunnelServer = gui.TextField()
tunnelWait = gui.NumericField(default='30')
verifyCertificate = gui.CheckBoxField(default=gui.FALSE)
verifyCertificate = gui.CheckBoxField(default=consts.FALSE_STR)
useEmptyCreds = gui.CheckBoxField()
fixedName = gui.TextField()
fixedPassword = gui.PasswordField()

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -49,7 +49,7 @@ class TRDPTransport(transports.Transport):
tunnelServer = gui.TextField()
tunnelWait = gui.NumericField(default='60')
verifyCertificate = gui.CheckBoxField(default=gui.FALSE)
verifyCertificate = gui.CheckBoxField(default=consts.FALSE_STR)
useEmptyCreds = gui.CheckBoxField()
fixedName = gui.TextField()
fixedPassword = gui.PasswordField()
@ -60,25 +60,25 @@ class TRDPTransport(transports.Transport):
allowDrives = gui.ChoiceField(default='false')
enforceDrives = gui.TextField()
allowSerials = gui.CheckBoxField()
allowClipboard = gui.CheckBoxField(default=gui.TRUE)
allowAudio = gui.CheckBoxField(default=gui.TRUE)
allowWebcam = gui.CheckBoxField(default=gui.FALSE)
allowClipboard = gui.CheckBoxField(default=consts.TRUE_STR)
allowAudio = gui.CheckBoxField(default=consts.TRUE_STR)
allowWebcam = gui.CheckBoxField(default=consts.FALSE_STR)
usbRedirection = gui.ChoiceField(default='false')
credssp = gui.CheckBoxField(default=gui.TRUE)
credssp = gui.CheckBoxField(default=consts.TRUE_STR)
rdpPort = gui.NumericField(default='3389')
screenSize = gui.ChoiceField(default='-1x-1')
colorDepth = gui.ChoiceField(default='24')
wallpaper = gui.CheckBoxField()
multimon = gui.CheckBoxField()
aero = gui.CheckBoxField()
smooth = gui.CheckBoxField(default=gui.TRUE)
showConnectionBar = gui.CheckBoxField(default=gui.TRUE)
smooth = gui.CheckBoxField(default=consts.TRUE_STR)
showConnectionBar = gui.CheckBoxField(default=consts.TRUE_STR)
multimedia = gui.CheckBoxField()
alsa = gui.CheckBoxField()
printerString = gui.TextField()
smartcardString = gui.TextField()
customParameters = gui.TextField()
allowMacMSRDC = gui.CheckBoxField(default=gui.FALSE)
allowMacMSRDC = gui.CheckBoxField(default=consts.FALSE_STR)
customParametersMAC = gui.TextField()
customParametersWindows = gui.TextField()
optimizeTeams = gui.CheckBoxField()

View File

@ -30,8 +30,8 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core import consts, transports
from uds.core.ui import gui
from uds.core import transports
from . import _migrator
@ -47,7 +47,7 @@ class TRDSTransport(transports.Transport):
default='30',
)
verifyCertificate = gui.CheckBoxField(default=gui.FALSE)
verifyCertificate = gui.CheckBoxField(default=consts.FALSE_STR)
useEmptyCreds = gui.CheckBoxField()
withoutDomain = gui.CheckBoxField()
@ -57,15 +57,15 @@ class TRDSTransport(transports.Transport):
allowDrives = gui.ChoiceField(default='false')
enforceDrives = gui.TextField()
allowSerials = gui.CheckBoxField()
allowClipboard = gui.CheckBoxField(default=gui.TRUE)
allowAudio = gui.CheckBoxField(default=gui.TRUE)
allowWebcam = gui.CheckBoxField(default=gui.FALSE)
credssp = gui.CheckBoxField(default=gui.TRUE)
allowClipboard = gui.CheckBoxField(default=consts.TRUE_STR)
allowAudio = gui.CheckBoxField(default=consts.TRUE_STR)
allowWebcam = gui.CheckBoxField(default=consts.FALSE_STR)
credssp = gui.CheckBoxField(default=consts.TRUE_STR)
rdpPort = gui.NumericField(default='3389')
colorDepth = gui.ChoiceField()
smooth = gui.CheckBoxField(default=gui.TRUE)
smooth = gui.CheckBoxField(default=consts.TRUE_STR)
windowState = gui.ChoiceField(default='normal')
executeAsShell = gui.CheckBoxField(default=gui.TRUE)
executeAsShell = gui.CheckBoxField(default=consts.TRUE_STR)
multimedia = gui.CheckBoxField()
alsa = gui.CheckBoxField()
printerString = gui.TextField()

View File

@ -31,7 +31,7 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
import logging
from uds.core.ui import gui
from uds.core import transports
from uds.core import transports, consts
from . import _migrator
@ -51,10 +51,10 @@ class TSPICETransport(transports.Transport):
verifyCertificate = gui.CheckBoxField()
serverCertificate = gui.TextField()
fullScreen = gui.CheckBoxField()
smartCardRedirect = gui.CheckBoxField(default=gui.FALSE)
usbShare = gui.CheckBoxField(default=gui.FALSE)
autoNewUsbShare = gui.CheckBoxField(default=gui.FALSE)
SSLConnection = gui.CheckBoxField(default=gui.TRUE)
smartCardRedirect = gui.CheckBoxField(default=consts.FALSE_STR)
usbShare = gui.CheckBoxField(default=consts.FALSE_STR)
autoNewUsbShare = gui.CheckBoxField(default=consts.FALSE_STR)
SSLConnection = gui.CheckBoxField(default=consts.TRUE_STR)
overridedProxy = gui.TextField()

View File

@ -30,9 +30,9 @@ Author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import logging
from uds.core.ui import gui
from uds.core import consts, transports
from uds.core.types.preferences import CommonPrefs
from uds.core import transports
from uds.core.ui import gui
from . import _migrator
@ -50,13 +50,13 @@ class TX2GOTransport(transports.Transport):
tunnelServer = gui.TextField()
tunnelWait = gui.NumericField(default='30')
verifyCertificate = gui.CheckBoxField(default=gui.FALSE)
verifyCertificate = gui.CheckBoxField(default=consts.FALSE_STR)
fixedName = gui.TextField()
screenSize = gui.ChoiceField(default=CommonPrefs.SZ_FULLSCREEN)
desktopType = gui.ChoiceField()
customCmd = gui.TextField()
sound = gui.CheckBoxField(default=gui.TRUE)
exports = gui.CheckBoxField(default=gui.FALSE)
sound = gui.CheckBoxField(default=consts.TRUE_STR)
exports = gui.CheckBoxField(default=consts.FALSE_STR)
speed = gui.ChoiceField(default='3')
soundType = gui.ChoiceField(default='pulse')
keyboardLayout = gui.TextField(default='')

View File

@ -37,7 +37,7 @@ import typing
from django.utils.translation import gettext_lazy
from django.utils.translation import gettext_noop as _
from uds.core import exceptions, types
from uds.core import exceptions, types, consts
from uds.core.managers.crypto import CryptoManager
from uds.core.ui import gui
@ -118,21 +118,21 @@ class LinuxOsADManager(LinuxOsManager):
'If checked, UDS will try to remove the machine from the domain USING the provided credentials'
),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
ssl = gui.CheckBoxField(
label=_('Use SSL'),
order=8,
tooltip=_('If checked, a ssl connection to Active Directory will be used'),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
automaticIdMapping = gui.CheckBoxField(
label=_('Automatic ID mapping'),
order=9,
tooltip=_('If checked, automatic ID mapping'),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
# Inherits base "onLogout"

View File

@ -37,7 +37,7 @@ import typing
from django.utils.translation import gettext_lazy
from django.utils.translation import gettext_noop as _
from uds.core import exceptions, types
from uds.core import exceptions, types, consts
from uds.core.managers.crypto import CryptoManager
from uds.core.ui import gui
@ -110,21 +110,21 @@ class LinuxOsFreeIPAManager(LinuxOsManager):
'If checked, UDS will try to remove the machine from the domain USING the provided credentials'
),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
ssl = gui.CheckBoxField(
label=_('Use SSL'),
order=7,
tooltip=_('If checked, a ssl connection to Active Directory will be used'),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
automaticIdMapping = gui.CheckBoxField(
label=_('Automatic ID mapping'),
order=8,
tooltip=_('If checked, automatic ID mapping'),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
# Inherits base "onLogout"

View File

@ -36,7 +36,7 @@ import typing
from django.utils.translation import gettext_lazy
from django.utils.translation import gettext_noop as _
from uds.core import osmanagers, types
from uds.core import osmanagers, types, consts
from uds.core.types.services import ServiceType as serviceTypes
from uds.core.ui import gui
from uds.core.util import log
@ -93,7 +93,7 @@ class LinuxOsManager(osmanagers.OSManager):
'If checked, UDS will try to logout user when the calendar for his current access expires'
),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
def __setProcessUnusedMachines(self) -> None:

View File

@ -69,7 +69,7 @@ class TestOSManager(osmanagers.OSManager):
'text': gettext_lazy('Keep service assigned even on new publication'),
},
],
default='keep',
default='remove',
)
idle = gui.NumericField(

View File

@ -15,7 +15,7 @@ import typing
from django.utils.translation import gettext_lazy
from django.utils.translation import gettext_noop as _
from uds.core import exceptions, osmanagers, types
from uds.core import exceptions, osmanagers, types, consts
from uds.core.types.services import ServiceType as serviceTypes
from uds.core.ui import gui
from uds.core.util import log
@ -84,7 +84,7 @@ class WindowsOsManager(osmanagers.OSManager):
'If checked, UDS will try to logout user when the calendar for his current access expires'
),
tab=types.ui.Tab.ADVANCED,
default=gui.TRUE,
default=consts.TRUE_STR,
)
_onLogout: str

View File

@ -41,7 +41,7 @@ import ldap
from django.utils.translation import gettext_noop as _
from uds.core.ui import gui
from uds.core.managers.crypto import CryptoManager
from uds.core import exceptions
from uds.core import exceptions, consts
from uds.core.util import log
from uds.core.util import ldaputil
@ -107,7 +107,7 @@ class WinDomainOsManager(WindowsOsManager):
'If checked, UDS will try to remove the machine from the domain USING the provided credentials'
),
tab=_('Advanced'),
default=gui.TRUE,
default=consts.TRUE_STR,
)
serverHint = gui.TextField(
length=64,
@ -121,7 +121,7 @@ class WinDomainOsManager(WindowsOsManager):
order=10,
tooltip=_('If checked, a ssl connection to Active Directory will be used'),
tab=_('Advanced'),
default=gui.TRUE,
default=consts.TRUE_STR,
)
# Inherits base "onLogout"

View File

@ -35,6 +35,7 @@ import logging
import typing
from django.utils.translation import gettext_noop as _
from uds.core import types
from uds.core.ui import gui
@ -114,7 +115,7 @@ def source_field_data(
model: typing.Any,
field: typing.Union[gui.ChoiceField, gui.MultiChoiceField],
) -> None:
dataList: typing.List[gui.ChoiceType] = [
dataList: typing.List[types.ui.ChoiceType] = [
gui.choiceItem(str(x.uuid), x.name) for x in model.objects.all().order_by('name')
]

View File

@ -34,7 +34,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import types, services
from uds.core import types, services, consts
from uds.core.transports import protocols
from uds.core.ui import gui
@ -137,7 +137,7 @@ class OGService(services.Service):
startIfUnavailable = gui.CheckBoxField(
label=_('Start if unavailable'),
default=gui.TRUE,
default=consts.TRUE_STR,
order=111,
tooltip=_(
'If active, machines that are not available on user connect (on some OS) will try to power on through OpenGnsys.'

View File

@ -35,7 +35,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import types
from uds.core import types, consts
from uds.core.services import ServiceProvider
from uds.core.ui import gui
from uds.core.util import validators
@ -204,7 +204,7 @@ class OpenStackProvider(ServiceProvider):
tooltip=_(
'If checked, the name of the subnets will be used instead of the names of networks'
),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)

View File

@ -33,7 +33,7 @@ import re
import typing
from django.utils.translation import gettext_noop as _
from uds.core import services, types
from uds.core import services, types, consts
from uds.core.transports import protocols
from uds.core.ui import gui
from uds.core.util import validators
@ -125,7 +125,7 @@ class ProxmoxLinkedService(services.Service): # pylint: disable=too-many-public
guestShutdown = gui.CheckBoxField(
label=_('Try SOFT Shutdown first'),
default=gui.FALSE,
default=consts.FALSE_STR,
order=103,
tooltip=_(
'If active, UDS will try to shutdown (soft) the machine using VMWare Guest Tools. Will delay 30 seconds the power off of hanged machines.'

View File

@ -37,7 +37,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import services, exceptions
from uds.core import services, exceptions, consts
from uds.core.ui import gui
from .service import ServiceOne, ServiceTwo
@ -137,7 +137,7 @@ class Provider(services.ServiceProvider):
order=5,
label=_('Is Methuselah still alive?'),
tooltip=_('If you fail, this will not get saved :-)'),
default=gui.TRUE, # : By default, at new item, check this
default=consts.TRUE_STR, # : By default, at new item, check this
)
# : Is Methuselah istill alive?
@ -145,7 +145,7 @@ class Provider(services.ServiceProvider):
order=5,
label=_('Is Methuselah still alive BBBB?'),
tooltip=_('If you fail, this will not get saved BBBB'),
default=gui.TRUE, # : By default, at new item, check this
default=consts.TRUE_STR, # : By default, at new item, check this
)
# : Is Methuselah istill alive?
@ -153,7 +153,7 @@ class Provider(services.ServiceProvider):
order=5,
label=_('Is Methuselah still alive CCCC?'),
tooltip=_('If you fail, this will not get saved CCCC'),
default=gui.TRUE, # : By default, at new item, check this
default=consts.TRUE_STR, # : By default, at new item, check this
)
methText = gui.TextField(

View File

@ -33,7 +33,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import types
from uds.core import types, consts
from uds.core.services import ServiceProvider
from uds.core.ui import gui
from uds.core.util.cache import Cache
@ -163,7 +163,7 @@ class XenProvider(ServiceProvider): # pylint: disable=too-many-public-methods
'If selected, certificate will be checked against system valid certificate providers'
),
tab=types.ui.Tab.ADVANCED,
default=gui.FALSE,
default=consts.FALSE_STR,
)
hostBackup = gui.TextField(

View File

@ -37,7 +37,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds import models
from uds.core import transports, types, ui
from uds.core import transports, types, ui, consts
from uds.core.managers.crypto import CryptoManager
from uds.core.util import fields, os_detector
from uds.core.util.model import getSqlDatetime
@ -136,7 +136,7 @@ class HTML5RDPTransport(transports.Transport):
order=21,
tooltip=_('If checked, the audio will be redirected to remote session (if client browser supports it)'),
tab=types.ui.Tab.PARAMETERS,
default=ui.gui.TRUE,
default=consts.TRUE_STR,
)
enableAudioInput = ui.gui.CheckBoxField(
label=_('Enable Microphone'),
@ -220,16 +220,16 @@ class HTML5RDPTransport(transports.Transport):
required=True,
choices=[
ui.gui.choiceItem(
ui.gui.FALSE,
consts.FALSE_STR,
_('Open every connection on the same window, but keeps UDS window.'),
),
ui.gui.choiceItem(ui.gui.TRUE, _('Force every connection to be opened on a new window.')),
ui.gui.choiceItem(consts.TRUE_STR, _('Force every connection to be opened on a new window.')),
ui.gui.choiceItem(
'overwrite',
_('Override UDS window and replace it with the connection.'),
),
],
default=ui.gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)
security = ui.gui.ChoiceField(
@ -472,7 +472,7 @@ class HTML5RDPTransport(transports.Transport):
ticket = models.TicketStore.create(params, validity=self.ticketValidity.num())
onw = f'&o_n_w={transport.uuid}'
if self.forceNewWindow.value == ui.gui.TRUE:
if self.forceNewWindow.value == consts.TRUE_STR:
onw = f'&o_n_w={userService.deployed_service.uuid}'
elif self.forceNewWindow.value == 'overwrite':
onw = '&o_s_w=yes'

View File

@ -224,7 +224,7 @@ class HTML5SSHTransport(transports.Transport):
ticket = models.TicketStore.create(params, validity=self.ticketValidity.num())
onw = ''
if self.forceNewWindow.value == gui.TRUE:
if self.forceNewWindow.value == consts.TRUE_STR:
onw = 'o_n_w={}'
elif self.forceNewWindow.value == 'overwrite':
onw = 'o_s_w=yes'

View File

@ -197,7 +197,7 @@ class HTML5VNCTransport(transports.Transport):
ticket = models.TicketStore.create(params, validity=self.ticketValidity.num())
onw = ''
if self.forceNewWindow.value == gui.TRUE:
if self.forceNewWindow.value == consts.TRUE_STR:
onw = 'o_n_w={}'
elif self.forceNewWindow.value == 'overwrite':
onw = 'o_s_w=yes'

View File

@ -35,7 +35,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core.ui import gui
from uds.core import transports, types
from uds.core import transports, types, consts
from uds.models import UserService
# Not imported at runtime, just for type checking
@ -135,21 +135,21 @@ class BaseRDPTransport(transports.Transport):
order=25,
tooltip=_('If checked, copy-paste functions will be allowed'),
tab=types.ui.Tab.PARAMETERS,
default=gui.TRUE,
default=consts.TRUE_STR,
)
allowAudio = gui.CheckBoxField(
label=_('Enable sound'),
order=26,
tooltip=_('If checked, sound will be redirected.'),
tab=types.ui.Tab.PARAMETERS,
default=gui.TRUE,
default=consts.TRUE_STR,
)
allowWebcam = gui.CheckBoxField(
label=_('Enable webcam'),
order=27,
tooltip=_('If checked, webcam will be redirected (ONLY Windows).'),
tab=types.ui.Tab.PARAMETERS,
default=gui.FALSE,
default=consts.FALSE_STR,
)
usbRedirection = gui.ChoiceField(
label=_('USB redirection'),
@ -173,7 +173,7 @@ class BaseRDPTransport(transports.Transport):
order=29,
tooltip=_('If checked, will enable Credentials Provider Support)'),
tab=types.ui.Tab.PARAMETERS,
default=gui.TRUE,
default=consts.TRUE_STR,
)
rdpPort = gui.NumericField(
order=30,
@ -247,7 +247,7 @@ class BaseRDPTransport(transports.Transport):
)
smooth = gui.CheckBoxField(
label=_('Font Smoothing'),
default=gui.TRUE,
default=consts.TRUE_STR,
order=36,
tooltip=_('If checked, fonts smoothing will be allowed'),
tab=types.ui.Tab.DISPLAY,
@ -257,7 +257,7 @@ class BaseRDPTransport(transports.Transport):
order=37,
tooltip=_('If checked, connection bar will be shown (only on Windows clients)'),
tab=types.ui.Tab.DISPLAY,
default=gui.TRUE,
default=consts.TRUE_STR,
)
multimedia = gui.CheckBoxField(
@ -301,7 +301,7 @@ class BaseRDPTransport(transports.Transport):
order=50,
tooltip=_('If checked, allows use of Microsoft Remote Desktop Client. PASSWORD WILL BE PROMPTED!'),
tab='Mac OS X',
default=gui.FALSE,
default=consts.FALSE_STR,
)
customParametersMAC = gui.TextField(

View File

@ -34,7 +34,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import transports, types
from uds.core import transports, types, consts
from uds.core.ui import gui
from uds.core.util import fields, os_detector, validators
from uds.models import TicketStore
@ -75,7 +75,7 @@ class TRDPTransport(BaseRDPTransport):
label=_('Force SSL certificate verification'),
order=23,
tooltip=_('If enabled, the certificate of tunnel server will be verified (recommended).'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.TUNNEL,
)

View File

@ -35,7 +35,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core.ui import gui
from uds.core import transports, types
from uds.core import transports, types, consts
from uds.core.transports import protocols
# Not imported at runtime, just for type checking
@ -96,28 +96,28 @@ class BaseSpiceTransport(transports.Transport):
order=6,
label=_('Smartcard Redirect'),
tooltip=_('If checked, SPICE protocol will allow smartcard redirection.'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)
usbShare = gui.CheckBoxField(
order=7,
label=_('Enable USB'),
tooltip=_('If checked, USB redirection will be allowed.'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)
autoNewUsbShare = gui.CheckBoxField(
order=8,
label=_('New USB Auto Sharing'),
tooltip=_('Auto-redirect USB devices when plugged in.'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)
SSLConnection = gui.CheckBoxField(
order=9,
label=_('SSL Connection'),
tooltip=_('If checked, SPICE protocol will allow SSL connections.'),
default=gui.TRUE,
default=consts.TRUE_STR,
tab=types.ui.Tab.ADVANCED,
)

View File

@ -34,7 +34,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import exceptions, transports, types
from uds.core import exceptions, transports, types, consts
from uds.core.ui import gui
from uds.core.util import fields, validators
from uds.models import TicketStore
@ -74,7 +74,7 @@ class TSPICETransport(BaseSpiceTransport):
tooltip=_(
'If enabled, the certificate of tunnel server will be verified (recommended).'
),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.TUNNEL,
)

View File

@ -36,15 +36,15 @@ import typing
from django.utils.translation import gettext_noop as _
from uds import models
from uds.core import exceptions, types, transports
from uds.core import consts, exceptions, transports, types
from uds.core.ui import gui
from uds.core.util import os_detector as OsDetector
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
from uds.core.module import Module
from uds.core.util.os_detector import DetectedOsInfo
from uds.core.types.request import ExtendedHttpRequestWithUser
from uds.core.util.os_detector import DetectedOsInfo
logger = logging.getLogger(__name__)
@ -79,7 +79,7 @@ class TestTransport(transports.Transport):
tooltip=_(
'If checked, every connection will try to open its own window instead of reusing the "global" one.'
),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)

View File

@ -36,7 +36,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds import models
from uds.core import exceptions, transports, types
from uds.core import exceptions, transports, types, consts
from uds.core.ui import gui
from uds.core.util import os_detector as OsDetector
@ -80,7 +80,7 @@ class URLCustomTransport(transports.Transport):
tooltip=_(
'If checked, every connection will try to open its own window instead of reusing the "global" one.'
),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.ADVANCED,
)

View File

@ -30,20 +30,20 @@
"""
@author: Adolfo Gómez, dkmaster at dkmon dot com
"""
import os
import io
import logging
import os
import typing
import paramiko
from django.utils.translation import gettext_lazy
from django.utils.translation import gettext_noop as _
from django.utils.translation import gettext_noop as _, gettext_lazy
from uds.core import consts, transports, types
from uds.core.managers.user_service import UserServiceManager
from uds.core.types.preferences import CommonPrefs
from uds.core.ui import gui
from uds.core import transports, types
from uds.core.util import os_detector
from uds.core.util import connection
from uds.core.util import connection, os_detector
# Not imported at runtime, just for type checking
if typing.TYPE_CHECKING:
@ -121,7 +121,7 @@ class BaseX2GOTransport(transports.Transport):
order=13,
label=_('Enable sound'),
tooltip=_('If checked, sound will be available'),
default=gui.TRUE,
default=consts.TRUE_STR,
tab=types.ui.Tab.PARAMETERS,
)
@ -129,7 +129,7 @@ class BaseX2GOTransport(transports.Transport):
order=14,
label=_('Redirect home folder'),
tooltip=_('If checked, user home folder will be redirected. (On linux, also redirects /media)'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.PARAMETERS,
)

View File

@ -34,7 +34,7 @@ import typing
from django.utils.translation import gettext_noop as _
from uds.core import transports, types
from uds.core import transports, types, consts
from uds.core.ui import gui
from uds.core.util import fields, validators
from uds.models import TicketStore
@ -74,7 +74,7 @@ class TX2GOTransport(BaseX2GOTransport):
label=_('Force SSL certificate verification'),
order=23,
tooltip=_('If enabled, the certificate of tunnel server will be verified (recommended).'),
default=gui.FALSE,
default=consts.FALSE_STR,
tab=types.ui.Tab.TUNNEL,
)