mirror of
https://github.com/asciinema/asciinema.git
synced 2025-12-16 19:58:03 +01:00
Remove stream/pipe recording
It doesn't make much sense to record non-interactive commands.
This commit is contained in:
21
src/cli.py
21
src/cli.py
@@ -66,19 +66,16 @@ def handle_unknown_action(action):
|
|||||||
def record_asciicast():
|
def record_asciicast():
|
||||||
asciicast = Asciicast()
|
asciicast = Asciicast()
|
||||||
|
|
||||||
if sys.stdin.isatty():
|
if options.command:
|
||||||
if options.command:
|
command = options.command
|
||||||
command = options.command
|
is_shell = False
|
||||||
is_shell = False
|
|
||||||
else:
|
|
||||||
command = os.environ['SHELL']
|
|
||||||
is_shell = True
|
|
||||||
|
|
||||||
stdin_file = asciicast.stdin_file if options.record_input else None
|
|
||||||
duration = recorders.record_process(command, is_shell,
|
|
||||||
asciicast.stdout_file, stdin_file)
|
|
||||||
else:
|
else:
|
||||||
duration = recorders.record_stream(sys.stdin, asciicast.stdout_file)
|
command = os.environ['SHELL']
|
||||||
|
is_shell = True
|
||||||
|
|
||||||
|
stdin_file = asciicast.stdin_file if options.record_input else None
|
||||||
|
duration = recorders.record_process(command, is_shell,
|
||||||
|
asciicast.stdout_file, stdin_file)
|
||||||
|
|
||||||
asciicast.user_token = config.user_token
|
asciicast.user_token = config.user_token
|
||||||
asciicast.command = options.command
|
asciicast.command = options.command
|
||||||
|
|||||||
@@ -12,11 +12,6 @@ import time
|
|||||||
import tty
|
import tty
|
||||||
|
|
||||||
|
|
||||||
def record_stream(stream, stdout_file):
|
|
||||||
recorder = StreamRecorder(stream, stdout_file)
|
|
||||||
return record(recorder)
|
|
||||||
|
|
||||||
|
|
||||||
def record_process(command, is_shell, stdout_file, stdin_file=None):
|
def record_process(command, is_shell, stdout_file, stdin_file=None):
|
||||||
recorder = ProcessRecorder(command, is_shell, stdout_file, stdin_file)
|
recorder = ProcessRecorder(command, is_shell, stdout_file, stdin_file)
|
||||||
return record(recorder)
|
return record(recorder)
|
||||||
@@ -29,23 +24,6 @@ def record(recorder):
|
|||||||
return end_time - start_time
|
return end_time - start_time
|
||||||
|
|
||||||
|
|
||||||
class StreamRecorder(object):
|
|
||||||
|
|
||||||
def __init__(self, stream, stdout_file):
|
|
||||||
self.stream = stream
|
|
||||||
self.stdout_file = stdout_file
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
while 1:
|
|
||||||
line = self.stream.readline()
|
|
||||||
|
|
||||||
if len(line) == 0:
|
|
||||||
break
|
|
||||||
|
|
||||||
self.stdout_file.write(line)
|
|
||||||
print line,
|
|
||||||
|
|
||||||
|
|
||||||
class ProcessRecorder(object):
|
class ProcessRecorder(object):
|
||||||
'''Pseudo-terminal recorder.
|
'''Pseudo-terminal recorder.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user