Skip to content

Commit

Permalink
Merge pull request #30 from jpwsutton/general-code-improvements
Browse files Browse the repository at this point in the history
feat: general code improvements and adding github workflow
  • Loading branch information
jpwsutton authored Dec 31, 2022
2 parents 51db4a4 + b8da01e commit cc56142
Show file tree
Hide file tree
Showing 30 changed files with 2,925 additions and 1,965 deletions.
5 changes: 5 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[flake8]
max-line-length = 120

select = C,E,F,W,B,B950
extend-ignore = E501,E203,W503
72 changes: 72 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Upload Instax Python Package


on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

environment: publish

steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Cache poetry install
uses: actions/cache@v3
with:
path: ~/.local # the path depends on OS
key: poetry-0 # increment to reset cache
- name: Install poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# Build Distributables
#----------------------------------------------
- name: Install project
run: poetry build

#----------------------------------------------
# build and publish to pypi
#----------------------------------------------
- name: Publish project
run: poetry publish
79 changes: 79 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "Build, Lint and Test"

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
#----------------------------------------------
# check-out repo and set-up python
#----------------------------------------------
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

#----------------------------------------------
# ----- install & configure poetry -----
#----------------------------------------------
- name: Cache poetry install
uses: actions/cache@v3
with:
path: ~/.local # the path depends on OS
key: poetry-0 # increment to reset cache
- name: Install poetry
if: steps.cached-poetry.outputs.cache-hit != 'true'
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
installer-parallel: true

#----------------------------------------------
# load cached venv if cache exists
#----------------------------------------------
- name: Load Cached venv
id: cached-poetry-dependencies
uses: actions/cache@v3
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version}}-${{ hashFiles('**/poetry.lock') }}

#----------------------------------------------
# install dependencies if cache does not exist
#----------------------------------------------
- name: Install dependencies
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
run: poetry install --no-interaction --no-root
#----------------------------------------------
# install your root project, if required
#----------------------------------------------
- name: Install project
run: poetry install --no-interaction

#----------------------------------------------
# lint project
#----------------------------------------------
- name: Lint Project
uses: pre-commit/[email protected]

#----------------------------------------------
# run test suite
#----------------------------------------------
- name: Run tests
run: |
source .venv/bin/activate
pytest --cov-report=lcov:coverage/lcov.info --cov=instax
coverage report
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: end-of-file-fixer
- id: check-added-large-files
- id: requirements-txt-fixer
- id: check-json
- id: check-merge-conflict
- repo: https://github.com/pycqa/flake8
rev: 5.0.4
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
name: isort (python)
args: ["--profile", "black"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.0
hooks:
- id: pyupgrade
args: ['--py3-plus', '--py36-plus']
- repo: https://github.com/psf/black
rev: 22.10.0
hooks:
- id: black
args:
- --line-length=120
- repo: https://github.com/jorisroovers/gitlint
rev: v0.17.0
hooks:
- id: gitlint
name: gitlint
language: python
entry: gitlint
args: [--staged, --msg-filename]
stages: [commit-msg]
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# instax_api

[![Build Status](https://img.shields.io/travis/jpwsutton/instax_api/master.svg)](https://travis-ci.org/jpwsutton/instax_api)
[![.github/workflows/python-test.yml](https://github.com/jpwsutton/instax_api/actions/workflows/python-test.yml/badge.svg)](https://github.com/jpwsutton/instax_api/actions/workflows/python-test.yml)
[![Coverage Status](https://img.shields.io/coveralls/jpwsutton/instax_api/master.svg)](https://coveralls.io/github/jpwsutton/instax_api?branch=master)

This is a Python Module to interact and print photos to the Fujifilm Instax SP-2 and SP-3 printers.
Expand All @@ -14,10 +13,13 @@ In order to use this library, you will need to be using Python 3
pip3 install instax-api
```


## Usage

**note** - From version 0.7.0 to 0.8.0, I moved away from adding a script to just calling the module from pyton using the `-m` argument.

```
$ instax-print --help
$ python3 -m instax.print --help
usage: instax-print [-h] [-i PIN] [-v {1,2,3}] image
positional arguments:
Expand All @@ -33,16 +35,16 @@ optional arguments:

### Examples:

- Printing a Photo to an SP-2 printer: `instax-print myPhoto.jpg`
- Printing a Photo to an SP-3 printer: `instax-print myPhoto.jpg -v 3`
- Printing a Photo to a printer with a pin that is not the default (1111) `instax-print myPhoto.jpg -i 1234`
- Printing a Photo to an SP-2 printer: `python3 -m instax.print myPhoto.jpg`
- Printing a Photo to an SP-3 printer: `python3 -m instax.print myPhoto.jpg -v 3`
- Printing a Photo to a printer with a pin that is not the default (1111) `python3 -m instax.print myPhoto.jpg -i 1234`

### Hints and tips:
- Make sure you are connected to the correct wifi network, once the printer is turned on, there will be an SSID / WiFi network available that starts with `INSTAX-` followed by 8 numbers. You'll need to connect to this.
- If you have a static IP address set up on your computer, you'll need to turn on DHCP before attempting to print, the Instax printer will automatically assign you a new address once you connect.
- Some Unix based operating systems may require you to use sudo in order to access the network.
- The printer will automatically turn itself off after roughly 10 minutes of innactivity.
- The instax-print utility will attempt to automatically rotate the image so that it either is correctly printed in portrait, or landscape with the thick bottom edge of the print on the left. If you wish to print your photos in a specific orientation that differs from this, then it's reccomended that you orient your photo in a tool like GIMP first, then strip out the rotation metadata. Once the rotation metadata has been stripped, the photo will need to be in a portrait orientation relative to the finished print (e.g. thick edge at the bottom).
- The instax.print utility will attempt to automatically rotate the image so that it either is correctly printed in portrait, or landscape with the thick bottom edge of the print on the left. If you wish to print your photos in a specific orientation that differs from this, then it's reccomended that you orient your photo in a tool like GIMP first, then strip out the rotation metadata. Once the rotation metadata has been stripped, the photo will need to be in a portrait orientation relative to the finished print (e.g. thick edge at the bottom).

## Install Manually

Expand Down
136 changes: 0 additions & 136 deletions bin/instax-print

This file was deleted.

Loading

0 comments on commit cc56142

Please sign in to comment.