Fix unittest issues introduced by shopfloor v2
BUG=none
TEST=manually run shopfloor_unittest.py and './shopfloord -t'
Original-Change-Id: Ia0dd2773b26b82fb557dce4c124b4bc537c95376
Reviewed-on: https://gerrit.chromium.org/gerrit/48643
Reviewed-by: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
(cherry picked from commit cefaff1f3df3c6fc7830defb7387a1b34d618158)
Change-Id: I6b5c61c3fe2d859f0739ce02240a91f435c85b68
Reviewed-on: https://gerrit.chromium.org/gerrit/48750
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Rong Chang <rongchang@chromium.org>
Tested-by: Rong Chang <rongchang@chromium.org>
diff --git a/py/shopfloor/launcher/http_service.py b/py/shopfloor/launcher/http_service.py
index 59a2257..533a147 100644
--- a/py/shopfloor/launcher/http_service.py
+++ b/py/shopfloor/launcher/http_service.py
@@ -110,7 +110,7 @@
output.append('%s"%s" => %s,' % (self._GetIndent(), key,
self._LightyConfAuto(value)))
self._DecIndent()
- output.append(self._GetIndent + ')')
+ output.append(self._GetIndent() + ')')
return '\n'.join(output)
def _LightyConfList(self, value_list):
diff --git a/py/shopfloor/launcher/shopfloord.py b/py/shopfloor/launcher/shopfloord.py
index 66aab2f..49735dc 100755
--- a/py/shopfloor/launcher/shopfloord.py
+++ b/py/shopfloor/launcher/shopfloord.py
@@ -64,7 +64,7 @@
log_format = '%(asctime)s %(levelname)s '
log_verbosity = logging.INFO
- if options.testrun:
+ if options.test_run:
log_format += '(%(filename)s:%(lineno)d) '
log_verbosity = logging.DEBUG
log_format += '%(message)s'
diff --git a/py/shopfloor/launcher/update_service.py b/py/shopfloor/launcher/update_service.py
index a93a6ed..5a55159 100644
--- a/py/shopfloor/launcher/update_service.py
+++ b/py/shopfloor/launcher/update_service.py
@@ -33,7 +33,7 @@
'name': 'updatersvc',
'args': [
'-d', env.GetUpdatesDir(),
- '-p', constants.DEFAULT_RSYNC_PORT],
+ '-p', str(constants.DEFAULT_RSYNC_PORT)],
'path': env.GetUpdatesDir(),
'logpipe': True,
'auto_restart': True}
diff --git a/py/shopfloor/launcher/utils.py b/py/shopfloor/launcher/utils.py
index 88de84a..1c12ea3 100644
--- a/py/shopfloor/launcher/utils.py
+++ b/py/shopfloor/launcher/utils.py
@@ -18,6 +18,7 @@
from cros.factory.shopfloor.launcher.yamlconf import LauncherYAMLConfig
from cros.factory.shopfloor.launcher.http_service import HttpService
from cros.factory.shopfloor.launcher.fcgi_service import FcgiService
+from cros.factory.shopfloor.launcher.update_service import FactoryUpdateService
# Launcher config holds the dictionary deserialized from YAML config file
@@ -27,18 +28,22 @@
def StartServices():
"""Starts all services."""
+ global _launcher_services
for service in _launcher_services:
if not service.subprocess:
service.Start()
def StopServices():
"""Stops all services."""
+ global _launcher_services
for service in _launcher_services:
if service.subprocess:
service.Stop()
def UpdateConfig(yaml_config_file):
"""Loads new launcher config file and restarts all services."""
+ global _launcher_services
+ global _launcher_config
StopServices()
_launcher_config = LauncherYAMLConfig( # pylint: disable=W0621
yaml_config_file)
@@ -47,7 +52,9 @@
def GenerateServices():
"""Generates service list."""
- return [FcgiService(_launcher_config), HttpService(_launcher_config)]
+ global _launcher_config
+ return [FcgiService(_launcher_config), HttpService(_launcher_config),
+ FactoryUpdateService(_launcher_config)]
def SearchFile(filename, folders):
"""Gets first match of filename in folders.
diff --git a/py/shopfloor/shopfloor_server.py b/py/shopfloor/shopfloor_server.py
index f5531f9..397eca4 100755
--- a/py/shopfloor/shopfloor_server.py
+++ b/py/shopfloor/shopfloor_server.py
@@ -262,6 +262,7 @@
options.module)
exit(1)
+ updater = None
if options.updater:
try:
logging.debug('Loading factory updater: %s', options.updater)