Excerpts from Simon Schampijer's message of 2011-10-21 12:27:02 +0200: > We need to make sure that we do not fail if git is not > installed and use the same fallback code as if we are > in a directory where no git information is present.
How about: """ When git is installed, it will return non-zero if it gets asked to list the files in a non-repository. The subprocess.Popen instantiation is successful in this case and the returncode attribute will contain the error code from git. The current code handles this fine. If git isn't installed, however, trying to instantiate subprocess.Popen will fail with OSError. We need to catch this and fall back to our own source file listing facility like we do for the non-repository case. """ [sugar.activity.bundlebuilder.XOPackager] > def _get_files_in_git(self): > - git_ls = subprocess.Popen(['git', 'ls-files'], > stdout=subprocess.PIPE, > - cwd=self.config.source_dir) > + try: > + git_ls = subprocess.Popen(['git', 'ls-files'], > + stdout=subprocess.PIPE, > + cwd=self.config.source_dir) > + except OSError: > + # Git not installed. Fall back to filtered list > + return list_files(self.config.source_dir, > + IGNORE_DIRS, IGNORE_FILES) Since our own listing code can generate different results than git ls-files does, we should log a warning (same applies to SourcePackager.get_files()). Sascha -- http://sascha.silbe.org/ http://www.infra-silbe.de/
signature.asc
Description: PGP signature
_______________________________________________ Sugar-devel mailing list Sugar-devel@lists.sugarlabs.org http://lists.sugarlabs.org/listinfo/sugar-devel