Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
bdragon300 committed May 15, 2021
2 parents 0512369 + c82670d commit b7fb0ed
Show file tree
Hide file tree
Showing 82 changed files with 6,041 additions and 19,258 deletions.
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[run]
omit =
pyzkaccess/cli.py
setup.py
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,8 @@ cython_debug/

# IntelliJIDEA/PyCharm
.idea/

# Autogenerated html documentation
/docs/pyzkaccess
/docs/*.js
/docs/*.html
25 changes: 21 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,42 @@
language: python
python:
- '3.5'
- '3.6'
- '3.7'
- '3.9'
- '3.8'
- '3.7'
- '3.6'
- '3.5'

install:
- pip install setuptools tox pytest-cov

script:
- tox
- ./run_tests.sh

after_success:
- "bash <(curl -s https://codecov.io/bash)"

jobs:
include:
- stage: build-docs
install: pip install setuptools pdoc3 wrapt fire prettytable
script:
- pdoc3 -o docs --template-dir pdoc_tpl --html pyzkaccess
after_success: true # https://travis-ci.community/t/does-skipping-everything-else-in-a-job-skip-deploy/6461/2
deploy:
provider: pages:git
edge: true
token: $GITHUB_TOKEN
keep_history: true
local_dir: docs
target_branch: gh-pages
on:
branch: master
- stage: deploy
script: skip
after_success: true # https://travis-ci.community/t/does-skipping-everything-else-in-a-job-skip-deploy/6461/2
deploy:
provider: pypi
edge: true
username: "__token__"
password: $PYPI_TOKEN
on:
Expand Down
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to
[Python Versioning](https://www.python.org/dev/peps/pep-0440/#public-version-identifiers).

## [1.0]

### Added
- Make a device data tables interface. Including making queries, changing and deleting records
- Add command-line interface
- Add alarm cancel function
- Add a device IP change function using a network broadcast method
- Add event type `206: Device start`
- Add python 3.9 support

### Changed
- Use Jekyll and pdoc3 instead of portray for documentation
- Upload github-pages to a separate branch
- Change docstrings format to Google style
- Fix empty relays list in `Door` objects with index in `DoorsList` > 0
- Fix `spring_daylight_time_mode1` and `fall_daylight_time_mode1` parameters value format
- Print one event by line and remove items collapsing in `EventLog` string representation
- Fix "no value" values handling in some paremeters
- Fix `search_devices` raises error when no devices found
- Rename `pyzkaccess.py` to `main.py` and `ctypes.py` to `ctypes_.py` in order to avoid
possible import issues
- Change type of warning to `ImportWarning` when non-Windows platform is used

### Removed
- Remove documentation html contents from repo

## [0.2]
### Added
- Add codecov
Expand Down
79 changes: 74 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,80 @@
# PyZKAccess

![version](https://img.shields.io/pypi/v/pyzkaccess)
![pyversions](https://img.shields.io/pypi/pyversions/pyzkaccess)
![travis](https://img.shields.io/travis/com/bdragon300/pyzkaccess/master)
[![version](https://img.shields.io/pypi/v/pyzkaccess)](https://pypi.org/project/pyzkaccess/)
[![pyversions](https://img.shields.io/pypi/pyversions/pyzkaccess)](https://pypi.org/project/pyzkaccess/)
[![travis](https://img.shields.io/travis/com/bdragon300/pyzkaccess/master)](https://travis-ci.com/github/bdragon300/pyzkaccess)
[![codecov](https://codecov.io/gh/bdragon300/pyzkaccess/branch/master/graph/badge.svg)](https://codecov.io/gh/bdragon300/pyzkaccess)
![license](https://img.shields.io/github/license/bdragon300/pyzkaccess)
[![license](https://img.shields.io/github/license/bdragon300/pyzkaccess)](https://github.com/bdragon300/pyzkaccess/blob/master/LICENSE)

**PyZKAccess** is a library for working with ZKTeco ZKAccess C3-100/200/400 access controllers.
**PyZKAccess** is a library and command-line interface for working with ZKTeco ZKAccess
C3-100/200/400 access controllers.

[Read documentation](https://bdragon300.github.io/pyzkaccess)

# Quick start

First, you need to install ZKTeco PULL SDK. See documentation for more info.

In order to make requests to your C3 device, you need to know its IP address. Let's scan a
local network and find a device:

```console
$ pyzkaccess search_devices
+---------------+-------------------+--------+---------------------+--------------------------+
| ip | mac | model | serial_number | version |
+---------------+-------------------+--------+---------------------+--------------------------+
| 192.168.1.201 | 00:17:61:C3:BA:55 | C3-400 | DGD9190010050345332 | AC Ver 4.3.4 Apr 28 2017 |
+---------------+-------------------+--------+---------------------+--------------------------+
```

Now you can connect to a device using its IP and, for example, print list of all Users:

```console
$ pyzkaccess connect 192.168.1.201 table User
+----------+------------+-------+----------+-----+------------+-----------------+
| card | end_time | group | password | pin | start_time | super_authorize |
+----------+------------+-------+----------+-----+------------+-----------------+
| 16268812 | 2020-12-01 | 2 | 123456 | 1 | 2020-06-01 | 1 |
| 16268813 | | 3 | 123451 | 3 | | 0 |
+----------+------------+-------+----------+-----+------------+-----------------+
```

Or select only needed records:

```console
$ pyzkaccess connect 192.168.1.201 table User where --card=16268812
+----------+------------+-------+----------+-----+------------+-----------------+
| card | end_time | group | password | pin | start_time | super_authorize |
+----------+------------+-------+----------+-----+------------+-----------------+
| 16268812 | 2020-12-01 | 2 | 123456 | 1 | 2020-06-01 | 1 |
+----------+------------+-------+----------+-----+------------+-----------------+
```

Also, you can update or delete records from a csv file. Or even delete all records from a query:

```console
$ cat users1.csv | pyzkaccess --format=csv connect 192.168.1.201 table User upsert
$ cat users2.csv | pyzkaccess --format=csv connect 192.168.1.201 table User delete
$ pyzkaccess connect 192.168.1.201 table User --card=16268812 delete_all
```

Switching relays and awaiting device events:

```console
$ pyzkaccess connect 192.168.1.201 relays switch_on
$ pyzkaccess connect 192.168.1.201 events --event_type=23 poll
card door entry_exit event_type pin time verify_mode
16268813 1 0 23 3 2020-05-09 22:35:55 0
```

Getting and setting parameters:

```console
$ pyzkaccess connect 192.168.1.201 parameters --names=ip_address,serial_number,datetime
+---------------------+---------------+---------------------+
| datetime | ip_address | serial_number |
+---------------------+---------------+---------------------+
| 2020-05-09 22:42:31 | 192.168.1.201 | DGD9190010050345332 |
+---------------------+---------------+---------------------+
$ pyzkaccess connect 192.168.1.201 parameters set --datetime='2020-05-09 22:42:31' --rs232_baud_rate=57600
```
3 changes: 3 additions & 0 deletions docs/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
theme: jekyll-theme-minimal
baseurl: 'pyzkaccess'
url: 'https://bdragon300.github.io'
33 changes: 33 additions & 0 deletions docs/cli.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Command-line interface

CLI interface uses command/subcommand chain approach. Typical CLI usage is:

Commands for a connected device:

```console
$ pyzkaccess connect <ip> <subcommand|group> [parameters] [<subcommand> [parameters] ...]
```

* Commands not related to a particular device:
```console
$ pyzkaccess <command> [parameters]
```

By default, all input consumes from stdin, and all output prints on stdout. You can specify a file
instead by setting `--file` parameter.

CLI gives access to most of PyZKAccess features. Also, it is supported the ascii tables in console
or CSV format.

Every command, group and subcommand has its own help contents, just type them and append
`--help` at the end. For example, here is the help for `connect` command:

```console
$ pyzkaccess connect --help
```

Or for `where` subcommand of `table` subcommand:

```console
$ pyzkaccess connect 192.168.1.201 table User where --help
```
Loading

0 comments on commit b7fb0ed

Please sign in to comment.