-
Notifications
You must be signed in to change notification settings - Fork 556
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #193 from fasiondog/feature/factor
优化日志在不同环境下输出; 优化系统部件reset和clone操作
- Loading branch information
Showing
31 changed files
with
419 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf8 -*- | ||
# | ||
# Create on: 2024-03-11 | ||
# Author: fasiondog | ||
|
||
# 来源于 pandas 中对 ipython,notebook 环境的检测代码 | ||
|
||
def in_interactive_session() -> bool: | ||
""" | ||
Check if we're running in an interactive shell. | ||
|
||
Returns | ||
------- | ||
bool | ||
True if running under python/ipython interactive shell. | ||
""" | ||
def check_main(): | ||
try: | ||
import __main__ as main | ||
except ModuleNotFoundError: | ||
return False | ||
return not hasattr(main, "__file__") | ||
|
||
try: | ||
# error: Name '__IPYTHON__' is not defined | ||
return __IPYTHON__ or check_main() # type: ignore[name-defined] | ||
except NameError: | ||
return check_main() | ||
|
||
|
||
def in_ipython_frontend() -> bool: | ||
""" | ||
Check if we're inside an IPython zmq frontend. 检测是否在 jupyter 环境中 | ||
|
||
Returns | ||
------- | ||
bool | ||
""" | ||
try: | ||
# error: Name 'get_ipython' is not defined | ||
ip = get_ipython() # type: ignore[name-defined] | ||
return "zmq" in str(type(ip)).lower() | ||
except NameError: | ||
pass | ||
|
||
return False |
Oops, something went wrong.