Return-Path: Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mail.openembedded.org (Postfix) with ESMTP id 53A056BCD6 for ; Mon, 21 Oct 2019 10:30:07 +0000 (UTC) Received: by mail-wr1-f51.google.com with SMTP id p4so13298057wrm.8 for ; Mon, 21 Oct 2019 03:30:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=pGM4XeiKExKCsKe7Io3YCz2yBK330CUplK7+7uqXa6c=; b=m5ERpLPmnEbJfrKNb3ac8a4JJ9SByqsxGnagvD/nZqbscpM/x804mqR1PI6d1Abmt4 QoSihYQ4r+tCmWssPWDbZs+IwuR+tWnUs4ke14g/Vw9Z9Orh3hRfj/+bUdT04ZxTrEoj eABLy1v1bgAHk+7/yXl2esyYC/BsNN10ESKjTs6d3xXDt4bUe92JJ+Vug/jmHX6i6y26 1ErtVl64rtDB8vH3jZkzZQ+rFat1YDdkI2rFcrxFjxXgq3kd2SYjr6nGQ9Mea76SstO/ FPXJi3OrScTpltXqU0tZuefXoqnWR2OaD/XS+sXr11fZ88hRclIz9e9WIQbkxGODujXe YP9A== X-Gm-Message-State: APjAAAU44yyn8lvJIGghwKB9HKw6IIqUeOmEIYyhzG9qBRLV++vrJfAF UUYmu9NJBALVVvn02ex4fTNqh5z0 X-Google-Smtp-Source: APXvYqzRzbKVjwXzMU6cHp9bqON3DmQH9WWQ+MSDkUi1yZRw7FPoGa63ZioLvSnJpTQXoZfZML/bbA== X-Received: by 2002:adf:f686:: with SMTP id v6mr20565229wrp.141.1571653807489; Mon, 21 Oct 2019 03:30:07 -0700 (PDT) Received: from 1aq-andre.garage.tyco.com ([77.107.218.170]) by smtp.gmail.com with ESMTPSA id 126sm14893069wma.48.2019.10.21.03.30.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2019 03:30:06 -0700 (PDT) From: =?UTF-8?q?Andr=C3=A9=20Draszik?= To: openembedded-core@lists.openembedded.org Date: Mon, 21 Oct 2019 11:30:06 +0100 Message-Id: <20191021103006.26194-1-git@andred.net> X-Mailer: git-send-email 2.23.0.rc1 MIME-Version: 1.0 Subject: [PATCH] oeqa/runtime/context.py: ignore more files when loading controllers X-BeenThere: openembedded-core@lists.openembedded.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Patches and discussions about the oe-core layer List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Oct 2019 10:30:07 -0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When loading controllers as (external) modules, the code currently tries to load all files ending with .py. This is a problem when during development using an editor that creates a lock-file in the same directory as the .py file, as the lock file is typically called '.#xxxx.py'. Python will try to load the lock file and fail miserably with an exception: The stack trace of python calls that resulted in this exception/failure was: File: 'exec_python_func() autogenerated', lineno: 2, function: 0001: *** 0002:do_testimage(d) 0003: File: 'poky/meta/classes/testimage.bbclass', lineno: 114, function: do_testimage 0110: netstat -an 0111:} 0112: 0113:python do_testimage() { *** 0114: testimage_main(d) 0115:} 0116: 0117:addtask testimage 0118:do_testimage[nostamp] = "1" File: 'poky/meta/classes/testimage.bbclass', lineno: 294, function: testimage_main 0290: 0291: # the robot dance 0292: target = OERuntimeTestContextExecutor.getTarget( 0293: d.getVar("TEST_TARGET"), logger, d.getVar("TEST_TARGET_IP"), *** 0294: d.getVar("TEST_SERVER_IP"), **target_kwargs) 0295: 0296: # test context 0297: tc = OERuntimeTestContext(td, logger, target, host_dumper, 0298: image_packages, extract_dir) File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 116, function: getTarget 0112: # XXX: Don't base your targets on this code it will be refactored 0113: # in the near future. 0114: # Custom target module loading 0115: target_modules_path = kwargs.get('target_modules_path', '') *** 0116: controller = OERuntimeTestContextExecutor.getControllerModule(target_type, target_modules_path) 0117: target = controller(logger, target_ip, server_ip, **kwargs) 0118: 0119: return target 0120: File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 128, function: getControllerModule 0124: # ImportError raised if a provided module can not be imported. 0125: @staticmethod 0126: def getControllerModule(target, target_modules_path): 0127: controllerslist = OERuntimeTestContextExecutor._getControllerModulenames(target_modules_path) *** 0128: controller = OERuntimeTestContextExecutor._loadControllerFromName(target, controllerslist) 0129: return controller 0130: 0131: # Return a list of all python modules in lib/oeqa/controllers for each 0132: # layer in bbpath File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 163, function: _loadControllerFromName 0159: # Raise ImportError if a provided module can not be imported 0160: @staticmethod 0161: def _loadControllerFromName(target, modulenames): 0162: for name in modulenames: *** 0163: obj = OERuntimeTestContextExecutor._loadControllerFromModule(target, name) 0164: if obj: 0165: return obj 0166: raise AttributeError("Unable to load {0} from available modules: {1}".format(target, str(modulenames))) 0167: File: 'poky/meta/lib/oeqa/runtime/context.py', lineno: 173, function: _loadControllerFromModule 0169: @staticmethod 0170: def _loadControllerFromModule(target, modulename): 0171: obj = None 0172: # import module, allowing it to raise import exception *** 0173: module = __import__(modulename, globals(), locals(), [target]) 0174: # look for target class in the module, catching any exceptions as it 0175: # is valid that a module may not have the target class. 0176: try: 0177: obj = getattr(module, target) Exception: ImportError: No module named 'oeqa.controllers.' Simply ignore those when collecting the list of files to try to load. Signed-off-by: André Draszik --- meta/lib/oeqa/runtime/context.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/lib/oeqa/runtime/context.py b/meta/lib/oeqa/runtime/context.py index 77d58eefa7..ef738a3359 100644 --- a/meta/lib/oeqa/runtime/context.py +++ b/meta/lib/oeqa/runtime/context.py @@ -138,7 +138,7 @@ class OERuntimeTestContextExecutor(OETestContextExecutor): def add_controller_list(path): if not os.path.exists(os.path.join(path, '__init__.py')): raise OSError('Controllers directory %s exists but is missing __init__.py' % path) - files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_')]) + files = sorted([f for f in os.listdir(path) if f.endswith('.py') and not f.startswith('_') and not f.startswith('.#')]) for f in files: module = 'oeqa.controllers.' + f[:-3] if module not in controllerslist: -- 2.23.0.rc1