本文整理汇总了Python中win_unicode_console.enable函数的典型用法代码示例。如果您正苦于以下问题:Python enable函数的具体用法?Python enable怎么用?Python enable使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了enable函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_ready
async def on_ready(self):
try:
win_unicode_console.enable()
except:
0
await self.change_status(game=discord.Game(name='with Eruru\'s tail'))
print('Connected!\n')
print('Username: %s' % self.user.name)
print('Bot ID: %s' % self.user.id)
print()
print('Command prefix is %s'% self.config.command_prefix)
print()
print('--Connected Servers List--')
if self.servers:
[print(s) for s in self.servers]
else:
print('No servers have been joined yet.')
print()
print('--Users Registered--')
if len(self.users) > 0:
for user in self.users:
print(user.id + ' - ' + user.kissUrl)
else:
print('No users have registered yet.')
print()
print('--Log--')
handler = getattr(self, 'event_loop', None)
await handler()
示例2: enable_win_unicode_console
def enable_win_unicode_console(self):
if sys.version_info >= (3, 6):
# Since PEP 528, Python uses the unicode APIs for the Windows
# console by default, so WUC shouldn't be needed.
return
import win_unicode_console
if PY3:
win_unicode_console.enable()
else:
# https://github.com/ipython/ipython/issues/9768
from win_unicode_console.streams import (TextStreamWrapper,
stdout_text_transcoded, stderr_text_transcoded)
class LenientStrStreamWrapper(TextStreamWrapper):
def write(self, s):
if isinstance(s, bytes):
s = s.decode(self.encoding, 'replace')
self.base.write(s)
stdout_text_str = LenientStrStreamWrapper(stdout_text_transcoded)
stderr_text_str = LenientStrStreamWrapper(stderr_text_transcoded)
win_unicode_console.enable(stdout=stdout_text_str,
stderr=stderr_text_str)
示例3: enable_win_unicode_console
def enable_win_unicode_console(self):
if sys.version_info >= (3, 6):
# Since PEP 528, Python uses the unicode APIs for the Windows
# console by default, so WUC shouldn't be needed.
return
import win_unicode_console
win_unicode_console.enable()
示例4: setup_win_unicode_console
def setup_win_unicode_console(enable):
""""Enables or disables unicode display on windows."""
enable = to_bool(enable)
if ON_WINDOWS and win_unicode_console:
if enable:
win_unicode_console.enable()
else:
win_unicode_console.disable()
return enable
示例5: on_ready
async def on_ready(self):
win_unicode_console.enable()
print('Connected!\n')
print('Username: ' + self.user.name)
print('ID: ' + self.user.id)
print('--Server List--')
for server in self.servers:
print(server.name)
print()
示例6: main
def main(argv):
# parse config file
configfile = './config.cfg'
if len(argv) == 2:
configfile = argv[1]
config = parse_config(configfile)
win_unicode_console.enable()
result = check_update(config)
win_unicode_console.disable()
return result
示例7: setup_win_unicode_console
def setup_win_unicode_console(enable):
""""Enables or disables unicode display on windows."""
try:
import win_unicode_console
except ImportError:
win_unicode_console = False
enable = to_bool(enable)
if ON_WINDOWS and win_unicode_console:
if enable:
win_unicode_console.enable()
else:
win_unicode_console.disable()
return enable
示例8: main
def main():
try:
if os.name == 'nt':
import win_unicode_console
win_unicode_console.enable()
fmt = '%(name)-20s%(lineno)-3s %(funcName)-17s: %(message)s'.format()
logging.basicConfig(format=fmt, level=logging.INFO)
functionName, args = simple_parse_args(sys.argv)
functionObject = get_function_from_name(functionName)
log.info("%s(%s) ...", functionObject.__name__, ", ".join(args))
functionObject(*args)
return 0
except KeyboardInterrupt:
print("\n... bye!")
示例9: init_io
def init_io(self):
if sys.platform not in {'win32', 'cli'}:
return
import win_unicode_console
import colorama
win_unicode_console.enable()
colorama.init()
# For some reason we make these wrappers around stdout/stderr.
# For now, we need to reset them so all output gets coloured.
# https://github.com/ipython/ipython/issues/8669
from IPython.utils import io
io.stdout = io.IOStream(sys.stdout)
io.stderr = io.IOStream(sys.stderr)
示例10: run
def run():
""" Run as CLI command """
try:
import win_unicode_console
win_unicode_console.enable(use_unicode_argv=True)
except ImportError:
pass
try:
import colorama
colorama.init()
except ImportError:
pass
import warnings
warnings.simplefilter("ignore")
sys.exit(main())
示例11: set_colors
def set_colors():
global G, Y, B, R, W , M , C , end ,Bold,underline
if os.name=="nt":
try:
import win_unicode_console , colorama
win_unicode_console.enable()
colorama.init()
#green - yellow - blue - red - white - magenta - cyan - reset
G,Y,B,R,W,M,C,end= '\033[92m','\033[93m','\033[94m','\033[91m','\x1b[37m','\x1b[35m','\x1b[36m','\033[0m'
Bold = "\033[1m"
underline = "\033[4m"
except:
G = Y = B = R = W = G = Y = B = R = Bold = underline = ''
else:
#import colorama
#colorama.init()
#green - yellow - blue - red - white - magenta - cyan - reset
G,Y,B,R,W,M,C,end= '\033[92m','\033[93m','\033[94m','\033[91m','\x1b[37m','\x1b[35m','\x1b[36m','\033[0m'
Bold = "\033[1m"
underline = "\033[4m"
示例12: enable_win_unicode_console
def enable_win_unicode_console(self):
import win_unicode_console
if PY3:
win_unicode_console.enable()
else:
# https://github.com/ipython/ipython/issues/9768
from win_unicode_console.streams import (TextStreamWrapper,
stdout_text_transcoded, stderr_text_transcoded)
class LenientStrStreamWrapper(TextStreamWrapper):
def write(self, s):
if isinstance(s, bytes):
s = s.decode(self.encoding, 'replace')
self.base.write(s)
stdout_text_str = LenientStrStreamWrapper(stdout_text_transcoded)
stderr_text_str = LenientStrStreamWrapper(stderr_text_transcoded)
win_unicode_console.enable(stdout=stdout_text_str,
stderr=stderr_text_str)
示例13: on_ready
async def on_ready(self):
win_unicode_console.enable()
print('Connected!\n')
print('Username: %s' % self.user.name)
print('Bot ID: %s' % self.user.id)
print('Owner ID: %s' % self.config.owner_id)
print()
print("Command prefix is %s" % self.config.command_prefix)
# print("Days active required to use commands is %s" % self.config.days_active) # NYI
print("Skip threshold at %s votes or %g%%" % (self.config.skips_required, self.config.skip_ratio_required*100))
print("Whitelist check is %s" % ['disabled', 'enabled'][self.config.white_list_check])
print("Now Playing message @mentions are %s" % ['disabled', 'enabled'][self.config.now_playing_mentions])
print("Autosummon is %s" % ['disabled', 'enabled'][self.config.auto_summon])
print("Auto-playlist is %s" % ['disabled', 'enabled'][self.config.auto_playlist])
print()
if self.servers:
print('--Server List--')
[print(s) for s in self.servers]
else:
print("No servers have been joined yet.")
print()
if self.config.owner_id == self.user.id:
print(
"[Notice] You have either set the OwnerID config option to the bot's id instead "
"of yours, or you've used your own credentials to log the bot in instead of the "
"bot's account (the bot needs its own account to work properly).")
# maybe option to leave the ownerid blank and generate a random command for the owner to use
if self.config.auto_summon:
as_ok = await self._auto_summon()
if self.config.auto_playlist and as_ok:
await self.on_finished_playing(await self.get_player(self._get_owner_voice_channel()))
示例14: print
pass
# Check if we are running this on windows platform
is_windows = sys.platform.startswith('win')
# Console Colors
if is_windows:
# Windows deserves coloring too :D
G = '\033[92m' # green
Y = '\033[93m' # yellow
B = '\033[94m' # blue
R = '\033[91m' # red
W = '\033[0m' # white
try:
import win_unicode_console , colorama
win_unicode_console.enable()
colorama.init()
#Now the unicode will work ^_^
except:
print("[!] Error: Coloring libraries not installed, no coloring will be used [Check the readme]")
G = Y = B = R = W = G = Y = B = R = W = ''
else:
G = '\033[92m' # green
Y = '\033[93m' # yellow
B = '\033[94m' # blue
R = '\033[91m' # red
W = '\033[0m' # white
示例15: init_output
def init_output():
import colorama
win_unicode_console.enable()
colorama.init()