From 6038f931897bda1782a6244848893512b3d80f2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adolfo=20G=C3=B3mez=20Garc=C3=ADa?= Date: Thu, 14 Nov 2019 09:27:26 +0100 Subject: [PATCH] Fixing up services --- server/src/uds/services/OVirt/provider.py | 3 +-- server/src/uds/services/Sample/__init__.py | 2 +- server/src/uds/services/Sample/provider.py | 2 +- server/src/uds/services/Sample/publication.py | 9 ++++----- server/src/uds/services/Sample/service.py | 3 +-- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/server/src/uds/services/OVirt/provider.py b/server/src/uds/services/OVirt/provider.py index 4abf1e93..10f64656 100644 --- a/server/src/uds/services/OVirt/provider.py +++ b/server/src/uds/services/OVirt/provider.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # # Copyright (c) 2012-2019 Virtual Cable S.L. # All rights reserved. @@ -423,7 +422,7 @@ class OVirtProvider(services.ServiceProvider): # pylint: disable=too-many-publi return self.__getApi().getConsoleConnection(machineId) @staticmethod - def test(env, data): + def test(env: 'Environment', data: 'Module.ValuesType') -> typing.List[typing.Any]: """ Test ovirt Connectivity diff --git a/server/src/uds/services/Sample/__init__.py b/server/src/uds/services/Sample/__init__.py index b93d46e4..2afbe453 100644 --- a/server/src/uds/services/Sample/__init__.py +++ b/server/src/uds/services/Sample/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2012 Virtual Cable S.L. +# Copyright (c) 2012-2019 Virtual Cable S.L. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, diff --git a/server/src/uds/services/Sample/provider.py b/server/src/uds/services/Sample/provider.py index 2bec3a8e..d15ad81c 100644 --- a/server/src/uds/services/Sample/provider.py +++ b/server/src/uds/services/Sample/provider.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2012 Virtual Cable S.L. +# Copyright (c) 2012-2019 Virtual Cable S.L. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, diff --git a/server/src/uds/services/Sample/publication.py b/server/src/uds/services/Sample/publication.py index 9c684791..36542757 100644 --- a/server/src/uds/services/Sample/publication.py +++ b/server/src/uds/services/Sample/publication.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2012 Virtual Cable S.L. +# Copyright (c) 2012-2019 Virtual Cable S.L. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -30,6 +30,8 @@ """ .. moduleauthor:: Adolfo Gómez, dkmaster at dkmon dot com """ +import random +import string import logging import typing @@ -193,7 +195,6 @@ class SamplePublication(services.Publication): In our case, destroy is 1-step action so this will no get called while destroying... """ - import random self._number -= 1 # Serialization will take care of storing self._number @@ -215,10 +216,8 @@ class SamplePublication(services.Publication): Returned value, if any, is ignored """ - import string - import random # Make simply a random string - self._name = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10)) + self._name = ''.join(random.SystemRandom().choices(string.ascii_uppercase + string.digits, k=10)) def reasonOfError(self) -> str: """ diff --git a/server/src/uds/services/Sample/service.py b/server/src/uds/services/Sample/service.py index 7e5d8aca..b62e38d9 100644 --- a/server/src/uds/services/Sample/service.py +++ b/server/src/uds/services/Sample/service.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# Copyright (c) 2012 Virtual Cable S.L. +# Copyright (c) 2012-2019 Virtual Cable S.L. # All rights reserved. # # Redistribution and use in source and binary forms, with or without modification, @@ -196,7 +196,6 @@ class ServiceOne(services.Service): return self.baseName.value - class ServiceTwo(services.Service): """ Just a second service, no comments here (almost same that ServiceOne