本文整理汇总了Python中terminal.Terminal类的典型用法代码示例。如果您正苦于以下问题:Python Terminal类的具体用法?Python Terminal怎么用?Python Terminal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Terminal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, text, generatorFunc = None):
Terminal.__init__(self, text)
if generatorFunc is None:
generatorFunc = lambda _: text
self.generator = generatorFunc
开发者ID:arita37,项目名称:gptrees,代码行数:7,代码来源:id.py
示例2: onClickConectar
def onClickConectar(self, widget, data):
self.log("Conectando a " + data["ip"] +
" con el usuario " + data["usuario"] +
" ["+data["nombre"]+"]")
t = Terminal(data)
t.show_all()
开发者ID:brutalchrist,项目名称:sshthon,代码行数:7,代码来源:sshthon.py
示例3: render_log_frames
def render_log_frames(golog_path, rows, cols, limit=None):
"""
Returns the frames of *golog_path* as a list of HTML-encoded strings that
can be used with the playback_log.html template. It accomplishes this task
by running the frames through the terminal emulator and capturing the HTML
output from the `Terminal.dump_html` method.
If *limit* is given, only return that number of frames (e.g. for preview)
"""
out_frames = []
from terminal import Terminal
term = Terminal(
# 14/7 for the em_height should be OK for most browsers to ensure that
# images don't always wind up at the bottom of the screen.
rows=rows, cols=cols, em_dimensions={'height':14, 'width':7})
for i, frame in enumerate(get_frames(golog_path)):
if limit and i == limit:
break
if len(frame) > 14:
if i == 0 and frame[14:15] == b'{':
# This is just the metadata frame. Skip it
continue
frame_time = int(float(frame[:13]))
frame_screen = frame[14:] # Skips the colon
# Emulate how a real shell would output newlines:
frame_screen = frame_screen.replace(b'\n', b'\r\n')
term.write(frame_screen)
# Ensure we're not in the middle of capturing a file. Otherwise
# it might get cut off and result in no image being shown.
if term.capture:
continue
scrollback, screen = term.dump_html()
out_frames.append({'screen': screen, 'time': frame_time})
del term # Ensures any file capture file descriptors are cleaned up
return out_frames # Skip the first frame which is the metadata
开发者ID:jumping,项目名称:GateOne,代码行数:35,代码来源:logviewer.py
示例4: Theatre
class Theatre(object):
def __init__(self, here, manager_loc, core_store, store_lock, current_id, id_lock, current_creator, creator_lock, port_range, f = None, args = None, kwds = None, ps = None):
log.debug(self, 'starting')
self.__here = here
port = ids.port_from_loc(here)
self.__shared_data = Shared(port, current_id, id_lock, core_store, store_lock, current_creator, creator_lock, port_range)
self.__actor_store = LocalActorStore(self.__here, self.__shared_data)
self.__messenger = Messenger(here, self.__actor_store)
self.__migrator = Migrator(here, self.__actor_store, self.__shared_data)
self.__manager_loc = manager_loc
self.__port_range = port_range
self.__term = None
self.__processes = ps
if (port == port_range[0]):
self.__term = Terminal(self, here)
self.valve = rpc.RPCValve(port, self.external_interface(), log)
set_local_theatre(self.internal_interface())
self.valve.listen()
print('Theatre created on port ' + str(port))
vis.add_host(here)
if (port != port_range[0]):
while True:
try:
time.sleep(5)
except:
pass
else:
self.f = f
self.f(*args, **kwds)
self.__term.shell()
def external_interface(self):
return TheatreExternalInterface(self.__messenger, self.__migrator, self.__term, self, self.__actor_store)
def internal_interface(self):
return TheatreInternalInterface(self.__here, self.__messenger, self.__actor_store, self.__migrator, self.__manager_loc, self.__shared_data)
def shutdown(self):
for port in self.__port_range:
if (port != self.__port_range[0]):
network_locator = rpc.RPCConnector("127.0.0.1:" + str(port))
locator = network_locator.connect()
locator.shutdown()
locator.disconnect()
self.valve.shutdown()
time.sleep(2)
for p in self.__processes:
p.terminate()
time.sleep(2)
sys.exit()
def __str__(self):
return "Theatre"
开发者ID:fredvdd,项目名称:Swan,代码行数:58,代码来源:theatre.py
示例5: _style
def _style(self, obj):
f, b = None, None
if obj.color:
f = Terminal.fcolor(obj.color, obj.bright)
if obj.bg_color:
b = Terminal.bcolor(obj.bg_color, obj.bg_bright)
self.styles.append((f, b))
obj.enter(self.selector)
self.styles.pop()
开发者ID:joushou,项目名称:newui,代码行数:9,代码来源:system.py
示例6: enter_status_line
def enter_status_line(self, mode, enter):
if not enter:
status_line = ''.join(self.status_line)
if len(status_line) > 0:
self.process_status_line(mode, status_line)
else:
self.status_line = []
self.status_line_mode = mode
Terminal.enter_status_line(self, mode, enter)
开发者ID:stonewell,项目名称:pymterm,代码行数:10,代码来源:terminal_gui.py
示例7: add_terminal
def add_terminal (self):
terminal = Terminal (self.config)
terminal.connect ("key-release", self.__on_key_release)
terminal.connect ("exited", self.__on_terminal_exited)
number = self.notebook.append_page (terminal, None)
self.tabs[number] = terminal
self.notebook.set_current_page (number)
return terminal
开发者ID:gsterjov,项目名称:quick-terminal,代码行数:10,代码来源:window.py
示例8: on_data
def on_data(self, data):
try:
# self._data_lock.acquire()
Terminal.on_data(self, data)
except:
LOGGER.exception('on data')
finally:
# self._data_lock.release()
pass
self.refresh_display()
开发者ID:stonewell,项目名称:pymterm,代码行数:11,代码来源:terminal_gui.py
示例9: _retrieve_log_flat
def _retrieve_log_flat(queue, settings):
"""
Writes the given *log_filename* to *queue* in a flat format equivalent to::
./logviewer.py --flat log_filename
*settings* - A dict containing the *log_filename*, *colors*, and *theme* to
use when generating the HTML output.
"""
out_dict = {
'result': "",
'log': "",
'metadata': {},
}
# Local variables
out = []
spanstrip = re.compile(r'\s+\<\/span\>$')
gateone_dir = settings['gateone_dir']
user = settings['user']
users_dir = settings['users_dir']
container = settings['container']
prefix = settings['prefix']
log_filename = settings['log_filename']
theme = "%s.css" % settings['theme']
colors = "%s.css" % settings['colors']
logs_dir = os.path.join(users_dir, "logs")
log_path = os.path.join(logs_dir, log_filename)
if os.path.exists(log_path):
out_dict['metadata'] = get_or_update_metadata(log_path, user)
out_dict['metadata']['filename'] = log_filename
out_dict['result'] = "Success"
import StringIO
# Use the terminal emulator to create nice HTML-formatted output
from terminal import Terminal
term = Terminal(rows=100, cols=300)
io_obj = StringIO.StringIO()
flatten_log(log_path, io_obj)
io_obj.seek(0)
# Needed to emulate an actual term
flattened_log = io_obj.read().replace('\n', '\r\n')
term.write(flattened_log)
scrollback, screen = term.dump_html()
# Join them together
log_lines = scrollback + screen
# rstrip the lines
log_lines = [a.rstrip() for a in log_lines]
# Fix things like "<span>whatever [lots of whitespace] </span>"
for i, line in enumerate(log_lines):
out.append(spanstrip.sub("</span>", line))
out_dict['log'] = out
else:
out_dict['result'] = _("ERROR: Log not found")
message = {'logging_log_flat': out_dict}
queue.put(message)
开发者ID:Kacn,项目名称:GateOne,代码行数:54,代码来源:logging_plugin.py
示例10: _retrieve_log_flat
def _retrieve_log_flat(queue, settings):
"""
Writes the given *log_filename* to *queue* in a flat format equivalent to::
./logviewer.py --flat log_filename
*settings* - A dict containing the *log_filename*, *colors_css*, and
*theme_css* to use when generating the HTML output.
"""
out_dict = {
'result': "",
'log': "",
'metadata': {},
}
# Local variables
out = []
spanstrip = re.compile(r'\s+\<\/span\>$')
user = settings['user']
users_dir = settings['users_dir']
log_filename = settings['log_filename']
logs_dir = os.path.join(users_dir, "logs")
log_path = os.path.join(logs_dir, log_filename)
if os.path.exists(log_path):
out_dict['metadata'] = get_or_update_metadata(log_path, user)
out_dict['metadata']['filename'] = log_filename
out_dict['result'] = "Success"
from io import BytesIO
# Use the terminal emulator to create nice HTML-formatted output
from terminal import Terminal
term = Terminal(rows=100, cols=300, em_dimensions=0)
io_obj = BytesIO()
flatten_log(log_path, io_obj)
io_obj.seek(0)
# Needed to emulate an actual term
flattened_log = io_obj.read().replace(b'\n', b'\r\n')
# NOTE: Using chunking below to emulate how a stream might actually be
# written to the terminal emulator. This is to prevent the emulator
# from thinking that any embedded files (like PDFs) are never going to
# end.
def chunker(s, n):
"""Produce `n`-character chunks from `s`."""
for start in range(0, len(s), n):
yield s[start:start+n]
for chunk in chunker(flattened_log, 499):
term.write(chunk)
scrollback, screen = term.dump_html()
# Join them together
log_lines = scrollback + screen
# rstrip the lines
log_lines = [a.rstrip() for a in log_lines]
# Fix things like "<span>whatever [lots of whitespace] </span>"
for i, line in enumerate(log_lines):
out.append(spanstrip.sub("</span>", line))
out_dict['log'] = out
term.clear_screen() # Ensure the function below works...
term.close_captured_fds() # Force clean up open file descriptors
else:
out_dict['result'] = _("ERROR: Log not found")
message = {'terminal:logging_log_flat': out_dict}
queue.put(message)
开发者ID:ArneBab,项目名称:GateOne,代码行数:60,代码来源:logging_plugin.py
示例11: _styleoverride
def _styleoverride(self, obj):
height, width, x_off, y_off = self.box_stack[-1]
if obj.absolute:
x_off = obj.pos_x
y_off = obj.pos_y
x, y = x_off + obj.margin_left, y_off + obj.margin_top
val, fg, bg, z_index = self.screen.get(x, y)
if obj.color:
fg = Terminal.fcolor(obj.color, obj.bright)
if obj.bg_color:
bg = Terminal.bcolor(obj.bg_color, obj.bg_bright)
self.screen.set(x, y, fg=fg, bg=bg, z_index=z_index+10)
开发者ID:joushou,项目名称:newui,代码行数:14,代码来源:system.py
示例12: has_directories
def has_directories(self, directories, auto_create=True):
try:
self.ssh_client.connect(self.address, username=self.user)
for directory in directories:
if not self._has_file(directory):
if auto_create:
Terminal.print_warn('Missing directory "%s", attempting to create.' % directory)
if not self._create_directory(directory):
raise ServerError('Could not create directory "%s"' % directory)
else:
raise ServerError('Missing directory "%s".' % directory)
except IOError, e:
raise ServerError('An error occurred with the ssh connection.\n\t> %s' % e, base=e)
开发者ID:OlivierBoucher,项目名称:Deploy,代码行数:15,代码来源:server.py
示例13: __init__
def __init__(self, file_to_open=""):
super().__init__()
self.setWindowTitle("New file")
self.force_quit_flag = False
self.config = read_config()
self.setStyleSheet("background: " + self.config["theme"]["background"])
layout = QtGui.QVBoxLayout(self)
common.kill_theming(layout)
scene_container = QtGui.QScrollArea(self)
layout.addWidget(scene_container, stretch=1)
self.scene = Scene(
self.config, scene_container.horizontalScrollBar().value, scene_container.verticalScrollBar().value
)
scene_container.setWidget(self.scene)
self.terminal = Terminal(self, lambda: self.scene.file_path)
layout.addWidget(self.terminal)
self.connect_signals(self.scene, self.terminal)
common.set_hotkey("Escape", self, self.terminal.toggle)
if file_to_open:
self.scene.open_file(file_to_open)
self.show()
开发者ID:nycz,项目名称:urd,代码行数:32,代码来源:urd.py
示例14: __init__
def __init__(self, here, manager_loc, core_store, store_lock, current_id, id_lock, current_creator, creator_lock, port_range, f = None, args = None, kwds = None, ps = None):
log.debug(self, 'starting')
self.__here = here
port = ids.port_from_loc(here)
self.__shared_data = Shared(port, current_id, id_lock, core_store, store_lock, current_creator, creator_lock, port_range)
self.__actor_store = LocalActorStore(self.__here, self.__shared_data)
self.__messenger = Messenger(here, self.__actor_store)
self.__migrator = Migrator(here, self.__actor_store, self.__shared_data)
self.__manager_loc = manager_loc
self.__port_range = port_range
self.__term = None
self.__processes = ps
if (port == port_range[0]):
self.__term = Terminal(self, here)
self.valve = rpc.RPCValve(port, self.external_interface(), log)
set_local_theatre(self.internal_interface())
self.valve.listen()
print('Theatre created on port ' + str(port))
vis.add_host(here)
if (port != port_range[0]):
while True:
try:
time.sleep(5)
except:
pass
else:
self.f = f
self.f(*args, **kwds)
self.__term.shell()
开发者ID:fredvdd,项目名称:Swan,代码行数:33,代码来源:theatre.py
示例15: cleanup
def cleanup(self):
if self.oldattrs is not None:
termios.tcsetattr(sys.stdin, termios.TCSANOW, self.oldattrs)
sys.stdout.write(Terminal.cursor_show())
sys.stdout.flush()
self.disable_alternate()
fl = fcntl.fcntl(sys.stdin.fileno(), fcntl.F_GETFL)
fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, fl & ~os.O_NONBLOCK)
开发者ID:joushou,项目名称:newui,代码行数:9,代码来源:system.py
示例16: get_supervisor_config
def get_supervisor_config(self, project, auto_create=True):
try:
self.ssh_client.connect(self.address, username=self.user)
ubuntu_config_dir = '/etc/supervisor/conf.d'
rehl_config_dir = '/etc/supervisord.d'
config_path = ''
if self._has_file(ubuntu_config_dir):
config_path = "%s/%s.conf" % (ubuntu_config_dir, project.lower())
elif self._has_file(rehl_config_dir):
config_path = '%s/%s.conf' % (rehl_config_dir, project.lower())
else:
raise ServerError('Could not find supervisor include dir')
if not self._has_file(config_path):
if auto_create:
Terminal.print_warn(
'Missing supervisor config for %s in "%s", attempting to create.' % (project, config_path))
if self.user != 'root' and self.password is None:
self._prompt_superuser_pwd(
'Missing file "%s", Please enter password to proceed to creation.' % config_path)
out, err = self._execute_sudo_cmd('touch %s' % config_path)
if err != '':
self.password = None
raise ServerError('Could not create supervisor config in "%s" : %s' % (config_path, err))
return ''
else:
raise ServerError('Missing supervisor config for %s in "%s".' % (project, config_path))
stdin, stdout, stderr = self.ssh_client.exec_command('cat %s' % config_path)
out, err = stdout.read().rstrip(), stderr.read().rstrip()
if err != '':
raise ServerError('Could not read supervisor config "%s"' % config_path)
return out
except IOError, e:
raise ServerError('An error occurred with the ssh connection.\n\t> %s' % e, base=e)
开发者ID:OlivierBoucher,项目名称:Deploy,代码行数:44,代码来源:server.py
示例17: main
def main():
try:
os.environ["TERM"] = "xterm-256color"
screen = init_curses()
terminal = Terminal(screen)
timer = Stopwatch()
#Application Loop
while True:
#Determine if user input should be used this cycle
if timer.get_elapsed() >= PERIOD:
terminal.use_key = True
timer.reset()
#Generate and display the terminal frame
terminal.application_frame()
finally:
exit_curses(screen)
开发者ID:pholtz,项目名称:terminalia,代码行数:20,代码来源:terminalia.py
示例18: has_git_repositories
def has_git_repositories(self, bare_repo_directory, src_repo_directory, auto_create=True):
try:
self.ssh_client.connect(self.address, username=self.user)
if not self._is_repo(bare_repo_directory, bare=True):
if auto_create:
Terminal.print_warn('No bare git repository in "%s", attempting to create.' % bare_repo_directory)
if not self._init_repo(bare_repo_directory, bare=True):
raise ServerError('Could not create bare git repository in "%s"' % bare_repo_directory)
else:
raise ServerError('Missing bare git repository in "%s".' % bare_repo_directory)
if not self._is_repo(src_repo_directory, bare=False):
if auto_create:
Terminal.print_warn('No src git repository in "%s", attempting to create.' % src_repo_directory)
if not self._clone_repo(bare_repo_directory, src_repo_directory):
raise ServerError('Could not create src git repository in "%s"' % src_repo_directory)
else:
raise ServerError('Missing src git repository in "%s".' % src_repo_directory)
except IOError, e:
raise ServerError('An error occurred with the ssh connection.\n\t> %s' % e, base=e)
开发者ID:OlivierBoucher,项目名称:Deploy,代码行数:21,代码来源:server.py
示例19: __init__
def __init__(self, user_config, reactor=reactor):
super(UI, self).__init__()
self.user_config = user_config
self.reactor = reactor
self.player = Player(initial_volume=user_config.persistent.volume)
self.progress_bar = ProgressBar(
self.user_config.appearance.progress_bar)
self.time_check = TimeCheck()
self.status_bar = HorizontalContainer(
(self.progress_bar, self.time_check))
self.terminal = Terminal()
self.key_bindings = self._create_key_bindings()
开发者ID:William-Weaver,项目名称:pyamp,代码行数:12,代码来源:pyamp.py
示例20: __init__
def __init__(self, cfg):
Terminal.__init__(self, cfg)
self.term_widget = None
self.session = None
self.col = 0
self.row = 0
self.remain_buffer = []
self.cur_line_option = get_default_text_attribute()
self.saved_screen_buffer, self.saved_cursor, \
self.saved_cur_line_option = \
ScreenBuffer(), (0, 0), get_default_text_attribute()
self.status_line = []
self.status_line_mode = 0
self.charset_modes_translate = [None, None]
self.charset_mode = 0
self._saved_charset_modes_translate = [None, None]
self._saved_charset_mode = 0
self._data_lock = threading.RLock()
self._screen_buffer = ScreenBuffer()
self._dec_mode = False
self._force_column = False
self._force_column_count = 80
self._origin_mode = False
self._saved_origin_mode = False
self._tab_stops = {}
self._set_default_tab_stops()
self._cursor_visible = True
开发者ID:stonewell,项目名称:pymterm,代码行数:39,代码来源:terminal_gui.py
注:本文中的terminal.Terminal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论