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

error when writing diff output to file #453

Closed
volaya opened this issue Jul 7, 2021 · 3 comments
Closed

error when writing diff output to file #453

volaya opened this issue Jul 7, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@volaya
Copy link

volaya commented Jul 7, 2021

The following command:

$ kart diff -o json --output test.json

causes this exception:

File "kart_cli.py", line 4, in
File "kart\cli.py", line 333, in entrypoint
File "lib\site-packages\click\core.py", line 829, in call
File "lib\site-packages\click\core.py", line 782, in main
File "kart\cli.py", line 157, in invoke
File "lib\site-packages\click\core.py", line 1259, in invoke
File "lib\site-packages\click\core.py", line 1066, in invoke
File "lib\site-packages\click\core.py", line 610, in invoke
File "lib\site-packages\click\decorators.py", line 21, in new_func
File "kart\diff.py", line 198, in diff
File "kart\text_diff_writer.py", line 33, in init
File "kart\output_util.py", line 247, in resolve_output_path
AttributeError: 'str' object has no attribute 'open'
[12092] Failed to execute script kart_cli

Looks like resolve_output_path is assuming that the object is a Path object, while it's just a plain string

@volaya
Copy link
Author

volaya commented Jul 7, 2021

This is a new issue in v0.10. Diff to file output was working fine in v0.9

@hamishcampbell
Copy link
Member

Confirmed. It appears to be a regression in v0.10.1.

v.0.10.0

➜  project (master) kart --version
Kart v0.10.0, Copyright (c) Kart Contributors
» GDAL v3.2.0; PROJ v6.3.0
» PyGit2 v1.3.0; Libgit2 v1.1.0; Git v2.31.1
» SQLAlchemy v1.4.11; pysqlite3 v2.6.0/v3.31.1; SpatiaLite v5.0.0; Libpq v13.0.2
» SpatialIndex v1.9.3
➜  project (master) kart diff HEAD^ -o json --output test.json
➜  project (master) ls *.json
test.json

v0.10.1

➜  project (master) kart --version
Kart v0.10.1, Copyright (c) Kart Contributors
» GDAL v3.2.0; PROJ v6.3.0
» PyGit2 v1.3.0; Libgit2 v1.1.0; Git v2.31.1
» SQLAlchemy v1.4.11; pysqlite3 v2.6.0/v3.31.1; SpatiaLite v5.0.0; Libpq v13.0.2
» SpatialIndex v1.9.3
➜  project (master) kart diff HEAD^ -o json --output test.json
Traceback (most recent call last):
  File "kart_cli.py", line 4, in <module>
  File "kart/cli.py", line 333, in entrypoint
  File "click/core.py", line 829, in __call__
  File "click/core.py", line 782, in main
  File "kart/cli.py", line 157, in invoke
  File "click/core.py", line 1259, in invoke
  File "click/core.py", line 1066, in invoke
  File "click/core.py", line 610, in invoke
  File "click/decorators.py", line 21, in new_func
  File "kart/diff.py", line 200, in diff
  File "kart/json_diff_writers.py", line 63, in write_diff
  File "kart/output_util.py", line 191, in dump_json_output
  File "kart/output_util.py", line 247, in resolve_output_path
AttributeError: 'str' object has no attribute 'open'
[3536] Failed to execute script kart_cli

@olsen232
Copy link
Collaborator

olsen232 commented Jul 8, 2021

Fixed... fix will be in the next release of course, but until then, a very workable workaround is to redirect stdout using the > operator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants