You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sudo apt-get install nmap # nmap is needed for the man parser in UnitTest
30
+
sudo apt-get --yes install net-tools nmap # needed for the man parser in UnitTest
31
+
# sudo apt-get --yes install xclip # needed for pyperclip, only on Linux (more info: https://pyperclip.readthedocs.io/en/latest/index.html#not-implemented-error)
31
32
elif [[ "$OSTYPE" == "darwin"* ]]; then
32
33
echo "OS: Mac OSX"
33
34
brew install nmap
@@ -40,6 +41,8 @@ jobs:
40
41
if: always()
41
42
run: |
42
43
$GITHUB_WORKSPACE/installer.sh
44
+
# this flag file is needed to run the TestMain unitTests (test_main.py)
Copy file name to clipboardExpand all lines: fastHistory/console/consoleUtils.py
+25-14Lines changed: 25 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -15,31 +15,42 @@ class ConsoleUtils:
15
15
"""
16
16
17
17
@staticmethod
18
-
deffill_terminal_input(data):
18
+
defpaste_into_terminal(data):
19
19
"""
20
20
Fill terminal input with data
21
21
# https://unix.stackexchange.com/a/217390
22
22
"""
23
-
# check if python version >= 3
24
-
ifsys.version_info>= (3,):
25
-
# reverse the automatic encoding and pack into a list of bytes
26
-
data= (struct.pack('B', c) forcinos.fsencode(data))
27
23
28
-
# put each char of data in the standard input of the current terminal
29
-
forcindata:
30
-
fcntl.ioctl(sys.stdin, termios.TIOCSTI, c)
31
-
# clear output printed by the previous command
32
-
# and leave only the terminal with the submitted input
33
-
sys.stdout.write('\r')
24
+
try:
25
+
# check if python version >= 3
26
+
ifsys.version_info>= (3,):
27
+
# reverse the automatic encoding and pack into a list of bytes
28
+
data_bytes= (struct.pack('B', c) forcinos.fsencode(data))
29
+
30
+
# put each char of data in the standard input of the current terminal
31
+
forcindata_bytes:
32
+
fcntl.ioctl(sys.stdin, termios.TIOCSTI, c)
33
+
# clear output printed by the previous command
34
+
# and leave only the terminal with the submitted input
35
+
sys.stdout.write('\r')
36
+
return [True, None]
37
+
exceptException:
38
+
res=ConsoleUtils.copy_to_clipboard(data)
39
+
ifres[0]:
40
+
return [False, "your terminal does not support auto-paste, the command is copied to clipboard instead:\n%s"%data]
41
+
else:
42
+
return [False, "your terminal does not support auto-paste\ncopy-to-clipboard failed too with the following message:\n\t%s\nplease manually copy and use the following command:\n\t%s"% (res[1], data)]
34
43
35
44
@staticmethod
36
-
defset_value_clipboard(data):
45
+
defcopy_to_clipboard(data):
37
46
try:
38
47
importpyperclip
39
48
pyperclip.copy(data)
40
-
returnTrue
49
+
return [True, "copied to clipboard: %s"%data]
50
+
exceptImportError:
51
+
return [False, "pyperclip module not found (to install it run 'pip3 install pyperclip')"]
0 commit comments