Skip to content

Commit

Permalink
Merge pull request #59 from nschloe/fix-import-profiles
Browse files Browse the repository at this point in the history
Fix import profiles
  • Loading branch information
nschloe authored Nov 28, 2019
2 parents 74333e4 + 8f30907 commit da70fea
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ upload: setup.py
twine upload dist/*

update:
curl https://stackpath.bootstrapcdn.com/bootstrap/4.4.0/css/bootstrap.min.css > tuna/web/static/bootstrap.min.css
curl https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css > tuna/web/static/bootstrap.min.css
curl https://d3js.org/d3.v5.min.js > tuna/web/static/d3.min.js

publish: tag upload
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
[![GitHub stars](https://img.shields.io/github/stars/nschloe/tuna.svg?style=flat-square&logo=github&label=Stars&logoColor=white)](https://github.com/nschloe/tuna)
[![PyPi downloads](https://img.shields.io/pypi/dm/tuna.svg?style=flat-square)](https://pypistats.org/packages/tuna)

tuna is a modern, lightweight Python profile viewer inspired by the amazing
tuna is a modern, lightweight Python profile viewer inspired by
[SnakeViz](https://github.com/jiffyclub/snakeviz). It handles runtime and import
profiles, has zero dependencies, uses [d3](https://d3js.org/) and
profiles, has no Python dependencies, uses [d3](https://d3js.org/) and
[bootstrap](https://getbootstrap.com/), and avoids
[certain](https://github.com/jiffyclub/snakeviz/issues/111)
[errors](https://github.com/jiffyclub/snakeviz/issues/112) present in SnakeViz.
Expand Down
2 changes: 1 addition & 1 deletion tuna/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
__author_email__ = "nico.schloemer@gmail.com"
__copyright__ = "Copyright (c) 2018-2019, {} <{}>".format(__author__, __author_email__)
__license__ = "License :: OSI Approved :: MIT License"
__version__ = "0.3.4"
__version__ = "0.3.5"
__maintainer__ = "Nico Schlömer"
__status__ = "Development Status :: 5 - Production/Stable"
10 changes: 5 additions & 5 deletions tuna/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def read(filename):

# runtime profile
data = read_runtime_profile(filename)
return {"data": data, "filename": filename}
return data


def read_runtime_profile(prof_filename):
Expand Down Expand Up @@ -188,15 +188,15 @@ def read_import_profile(filename):
return tree[0]


def render(data):
def render(data, filename):
this_dir = os.path.dirname(__file__)
with open(os.path.join(this_dir, "web", "index.html")) as _file:
template = string.Template(_file.read())

return template.substitute(
data=escape(json.dumps(data["data"]).replace("</", "<\\/")),
data=escape(json.dumps(data).replace("</", "<\\/")),
version=escape(__version__),
filename=escape(data["filename"].replace("</", "<\\/")),
filename=escape(filename.replace("</", "<\\/")),
)


Expand All @@ -215,7 +215,7 @@ def do_GET(self):
if self.path == "/":
self.send_header("Content-type", "text/html")
self.end_headers()
self.wfile.write(render(data).encode("utf-8"))
self.wfile.write(render(data, prof_filename).encode("utf-8"))
else:
this_dir = os.path.dirname(__file__)
# Remove the leading slash in self.path
Expand Down

0 comments on commit da70fea

Please sign in to comment.