forked from bbfamily/abu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwidget_base.py
executable file
·42 lines (36 loc) · 1.43 KB
/
widget_base.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- encoding:utf-8 -*-
from __future__ import print_function
from __future__ import division
from contextlib import contextmanager
import os
import sys
import warnings
sys.path.insert(0, os.path.abspath('../'))
warnings.filterwarnings('ignore')
warnings.simplefilter('ignore')
@contextmanager
def show_ui_ct():
print('正在初始化界面元素,请稍后...')
from abupy import ABuStrUtil
go_on = True
try:
if ABuStrUtil.str_is_cn(str(ABuStrUtil.__file__)):
# 检测到运行环境路径中含有中文,严重错误,将出错,使用中文警告
msg = u'严重错误!当前运行环境下有中文路径,abu将无法正常运行!请不要使用中文路径名称, 当前环境为{}'.format(
ABuStrUtil.to_unicode(str(ABuStrUtil.__file__)))
import logging
logging.info(msg)
go_on = False
except:
# 如果是其它编码的字符路径会进到这里
import logging
msg = 'error!non English characters in the current running environment,abu will not work properly!'
logging.info(msg)
go_on = False
yield go_on
if go_on:
from IPython.display import clear_output
clear_output()
# import time
# 这里sleep(0.3)防止有些版本clear_output把下面要展示的清除了,也不能使用clear_output的wait参数,有些浏览器卡死
# time.sleep(0.3)