Skip to content

Commit

Permalink
Merge pull request #3 from doronz88/feature/github_workflows
Browse files Browse the repository at this point in the history
github: add workflows and issue template
  • Loading branch information
doronz88 authored Feb 1, 2022
2 parents a7cb5a6 + 31b33ce commit c8bc8fc
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 5 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Test environment**
- Host OS version.
- Target device model and iOS version.

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Logs**
If applicable, add logs including backtraces for the given error that help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
39 changes: 39 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python application

on:
push:
branches: [ '**' ]

jobs:
build:
runs-on: ${{ matrix.os }}

defaults:
run:
working-directory: ./src/pyzshell

strategy:
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9, "3.10" ]
os: [ ubuntu-latest, macos-latest, windows-latest ]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Lint with flake8
run: |
python -m pip install flake8
flake8 . --max-complexity=10 --max-line-length=127 --statistics
- name: Test install
run: |
python -m pip install --upgrade pip
python -m pip install -U .
- name: Test show usage
run: |
python -m pyzshell
35 changes: 35 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package

on:
release:
types: [created]

jobs:
deploy:

runs-on: ubuntu-latest

defaults:
run:
working-directory: ./src/pyzshell

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
23 changes: 23 additions & 0 deletions .github/workflows/server-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Server application

on:
push:
branches: [ '**' ]

jobs:
build:
runs-on: ${{ matrix.os }}

defaults:
run:
working-directory: ./src/remote_server

strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]

steps:
- uses: actions/checkout@v2
- name: Test make
run: |
make clean all
21 changes: 17 additions & 4 deletions src/pyzshell/pyzshell/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import logging
import os
import sys
import termios
import tty
import typing
from select import select
from socket import socket
Expand All @@ -23,6 +21,15 @@
from pyzshell.symbol import Symbol
from pyzshell.symbols_jar import SymbolsJar

tty_support = False
try:
import termios
import tty

tty_support = True
except ImportError:
logging.warning('termios not available on your system. some functionality may not work as expected')

CHUNK_SIZE = 1024

USAGE = '''
Expand Down Expand Up @@ -179,7 +186,9 @@ def spawn(self, argv: typing.List[str] = None, envp: typing.List[str] = None):
self._prepare_terminal()
try:
result = self._execution_loop()
except:
except: # noqa: E722
# this is important to really catch every exception here, even exceptions not inheriting from Exception
# so the controlling terminal will remain working with its previous settings
self._restore_terminal()
self.reconnect()
raise
Expand Down Expand Up @@ -233,7 +242,7 @@ def _ipython_run_cell_hook(self, info):
"""
if info.raw_cell.startswith('!'):
return

for node in ast.walk(ast.parse(info.raw_cell)):
if not isinstance(node, ast.Name):
# we are only interested in names
Expand Down Expand Up @@ -270,9 +279,13 @@ def _execute(self, argv: typing.List[str], envp: typing.List[str]) -> int:
return pid

def _restore_terminal(self):
if not tty_support:
return
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, self._old_settings)

def _prepare_terminal(self):
if not tty_support:
return
fd = sys.stdin
self._old_settings = termios.tcgetattr(fd)
atexit.register(self._restore_terminal)
Expand Down
3 changes: 2 additions & 1 deletion src/pyzshell/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ def parse_requirements():


def get_description():
return (BASE_DIR / 'README.md').read_text()
# on Windows, read_text() will replace the emoji unicode characters
return (BASE_DIR / 'README.md').read_text(errors='ignore')


def get_data_files():
Expand Down

0 comments on commit c8bc8fc

Please sign in to comment.