Skip to content

Commit

Permalink
Migrate from setuptools to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
micoli committed Dec 27, 2022
1 parent b478ef6 commit 098fe62
Show file tree
Hide file tree
Showing 14 changed files with 1,008 additions and 94 deletions.
48 changes: 24 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,32 @@ jobs:

- name: Install dependencies
run: |
pip install -e ".[testing]"
poetry install
- name: Run tests with pytest
run: |
python setup.py --verbose test
poetry install --with test
python3 -m pylint gocker/ test/
- name: Install pypa/build
run: python -m pip install build --user

- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
verbose: true
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/

- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
with:
skip_existing: true
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
# - name: Install pypa/build
# run: python -m pip install build --user
#
# - name: Build a binary wheel and a source tarball
# run: python -m build --sdist --wheel --outdir dist/
#
# - name: Publish distribution 📦 to Test PyPI
# uses: pypa/gh-action-pypi-publish@master
# with:
# skip_existing: true
# verbose: true
# user: __token__
# password: ${{ secrets.TEST_PYPI_API_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
#
# - name: Publish distribution 📦 to PyPI
# if: startsWith(github.ref, 'refs/tags')
# uses: pypa/gh-action-pypi-publish@master
# with:
# skip_existing: true
# user: __token__
# password: ${{ secrets.PYPI_API_TOKEN }}
1 change: 0 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ disable=
C0114,
C0115,
C0116,
R0201,
C0209,
R0801,
R0903,
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
init:
pip3 install -e ".[testing]"
poetry install

test: clean init
python3 setup.py --verbose test
poetry install --with test
python3 -m pylint gocker/ test/

test-e2e: clean init
cd tmp/test-basic;gocker --list
gocker --shortcut-list

clean:
find . -name "__pycache__" | xargs rm -r
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Gantry Crane
# GOCKER

`Gui on dOCKER`

Expand All @@ -13,7 +13,7 @@
- start/stop services in docker-compose
- interact with supervisord instance within a container

[![asciicast](https://asciinema.org/a/i5fXfAIYfsSncklwkY6QFpIQf.svg)](https://asciinema.org/a/i5fXfAIYfsSncklwkY6QFpIQf)
[![asciicast](https://asciinema.org/a/548247.svg)](https://asciinema.org/a/548247)

## Shortcuts
[//]: <> (command-placeholder-start "gocker --action shortcut-list")
Expand Down Expand Up @@ -101,11 +101,11 @@ example:
[//]: <> (command-placeholder-start "gocker --help")
```
usage: gocker [-h] [--action {gui,shortcut-list}] [--verbose] [--debug]
[--docker-host DOCKER_HOST]
[--fsevents-address FSEVENTS_ADDRESS]
[--fsevents-port FSEVENTS_PORT]
[--docker-host DOCKER_HOST]
[--fsevents-address FSEVENTS_ADDRESS]
[--fsevents-port FSEVENTS_PORT]
Gocker
gocker
optional arguments:
-h, --help show this help message and exit
Expand Down
5 changes: 5 additions & 0 deletions gocker/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from gocker.arguments import parse_main_args, ArgumentAction
from gocker.gui import gui
from gocker.arguments import get_docker_socket_paths
from gocker.gui.shortcut import shortcuts

colored_traceback.add_hook(always=True)
Expand Down Expand Up @@ -45,6 +46,10 @@ def main() -> None:
if args.action == ArgumentAction.ACTION_GUI:
init_logger(args.loglevel, GUI_LOG_FILE)
logging.info("Starting gui")
if args.docker_host is None:
print(f"Can't find a valid docker.sock path in {repr(get_docker_socket_paths())}")
sys.exit(1)

gui(args.docker_host, args.fsevents_address, args.fsevents_port)
sys.exit(0)

Expand Down
16 changes: 12 additions & 4 deletions gocker/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,19 @@ class ArgumentAction:
ACTION_SHORTCUT_LIST = 'shortcut-list'


def get_docker_socket_paths():
return [
'/Users/%s/.colima/docker.sock' % os.getenv('USER'),
'/Users/%s/.docker/run/docker.sock' % os.getenv('USER'),
'/var/run/docker.sock'
]

def get_default_docker_socket():
docker_path = '/Users/%s/.colima/docker.sock' % os.getenv('USER')
if os.path.exists(docker_path):
return 'unix:/' + docker_path
return 'unix://var/run/docker.sock'
for path in get_docker_socket_paths():
if not os.path.exists(path):
continue
return 'unix:/' + path
return None


def parse_main_args():
Expand Down
4 changes: 2 additions & 2 deletions gocker/gui/components/event_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ def __init__(self, event: SystemEvent):
self.content = event
cols = [
('fixed', 8, urwid.AttrWrap(
urwid.Text('%s' % datetime.fromtimestamp(event.timestamp).strftime('%H:%M:%S')),
urwid.Text(datetime.fromtimestamp(event.timestamp).strftime('%H:%M:%S')),
'container_name',
'container_name_selected'
)),
('weight', 1, urwid.AttrWrap(
urwid.Text(event.type),
urwid.Text(f"{event.type:.8}"),
'container_name',
'container_name_selected'
)),
Expand Down
5 changes: 4 additions & 1 deletion gocker/gui/services/fs_event/fs_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def __init__(
def run(self):
if self.fsevents_port == 0:
return
request = requests.get('http://%s:%s/logs' % (self.fsevents_address, self.fsevents_port), stream=True)
request = requests.get(
'http://%s:%s/logs' % (self.fsevents_address, self.fsevents_port),
stream=True,
timeout=30)
if request.encoding is None:
request.encoding = 'utf-8'
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(
self.group_name = group_name
self.stream = stream
url = '%s/logtail/%s/%s' % (self.supervisor_client_options['url'], self.group_name, stream)
self.request = requests.get(url, stream=True)
self.request = requests.get(url, stream=True, timeout=20)
if self.request.encoding is None:
self.request.encoding = 'utf-8'

Expand Down

0 comments on commit 098fe62

Please sign in to comment.