Skip to content

Commit a69e610

Browse files
authored
Merge pull request #27 from yarikoptic/enh-codespell
Add codespell support (config, workflow to detect/not fix) and make it fix few typos
2 parents 7061909 + 0e00255 commit a69e610

File tree

7 files changed

+46
-15
lines changed

7 files changed

+46
-15
lines changed

.codespellrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[codespell]
2+
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
3+
skip = .git*,.codespellrc
4+
check-hidden = true
5+
# ignore-regex =
6+
# ignore-words-list =

.github/workflows/codespell.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Codespell configuration is within .codespellrc
2+
---
3+
name: Codespell
4+
5+
on:
6+
push:
7+
branches: [master]
8+
pull_request:
9+
branches: [master]
10+
11+
permissions:
12+
contents: read
13+
14+
jobs:
15+
codespell:
16+
name: Check for spelling errors
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
- name: Annotate locations with typos
23+
uses: codespell-project/codespell-problem-matcher@v1
24+
- name: Codespell
25+
uses: codespell-project/actions-codespell@v2

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
## Features
3232

33-
- command_runner now has a `command_runner_threaded()` function which allows to run in background, but stil provide live stdout/stderr stream output via queues/callbacks
33+
- command_runner now has a `command_runner_threaded()` function which allows to run in background, but still provide live stdout/stderr stream output via queues/callbacks
3434
- Refactor poller mode to allow multiple stdout / stderr stream redirectors
3535
- Passing a queue.Queue() instance to stdout/stderr arguments will fill queue with live stream output
3636
- Passing a function to stdout/stderr arguments will callback said function with live stream output
@@ -115,7 +115,7 @@
115115
- All tests are done for both capture methods
116116
- Timeout tests are more accurate
117117
- Added missing encoding tests
118-
- 2500 rounds of file reading and comparaison are added to detect rare queue read misses
118+
- 2500 rounds of file reading and comparison are added to detect rare queue read misses
119119

120120
# v0.7.0 (yanked - do not use; see v1.2.0 critical fixes) - The windows GUI
121121

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ It works as wrapper for subprocess.popen and subprocess.communicate that solves:
4343
- Can show command output on the fly without waiting the end of execution (with `live_output=True` argument)
4444
- Can give command output on the fly to application by using queues or callback functions
4545
- Catch all possible exceptions and log them properly with encoding fixes
46-
- Be compatible, and always return the same result regarless of platform
46+
- Be compatible, and always return the same result regardless of platform
4747

4848
command_runner also promises to properly kill commands when timeouts are reached, including spawned subprocesses of such commands.
4949
This specific behavior is achieved via psutil module, which is an optional dependency.
@@ -69,7 +69,7 @@ exit_code, output = command_runner('ping 127.0.0.1', timeout=10)
6969

7070
### Special exit codes
7171

72-
In order to keep the promise to always provide an exit_code, spcial exit codes have been added for the case where none is given.
72+
In order to keep the promise to always provide an exit_code, special exit codes have been added for the case where none is given.
7373
Those exit codes are:
7474

7575
- -250 : command_runner called with incompatible arguments
@@ -208,7 +208,7 @@ command_runner can redirect the command's stdout and/or stderr streams to differ
208208
Unless an output redirector is given for `stderr` argument, stderr will be redirected to `stdout` stream.
209209
Note that both queues and callback function redirectors require `poller` method and will fail if method is not set.
210210

211-
Output redirector descrptions:
211+
Output redirector descriptions:
212212

213213
- subprocess pipes
214214

