Skip to content

Commit

Permalink
script: update common.py for python3
Browse files Browse the repository at this point in the history
  • Loading branch information
SakuraKyuo committed Dec 18, 2024
1 parent 6df68f1 commit 9f9af91
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions bin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import getopt
import getpass
import gzip
import imp
import importlib.util
import time
import json
import logging
Expand Down Expand Up @@ -2793,15 +2793,22 @@ def __init__(self, **kwargs):
return
try:
if os.path.isdir(path):
info = imp.find_module("releasetools", [path])
module_name = "releasetools"
spec = importlib.util.find_spec(module_name, path)
else:
d, f = os.path.split(path)
b, x = os.path.splitext(f)
if x == ".py":
f = b
info = imp.find_module(f, [d])
logger.info("loaded device-specific extensions from %s", path)
self.module = imp.load_module("device_specific", *info)
module_name = f
spec = importlib.util.find_spec(module_name, d)

if spec is not None:
self.module = importlib.util.module_from_spec(spec)
spec.loader.exec_module(self.module)
logger.info("loaded device-specific extensions from %s", path)
else:
logger.error("Module %s not found in %s", module_name, path)
except ImportError:
logger.info("unable to load device-specific module; assuming none")

Expand Down

0 comments on commit 9f9af91

Please sign in to comment.