本文整理汇总了Python中terminalsize.get_terminal_size函数的典型用法代码示例。如果您正苦于以下问题:Python get_terminal_size函数的具体用法?Python get_terminal_size怎么用?Python get_terminal_size使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_terminal_size函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
self.screen = curses.initscr()
self.screen.timeout(100) # the screen refresh every 100ms
# charactor break buffer
curses.cbreak()
self.screen.keypad(1)
self.netease = NetEase()
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
# term resize handling
size = terminalsize.get_terminal_size()
self.x = max(size[0], 10)
self.y = max(size[1], 25)
self.startcol = int(float(self.x) / 5)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.lyric = ""
self.now_lyric = ""
self.storage = Storage()
self.newversion = False
# Set cursor to invisible.
try:
curses.curs_set(0)
except curses.error:
# The terminal does not supports the visibility requested.
pass
开发者ID:royaso,项目名称:musicbox,代码行数:31,代码来源:ui.py
示例2: init
def init():
height_term, width_term = get_terminal_size()
height_min = COL_HEIGHT * HEIGHT + 2 + 9
width_min = COL_WIDTH * WIDTH + 2 + 5
if height_term < height_min or width_term < width_min:
# resize the terminal to fit the minimum size to display the connect4 before exit
stdout.write("\x1b[8;{h};{w}t".format(h=max(height_min, height_term), w=max(width_min, width_term)))
exit('\033[91m' + 'The terminal was too small, you can now restart ' + '\033[1m' + 'Connect4' + '\033[0m')
stdscr = curses.initscr()
height,width = stdscr.getmaxyx()
if height < height_min or width < width_min:
# abort the program if the terminal can't be resized
curses.endwin()
exit('Please resize your terminal [%d%s%d] (minimum required %d%s%d)' %(width, 'x', height, width_min, 'x', height_min))
curses.noecho()
curses.cbreak()
curses.curs_set(0)
stdscr.keypad(1)
#define the different colors
if curses.can_change_color():
defineColors()
#return stdscr, width
stdscr.clear()
stdscr.border(0)
return stdscr, width, height
开发者ID:guglielmilo,项目名称:connect4,代码行数:25,代码来源:terminal.py
示例3: __init__
def __init__(self):
self.screen = curses.initscr()
self.screen.timeout(100) # the screen refresh every 100ms
# charactor break buffer
curses.cbreak()
self.screen.keypad(1)
self.netease = NetEase()
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
# term resize handling
size = terminalsize.get_terminal_size()
self.x = max(size[0], 10)
self.y = max(size[1], 25)
self.startcol = int(float(self.x) / 5)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.lyric = ''
self.now_lyric = ''
self.tlyric = ''
self.storage = Storage()
self.config = Config()
self.newversion = False
开发者ID:Zorgodon,项目名称:musicbox,代码行数:26,代码来源:ui.py
示例4: print_game_field
def print_game_field():
'''
Function prints game field.
Arguments: none
Return:
game_matrix - array with screen coordinates
'''
cols, rows = terminalsize.get_terminal_size()
start_x = cols/2-5
start_y = rows/2-5
sys.stdout.write("\033[{}H".format(start_y))
sys.stdout.write("\033[{}G | | \n".format(start_x))
sys.stdout.write("\033[{}G---+---+---\n".format(start_x))
sys.stdout.write("\033[{}G | | \n".format(start_x))
sys.stdout.write("\033[{}G---+---+---\n".format(start_x))
sys.stdout.write("\033[{}G | | \n".format(start_x))
sys.stdout.flush()
game_matrix = []
for x in range(3):
game_matrix.append([])
for y in range(3):
game_matrix[x].append({'x':(start_x+1+x*4),'y':(start_y+y*2)})
return game_matrix
开发者ID:andreikhudavets,项目名称:pylearning,代码行数:25,代码来源:tictactoe.py
示例5: main
def main():
print("Let the adventure begin!")
getgoing()
print("And so we continue!")
#Give the screen dimensions greater scope than the renderscreen function
(widthpass, heightpass) = terminalsize.get_terminal_size()
#The first screen
(numofchoices, choicemap) = renderscreen("_init", widthpass, heightpass)
#The main game loop
while True == True:
#getchoice handles exiting the loop, so no external control is needed
choice = getchoice(numofchoices)
#Get the proper screen size
(widthpass, heightpass) = terminalsize.get_terminal_size()
#Will use the choice to render the appropriate screen, ultimately
(numofchoices, choicemap) = renderscreen(choicemap[choice], widthpass, heightpass)
开发者ID:mhspradlin,项目名称:python,代码行数:16,代码来源:main.py
示例6: list_dbentries
def list_dbentries(self):
"""
list all entries in the db.
"""
dbdir = os.path.expanduser('~')
fragnames = []
num = 0
try:
(width, _) = get_terminal_size()
except():
width = 80
print('\n Entries found in the databases:\n')
print(' Fragment | Line | DB Name | Full name, Comments ')
print(sep_line)
for num, line in enumerate(self.gdb.list_fragments()):
fragnames.append(line[0])
line = ' {:<17}| {:<5}| {:<11}| {}'.format(*line)
print(line[:width - 1])
print('\n {} Fragments in the database(s).'.format(num),
'\n Feel free to add more fragments to "{}dsr_user_db.txt"'.format(dbdir + os.path.sep))
for fragment in fragnames:
self.gdb.check_consistency(fragment)
self.gdb.check_db_atom_consistency(fragment)
self.gdb.check_db_restraints_consistency(fragment)
self.gdb.check_sadi_consistence(fragment)
from selfupdate import is_update_needed
if is_update_needed(silent=True):
print("\n*** An update for DSR is available. You can update with 'dsr -u' ***")
sys.exit()
开发者ID:dkratzert,项目名称:DSR,代码行数:29,代码来源:dsr.py
示例7: borrar
def borrar(secadora):
global esclavo
width,height=terminalsize.get_terminal_size()
sys.stdout.write('\0\033[' + str(esclavo[secadora].renglon) + ';1H')
sys.stdout.write('\0\033[1;31m')
printw(esclavo[secadora].nombre)
printw('-',width-9)
开发者ID:hhautomatizacion,项目名称:monitorsecadoras,代码行数:7,代码来源:dryermon.py
示例8: main
def main():
assert_git_config()
try:
usage = ("""usage: %prog <command> [options]
%prog clone [-r alias] [-m URL]
%prog branch [-r alias] [-m URL] [--rf package] [--dryrun]
%prog prepare [-r alias] [-m URL] [--rf package] [--dryrun]
%prog perform [-r alias] [-m URL] [--rf package] [--dryrun]""")
description = """Release Nuxeo Packages.\n
The first call must provide an URL for the configuration. If set to '' (empty string), it defaults to '%s'. You can use
a local file URL ('file://').\n
Then, a 'release.ini' file is generated and will be reused for the next calls. For each package, a
'release-$PACKAGE_NAME.log' file is also generated and corresponds to the file generated by the release.py script.\n
The 'release.ini' file contains informations about the release process:\n
- 'prepared = True' if the prepare task succeeded,\n
- 'performed = True' if the perform task succeeded,\n
- 'uploaded = ...' if an upload successfully happened,\n
- 'skip = Failed!' followed by a stack trace in case of error.\n
The script can be re-called: it will skip the packages with a skip value and skip the prepare (or perform) if
'prepared = True' (or 'performed = True').\n
Failed uploads are not retried and must be manually done.""" % DEFAULT_MP_CONF_URL
help_formatter = IndentedHelpFormatterWithNL(max_help_position=7, width=get_terminal_size()[0])
parser = optparse.OptionParser(usage=usage, description=description, formatter=help_formatter)
parser.add_option('-r', action="store", type="string", dest='remote_alias', default='origin',
help="""The Git alias of remote URL. Default: '%default'""")
parser.add_option('-m', "--marketplace-conf", action="store", type="string", dest='marketplace_conf',
default=None, help="""The Marketplace configuration URL. Default: '%default'""")
parser.add_option('-i', '--interactive', action="store_true", dest='interactive', default=False,
help="""Not implemented (TODO NXP-8573). Interactive mode. Default: '%default'""")
parser.add_option('--rf', '--restart-from', action="store", dest='restart_from', default=None,
help="""Restart from a package. Default: '%default'""")
parser.add_option('--dryrun', action="store_true", dest='dryrun', default=False,
help="""Dry run mode. Default: '%default'""")
(options, args) = parser.parse_args()
if len(args) == 1:
command = args[0]
elif len(args) > 1:
raise ExitException(1, "'command' must be a single argument. See usage with '-h'.")
full_release = ReleaseMP(options.remote_alias, options.restart_from, options.marketplace_conf)
if "command" not in locals():
raise ExitException(1, "Missing command. See usage with '-h'.")
elif command == "clone":
full_release.clone()
elif command == "branch":
full_release.release_branch(dryrun=options.dryrun)
elif command == "prepare":
full_release.prepare(dryrun=options.dryrun)
elif command == "perform":
full_release.perform(dryrun=options.dryrun)
elif command == "test":
full_release.test()
else:
raise ExitException(1, "Unknown command! See usage with '-h'.")
except ExitException, e:
if e.message is not None:
log("[ERROR] %s" % e.message, sys.stderr)
sys.exit(e.return_code)
开发者ID:Vozro,项目名称:nuxeo,代码行数:58,代码来源:release_mp.py
示例9: print_top_right
def print_top_right(text):
'''
print text to top right in terminal
'''
(width, heigth) = terminalsize.get_terminal_size() # @UnusedVariable
text_len = len(text)
text = '| %s |' % text
print_there(1, width - len(text) + 1, '+%s+' % ('-' * (text_len + 2)))
print_there(2, width - len(text) + 1, text)
print_there(3, width - len(text) + 1, '+%s+' % ('-' * (text_len + 2)))
开发者ID:eljrax,项目名称:pyraxshell,代码行数:10,代码来源:utility.py
示例10: printwords
def printwords(self):
"""Nicely print words in columns, sensitive to console width!"""
(console_width, console_height) = terminalsize.get_terminal_size()
if len(self.wordlist) > 0:
word_length = max([len(word) for word in self.wordlist]) + 1
columns = console_width / word_length
for index, word in enumerate(self.wordlist):
if (index+1) % columns == 0:
print
print word.ljust(word_length),
print "\n%d words in list" % len(self.wordlist)
开发者ID:LunaticNeko,项目名称:hackboy,代码行数:11,代码来源:hackboy.py
示例11: __init__
def __init__(self, dim = 15):
self.size = dim
self.board = None
#self.loadedWords = ["word", "test", "another", "much", "words", "blue", "etc"] #todo
self.terminalSize = terminalsize.get_terminal_size()
self.getchar = _Getch()
self.cls = ClearScreen()
self.loadWords()
self.manageMenu()
开发者ID:wgml,项目名称:wordgame,代码行数:11,代码来源:wordgame.py
示例12: print_notification
def print_notification(text):
'''
Function prints notification about current game status.
Input:
text - text string
Return: none
'''
cols, rows = terminalsize.get_terminal_size()
sys.stdout.write("\033[{};{}H".format(rows,0))
sys.stdout.write(text)
sys.stdout.flush()
开发者ID:andreikhudavets,项目名称:pylearning,代码行数:11,代码来源:tictactoe.py
示例13: __init__
def __init__(self):
self.stdout = sys.stdout
self.width, self.height = get_terminal_size()
self.buffers = ['' for i in xrange(self.width)]
self.speed = [randint(-SPEED_RANGE, MAX_SPEED)
for i in xrange(self.width)]
self.in_matrix = True
self.counter = 0
self.animation_thread = Thread(target=self.animation)
self.clrscr()
self.animation_thread.start()
开发者ID:yashunsky,项目名称:matrix,代码行数:12,代码来源:matrix.py
示例14: update_size
def update_size(self):
# get terminal size
size = terminalsize.get_terminal_size()
self.x = max(size[0], 10)
self.y = max(size[1], 25)
# update intendations
curses.resizeterm(self.y, self.x)
self.startcol = int(float(self.x)/5)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
self.screen.clear()
self.screen.refresh()
开发者ID:hoyho,项目名称:musicbox,代码行数:13,代码来源:ui.py
示例15: print_list
def print_list(self):
colorama.init()
sizex, sizey = terminalsize.get_terminal_size()
sizex -= 5
# Print active tasks
tlen = 9 + 10 + 20 + 3
clen = sizex - tlen
fmtstr = (
"%(id)3s | %(content)-"
+ str(clen)
+ "s | %(due)-20s | %(priority)-10s"
+ Fore.RESET
+ Back.RESET
+ Style.RESET_ALL
)
print Back.WHITE + Fore.BLACK + fmtstr % {"id": "#", "content": "Task", "due": "Due", "priority": "Priority"}
if len(self.activetasks) == 0:
print "There are no active tasks. Use the 'Add' command to to one."
else:
c = 0
for t in self.activetasks:
numlines = int(len(t.content) / (clen)) + 1
col1 = c
col2 = ""
col3 = time.strftime("%H:%M:%S %d/%m/%Y", time.localtime(t.duedate))
col4 = t.priority
start = 0
for i in range(numlines):
end = start + clen
if end < len(t.content):
while end > 0:
if t.content[end].isspace():
break
end -= 1
if end == 0:
end = start + clen
col2 = (t.content[start:end]).strip()
start = end
print self.priorityStyles[t.priority] + fmtstr % {
"id": col1,
"content": col2,
"due": col3,
"priority": col4,
}
col1 = col3 = col4 = ""
c += 1
print ""
开发者ID:AstromechZA,项目名称:Tasker,代码行数:50,代码来源:tasklist.py
示例16: __init__
def __init__(self):
self.log_dir = RUN_DIR +'log'
self.error_log = self.log_dir + '/error.txt'
self.success_log = self.log_dir + '/success.txt'
self.debug_log = self.log_dir + '/debug.txt'
self.term_width = get_terminal_size()[0]
if not os.path.exists(self.log_dir):
os.mkdir(self.log_dir)
elif os.path.isfile(self.log_dir):
sys.stderr.write('Failed to create log directory: file with name %s, exists!\n' % (os.path.abspath(self.log_dir)))
exit(1)
elif not os.path.isdir(self.log_dir):
sys.stderr.write('Unknown error creating log directory with name %s\n' % (os.path.abspath(self.log_dir)))
exit(1)
开发者ID:samhowes,项目名称:Downloader,代码行数:15,代码来源:CustomUtilities.py
示例17: execute
def execute(workload_result_file, command_lines):
proc = subprocess.Popen(" ".join(command_lines), shell=True, bufsize=1, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
count = 100
last_time=0
log_file = open(workload_result_file, 'w')
# see http://stackoverflow.com/a/4417735/1442961
lines_iterator = iter(proc.stdout.readline, b"")
for line in lines_iterator:
count += 1
if count > 100 or time()-last_time>1: # refresh terminal size for 100 lines or each seconds
count, last_time = 0, time()
width, height = get_terminal_size()
width -= 1
try:
line = line.rstrip()
log_file.write(line+"\n")
log_file.flush()
except KeyboardInterrupt:
proc.terminate()
break
line = line.decode('utf-8')
line = replace_tab_to_space(line)
#print "{Red}log=>{Color_Off}".format(**Color), line
lline = line.lower()
if ("warn" in lline or 'err' in lline or 'exception' in lline) and lline.lstrip() == lline:
COLOR="Yellow" if "warn" in lline else "Red"
sys.stdout.write((u"{%s}{line}{Color_Off}{ClearEnd}\n" % COLOR).format(line=line,**Color).encode('utf-8'))
else:
if len(line) >= width:
line = line[:width-4]+'...'
progress = matcher.match(lline)
if progress is not None:
show_with_progress_bar(line, progress, width)
else:
sys.stdout.write(u"{line}{ClearEnd}\r".format(line=line, **Color).encode('utf-8'))
sys.stdout.flush()
print
log_file.close()
try:
proc.wait()
except KeyboardInterrupt:
proc.kill()
return 1
return proc.returncode
开发者ID:LakeCarrot,项目名称:EC2_Initializing,代码行数:46,代码来源:execute_with_log.py
示例18: do_about
def do_about(self, args):
'''about
Tells you what this software is about'''
(console_width, console_height) = terminalsize.get_terminal_size()
for par in ['''\
This tool, developed by NeCo Corporation, is designed to assist users with
auditing RobCo TERMLINK security installations, which are notorious for
flawed in-memory security.
''','','''
Weaker passwords, usually 4 characters in length, are trivial and may not
require much forethought. However, when encountered with strong security
with no additional memory access attempts or filtering out improbable
ciphers, it becomes more cumbersome for a security auditor or technician
to service the system. This tool was therefore created.
''']:
print textwrap.fill(textwrap.dedent(par), console_width)
开发者ID:LunaticNeko,项目名称:hackboy,代码行数:17,代码来源:hackboy.py
示例19: __init__
def __init__(self):
self.screen = curses.initscr()
# charactor break buffer
curses.cbreak()
self.screen.keypad(1)
self.netease = NetEase()
curses.start_color()
curses.init_pair(1, curses.COLOR_GREEN, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(4, curses.COLOR_YELLOW, curses.COLOR_BLACK)
# term resize handling
size = terminalsize.get_terminal_size()
self.x = max(size[0], 10)
self.y = max(size[1], 25)
self.startcol = int(float(self.x)/5)
self.indented_startcol = max(self.startcol - 3, 0)
self.update_space()
开发者ID:GarfieldLinux,项目名称:musicbox,代码行数:18,代码来源:ui.py
示例20: imprimir
def imprimir(secadora,color='blanco'):
global esclavo
width,height=terminalsize.get_terminal_size()
if width >87:
sys.stdout.write('\0\033[' + str(esclavo[secadora].renglon) + ';1H')
if color=='blanco':
sys.stdout.write('\0\033[1;37m')
if color=='verde':
sys.stdout.write('\0\033[1;32m')
if color=='amarillo':
sys.stdout.write('\0\033[1;33m')
printw(esclavo[secadora].nombre)
printw(esclavo[secadora].temp1,8)
printw(esclavo[secadora].temp2,8)
printw(esclavo[secadora].entrada1,3)
printw(esclavo[secadora].entrada2,3)
printw(esclavo[secadora].formula)
printw(esclavo[secadora].display,width-87)
printw(str(esclavo[secadora].version))
printw(str(esclavo[secadora].tiemporespuesta),17)
printw(str(esclavo[secadora].tiemporespuestas),17)
开发者ID:hhautomatizacion,项目名称:monitorsecadoras,代码行数:21,代码来源:dryermon.py
注:本文中的terminalsize.get_terminal_size函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论