@@ -240,7 +240,7 @@ exit_code, output = command_runner('dir', stdout='/tmp/stdout.log', stderr='/tmp
240240
- Queue(s) will be filled up by command_runner.
241241
- In order to keep your program "live", we'll use the threaded version of command_runner which is basically the same except it returns a future result instead of a tuple.
242242
- Note: With all the best will, there's no good way to achieve this under Python 2.7 without using more queues, so the threaded version is only compatible with Python 3.3+.
243-
- For Python 2.7, you must create your thread and queue reader yourself (see footnote for a Python 2.7 comaptible example).
243+
- For Python 2.7, you must create your thread and queue reader yourself (see footnote for a Python 2.7 compatible example).
244244
- Threaded command_runner plus queue example:
245245

246246
```python

command_runner/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ def to_encoding(
320320
# type: (...) -> str
321321
"""
322322
Convert bytes output to string and handles conversion errors
323-
Varation of ofunctions.string_handling.safe_string_convert
323+
Variation of ofunctions.string_handling.safe_string_convert
324324
"""
325325

326326
if not encoding:
@@ -352,7 +352,7 @@ def kill_childs_mod(
352352
"""
353353
Inline version of ofunctions.kill_childs that has no hard dependency on psutil
354354
355-
Kills all childs of pid (current pid can be obtained with os.getpid())
355+
Kills all children of pid (current pid can be obtained with os.getpid())
356356
If no pid given current pid is taken
357357
Good idea when using multiprocessing, is to call with atexit.register(ofunctions.kill_childs, os.getpid(),)
358358
@@ -625,7 +625,7 @@ def _read_pipe(
625625

626626
# We also need to check that stream has readline, in case we're writing to files instead of PIPE
627627

628-
# Another magnificient python 2.7 fix
628+
# Another magnificent python 2.7 fix
629629
# So we need to convert sentinel_char which would be unicode because of unicode_litterals
630630
# to str which is the output format from stream.readline()
631631

@@ -687,7 +687,7 @@ def __check_timeout(
687687
# type: (...) -> None
688688
"""
689689
Simple subfunction to check whether timeout is reached
690-
Since we check this alot, we put it into a function
690+
Since we check this a lot, we put it into a function
691691
"""
692692
if timeout and (datetime.now() - begin_time).total_seconds() > timeout:
693693
kill_childs_mod(process.pid, itself=True, soft_kill=False)
@@ -820,7 +820,7 @@ def _timeout_check_thread(
820820
break
821821
if process.poll() is not None:
822822
break
823-
# We definitly need some sleep time here or else we will overload CPU
823+
# We definitely need some sleep time here or else we will overload CPU
824824
sleep(check_interval)
825825

826826
def _monitor_process(

command_runner/elevate.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def _check_environment():
146146
# Regardless of the runner (CPython, Nuitka or frozen CPython), sys.argv[0] is the relative path to script,
147147
# sys.argv[1] are the arguments
148148
# The only exception being CPython on Windows where sys.argv[0] contains absolute path to script
149-
# Regarless of OS, sys.executable will contain full path to python binary for CPython and Nuitka,
149+
# Regardless of OS, sys.executable will contain full path to python binary for CPython and Nuitka,
150150
# and full path to frozen executable on frozen CPython
151151

152152
# Recapitulative table create with
@@ -231,7 +231,7 @@ def elevate(callable_function, *args, **kwargs):
231231
callable_function(*args, **kwargs)
232232
else:
233233
command = ["sudo", runner] + arguments
234-
# Optionnaly might also pass a stdout PIPE to command_runner so we get live output
234+
# Optionally might also pass a stdout PIPE to command_runner so we get live output
235235
exit_code, output = command_runner(command, shell=False, timeout=None)
236236

237237
logger.info("Child output: {}".format(output))

tests/test_command_runner.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def test_unix_only_split_command():
265265
if os.name == 'posix':
266266
for method in methods:
267267
exit_code, _ = command_runner(' '.join(PING_CMD), method=method)
268-
assert exit_code == 0, 'Non splitted command should not trigger an error with method {}'.format(method)
268+
assert exit_code == 0, 'Non split command should not trigger an error with method {}'.format(method)
269269

270270

271271
def test_create_no_window():
@@ -296,7 +296,7 @@ def test_read_file():
296296
max_rounds = 100 if is_pypy() else 1000
297297
print("\nSetting up test_read_file for {} rounds".format(max_rounds))
298298
for round in range(0, max_rounds):
299-
print('Comparaison round {} with method {}'.format(round, method))
299+
print('Comparison round {} with method {}'.format(round, method))
300300
exit_code, output = command_runner(PRINT_FILE_CMD, shell=True, method=method)
301301
if os.name == 'nt':
302302
output = output.replace('\r\n', '\n')

0 commit comments

Comments
 (0)