Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add basic html output to conan list #13135

Merged
merged 5 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conan/cli/formatters/list/list.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import os

from jinja2 import Template, select_autoescape
Expand All @@ -15,6 +16,6 @@ def list_packages_html(result):
user_template = os.path.join(template_folder, "list_packages.html")
template = load(user_template) if os.path.isfile(user_template) else list_packages_html_template
template = Template(template, autoescape=select_autoescape(['html', 'xml']))
content = template.render(results=results, base_template_path=template_folder,
content = template.render(results=json.dumps(results), base_template_path=template_folder,
version=client_version)
cli_out_write(content)
73 changes: 22 additions & 51 deletions conan/cli/formatters/list/search_table_html.py
Original file line number Diff line number Diff line change
@@ -1,57 +1,28 @@
list_packages_html_template = r"""
<!DOCTYPE html>
<html lang="en">
<head>
<title>Conan | {{ reference }}</title>
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.21/css/dataTables.bootstrap.min.css"/>
<style>
tr td {
white-space:nowrap;
}
</style>
</head>
<body>
<div class="container-fluid">
<h1>{{ reference }}</h1>
<div class="info">
<p>
Depending on your package_id_mode, any combination of settings, options and requirements
can give you a different packageID. Take into account that your configuration might be
different from the one used to generate the packages.
</p>
</div>
<head>
<title>conan list results</title>
<script>
var list_results = {{ results|safe }};
document.addEventListener("DOMContentLoaded", function () {
var divContainer = document.getElementById("showResults");
divContainer.innerHTML = JSON.stringify(list_results, null, 2);
});
</script>
</head>


<table id="results" class="table table-striped table-bordered" style="width:100%">
<thead>

</thead>
<tbody>

</tbody>
<tfoot>

</tfoot>
</table>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.datatables.net/v/dt/dt-1.10.20/datatables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/1.10.21/js/dataTables.bootstrap.min.js"></script>
<script>

</script>
</div>
</body>
<footer>
<div class="container-fluid">
<div class="info">
<p>
Conan <b>v{{ version }}</b> <script>document.write(new Date().getFullYear())</script> JFrog LTD. <a>https://conan.io</a>
</p>
</div>
</div>
</footer>
<body>
<pre id="showResults"></pre>
</body>
<footer>
<p>
Conan <b>{{ version }}</b>
<script>
document.write(new Date().getFullYear());
</script>
JFrog LTD. <a href="https://conan.io">https://conan.io</a>
</p>
</footer>
</html>
"""
12 changes: 6 additions & 6 deletions conans/client/graph/install_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ def _raise_missing(missing):
else:
build_str = " ".join(list(sorted(["--build=%s" % str(pref.ref) for pref in missing_prefs])))

raise ConanException(textwrap.dedent('''\
Missing prebuilt package for '%s'
Use 'conan list packages %s --format=html -r=remote > table.html' and open the table.html file to see available packages
Or try to build locally from sources with '%s'
raise ConanException(textwrap.dedent(f'''\
Missing prebuilt package for '{missing_pkgs}'
Check the available packages using 'conan list {ref}:* -r=remote'
or try to build locally from sources using the '{build_str}' argument
czoido marked this conversation as resolved.
Show resolved Hide resolved

More Info at 'https://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package'
''' % (missing_pkgs, ref, build_str)))
More Info at 'https://docs.conan.io/en/2/knowledge/faq.html#error-missing-prebuilt-package'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this url does not exist yet, this is were the docs will be published in the near future before we launch 2.0

'''))
6 changes: 3 additions & 3 deletions conans/test/functional/only_source_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ def test_conan_test(self):
# Will Fail because hello0/0.0 and hello1/1.1 has not built packages
# and by default no packages are built
client.run("create . --user=lasote --channel=stable", assert_error=True)
self.assertIn("Or try to build locally from sources with '--build=hello0/0.0@lasote/stable "
self.assertIn("or try to build locally from sources using the '--build=hello0/0.0@lasote/stable "
"--build=hello1/1.1@lasote/stable'",
client.out)
# Only 1 reference!
assert "Use 'conan list packages hello0/0.0@lasote/stable" in client.out
assert "Check the available packages using 'conan list hello0/0.0@lasote/stable:* -r=remote'" in client.out

# We generate the package for hello0/0.0
client.run("install --requires=hello0/0.0@lasote/stable --build hello0*")

# Still missing hello1/1.1
client.run("create . --user=lasote --channel=stable", assert_error=True)
self.assertIn("Or try to build locally from sources with "
self.assertIn("or try to build locally from sources using the "
"'--build=hello1/1.1@lasote/stable'", client.out)

# We generate the package for hello1/1.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ def test_missing_multiple_dep(self):
client.save({"conanfile.py": conanfile}, clean_first=True)
client.run("create . --name=pkg --version=1.0", assert_error=True)
self.assertIn("ERROR: Missing prebuilt package for 'dep1/1.0', 'dep2/1.0'", client.out)
self.assertIn("Or try to build locally from sources with '--build=dep1/1.0 --build=dep2/1.0'", client.out)
self.assertIn("or try to build locally from sources using the '--build=dep1/1.0 --build=dep2/1.0'", client.out)