From f08770884a6f1c5b9dec808a128ff919d1265e32 Mon Sep 17 00:00:00 2001 From: Stephen Kyle Date: Wed, 7 Apr 2021 17:09:51 +0100 Subject: [PATCH] speedometer: fix @once methods which declare attributes We need to make those attributes class-attributes, to make sure they are still defined in subsequent jobs. We still access them through 'self', however. --- wa/workloads/speedometer/__init__.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/wa/workloads/speedometer/__init__.py b/wa/workloads/speedometer/__init__.py index 0b696949..36078e1d 100755 --- a/wa/workloads/speedometer/__init__.py +++ b/wa/workloads/speedometer/__init__.py @@ -128,7 +128,7 @@ class Speedometer(Workload): @once def initialize(self, context): super(Speedometer, self).initialize(context) - self.archive_server = ArchiveServer() + Speedometer.archive_server = ArchiveServer() if not self.target.is_rooted: raise WorkloadError( "Device must be rooted for the speedometer workload currently" @@ -148,18 +148,17 @@ class Speedometer(Workload): # Temporary directory used for storing the Speedometer files, uiautomator # dumps, and modified XML chrome config files. - self.temp_dir = tempfile.TemporaryDirectory() - self.document_root = os.path.join(self.temp_dir.name, "document_root") + Speedometer.temp_dir = tempfile.TemporaryDirectory() + Speedometer.document_root = os.path.join(self.temp_dir.name, "document_root") # Host a copy of Speedometer locally tarball = context.get_resource(File(self, "speedometer_archive.tgz")) with tarfile.open(name=tarball) as handle: handle.extractall(self.temp_dir.name) self.archive_server.start(self.document_root, self.target) - self.webserver_port = self.archive_server.get_port() - self.speedometer_url = "http://localhost:{}/Speedometer2.0/index.html".format( - self.webserver_port + Speedometer.speedometer_url = "http://localhost:{}/Speedometer2.0/index.html".format( + self.archive_server.get_port() ) def setup(self, context):