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

Support slash in file path in reduce command #129

Conversation

fabienheureux
Copy link
Contributor

@fabienheureux fabienheureux commented Dec 24, 2021

Reduce commands fails when using a nested xml file path

I am using a docker setup locally, and have my xml file located in /app/dump.xml in the docker container.
I am using the reduce command as : python manage.py reduce_xml /app/dump.xml
This causes the command to fail when writing the stats file as the command tries to write f = open(f"stats-{file_path}.json", "w") resulting in 'stats-/app/dump.xml.json'

Here is the full stacktrace
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python3.8/site-packages/wagtail_wordpress_import/management/commands/reduce_xml.py", line 109, in handle
    f = open(f"stats-{file_path}.json", "w")
FileNotFoundError: [Errno 2] No such file or directory: 'stats-/app/dump.xml.json'

  • Testing
    • CI passes
    • If necessary, tests are added for new or fixed behaviour
    • These changes do not reduce test coverage
  • Documentation.
    • This PR adds or updates documentation
    • Documentation changes are not necessary because they do not change the reduce command behavior/arguments

@codecov-commenter
Copy link

codecov-commenter commented Dec 24, 2021

Codecov Report

Merging #129 (a61b072) into main (3c27330) will increase coverage by 0.19%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #129      +/-   ##
==========================================
+ Coverage   65.38%   65.57%   +0.18%     
==========================================
  Files          32       32              
  Lines        1251     1255       +4     
  Branches      222      222              
==========================================
+ Hits          818      823       +5     
+ Misses        392      391       -1     
  Partials       41       41              
Impacted Files Coverage Δ
...wordpress_import/management/commands/reduce_xml.py 32.30% <83.33%> (+6.07%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c27330...a61b072. Read the comment docs.

@nickmoreton nickmoreton added bug Something isn't working enhancement New feature or request labels Dec 24, 2021
@nickmoreton
Copy link
Collaborator

@fabienheureux Thank you for the PR. The tests are now passing :)

@nickmoreton nickmoreton self-requested a review December 24, 2021 11:36
Copy link
Collaborator

@nickmoreton nickmoreton left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@nickmoreton nickmoreton merged commit af641d3 into torchbox:main Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants