From 5593dc014a41c563ba524b9303e75da46ee96bd5 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Nov 2009 18:22:29 +0100 Subject: Fixed windows TASKKILL so it actually does something *silently* --- lib/git/cmd.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/git/cmd.py') diff --git a/lib/git/cmd.py b/lib/git/cmd.py index fb6f2998..ab34fa58 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -63,7 +63,10 @@ class Git(object): os.kill(self.proc.pid, 2) # interrupt signal except AttributeError: # try windows - subprocess.call(("TASKKILL", "/T", "/PID", self.proc.pid)) + # for some reason, providing None for stdout/stderr still prints something. This is why + # we simply use the shell and redirect to nul. Its slower than CreateProcess, question + # is whether we really want to see all these messages. Its annoying no matter what. + subprocess.call(("TASKKILL /F /T /PID %s > nul" % str(self.proc.pid)), shell=True) # END exception handling def __getattr__(self, attr): -- cgit v1.2.1 From a67bf61b5017e41740e997147dc88282b09c6f86 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Nov 2009 18:27:21 +0100 Subject: git cmd on windows now runs without the shell, see diff for explanation --- lib/git/cmd.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/git/cmd.py') diff --git a/lib/git/cmd.py b/lib/git/cmd.py index ab34fa58..97d6613d 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -17,8 +17,13 @@ execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'output_stream' ) extra = {} -if sys.platform == 'win32': - extra = {'shell': True} +# NOTE: Execution through a shell appears to be slightly faster, but in fact +# I consider it a problem whenever complex strings are passed and *interpreted* +# by the shell beforehand. This can cause great confusion and reduces compatability +# between the OS which is why the shell should not be used ( unless it does not work +# otherwise ) +#if sys.platform == 'win32': +# extra = {'shell': False} def dashify(string): return string.replace('_', '-') -- cgit v1.2.1 From 46c9a0df4403266a320059eaa66e7dce7b3d9ac4 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Nov 2009 20:09:35 +0100 Subject: cmd: added clear_cache method now used by test repo decorators to be sure persistent commands are killed before trying to remove the directory. Unfortunately, it still claims someone has opened the file. handle.exe does not show anyone, so what is happening here ? Is it just a windows odity ? If nothing helps I could just keep the temp data, but lets do some more testing first --- lib/git/cmd.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'lib/git/cmd.py') diff --git a/lib/git/cmd.py b/lib/git/cmd.py index 97d6613d..6d712ca9 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -17,7 +17,7 @@ execute_kwargs = ('istream', 'with_keep_cwd', 'with_extended_output', 'output_stream' ) extra = {} -# NOTE: Execution through a shell appears to be slightly faster, but in fact +# NOTE: Execution through a shell on windows appears to be slightly faster, but in fact # I consider it a problem whenever complex strings are passed and *interpreted* # by the shell beforehand. This can cause great confusion and reduces compatability # between the OS which is why the shell should not be used ( unless it does not work @@ -401,3 +401,16 @@ class Git(object): cmd.stdout.read(1) # finishing newlines return (hexsha, typename, size, data) + + def clear_cache(self): + """ + Clear all kinds of internal caches to release resources. + + Currently persistent commands will be interrupted. + + Returns + self + """ + self.cat_file_all = None + self.cat_file_header = None + return self -- cgit v1.2.1 From d9671e15703918048982c9ff4e2e0fef21ede320 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Thu, 5 Nov 2009 20:31:40 +0100 Subject: fixed test_repo to work on windows cmd: taskkill now pipes stderror to nul as well --- lib/git/cmd.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/git/cmd.py') diff --git a/lib/git/cmd.py b/lib/git/cmd.py index 6d712ca9..bccfb611 100644 --- a/lib/git/cmd.py +++ b/lib/git/cmd.py @@ -71,7 +71,7 @@ class Git(object): # for some reason, providing None for stdout/stderr still prints something. This is why # we simply use the shell and redirect to nul. Its slower than CreateProcess, question # is whether we really want to see all these messages. Its annoying no matter what. - subprocess.call(("TASKKILL /F /T /PID %s > nul" % str(self.proc.pid)), shell=True) + subprocess.call(("TASKKILL /F /T /PID %s 2>nul 1>nul" % str(self.proc.pid)), shell=True) # END exception handling def __getattr__(self, attr): -- cgit v1.2.1