bashhub 3.0.3__tar.gz → 3.1.0__tar.gz

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.
Files changed (49) hide show
  1. {bashhub-3.0.3/bashhub.egg-info → bashhub-3.1.0}/PKG-INFO +2 -3
  2. {bashhub-3.0.3 → bashhub-3.1.0}/README.md +1 -2
  3. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/bashhub.py +17 -4
  4. bashhub-3.1.0/bashhub/shell/deps/fish/functions/__bh_check_bashhub_installation.fish +27 -0
  5. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell/deps/lib-bashhub.sh +1 -1
  6. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/version.py +1 -1
  7. {bashhub-3.0.3 → bashhub-3.1.0/bashhub.egg-info}/PKG-INFO +2 -3
  8. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub.egg-info/SOURCES.txt +1 -0
  9. {bashhub-3.0.3 → bashhub-3.1.0}/pyproject.toml +7 -1
  10. bashhub-3.1.0/tests/test_bashhub.py +109 -0
  11. bashhub-3.0.3/tests/test_bashhub.py +0 -55
  12. {bashhub-3.0.3 → bashhub-3.1.0}/LICENSE.md +0 -0
  13. {bashhub-3.0.3 → bashhub-3.1.0}/MANIFEST.in +0 -0
  14. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/__init__.py +0 -0
  15. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/bashhub_globals.py +0 -0
  16. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/bashhub_setup.py +0 -0
  17. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/bh.py +0 -0
  18. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/i_search.py +0 -0
  19. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/interactive_search.py +0 -0
  20. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/__init__.py +0 -0
  21. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/command.py +0 -0
  22. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/command_form.py +0 -0
  23. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/min_command.py +0 -0
  24. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/serializable.py +0 -0
  25. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/status_view.py +0 -0
  26. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/model/system.py +0 -0
  27. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/rest_client.py +0 -0
  28. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell/bashhub.fish +0 -0
  29. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell/bashhub.sh +0 -0
  30. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell/bashhub.zsh +0 -0
  31. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell/deps/bash-preexec.sh +0 -0
  32. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/shell_utils.py +0 -0
  33. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/validation.py +0 -0
  34. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/view/__init__.py +0 -0
  35. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub/view/status.py +0 -0
  36. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub.egg-info/dependency_links.txt +0 -0
  37. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub.egg-info/entry_points.txt +0 -0
  38. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub.egg-info/requires.txt +0 -0
  39. {bashhub-3.0.3 → bashhub-3.1.0}/bashhub.egg-info/top_level.txt +0 -0
  40. {bashhub-3.0.3 → bashhub-3.1.0}/setup.cfg +0 -0
  41. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_bashhub_globals.py +0 -0
  42. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_bashhub_setup.py +0 -0
  43. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_bh.py +0 -0
  44. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_command.py +0 -0
  45. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_command_form.py +0 -0
  46. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_interactive_search.py +0 -0
  47. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_rest_client.py +0 -0
  48. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_shell_utils.py +0 -0
  49. {bashhub-3.0.3 → bashhub-3.1.0}/tests/test_validation.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bashhub
3
- Version: 3.0.3
3
+ Version: 3.1.0
4
4
  Summary: Bashhub.com python client
5
5
  Author-email: Ryan Caloras <ryan@bashhub.com>
6
6
  License-Expression: Apache-2.0
@@ -55,8 +55,7 @@ curl -OL https://bashhub.com/setup && $SHELL setup
55
55
  ```
56
56
  For non default login shells, just specify the shell e.g. (`bash setup`, `zsh setup`, `fish setup`)
57
57
 
58
- Detailed installation instructions can be found at
59
- https://github.com/rcaloras/bashhub-client/wiki/Install
58
+ The installer uses [uv](https://docs.astral.sh/uv/) to install Bashhub. Detailed installation instructions can be found at https://github.com/rcaloras/bashhub-client/wiki/Install
60
59
 
61
60
  # Usage
62
61
  Bashhub can be accessed from the command line in a couple ways:
@@ -21,8 +21,7 @@ curl -OL https://bashhub.com/setup && $SHELL setup
21
21
  ```
