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 2 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: 5 additions & 7 deletions conans/client/graph/install_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,8 @@ 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'

More Info at 'https://docs.conan.io/en/latest/faq/troubleshooting.html#error-missing-prebuilt-package'
''' % (missing_pkgs, ref, build_str)))
raise ConanException(textwrap.dedent(f'''\
Missing prebuilt package for '{missing_pkgs}'
Check the available packages using the 'conan list' command
or try to build locally from sources using the '{build_str}' argument
czoido marked this conversation as resolved.
Show resolved Hide resolved
'''))