mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-29 22:26:31 +00:00
graph-depends.py: support python3
This patch is the result of 2to3. In addition, universal_newlines=True is added to the Popen calls. In python3, this makes sure that the output is decoded so that we get a string instead of a buffer object. Cc: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
This commit is contained in:
parent
28cee8101d
commit
63454b1c07
@ -82,7 +82,7 @@ allpkgs = []
|
|||||||
def get_targets():
|
def get_targets():
|
||||||
sys.stderr.write("Getting targets\n")
|
sys.stderr.write("Getting targets\n")
|
||||||
cmd = ["make", "-s", "show-targets"]
|
cmd = ["make", "-s", "show-targets"]
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
output = p.communicate()[0].strip()
|
output = p.communicate()[0].strip()
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
return None
|
return None
|
||||||
@ -98,7 +98,7 @@ def get_depends(pkgs):
|
|||||||
cmd = ["make", "-s" ]
|
cmd = ["make", "-s" ]
|
||||||
for pkg in pkgs:
|
for pkg in pkgs:
|
||||||
cmd.append("%s-show-depends" % pkg)
|
cmd.append("%s-show-depends" % pkg)
|
||||||
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
|
||||||
output = p.communicate()[0]
|
output = p.communicate()[0]
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
sys.stderr.write("Error getting dependencies %s\n" % pkgs)
|
sys.stderr.write("Error getting dependencies %s\n" % pkgs)
|
||||||
@ -203,7 +203,7 @@ elif mode == MODE_PKG:
|
|||||||
# Make the dependencies a dictionnary { 'pkg':[dep1, dep2, ...] }
|
# Make the dependencies a dictionnary { 'pkg':[dep1, dep2, ...] }
|
||||||
dict_deps = {}
|
dict_deps = {}
|
||||||
for dep in dependencies:
|
for dep in dependencies:
|
||||||
if not dict_deps.has_key(dep[0]):
|
if dep[0] not in dict_deps:
|
||||||
dict_deps[dep[0]] = []
|
dict_deps[dep[0]] = []
|
||||||
dict_deps[dep[0]].append(dep[1])
|
dict_deps[dep[0]].append(dep[1])
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ for dep in dependencies:
|
|||||||
# transitive) of pkg2, dependencies being listed in the deps
|
# transitive) of pkg2, dependencies being listed in the deps
|
||||||
# dictionary. Returns False otherwise.
|
# dictionary. Returns False otherwise.
|
||||||
def is_dep(pkg,pkg2,deps):
|
def is_dep(pkg,pkg2,deps):
|
||||||
if deps.has_key(pkg2):
|
if pkg2 in deps:
|
||||||
for p in deps[pkg2]:
|
for p in deps[pkg2]:
|
||||||
if pkg == p:
|
if pkg == p:
|
||||||
return True
|
return True
|
||||||
@ -248,10 +248,10 @@ def remove_toolchain_deps(pkg,deps):
|
|||||||
# This functions trims down the dependency list of all packages.
|
# This functions trims down the dependency list of all packages.
|
||||||
# It applies in sequence all the dependency-elimination methods.
|
# It applies in sequence all the dependency-elimination methods.
|
||||||
def remove_extra_deps(deps):
|
def remove_extra_deps(deps):
|
||||||
for pkg in deps.keys():
|
for pkg in list(deps.keys()):
|
||||||
if not pkg == 'all':
|
if not pkg == 'all':
|
||||||
deps[pkg] = remove_toolchain_deps(pkg,deps)
|
deps[pkg] = remove_toolchain_deps(pkg,deps)
|
||||||
for pkg in deps.keys():
|
for pkg in list(deps.keys()):
|
||||||
if not transitive or pkg == 'all':
|
if not transitive or pkg == 'all':
|
||||||
deps[pkg] = remove_transitive_deps(pkg,deps)
|
deps[pkg] = remove_transitive_deps(pkg,deps)
|
||||||
return deps
|
return deps
|
||||||
@ -274,8 +274,8 @@ def print_attrs(pkg):
|
|||||||
color = host_colour
|
color = host_colour
|
||||||
else:
|
else:
|
||||||
color = target_colour
|
color = target_colour
|
||||||
print "%s [label = \"%s\"]" % (name, label)
|
print("%s [label = \"%s\"]" % (name, label))
|
||||||
print "%s [color=%s,style=filled]" % (name, color)
|
print("%s [color=%s,style=filled]" % (name, color))
|
||||||
|
|
||||||
# Print the dependency graph of a package
|
# Print the dependency graph of a package
|
||||||
def print_pkg_deps(depth, pkg):
|
def print_pkg_deps(depth, pkg):
|
||||||
@ -283,17 +283,17 @@ def print_pkg_deps(depth, pkg):
|
|||||||
return
|
return
|
||||||
done_deps.append(pkg)
|
done_deps.append(pkg)
|
||||||
print_attrs(pkg)
|
print_attrs(pkg)
|
||||||
if not dict_deps.has_key(pkg):
|
if pkg not in dict_deps:
|
||||||
return
|
return
|
||||||
if max_depth == 0 or depth < max_depth:
|
if max_depth == 0 or depth < max_depth:
|
||||||
for d in dict_deps[pkg]:
|
for d in dict_deps[pkg]:
|
||||||
print "%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d))
|
print("%s -> %s" % (pkg_node_name(pkg), pkg_node_name(d)))
|
||||||
print_pkg_deps(depth+1, d)
|
print_pkg_deps(depth+1, d)
|
||||||
|
|
||||||
# Start printing the graph data
|
# Start printing the graph data
|
||||||
print "digraph G {"
|
print("digraph G {")
|
||||||
|
|
||||||
done_deps = []
|
done_deps = []
|
||||||
print_pkg_deps(0, rootpkg)
|
print_pkg_deps(0, rootpkg)
|
||||||
|
|
||||||
print "}"
|
print("}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user