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

hamster-cli with export fails #373

Closed
mabgh opened this issue Jan 6, 2019 · 5 comments
Closed

hamster-cli with export fails #373

mabgh opened this issue Jan 6, 2019 · 5 comments
Assignees
Labels

Comments

@mabgh
Copy link

mabgh commented Jan 6, 2019

hamster export html 2018-12-01 2018-12-31
  File "/usr/bin/hamster", line 391, in <module>
    getattr(hamster_client, command)(*args)
  File "/usr/bin/hamster", line 218, in export
    writer = reports.simple(facts, start_time, end_time, export_format)
  File "/usr/lib/python3.6/site-packages/hamster/reports.py", line 60, in simple
    writer.write_report(facts)
  File "/usr/lib/python3.6/site-packages/hamster/reports.py", line 101, in write_report
    self._finish(facts)
  File "/usr/lib/python3.6/site-packages/hamster/reports.py", line 339, in _finish
    self.file.write(Template(self.main_template).safe_substitute(data))
  File "/usr/lib64/python3.6/codecs.py", line 377, in write
    self.stream.write(data)
TypeError: string argument expected, got 'bytes'

with lines 339 in reports.py as

    data = Template(self.main_template).safe_substitute(data)
    print(data) 

data is class str and a correct html is printed to stdout

@ederag
Copy link
Collaborator

ederag commented Jan 6, 2019

Thanks for the report.
Which hamster version are you using ?

@ederag ederag self-assigned this Jan 6, 2019
@mabgh
Copy link
Author

mabgh commented Jan 6, 2019 via email

@ederag
Copy link
Collaborator

ederag commented Jan 6, 2019

Thanks, confirmed. I'll look into that.

@ederag ederag added the bug label Jan 6, 2019
@ederag
Copy link
Collaborator

ederag commented Jan 9, 2019

Got it. The issue was two-fold. The second part is

self.file = open(path, "w") if path else codecs.getwriter("utf8")(StringIO())

What output is expected from the command-line ?
(just print the html to standard output, for redirection ?)

ederag added a commit to ederag/hamster that referenced this issue Jan 10, 2019
No longer used in hamster. And could lead to
ValueError: I/O operation on closed file
ederag added a commit to ederag/hamster that referenced this issue Jan 10, 2019
No longer used in hamster. And could lead to
ValueError: I/O operation on closed file
ederag added a commit to ederag/hamster that referenced this issue Jan 10, 2019
No longer used in hamster. And could lead to
ValueError: I/O operation on closed file
@ederag
Copy link
Collaborator

ederag commented Jan 10, 2019

Should be fixed by PR #375.

ederag added a commit that referenced this issue Jan 12, 2019
Fix command line export (PR #375)

Fix issue #373.
Export to ical, tsv, xml and html work.

- Now `Fact.delta` is calculated upon access.
  This fixes durations that were not updated in the overview
  for the running activity.
- Pass dates to reports, not datetimes.
- Remove the `ReportWriter.export` function.
- Create Fact.copy()
@ederag ederag closed this as completed Jan 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants