puntonim / promptastic

A fantastic prompt for Bash
http://painl.es/promptastic/
Apache License 2.0
81 stars 16 forks source link

FileNotFoundError is not defined #17

Closed taylorkline closed 9 years ago

taylorkline commented 9 years ago

I am suddenly getthing this error whenever I am not in a directory of a git repo:

Traceback (most recent call last):
  File "/home/rogermortis/dotfiles/bash/promptastic/segments/git.py", line 42, in get_branch_name
    raise FileNotFoundError
NameError: global name 'FileNotFoundError' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/rogermortis/promptastic/promptastic.py", line 164, in <module>
    prompt.first_line_right.append(git.Git())
  File "/home/rogermortis/dotfiles/bash/promptastic/segments/__init__.py", line 22, in __init__
    self.init(*args, **kwargs)
  File "/home/rogermortis/dotfiles/bash/promptastic/segments/git.py", line 11, in init
    branch_name = self.get_branch_name()
  File "/home/rogermortis/dotfiles/bash/promptastic/segments/git.py", line 43, in get_branch_name
    except FileNotFoundError:
NameError: global name 'FileNotFoundError' is not defined

I don't think I changed anything...

puntonim commented 9 years ago

FileNotFoundError is a Python 3 exception which does not exist in Python 2. So my guess is that you are trying to run Promptastic with Python 2.

Can you make sure that your file promptastic.py starts with #!/usr/bin/env python3?

Btw I am planning to update Promptastic soon and make it compatible with both Python 2 and 3.

taylorkline commented 9 years ago

I definitely have Python 3 installed and the shebang is there:

https://github.com/jkdf2/dotfiles/blob/master/bash/promptastic/promptastic.py

taylorkline commented 9 years ago

After reading this: http://stackoverflow.com/questions/15032108/pythons-open-throws-different-errors-for-file-not-found-how-to-handle-b

I changed FileNotFoundError to OSError. All seems to be working now.