22
22
  For non default login shells, just specify the shell e.g. (`bash setup`, `zsh setup`, `fish setup`)
23
23
 
24
- Detailed installation instructions can be found at
25
- https://github.com/rcaloras/bashhub-client/wiki/Install
24
+ The installer uses [uv](https://docs.astral.sh/uv/) to install Bashhub. Detailed installation instructions can be found at https://github.com/rcaloras/bashhub-client/wiki/Install
26
25
 
27
26
  # Usage
28
27
  Bashhub can be accessed from the command line in a couple ways:
@@ -4,9 +4,9 @@ from __future__ import annotations
4
4
  import io
5
5
  import os
6
6
  import re
7
- import shutil
8
7
  import subprocess
9
8
  import sys
9
+ from importlib import resources
10
10
  from time import mktime
11
11
 
12
12
  import click
@@ -191,15 +191,22 @@ def update(version: str) -> None:
191
191
 
192
192
  query_param = '?version={0}'.format(version) if version else ''
193
193
  url = 'https://bashhub.com/setup' + query_param
194
- response = requests.get(url, stream=True)
195
194
  filename = 'update-bashhub.sh'
196
- with open(filename, 'wb') as out_file:
197
- shutil.copyfileobj(response.raw, out_file)
195
+ download_installer(url, filename)
198
196
 
199
197
  subprocess.call(["bash", "-e", filename, version])
200
198
  os.remove(filename)
201
199
 
202
200
 
201
+ def download_installer(url: str, filename: str) -> None:
202
+ response = requests.get(url, stream=True)
203
+ response.raise_for_status()
204
+
205
+ with open(filename, 'wb') as out_file:
206
+ for chunk in response.iter_content(chunk_size=8192):
207
+ out_file.write(chunk)
208
+
209
+
203
210
  @bashhub.group()
204
211
  def util() -> None:
205
212
  """Misc utils used by Bashhub"""
@@ -214,6 +221,12 @@ def update_system_info() -> None:
214
221
  sys.exit(0) if result is not None else sys.exit(1)
215
222
 
216
223
 
224
+ @util.command()
225
+ def shell_dir() -> None:
226
+ """Print the installed Bashhub shell assets directory"""
227
+ click.echo(resources.files("bashhub").joinpath("shell"))
228
+
229
+
217
230
  @util.command()
218
231
  @click.argument('date_string', type=str)
219
232
  def parsedate(date_string: str) -> None:
@@ -0,0 +1,27 @@
1
+ #
2
+ # __bh_check_bashhub_installation.fish
3
+ # Should only be sourced once following installation.
4
+ #
5
+
6
+ # Small function to check our Bashhub installation.
7
+ function __bh_check_bashhub_installation
8
+ set -l ret 0
9
+ set -l config_path "$BH_HOME_DIRECTORY/config"
10
+ if not [ -f "$config_path" ]
11
+ echo "Missing Bashhub config file. Please run 'bashhub setup' to generate one."
12
+ set ret 2
13
+ else if not grep -Fq "access_token" "$config_path"
14
+ echo "Missing Bashhub access token. Please run 'bashhub setup' to re-login."
15
+ set ret 3
16
+ else if not grep -Fq "system_name" "$config_path"
17
+ echo "Missing system name. Please run 'bashhub setup' to re-login."
18
+ set ret 4
19
+ else if grep -Fq "save_commands = False" "$config_path"
20
+ echo "Bashhub is currently disabled. Run 'bashhub on' to re-enable."
21
+ set ret 5
22
+ end
23
+
24
+ return $ret
25
+ end
26
+
27
+ __bh_check_bashhub_installation
@@ -23,7 +23,7 @@ contains_element() {
23
23
  return 1
24
24
  }
25
25
 
26
- # Make sure our bin directory is on our path
26
+ # Make sure Bashhub's stable command directory is on our path
27
27
  __bh_path_add "$HOME/.bashhub/bin"
28
28
 
29
29
  #
@@ -1,5 +1,5 @@
1
1
  import platform
2
2
 
3
- __version__ = '3.0.3'
3
+ __version__ = '3.1.0'
4
4
 
5
5
  version_str = 'Bashhub {0} (python {1})'.format(__version__, platform.python_version())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bashhub
3
- Version: 3.0.3
3
+ Version: 3.1.0
4
4
  Summary: Bashhub.com python client
5
5
  Author-email: Ryan Caloras <ryan@bashhub.com>
6
6
  License-Expression: Apache-2.0
@@ -55,8 +55,7 @@ curl -OL https://bashhub.com/setup && $SHELL setup
55
55
  ```
56
56
  For non default login shells, just specify the shell e.g. (`bash setup`, `zsh setup`, `fish setup`)
57
57
 
58
- Detailed installation instructions can be found at
59
- https://github.com/rcaloras/bashhub-client/wiki/Install
58
+ The installer uses [uv](https://docs.astral.sh/uv/) to install Bashhub. Detailed installation instructions can be found at https://github.com/rcaloras/bashhub-client/wiki/Install
60
59
 
61
60
  # Usage
62
61
  Bashhub can be accessed from the command line in a couple ways:
@@ -31,6 +31,7 @@ bashhub/shell/bashhub.sh
31
31
  bashhub/shell/bashhub.zsh
32
32
  bashhub/shell/deps/bash-preexec.sh
33
33
  bashhub/shell/deps/lib-bashhub.sh
34
+ bashhub/shell/deps/fish/functions/__bh_check_bashhub_installation.fish
34
35
  bashhub/view/__init__.py
35
36
  bashhub/view/status.py
36
37
  tests/test_bashhub.py
@@ -77,4 +77,10 @@ include-package-data = true
77
77
  include = ["bashhub*"]
78
78
 
79
79
  [tool.setuptools.package-data]
80
- bashhub = ["shell/*.fish", "shell/*.sh", "shell/*.zsh", "shell/deps/*.sh"]
80
+ bashhub = [
81
+ "shell/*.fish",
82
+ "shell/*.sh",
83
+ "shell/*.zsh",
84
+ "shell/deps/*.sh",
85
+ "shell/deps/fish/functions/*.fish",
86
+ ]
@@ -0,0 +1,109 @@
1
+ import os
2
+ from pathlib import Path
3
+
4
+ import click
5
+ import pytest
6
+ from click.testing import CliRunner
7
+
8
+ from bashhub.bashhub import bashhub, download_installer
9
+ from bashhub.version import __version__
10
+ from bashhub.bashhub import rest_client
11
+ from bashhub.bashhub import bashhub_globals
12
+
13
+
14
+ def test_bashhub_save():
15
+ def print_failed(command):
16
+ print("Failed")
17
+ pass
18
+
19
+ rest_client.save_command = print_failed
20
+
21
+ runner = CliRunner()
22
+ args = ['save', 'echo "Running bashhub tests"', '/tmp', '1', '100000', '1']
23
+
24
+ ignored_command = ['save', 'echo "Running bashhub tests" #ignore', '/tmp',
25
+ '1', '100000', '1']
26
+
27
+ # Should omit saving if save_commands is set
28
+ bashhub_globals.BH_SAVE_COMMANDS = False
29
+ result = runner.invoke(bashhub, args)
30
+ assert '' == result.output
31
+
32
+ bashhub_globals.BH_SAVE_COMMANDS = True
33
+
34
+ # Should omit saving if #ignore is set
35
+ result = runner.invoke(bashhub, ignored_command)
36
+ assert '' == result.output
37
+
38
+ # Should omit saving a command if BH_FILTER regex is set
39
+ bashhub_globals.BH_FILTER = 'echo'
40
+ result = runner.invoke(bashhub, args)
41
+ assert '' == result.output
42
+
43
+ def no_auth_token():
44
+ return ''
45
+
46
+ # Should not try to save a command if we don't have an auth token
47
+
48
+ bashhub_globals.BH_AUTH = no_auth_token
49
+ result = runner.invoke(bashhub, ['save', 'date', '/tmp', '1', '1000', '1'])
50
+ error_message = "No auth token found. Run 'bashhub setup' to login.\n"
51
+ assert error_message == result.output
52
+
53
+
54
+ def test_bashhub_version():
55
+ runner = CliRunner()
56
+ result = runner.invoke(bashhub, ['version'])
57
+ assert __version__ in result.output
58
+
59
+
60
+ def test_bashhub_update_writes_decoded_installer_response(monkeypatch):
61
+ script = b'#!/bin/bash\necho setup\n'
62
+ calls = []
63
+
64
+ class GitHubResponse:
65
+ status_code = 200
66
+
67
+ class SetupResponse:
68
+ def raise_for_status(self):
69
+ return None
70
+
71
+ def iter_content(self, chunk_size):
72
+ assert chunk_size == 8192
73
+ return [script]
74
+
75
+ def get(url, stream=False):
76
+ calls.append((url, stream))
77
+ if 'github.com' in url:
78
+ return GitHubResponse()
79
+ return SetupResponse()
80
+
81
+ def call(args):
82
+ with open(args[2], 'rb') as installer:
83
+ assert installer.read() == script
84
+ assert args == ['bash', '-e', 'update-bashhub.sh', '3.1.0rc2']
85
+ return 0
86
+
87
+ monkeypatch.setattr('bashhub.bashhub.requests.get', get)
88
+ monkeypatch.setattr('bashhub.bashhub.subprocess.call', call)
89
+
90
+ runner = CliRunner()
91
+ with runner.isolated_filesystem():
92
+ result = runner.invoke(bashhub, ['update', '3.1.0rc2'])
93
+
94
+ assert result.exit_code == 0
95
+ assert ('https://bashhub.com/setup?version=3.1.0rc2', True) in calls
96
+
97
+
98
+ @pytest.mark.skipif(
99
+ not os.getenv('functional_test'),
100
+ reason='requires the production Bashhub setup endpoint',
101
+ )
102
+ def test_bashhub_update_downloads_production_installer(tmp_path):
103
+ installer = tmp_path / 'update-bashhub.sh'
104
+
105
+ download_installer('https://bashhub.com/setup', str(installer))
106
+
107
+ script = Path(installer).read_bytes()
108
+ assert script.startswith(b'#!/bin/bash')
109
+ assert b'install_bashhub' in script
@@ -1,55 +0,0 @@
1
- import os
2
-
3
- import click
4
- from click.testing import CliRunner
5
-
6
- from bashhub.bashhub import bashhub
7
- from bashhub.version import __version__
8
- from bashhub.bashhub import rest_client
9
- from bashhub.bashhub import bashhub_globals
10
-
11
-
12
- def test_bashhub_save():
13
- def print_failed(command):
14
- print("Failed")
15
- pass
16
-
17
- rest_client.save_command = print_failed
18
-
19
- runner = CliRunner()
20
- args = ['save', 'echo "Running bashhub tests"', '/tmp', '1', '100000', '1']
21
-
22
- ignored_command = ['save', 'echo "Running bashhub tests" #ignore', '/tmp',
23
- '1', '100000', '1']
24
-
25
- # Should omit saving if save_commands is set
26
- bashhub_globals.BH_SAVE_COMMANDS = False
27
- result = runner.invoke(bashhub, args)
28
- assert '' == result.output
29
-
30
- bashhub_globals.BH_SAVE_COMMANDS = True
31
-
32
- # Should omit saving if #ignore is set
33
- result = runner.invoke(bashhub, ignored_command)
34
- assert '' == result.output
35
-
36
- # Should omit saving a command if BH_FILTER regex is set
37
- bashhub_globals.BH_FILTER = 'echo'
38
- result = runner.invoke(bashhub, args)
39
- assert '' == result.output
40
-
41
- def no_auth_token():
42
- return ''
43
-
44
- # Should not try to save a command if we don't have an auth token
45
-
46
- bashhub_globals.BH_AUTH = no_auth_token
47
- result = runner.invoke(bashhub, ['save', 'date', '/tmp', '1', '1000', '1'])
48
- error_message = "No auth token found. Run 'bashhub setup' to login.\n"
49
- assert error_message == result.output
50
-
51
-
52
- def test_bashhub_version():
53
- runner = CliRunner()
54
- result = runner.invoke(bashhub, ['version'])
55
- assert __version__ in result.output
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes