Esempio n. 1
0
def AddInfoFromPip(grph, node, packageKey):
    try:
        # TODO: What about several Python versions ?
        installed_packages = lib_python.PipGetInstalledDistributions()

        # TODO: Maybe the version should be part of the key.
        for pckg in installed_packages:
            if packageKey == pckg.key:
                FillOnePackage(grph, node, pckg)
            else:
                for subReq in pckg.requires():
                    # sys.stderr.write("subReq.key=%s pckg.key=%s\n"%(subReq.key,packageKey))
                    if subReq.key == packageKey:
                        subNode = MakeUri(pckg.key)
                        # [('>=', '4.0.0')]+[]+[('>=','4.0')]+[]
                        aSpecs = subReq.specs
                        if aSpecs:
                            # TODO: This should be displayed on the edge !!!
                            grph.add(
                                (node,
                                 lib_common.MakeProp("Condition " + pckg.key),
                                 lib_common.NodeLiteral(str(aSpecs))))
                        grph.add((subNode, propPythonRequires, node))
                        break

    except Exception:
        exc = sys.exc_info()[1]
        grph.add(
            (node, pc.property_information, lib_common.NodeLiteral(str(exc))))
Esempio n. 2
0
def _add_info_from_pip(grph, node, package_key):
    """Each entity can have such a file with its name as file name.
    Then in its file, by convention adds information to a node."""
    try:
        # TODO: What about several Python versions ?
        installed_packages = lib_python.PipGetInstalledDistributions()

        # TODO: Maybe the version should be part of the key.
        for pckg in installed_packages:
            if package_key == pckg.key:
                _fill_one_package(grph, node, pckg)
            else:
                for sub_req in pckg.requires():
                    if sub_req.key == package_key:
                        subNode = MakeUri(pckg.key)
                        # [('>=', '4.0.0')]+[]+[('>=','4.0')]+[]
                        a_specs = sub_req.specs
                        if a_specs:
                            # TODO: This should be displayed on the edge !!!
                            grph.add(
                                (node,
                                 lib_common.MakeProp("Condition " + pckg.key),
                                 lib_util.NodeLiteral(str(a_specs))))
                        grph.add((subNode, prop_python_requires, node))
                        break

    except Exception as exc:
        grph.add(
            (node, pc.property_information, lib_util.NodeLiteral(str(exc))))
Esempio n. 3
0
def Main():
	cgiEnv = lib_common.CgiEnv()

	Main.dictKeyToPckg = dict()

	def KeyToPckgNode(key):
		try:
			packageNode = Main.dictKeyToPckg[ key ]
		except KeyError:
			packageNode = package.MakeUri( key )
			Main.dictKeyToPckg[ key ] = packageNode
		return packageNode

	grph = cgiEnv.GetGraph()

	# TODO: What about several Python versions ?
	installed_packages = lib_python.PipGetInstalledDistributions()

	cnt = 0

	# TODO: Maybe the version should be part of the key.
	for pckg in installed_packages:
		cnt += 1

		sys.stderr.write("cnt=%d key=%s\n" % (cnt,pckg.key) )

		# With this module, "dot" crashes...
		# TODO: WHY IS THIS BROKEN ?????
		if pckg.key in ["aff4-snappy"]:
			continue

		packageNode = KeyToPckgNode( pckg.key )
		grph.add( ( packageNode, package.propPythonVersion, lib_common.NodeLiteral(pckg.version) ) )

		reqPckg = pckg.requires()
		if reqPckg:
			for subReq in pckg.requires():
				subNode = KeyToPckgNode( subReq.key )

				# TODO: Should do that on the edge !!!!!
				# [('>=', '4.0.0')]+[]+[('>=','4.0')]+[]
				# aSpecs = subReq.specs
				# if aSpecs:
				#	grph.add( (subNode, lib_common.MakeProp("Condition"), lib_common.NodeLiteral( str(aSpecs) ) ) )

				grph.add( (packageNode, package.propPythonRequires, subNode ) )
		else:
			grph.add( ( lib_common.nodeMachine, package.propPythonPackage, packageNode ) )

	cgiEnv.OutCgiRdf("LAYOUT_SPLINE")