| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 987dbf4 commit 7bbccb4
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,8 +81,8 @@ | |||
| 81 | 81 | "strip_newline_in_stdout", | |
| 82 | 82 | } | |
| 83 | 83 | ||
| 84 | - log = logging.getLogger(__name__) | ||
| 85 | - log.addHandler(logging.NullHandler()) | ||
| 84 | + _logger = logging.getLogger(__name__) | ||
| 85 | + _logger.addHandler(logging.NullHandler()) | ||
| 86 | 86 | ||
| 87 | 87 | __all__ = ("Git",) | |
| 88 | 88 | ||
@@ -146,7 +146,7 @@ def pump_stream( | |||
| 146 | 146 | handler(line) | |
| 147 | 147 | ||
| 148 | 148 | except Exception as ex: | |
| 149 | - log.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}") | ||
| 149 | + _logger.error(f"Pumping {name!r} of cmd({remove_password_if_present(cmdline)}) failed due to: {ex!r}") | ||
| 150 | 150 | if "I/O operation on closed file" not in str(ex): | |
| 151 | 151 | # Only reraise if the error was not due to the stream closing | |
| 152 | 152 | raise CommandError([f"<{name}-pump>"] + remove_password_if_present(cmdline), ex) from ex | |
@@ -600,7 +600,7 @@ def _terminate(self) -> None: | |||
| 600 | 600 | self.status = self._status_code_if_terminate or proc.poll() | |
| 601 | 601 | return | |
| 602 | 602 | except OSError as ex: | |
| 603 | - log.info("Ignored error after process had died: %r", ex) | ||
| 603 | + _logger.info("Ignored error after process had died: %r", ex) | ||
| 604 | 604 | ||
| 605 | 605 | # It can be that nothing really exists anymore... | |
| 606 | 606 | if os is None or getattr(os, "kill", None) is None: | |
@@ -613,7 +613,7 @@ def _terminate(self) -> None: | |||
| 613 | 613 | ||
| 614 | 614 | self.status = self._status_code_if_terminate or status | |
| 615 | 615 | except OSError as ex: | |
| 616 | - log.info("Ignored error after process had died: %r", ex) | ||
| 616 | + _logger.info("Ignored error after process had died: %r", ex) | ||
| 617 | 617 | # END exception handling | |
| 618 | 618 | ||
| 619 | 619 | def __del__(self) -> None: | |
@@ -654,7 +654,7 @@ def read_all_from_possibly_closed_stream(stream: Union[IO[bytes], None]) -> byte | |||
| 654 | 654 | ||
| 655 | 655 | if status != 0: | |
| 656 | 656 | errstr = read_all_from_possibly_closed_stream(p_stderr) | |
| 657 | - log.debug("AutoInterrupt wait stderr: %r" % (errstr,)) | ||
| 657 | + _logger.debug("AutoInterrupt wait stderr: %r" % (errstr,)) | ||
| 658 | 658 | raise GitCommandError(remove_password_if_present(self.args), status, errstr) | |
| 659 | 659 | return status | |
| 660 | 660 | ||
@@ -1018,7 +1018,7 @@ def execute( | |||
| 1018 | 1018 | # Remove password for the command if present. | |
| 1019 | 1019 | redacted_command = remove_password_if_present(command) | |
| 1020 | 1020 | if self.GIT_PYTHON_TRACE and (self.GIT_PYTHON_TRACE != "full" or as_process): | |
| 1021 | - log.info(" ".join(redacted_command)) | ||
| 1021 | + _logger.info(" ".join(redacted_command)) | ||
| 1022 | 1022 | ||
| 1023 | 1023 | # Allow the user to have the command executed in their working dir. | |
| 1024 | 1024 | try: | |
@@ -1055,7 +1055,7 @@ def execute( | |||
| 1055 | 1055 | stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb") | |
| 1056 | 1056 | if shell is None: | |
| 1057 | 1057 | shell = self.USE_SHELL | |
| 1058 | - log.debug( | ||
| 1058 | + _logger.debug( | ||
| 1059 | 1059 | "Popen(%s, cwd=%s, stdin=%s, shell=%s, universal_newlines=%s)", | |
| 1060 | 1060 | redacted_command, | |
| 1061 | 1061 | cwd, | |
@@ -1167,17 +1167,17 @@ def as_text(stdout_value: Union[bytes, str]) -> str: | |||
| 1167 | 1167 | # END as_text | |
| 1168 | 1168 | ||
| 1169 | 1169 | if stderr_value: | |
| 1170 | - log.info( | ||
| 1170 | + _logger.info( | ||
| 1171 | 1171 | "%s -> %d; stdout: '%s'; stderr: '%s'", | |
| 1172 | 1172 | cmdstr, | |
| 1173 | 1173 | status, | |
| 1174 | 1174 | as_text(stdout_value), | |
| 1175 | 1175 | safe_decode(stderr_value), | |
| 1176 | 1176 | ) | |
| 1177 | 1177 | elif stdout_value: | |
| 1178 | - log.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value)) | ||
| 1178 | + _logger.info("%s -> %d; stdout: '%s'", cmdstr, status, as_text(stdout_value)) | ||
| 1179 | 1179 | else: | |
| 1180 | - log.info("%s -> %d", cmdstr, status) | ||
| 1180 | + _logger.info("%s -> %d", cmdstr, status) | ||
| 1181 | 1181 | # END handle debug printing | |
| 1182 | 1182 | ||
| 1183 | 1183 | if with_exceptions and status != 0: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -61,8 +61,8 @@ | |||
| 61 | 61 | __all__ = ("GitConfigParser", "SectionConstraint") | |
| 62 | 62 | ||
| 63 | 63 | ||
| 64 | - log = logging.getLogger(__name__) | ||
| 65 | - log.addHandler(logging.NullHandler()) | ||
| 64 | + _logger = logging.getLogger(__name__) | ||
| 65 | + _logger.addHandler(logging.NullHandler()) | ||
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | 68 | CONFIG_LEVELS: ConfigLevels_Tup = ("system", "user", "global", "repository") | |
@@ -412,7 +412,7 @@ def release(self) -> None: | |||
| 412 | 412 | try: | |
| 413 | 413 | self.write() | |
| 414 | 414 | except IOError: | |
| 415 | - log.error("Exception during destruction of GitConfigParser", exc_info=True) | ||
| 415 | + _logger.error("Exception during destruction of GitConfigParser", exc_info=True) | ||
| 416 | 416 | except ReferenceError: | |
| 417 | 417 | # This happens in Python 3... and usually means that some state cannot be | |
| 418 | 418 | # written as the sections dict cannot be iterated. This usually happens when | |
@@ -712,7 +712,7 @@ def write(self) -> None: | |||
| 712 | 712 | # END assert multiple files | |
| 713 | 713 | ||
| 714 | 714 | if self._has_includes(): | |
| 715 | - log.debug( | ||
| 715 | + _logger.debug( | ||
| 716 | 716 | "Skipping write-back of configuration file as include files were merged in." | |
| 717 | 717 | + "Set merge_includes=False to prevent this." | |
| 718 | 718 | ) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -52,8 +52,8 @@ | |||
| 52 | 52 | ||
| 53 | 53 | # ------------------------------------------------------------------------ | |
| 54 | 54 | ||
| 55 | - log = logging.getLogger(__name__) | ||
| 56 | - log.addHandler(logging.NullHandler()) | ||
| 55 | + _logger = logging.getLogger(__name__) | ||
| 56 | + _logger.addHandler(logging.NullHandler()) | ||
| 57 | 57 | ||
| 58 | 58 | __all__ = ("Commit",) | |
| 59 | 59 | ||
@@ -767,7 +767,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 767 | 767 | self.author_tz_offset, | |
| 768 | 768 | ) = parse_actor_and_date(author_line.decode(self.encoding, "replace")) | |
| 769 | 769 | except UnicodeDecodeError: | |
| 770 | - log.error( | ||
| 770 | + _logger.error( | ||
| 771 | 771 | "Failed to decode author line '%s' using encoding %s", | |
| 772 | 772 | author_line, | |
| 773 | 773 | self.encoding, | |
@@ -781,7 +781,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 781 | 781 | self.committer_tz_offset, | |
| 782 | 782 | ) = parse_actor_and_date(committer_line.decode(self.encoding, "replace")) | |
| 783 | 783 | except UnicodeDecodeError: | |
| 784 | - log.error( | ||
| 784 | + _logger.error( | ||
| 785 | 785 | "Failed to decode committer line '%s' using encoding %s", | |
| 786 | 786 | committer_line, | |
| 787 | 787 | self.encoding, | |
@@ -795,7 +795,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit": | |||
| 795 | 795 | try: | |
| 796 | 796 | self.message = self.message.decode(self.encoding, "replace") | |
| 797 | 797 | except UnicodeDecodeError: | |
| 798 | - log.error( | ||
| 798 | + _logger.error( | ||
| 799 | 799 | "Failed to decode message '%s' using encoding %s", | |
| 800 | 800 | self.message, | |
| 801 | 801 | self.encoding, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,8 +56,8 @@ | |||
| 56 | 56 | __all__ = ["Submodule", "UpdateProgress"] | |
| 57 | 57 | ||
| 58 | 58 | ||
| 59 | - log = logging.getLogger(__name__) | ||
| 60 | - log.addHandler(logging.NullHandler()) | ||
| 59 | + _logger = logging.getLogger(__name__) | ||
| 60 | + _logger.addHandler(logging.NullHandler()) | ||
| 61 | 61 | ||
| 62 | 62 | ||
| 63 | 63 | class UpdateProgress(RemoteProgress): | |
@@ -731,7 +731,7 @@ def update( | |||
| 731 | 731 | ) | |
| 732 | 732 | mrepo.head.reference.set_tracking_branch(remote_branch) | |
| 733 | 733 | except (IndexError, InvalidGitRepositoryError): | |
| 734 | - log.warning("Failed to checkout tracking branch %s", self.branch_path) | ||
| 734 | + _logger.warning("Failed to checkout tracking branch %s", self.branch_path) | ||
| 735 | 735 | # END handle tracking branch | |
| 736 | 736 | ||
| 737 | 737 | # NOTE: Have to write the repo config file as well, otherwise the | |
@@ -761,14 +761,14 @@ def update( | |||
| 761 | 761 | binsha = rcommit.binsha | |
| 762 | 762 | hexsha = rcommit.hexsha | |
| 763 | 763 | else: | |
| 764 | - log.error( | ||
| 764 | + _logger.error( | ||
| 765 | 765 | "%s a tracking branch was not set for local branch '%s'", | |
| 766 | 766 | msg_base, | |
| 767 | 767 | mrepo.head.reference, | |
| 768 | 768 | ) | |
| 769 | 769 | # END handle remote ref | |
| 770 | 770 | else: | |
| 771 | - log.error("%s there was no local tracking branch", msg_base) | ||
| 771 | + _logger.error("%s there was no local tracking branch", msg_base) | ||
| 772 | 772 | # END handle detached head | |
| 773 | 773 | # END handle to_latest_revision option | |
| 774 | 774 | ||
@@ -786,15 +786,15 @@ def update( | |||
| 786 | 786 | if force: | |
| 787 | 787 | msg = "Will force checkout or reset on local branch that is possibly in the future of" | |
| 788 | 788 | msg += " the commit it will be checked out to, effectively 'forgetting' new commits" | |
| 789 | - log.debug(msg) | ||
| 789 | + _logger.debug(msg) | ||
| 790 | 790 | else: | |
| 791 | 791 | msg = "Skipping %s on branch '%s' of submodule repo '%s' as it contains un-pushed commits" | |
| 792 | 792 | msg %= ( | |
| 793 | 793 | is_detached and "checkout" or "reset", | |
| 794 | 794 | mrepo.head, | |
| 795 | 795 | mrepo, | |
| 796 | 796 | ) | |
| 797 | - log.info(msg) | ||
| 797 | + _logger.info(msg) | ||
| 798 | 798 | may_reset = False | |
| 799 | 799 | # END handle force | |
| 800 | 800 | # END handle if we are in the future | |
@@ -834,7 +834,7 @@ def update( | |||
| 834 | 834 | except Exception as err: | |
| 835 | 835 | if not keep_going: | |
| 836 | 836 | raise | |
| 837 | - log.error(str(err)) | ||
| 837 | + _logger.error(str(err)) | ||
| 838 | 838 | # END handle keep_going | |
| 839 | 839 | ||
| 840 | 840 | # HANDLE RECURSION | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,8 @@ | |||
| 22 | 22 | ||
| 23 | 23 | __all__ = ["RootModule", "RootUpdateProgress"] | |
| 24 | 24 | ||
| 25 | - log = logging.getLogger(__name__) | ||
| 26 | - log.addHandler(logging.NullHandler()) | ||
| 25 | + _logger = logging.getLogger(__name__) | ||
| 26 | + _logger.addHandler(logging.NullHandler()) | ||
| 27 | 27 | ||
| 28 | 28 | ||
| 29 | 29 | class RootUpdateProgress(UpdateProgress): | |
@@ -321,7 +321,7 @@ def update( | |||
| 321 | 321 | # this way, it will be checked out in the next step. | |
| 322 | 322 | # This will change the submodule relative to us, so | |
| 323 | 323 | # the user will be able to commit the change easily. | |
| 324 | - log.warning( | ||
| 324 | + _logger.warning( | ||
| 325 | 325 | "Current sha %s was not contained in the tracking\ | |
| 326 | 326 | branch at the new remote, setting it the the remote's tracking branch", | |
| 327 | 327 | sm.hexsha, | |
@@ -393,7 +393,7 @@ def update( | |||
| 393 | 393 | except Exception as err: | |
| 394 | 394 | if not keep_going: | |
| 395 | 395 | raise | |
| 396 | - log.error(str(err)) | ||
| 396 | + _logger.error(str(err)) | ||
| 397 | 397 | # END handle keep_going | |
| 398 | 398 | ||
| 399 | 399 | # FINALLY UPDATE ALL ACTUAL SUBMODULES | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,8 +65,8 @@ | |||
| 65 | 65 | # ------------------------------------------------------------- | |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | - log = logging.getLogger(__name__) | ||
| 69 | - log.addHandler(logging.NullHandler()) | ||
| 68 | + _logger = logging.getLogger(__name__) | ||
| 69 | + _logger.addHandler(logging.NullHandler()) | ||
| 70 | 70 | ||
| 71 | 71 | ||
| 72 | 72 | __all__ = ("RemoteProgress", "PushInfo", "FetchInfo", "Remote") | |
@@ -857,7 +857,7 @@ def _get_fetch_info_from_stderr( | |||
| 857 | 857 | stderr_text = progress.error_lines and "\n".join(progress.error_lines) or "" | |
| 858 | 858 | proc.wait(stderr=stderr_text) | |
| 859 | 859 | if stderr_text: | |
| 860 | - log.warning("Error lines received while fetching: %s", stderr_text) | ||
| 860 | + _logger.warning("Error lines received while fetching: %s", stderr_text) | ||
| 861 | 861 | ||
| 862 | 862 | for line in progress.other_lines: | |
| 863 | 863 | line = force_text(line) | |
@@ -878,9 +878,9 @@ def _get_fetch_info_from_stderr( | |||
| 878 | 878 | msg += "length of progress lines %i should be equal to lines in FETCH_HEAD file %i\n" | |
| 879 | 879 | msg += "Will ignore extra progress lines or fetch head lines." | |
| 880 | 880 | msg %= (l_fil, l_fhi) | |
| 881 | - log.debug(msg) | ||
| 882 | - log.debug(b"info lines: " + str(fetch_info_lines).encode("UTF-8")) | ||
| 883 | - log.debug(b"head info: " + str(fetch_head_info).encode("UTF-8")) | ||
| 881 | + _logger.debug(msg) | ||
| 882 | + _logger.debug(b"info lines: " + str(fetch_info_lines).encode("UTF-8")) | ||
| 883 | + _logger.debug(b"head info: " + str(fetch_head_info).encode("UTF-8")) | ||
| 884 | 884 | if l_fil < l_fhi: | |
| 885 | 885 | fetch_head_info = fetch_head_info[:l_fil] | |
| 886 | 886 | else: | |
@@ -892,8 +892,8 @@ def _get_fetch_info_from_stderr( | |||
| 892 | 892 | try: | |
| 893 | 893 | output.append(FetchInfo._from_line(self.repo, err_line, fetch_line)) | |
| 894 | 894 | except ValueError as exc: | |
| 895 | - log.debug("Caught error while parsing line: %s", exc) | ||
| 896 | - log.warning("Git informed while fetching: %s", err_line.strip()) | ||
| 895 | + _logger.debug("Caught error while parsing line: %s", exc) | ||
| 896 | + _logger.warning("Git informed while fetching: %s", err_line.strip()) | ||
| 897 | 897 | return output | |
| 898 | 898 | ||
| 899 | 899 | def _get_push_info( | |
@@ -935,7 +935,7 @@ def stdout_handler(line: str) -> None: | |||
| 935 | 935 | if not output: | |
| 936 | 936 | raise | |
| 937 | 937 | elif stderr_text: | |
| 938 | - log.warning("Error lines received while fetching: %s", stderr_text) | ||
| 938 | + _logger.warning("Error lines received while fetching: %s", stderr_text) | ||
| 939 | 939 | output.error = e | |
| 940 | 940 | ||
| 941 | 941 | return output | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -89,7 +89,7 @@ | |||
| 89 | 89 | ||
| 90 | 90 | # ----------------------------------------------------------- | |
| 91 | 91 | ||
| 92 | - log = logging.getLogger(__name__) | ||
| 92 | + _logger = logging.getLogger(__name__) | ||
| 93 | 93 | ||
| 94 | 94 | __all__ = ("Repo",) | |
| 95 | 95 | ||
@@ -772,7 +772,7 @@ def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> boo | |||
| 772 | 772 | if object_info.type == object_type.encode(): | |
| 773 | 773 | return True | |
| 774 | 774 | else: | |
| 775 | - log.debug( | ||
| 775 | + _logger.debug( | ||
| 776 | 776 | "Commit hash points to an object of type '%s'. Requested were objects of type '%s'", | |
| 777 | 777 | object_info.type.decode(), | |
| 778 | 778 | object_type, | |
@@ -781,7 +781,7 @@ def is_valid_object(self, sha: str, object_type: Union[str, None] = None) -> boo | |||
| 781 | 781 | else: | |
| 782 | 782 | return True | |
| 783 | 783 | except BadObject: | |
| 784 | - log.debug("Commit hash is invalid.") | ||
| 784 | + _logger.debug("Commit hash is invalid.") | ||
| 785 | 785 | return False | |
| 786 | 786 | ||
| 787 | 787 | def _get_daemon_export(self) -> bool: | |
@@ -1298,7 +1298,7 @@ def _clone( | |||
| 1298 | 1298 | cmdline = getattr(proc, "args", "") | |
| 1299 | 1299 | cmdline = remove_password_if_present(cmdline) | |
| 1300 | 1300 | ||
| 1301 | - log.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout) | ||
| 1301 | + _logger.debug("Cmd(%s)'s unused stdout: %s", cmdline, stdout) | ||
| 1302 | 1302 | finalize_process(proc, stderr=stderr) | |
| 1303 | 1303 | ||
| 1304 | 1304 | # Our git command could have a different working dir than our actual | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -104,7 +104,7 @@ | |||
| 104 | 104 | "HIDE_WINDOWS_KNOWN_ERRORS", | |
| 105 | 105 | ] | |
| 106 | 106 | ||
| 107 | - log = logging.getLogger(__name__) | ||
| 107 | + _logger = logging.getLogger(__name__) | ||
| 108 | 108 | ||
| 109 | 109 | ||
| 110 | 110 | def _read_win_env_flag(name: str, default: bool) -> bool: | |
@@ -124,7 +124,7 @@ def _read_win_env_flag(name: str, default: bool) -> bool: | |||
| 124 | 124 | except KeyError: | |
| 125 | 125 | return default | |
| 126 | 126 | ||
| 127 | - log.warning( | ||
| 127 | + _logger.warning( | ||
| 128 | 128 | "The %s environment variable is deprecated. Its effect has never been documented and changes without warning.", | |
| 129 | 129 | name, | |
| 130 | 130 | ) | |
@@ -135,7 +135,7 @@ def _read_win_env_flag(name: str, default: bool) -> bool: | |||
| 135 | 135 | return False | |
| 136 | 136 | if adjusted_value in {"1", "true", "yes"}: | |
| 137 | 137 | return True | |
| 138 | - log.warning("%s has unrecognized value %r, treating as %r.", name, value, default) | ||
| 138 | + _logger.warning("%s has unrecognized value %r, treating as %r.", name, value, default) | ||
| 139 | 139 | return default | |
| 140 | 140 | ||
| 141 | 141 | ||
@@ -466,7 +466,7 @@ def is_cygwin_git(git_executable: Union[None, PathLike]) -> bool: | |||
| 466 | 466 | # retcode = process.poll() | |
| 467 | 467 | is_cygwin = "CYGWIN" in uname_out | |
| 468 | 468 | except Exception as ex: | |
| 469 | - log.debug("Failed checking if running in CYGWIN due to: %r", ex) | ||
| 469 | + _logger.debug("Failed checking if running in CYGWIN due to: %r", ex) | ||
| 470 | 470 | _is_cygwin_cache[git_executable] = is_cygwin | |
| 471 | 471 | ||
| 472 | 472 | return is_cygwin | |
| Back | FazBrowse Home | New Git URL |
0 commit comments