Permalink
Browse files

ignore files in non-existent directories

  • Loading branch information...
1 parent 964c1b1 commit 822c6da70bc76c62189b1a89da5a6cc1ee4ea8f6 Spencer Creasey committed Nov 2, 2012
Showing with 22 additions and 17 deletions.
  1. +22 −17 git.py
View
39 git.py
@@ -105,23 +105,28 @@ def __init__(self, command, on_done, working_dir="", fallback_encoding="", **kwa
def run(self):
try:
- # Per http://bugs.python.org/issue8557 shell=True is required to
- # get $PATH on Windows. Yay portable code.
- shell = os.name == 'nt'
- if self.working_dir != "":
- os.chdir(self.working_dir)
-
- proc = subprocess.Popen(self.command,
- stdout=self.stdout, stderr=subprocess.STDOUT,
- stdin=subprocess.PIPE,
- shell=shell, universal_newlines=True)
- output = proc.communicate(self.stdin)[0]
- if not output:
- output = ''
- # if sublime's python gets bumped to 2.7 we can just do:
- # output = subprocess.check_output(self.command)
- main_thread(self.on_done,
- _make_text_safeish(output, self.fallback_encoding), **self.kwargs)
+
+ # Ignore directories that no longer exist
+ if os.path.isdir(self.working_dir):
+
+ # Per http://bugs.python.org/issue8557 shell=True is required to
+ # get $PATH on Windows. Yay portable code.
+ shell = os.name == 'nt'
+ if self.working_dir != "":
+ os.chdir(self.working_dir)
+
+ proc = subprocess.Popen(self.command,
+ stdout=self.stdout, stderr=subprocess.STDOUT,
+ stdin=subprocess.PIPE,
+ shell=shell, universal_newlines=True)
+ output = proc.communicate(self.stdin)[0]
+ if not output:
+ output = ''
+ # if sublime's python gets bumped to 2.7 we can just do:
+ # output = subprocess.check_output(self.command)
+ main_thread(self.on_done,
+ _make_text_safeish(output, self.fallback_encoding), **self.kwargs)
+
except subprocess.CalledProcessError, e:
main_thread(self.on_done, e.returncode)
except OSError, e:

0 comments on commit 822c6da

Please sign in to comment.