bear-utils 0.7.13__py3-none-any.whl → 0.7.14__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -284,17 +284,14 @@ class AsyncShellSession(SimpleShellSession):
|
|
284
284
|
if self.empty_history and cmd is None:
|
285
285
|
raise ValueError("No commands to run")
|
286
286
|
|
287
|
-
self.logger.debug(f"Running command: {cmd} with args: {args}")
|
288
287
|
if self.has_history and cmd is not None:
|
289
288
|
raise ValueError("Use `amp` to chain commands, not `run`")
|
290
289
|
if self.has_history and cmd is None:
|
291
290
|
command = self.cmd
|
292
291
|
elif self.empty_history and cmd is not None:
|
293
292
|
self.cmd_buffer.write(f"{cmd}")
|
294
|
-
self.logger.info(f"{self.cmd_buffer.getvalue()}")
|
295
293
|
if args:
|
296
294
|
self.cmd_buffer.write(" ".join(map(str, args)))
|
297
|
-
|
298
295
|
command = self.cmd
|
299
296
|
else:
|
300
297
|
raise ValueError("Unexpected state")
|
@@ -305,7 +302,9 @@ class AsyncShellSession(SimpleShellSession):
|
|
305
302
|
"""Communicate with the process, sending input and waiting for completion"""
|
306
303
|
if self.process is None:
|
307
304
|
raise ValueError("No process has been started yet")
|
308
|
-
|
305
|
+
bytes_stdin = stdin.encode("utf-8") if isinstance(stdin, str) else stdin
|
306
|
+
|
307
|
+
stdout, stderr = await self.process.communicate(input=bytes_stdin)
|
309
308
|
return_code = await self.process.wait()
|
310
309
|
|
311
310
|
self.result = FancyCompletedProcess(
|
@@ -332,7 +331,7 @@ class AsyncShellSession(SimpleShellSession):
|
|
332
331
|
if not line: # EOF
|
333
332
|
break
|
334
333
|
yield line.decode("utf-8").rstrip("\n")
|
335
|
-
except Exception
|
334
|
+
except Exception:
|
336
335
|
break
|
337
336
|
|
338
337
|
async def stream_stdout(self) -> AsyncGenerator[str, None]:
|
bear_utils/extras/_tools.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import asyncio
|
2
2
|
import shutil
|
3
|
+
from asyncio.subprocess import PIPE
|
3
4
|
from collections import deque
|
4
5
|
from functools import cached_property
|
5
6
|
from subprocess import CompletedProcess
|
@@ -79,7 +80,7 @@ class ClipboardManager:
|
|
79
80
|
Returns:
|
80
81
|
int: The return code of the command.
|
81
82
|
"""
|
82
|
-
await self.shell.run(self._copy)
|
83
|
+
await self.shell.run(self._copy, stdin=PIPE)
|
83
84
|
result: CompletedProcess[str] = await self.shell.communicate(stdin=output)
|
84
85
|
if result.returncode == 0:
|
85
86
|
self.clipboard_history.append(output) # Only append to history if the copy was successful
|
@@ -125,7 +126,7 @@ def copy_to_clipboard(output: str) -> int:
|
|
125
126
|
int: The return code of the command.
|
126
127
|
"""
|
127
128
|
clipboard_manager = ClipboardManager()
|
128
|
-
loop = asyncio.get_event_loop()
|
129
|
+
loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
|
129
130
|
return loop.run_until_complete(clipboard_manager.copy(output))
|
130
131
|
|
131
132
|
|
@@ -151,7 +152,7 @@ def paste_from_clipboard() -> str:
|
|
151
152
|
str: The content of the clipboard.
|
152
153
|
"""
|
153
154
|
clipboard_manager = ClipboardManager()
|
154
|
-
loop = asyncio.get_event_loop()
|
155
|
+
loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
|
155
156
|
return loop.run_until_complete(clipboard_manager.paste())
|
156
157
|
|
157
158
|
|
@@ -174,7 +175,7 @@ def clear_clipboard() -> int:
|
|
174
175
|
int: The return code of the command.
|
175
176
|
"""
|
176
177
|
clipboard_manager = ClipboardManager()
|
177
|
-
loop = asyncio.get_event_loop()
|
178
|
+
loop: asyncio.AbstractEventLoop = asyncio.get_event_loop()
|
178
179
|
return loop.run_until_complete(clipboard_manager.clear())
|
179
180
|
|
180
181
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: bear-utils
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.14
|
4
4
|
Summary: Various utilities for Bear programmers, including a rich logging utility, a disk cache, and a SQLite database wrapper amongst other things.
|
5
5
|
Author: chaz
|
6
6
|
Author-email: bright.lid5647@fastmail.com
|
@@ -23,7 +23,7 @@ Requires-Dist: singleton-base (>=1.0.5)
|
|
23
23
|
Requires-Dist: sqlalchemy (>=2.0.40,<3.0.0)
|
24
24
|
Description-Content-Type: text/markdown
|
25
25
|
|
26
|
-
# Bear Utils v# Bear Utils v0.7.
|
26
|
+
# Bear Utils v# Bear Utils v0.7.14
|
27
27
|
|
28
28
|
Personal set of tools and utilities for Python projects, focusing on modularity and ease of use. This library includes components for caching, database management, logging, time handling, file operations, CLI prompts, image processing, clipboard interaction, gradient utilities, event systems, and async helpers.
|
29
29
|
|
@@ -11,7 +11,7 @@ bear_utils/cli/commands.py,sha256=B0eI6iPeE5uaEa7JvfwKZavHe4ZsK_fLFBWxojW1Cx8,15
|
|
11
11
|
bear_utils/cli/prompt_helpers.py,sha256=aGfa4tnO24kFKC-CBJhoiKtll8kc_uU5RvXmxSoD5BM,6094
|
12
12
|
bear_utils/cli/shell/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
13
|
bear_utils/cli/shell/_base_command.py,sha256=96zlL6BFWVkC_pJzxlxQy1o3oxu-P4e80mRcLEvS0PY,2251
|
14
|
-
bear_utils/cli/shell/_base_shell.py,sha256=
|
14
|
+
bear_utils/cli/shell/_base_shell.py,sha256=XW55HapnW2_1UnM-SKFQtQgqtOl6uUpUmT0Mn-Mfj6s,14529
|
15
15
|
bear_utils/cli/shell/_common.py,sha256=_KQyL5lvqOfjonFIwlEOyp3K9G3TSOj19RhgVzfNNpg,669
|
16
16
|
bear_utils/config/__init__.py,sha256=htYbcAhIAGXgA4BaSQMKRtwu5RjWwNsnAiD0JxZ82aE,289
|
17
17
|
bear_utils/config/config_manager.py,sha256=WojWwxsTo2Izf2EFxZJXjjUmhqcbbatZ-nBKq436BGw,2631
|
@@ -29,7 +29,7 @@ bear_utils/events/events_class.py,sha256=pEdZNS8l5wwrn3I4WrFspZlNiy3Lzcwjxr6E2hT
|
|
29
29
|
bear_utils/events/events_module.py,sha256=NtWqlBpTWAtaC_KVJnweReQe6OU2PXt04yNtAEcATuc,1852
|
30
30
|
bear_utils/extras/__init__.py,sha256=OzjuT-GSI6lT8lmOLBR4-ikA-QrpByy0YRlgiFd7cF4,547
|
31
31
|
bear_utils/extras/_async_helpers.py,sha256=OcgPmCfdAKcTsqGA3Fm8ORkePgaJSok_1t9-sbf-zNQ,416
|
32
|
-
bear_utils/extras/_tools.py,sha256=
|
32
|
+
bear_utils/extras/_tools.py,sha256=PdOX9KCB5uGEGzJ7SA9qeBukxyYRo160ePqBZU8dJCw,7094
|
33
33
|
bear_utils/extras/platform_utils.py,sha256=vRLybOm_Kk4ysVyNdsv1oTrMHD64vPeGre23fg-kJxI,1257
|
34
34
|
bear_utils/extras/wrappers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
35
35
|
bear_utils/extras/wrappers/add_methods.py,sha256=8JI9oFakHRBHcyix6sgqfiXZyXW5antLbyRdFL4F1_M,4222
|
@@ -73,6 +73,6 @@ bear_utils/logging/loggers.py,sha256=oFdKrm9ot7F4pKghzYQrq-BK7RfevKQSBaHsmSolHTA
|
|
73
73
|
bear_utils/monitoring/__init__.py,sha256=cj7UYsipfYFwxQmXtMpziAv4suRtGzWEdjdwOCbxJN4,168
|
74
74
|
bear_utils/monitoring/host_monitor.py,sha256=GwIK9X8rATUhYIbOXi4MINfACWgO3T1vzUK1gSK_TQc,12902
|
75
75
|
bear_utils/time/__init__.py,sha256=EHzc9KiGG3l6mAPhiIeFcYqxQG_w0QQ1ES3yRFVr8ug,721
|
76
|
-
bear_utils-0.7.
|
77
|
-
bear_utils-0.7.
|
78
|
-
bear_utils-0.7.
|
76
|
+
bear_utils-0.7.14.dist-info/METADATA,sha256=ZPN_uCXYTnpBMTDZKEC8xusGYMrKNDaN0UEJkZHlXB4,7494
|
77
|
+
bear_utils-0.7.14.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
78
|
+
bear_utils-0.7.14.dist-info/RECORD,,
|
File without changes
|