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

run_cmd function fails with a Not a directory error if the command is not found #269

Open
mschmidtkorth opened this issue Apr 28, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@mschmidtkorth
Copy link
Contributor

mschmidtkorth commented Apr 28, 2020

Error
When backing up dotfiles, some operations result in a NotADirectoryError exception, forcing the backup process to stop.

Example: Not a directory: 'apm'

I do not have Atom installed and therefore no 'apm' folder.

Intended behavior
Check if folder exists, if not ignore and do not attempt to backup.

Traceback (most recent call last):
  File "/usr/local/bin/shallow-backup", line 8, in <module>
    sys.exit(cli())
  File "/Users/mschmidtkorth/Library/Python/3.7/lib/python/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mschmidtkorth/Library/Python/3.7/lib/python/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/mschmidtkorth/Library/Python/3.7/lib/python/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mschmidtkorth/Library/Python/3.7/lib/python/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/__main__.py", line 147, in cli
    backup_all(dotfiles_path, packages_path, fonts_path, configs_path)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/backup.py", line 188, in backup_all
    backup_packages(packages_path, skip)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/backup.py", line 142, in backup_packages
    run_cmd_write_stdout(command, dest)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/utils.py", line 30, in run_cmd_write_stdout
    process = run_cmd(command)
  File "/usr/local/lib/python3.7/site-packages/shallow_backup/utils.py", line 15, in run_cmd
    process = sp.run(command.split(), stdout=sp.PIPE, stderr=sp.DEVNULL)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/local/Cellar/python/3.7.7/Frameworks/Python.framework/Versions/3.7/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
NotADirectoryError: [Errno 20] Not a directory: 'apm'
@alichtman
Copy link
Owner

alichtman commented Apr 29, 2020

I think your fix is right. Happy to approve a PR if you put one up.

This issue has to do with the run_cmd function, which fails with a Not a directory error if the command is not found, like apm.

@alichtman alichtman added the bug Something isn't working label Apr 29, 2020
@mschmidtkorth
Copy link
Contributor Author

Good to know, misleading error message. Sorry for the late reply, I didn't really have a lot of time the past days.

@alichtman alichtman changed the title NotADirectoryError: [Errno 20] Not a directory: 'apm' run_cmd function fails with a Not a directory error if the command is not found Jun 20, 2023
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

2 participants