mirror of
https://github.com/Ircama/epson_print_conf.git
synced 2024-10-18 09:10:36 -04:00
Add code python-syntax-checker and other github actions
This commit is contained in:
parent
bfd8e4a402
commit
604745de2d
4 changed files with 206 additions and 61 deletions
68
.github/workflows/codeql-analysis.yml
vendored
Normal file
68
.github/workflows/codeql-analysis.yml
vendored
Normal file
|
@ -0,0 +1,68 @@
|
|||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '39 8 * * 0'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
permissions: write-all
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'python' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||
# Learn more:
|
||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
#- run: |
|
||||
# make bootstrap
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
40
.github/workflows/python-syntax-checker.yml
vendored
Normal file
40
.github/workflows/python-syntax-checker.yml
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
# from https://docs.github.com/en/actions/guides/building-and-testing-python
|
||||
|
||||
name: Python syntax checker
|
||||
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
# version range and latest minor release (possibly 3.9.1)
|
||||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.x']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flake8
|
||||
# next line is alternative to the previous one, for future use of pytest
|
||||
# pip install flake8 pytest
|
||||
# next line is for future use of requirements file
|
||||
# if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||
- name: Lint with flake8
|
||||
run: |
|
||||
# stop the build if there are Python syntax errors or undefined names
|
||||
flake8 . --count --select=E9,F63,F7,F72,F82 --show-source --statistics
|
||||
# next lines is for future use of more accurate statistics
|
||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||
# flake8 . --count --exit-zero --max-complexity=40 --max-line-length=127 --statistics
|
||||
# next lines is for future use of pytest
|
||||
#- name: Test with pytest
|
||||
# run: |
|
||||
# pytest
|
26
.github/workflows/stale.yml
vendored
Normal file
26
.github/workflows/stale.yml
vendored
Normal file
|
@ -0,0 +1,26 @@
|
|||
name: Mark stale issues and automatically close them
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '00 23 * * *'
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v4 # https://github.com/actions/stale
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
stale-issue-message: 'This issue becomed stale because of no feedback for 30 days. Remove the stale label or add a comment; otherwise, this will be automatically closed in 60 days.'
|
||||
stale-pr-message: 'This PR becomed stale because of no feedback for 60 days.'
|
||||
days-before-stale: 30
|
||||
days-before-close: 60
|
||||
close-issue-message: 'This issue was closed because it has been stalled for 60 days with no activity.'
|
||||
days-before-pr-close: -1
|
||||
any-of-labels: answered,needs-rebase,inactive,Awaiting-Response,question,invalid,duplicate,wontfix
|
||||
exempt-all-pr-assignees: true
|
|
@ -244,8 +244,8 @@ class EpsonPrinter:
|
|||
return {
|
||||
printer_name
|
||||
for printer_name in self.PRINTER_CONFIG.keys()
|
||||
if "read_key" in self.PRINTER_CONFIG[printer_name] and
|
||||
"write_key" in self.PRINTER_CONFIG[printer_name]
|
||||
if "read_key" in self.PRINTER_CONFIG[printer_name]
|
||||
and "write_key" in self.PRINTER_CONFIG[printer_name]
|
||||
}
|
||||
|
||||
@property
|
||||
|
@ -444,8 +444,10 @@ class EpsonSession(easysnmp.Session):
|
|||
buf = buf[length:]
|
||||
|
||||
if self.debug:
|
||||
print("Processing status - ftype", hex(ftype),
|
||||
"length:", length, "item:", item.hex(' '))
|
||||
print(
|
||||
"Processing status - ftype", hex(ftype),
|
||||
"length:", length, "item:", item.hex(' ')
|
||||
)
|
||||
|
||||
if ftype == 0x0f: # ink
|
||||
colourlen = item[0]
|
||||
|
@ -643,8 +645,12 @@ class EpsonSession(easysnmp.Session):
|
|||
if "ink_replacement_counters" not in self.printer.parm:
|
||||
return None
|
||||
irc = {
|
||||
(color, counter, int(self.read_eeprom(
|
||||
value, label="ink_replacement_counters"), 16))
|
||||
(
|
||||
color,
|
||||
counter,
|
||||
int(self.read_eeprom(value, label="ink_replacement_counters"),
|
||||
16),
|
||||
)
|
||||
for color, data in self.printer.parm[
|
||||
"ink_replacement_counters"].items()
|
||||
for counter, value in data.items()
|
||||
|
@ -657,9 +663,13 @@ class EpsonSession(easysnmp.Session):
|
|||
if not result:
|
||||
return None
|
||||
if self.debug:
|
||||
print(textwrap.fill("PRINTER_STATUS: " +
|
||||
bytes([ord(i) for i in result]).hex(" "),
|
||||
initial_indent='', subsequent_indent=' ')
|
||||
print(
|
||||
textwrap.fill(
|
||||
"PRINTER_STATUS: " + bytes(
|
||||
[ord(i) for i in result]).hex(" "),
|
||||
initial_indent="",
|
||||
subsequent_indent=" ",
|
||||
)
|
||||
)
|
||||
return self.status_parser(bytes([ord(i) for i in result]))
|
||||
|
||||
|
@ -673,8 +683,7 @@ class EpsonSession(easysnmp.Session):
|
|||
self.printer.parm["main_waste"]["oids"], label="main_waste")
|
||||
level_b10 = int("".join(reversed(level)), 16)
|
||||
results.append(
|
||||
round(level_b10 / self.printer.parm["main_waste"]["divider"],
|
||||
2)
|
||||
round(level_b10 / self.printer.parm["main_waste"]["divider"], 2)
|
||||
)
|
||||
|
||||
if "borderless_waste" in self.printer.parm:
|
||||
|
@ -718,13 +727,13 @@ class EpsonSession(easysnmp.Session):
|
|||
def write_first_ti_received_time(
|
||||
self, year: int, month: int, day: int) -> None:
|
||||
"""Update first TI received time"""
|
||||
b = self.printer.parm["stats"]["First TI received time"][0]
|
||||
l = self.printer.parm["stats"]["First TI received time"][1]
|
||||
msb = self.printer.parm["stats"]["First TI received time"][0]
|
||||
lsb = self.printer.parm["stats"]["First TI received time"][1]
|
||||
n = (year - 2000) * 16 * 32 + 32 * month + day
|
||||
if self.debug:
|
||||
print("FTRT:", hex(n // 256), hex(n % 256), "=", n // 256, n % 256)
|
||||
self.write_eeprom(b, n // 256, label="First TI received time")
|
||||
self.write_eeprom(l, n % 256, label="First TI received time")
|
||||
self.write_eeprom(msb, n // 256, label="First TI received time")
|
||||
self.write_eeprom(lsb, n % 256, label="First TI received time")
|
||||
|
||||
def brute_force_read_key(
|
||||
self, minimum: int = 0x00, maximum: int = 0xFF
|
||||
|
@ -748,7 +757,6 @@ if __name__ == "__main__":
|
|||
import argparse
|
||||
from pprint import pprint
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
epilog='Epson Printer Configuration accessed via SNMP (TCP/IP)')
|
||||
|
||||
|
@ -872,10 +880,13 @@ if __name__ == "__main__":
|
|||
if ret:
|
||||
pprint(ret)
|
||||
else:
|
||||
print("No information returned."
|
||||
" Check printer definition.")
|
||||
print(
|
||||
"No information returned."
|
||||
" Check printer definition."
|
||||
)
|
||||
else:
|
||||
print("Option error: unavailable query.\n" +
|
||||
print(
|
||||
"Option error: unavailable query.\n" +
|
||||
textwrap.fill(
|
||||
"Available queries: " +
|
||||
", ".join(printer.list_methods),
|
||||
|
|
Loading…
Reference in a new issue