gomc-rest-client 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,223 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ # Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ # poetry.lock
109
+ # poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ # pdm.lock
116
+ # pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ # pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # Redis
135
+ *.rdb
136
+ *.aof
137
+ *.pid
138
+
139
+ # RabbitMQ
140
+ mnesia/
141
+ rabbitmq/
142
+ rabbitmq-data/
143
+
144
+ # ActiveMQ
145
+ activemq-data/
146
+
147
+ # SageMath parsed files
148
+ *.sage.py
149
+
150
+ # Environments
151
+ .env
152
+ .envrc
153
+ .venv
154
+ env/
155
+ venv/
156
+ ENV/
157
+ env.bak/
158
+ venv.bak/
159
+
160
+ # Spyder project settings
161
+ .spyderproject
162
+ .spyproject
163
+
164
+ # Rope project settings
165
+ .ropeproject
166
+
167
+ # mkdocs documentation
168
+ /site
169
+
170
+ # mypy
171
+ .mypy_cache/
172
+ .dmypy.json
173
+ dmypy.json
174
+
175
+ # Pyre type checker
176
+ .pyre/
177
+
178
+ # pytype static type analyzer
179
+ .pytype/
180
+
181
+ # Cython debug symbols
182
+ cython_debug/
183
+
184
+ # PyCharm
185
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
186
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
187
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
188
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
189
+ # .idea/
190
+
191
+ # Abstra
192
+ # Abstra is an AI-powered process automation framework.
193
+ # Ignore directories containing user credentials, local state, and settings.
194
+ # Learn more at https://abstra.io/docs
195
+ .abstra/
196
+
197
+ # Visual Studio Code
198
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
199
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
200
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
201
+ # you could uncomment the following to ignore the entire vscode folder
202
+ # .vscode/
203
+ # Temporary file for partial code execution
204
+ tempCodeRunnerFile.py
205
+
206
+ # Ruff stuff:
207
+ .ruff_cache/
208
+
209
+ # PyPI configuration file
210
+ .pypirc
211
+
212
+ # Marimo
213
+ marimo/_static/
214
+ marimo/_lsp/
215
+ __marimo__/
216
+
217
+ # Streamlit
218
+ .streamlit/secrets.toml
219
+
220
+ .claude/
221
+ .github/
222
+ .docs/
223
+ .vscode/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Moge800
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,144 @@
1
+ Metadata-Version: 2.4
2
+ Name: gomc-rest-client
3
+ Version: 0.1.0
4
+ Summary: Synchronous Python client for the gomc-rest API
5
+ Project-URL: Homepage, https://github.com/Moge800/gomc-rest
6
+ Author: Moge800
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Keywords: gomc-rest,mc-protocol,mitsubishi,plc
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+
21
+ # gomc-rest-client
22
+
23
+ [日本語版 README](https://github.com/Moge800/gomc_rest_client/blob/main/README_JP.md)
24
+
25
+ Python 3.10+ client library for the latest gomc-rest HTTP API.
26
+
27
+ This package wraps the synchronous REST endpoints exposed by gomc-rest for Mitsubishi PLC read, write, and remote-control operations using only the Python standard library, and converts API error responses into typed Python exceptions.
28
+
29
+ ## About gomc-rest-client
30
+
31
+ This package is a dedicated client library for gomc-rest. It is intended for users who already use gomc-rest, or who want to expose Mitsubishi PLC operations through the gomc-rest HTTP API.
32
+
33
+ This library does not communicate with PLCs directly. If you need the server, API surface, or gomc-rest itself, see the upstream project:
34
+
35
+ - https://github.com/Moge800/gomc-rest
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ uv add gomc-rest-client
41
+ ```
42
+
43
+ With pip:
44
+
45
+ ```bash
46
+ pip install gomc-rest-client
47
+ ```
48
+
49
+ For offline environments, install from a prebuilt wheel distributed inside your network:
50
+
51
+ ```bash
52
+ pip install dist/gomc_rest_client-*.whl
53
+ ```
54
+
55
+ This package has no runtime dependencies outside the Python standard library, so wheel-based offline installation is straightforward.
56
+
57
+ For local development:
58
+
59
+ ```bash
60
+ uv sync --group dev
61
+ ```
62
+
63
+ To build distributable artifacts before taking them into an offline environment:
64
+
65
+ ```bash
66
+ uv build
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ ```python
72
+ from gomc_rest_client import (
73
+ MINIMUM_SUPPORTED_GOMC_REST_VERSION,
74
+ BusyError,
75
+ PLCClient,
76
+ PLCProtocolError,
77
+ )
78
+
79
+ with PLCClient("http://192.168.0.1:8080") as plc:
80
+ health = plc.health()
81
+ metrics = plc.metrics()
82
+ version = plc.version()
83
+ is_supported = plc.is_supported_version()
84
+ is_compatible = plc.is_version_compatible(MINIMUM_SUPPORTED_GOMC_REST_VERSION)
85
+ values = plc.read("D100", 3)
86
+ bits = plc.read("M0", 4)
87
+ dwords = plc.read("D100", 2, dword=True)
88
+ signed = plc.read("D100", 3, sint=True)
89
+
90
+ plc.write("D100", [10, 20, 30])
91
+ plc.write("M0", [True, False])
92
+ plc.write("D100", [-1, -32768, 32767], sint=True)
93
+
94
+ try:
95
+ plc.remote_run(clear=0, force=False)
96
+ except BusyError:
97
+ pass
98
+ except PLCProtocolError as exc:
99
+ print(exc.end_code, exc.message)
100
+ ```
101
+
102
+ `is_supported_version()` and `is_version_compatible()` treat `dev` builds as compatible by default so local gomc-rest main builds can pass version checks during development.
103
+
104
+ ## Supported gomc-rest versions
105
+
106
+ This client supports gomc-rest `v0.6.0` and later.
107
+
108
+ Servers older than `v0.6.0` are not supported. In particular, servers without the `/version` endpoint are out of scope for this client.
109
+
110
+ This client expects the server to expose both `/version` and `/metrics`.
111
+
112
+ If you need to verify the support policy at runtime, call `plc.is_supported_version()` or compare against `MINIMUM_SUPPORTED_GOMC_REST_VERSION`.
113
+
114
+ ## API coverage
115
+
116
+ - GET /version
117
+ - GET /metrics
118
+ - GET /health
119
+ - GET /read
120
+ - POST /write
121
+ - POST /remote/run
122
+ - POST /remote/stop
123
+ - POST /remote/pause
124
+ - POST /remote/latch-clear
125
+ - POST /remote/reset
126
+
127
+ Remote-control endpoints require the gomc-rest server to start with `-enable-remote`.
128
+
129
+ ## Development
130
+
131
+ Run checks with uv:
132
+
133
+ ```bash
134
+ uv run pytest
135
+ uv run ruff check .
136
+ uv run ty check
137
+ uv build
138
+ ```
139
+
140
+ To publish to PyPI after configuring credentials:
141
+
142
+ ```bash
143
+ uv publish
144
+ ```
@@ -0,0 +1,124 @@
1
+ # gomc-rest-client
2
+
3
+ [日本語版 README](https://github.com/Moge800/gomc_rest_client/blob/main/README_JP.md)
4
+
5
+ Python 3.10+ client library for the latest gomc-rest HTTP API.
6
+
7
+ This package wraps the synchronous REST endpoints exposed by gomc-rest for Mitsubishi PLC read, write, and remote-control operations using only the Python standard library, and converts API error responses into typed Python exceptions.
8
+
9
+ ## About gomc-rest-client
10
+
11
+ This package is a dedicated client library for gomc-rest. It is intended for users who already use gomc-rest, or who want to expose Mitsubishi PLC operations through the gomc-rest HTTP API.
12
+
13
+ This library does not communicate with PLCs directly. If you need the server, API surface, or gomc-rest itself, see the upstream project:
14
+
15
+ - https://github.com/Moge800/gomc-rest
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ uv add gomc-rest-client
21
+ ```
22
+
23
+ With pip:
24
+
25
+ ```bash
26
+ pip install gomc-rest-client
27
+ ```
28
+
29
+ For offline environments, install from a prebuilt wheel distributed inside your network:
30
+
31
+ ```bash
32
+ pip install dist/gomc_rest_client-*.whl
33
+ ```
34
+
35
+ This package has no runtime dependencies outside the Python standard library, so wheel-based offline installation is straightforward.
36
+
37
+ For local development:
38
+
39
+ ```bash
40
+ uv sync --group dev
41
+ ```
42
+
43
+ To build distributable artifacts before taking them into an offline environment:
44
+
45
+ ```bash
46
+ uv build
47
+ ```
48
+
49
+ ## Usage
50
+
51
+ ```python
52
+ from gomc_rest_client import (
53
+ MINIMUM_SUPPORTED_GOMC_REST_VERSION,
54
+ BusyError,
55
+ PLCClient,
56
+ PLCProtocolError,
57
+ )
58
+
59
+ with PLCClient("http://192.168.0.1:8080") as plc:
60
+ health = plc.health()
61
+ metrics = plc.metrics()
62
+ version = plc.version()
63
+ is_supported = plc.is_supported_version()
64
+ is_compatible = plc.is_version_compatible(MINIMUM_SUPPORTED_GOMC_REST_VERSION)
65
+ values = plc.read("D100", 3)
66
+ bits = plc.read("M0", 4)
67
+ dwords = plc.read("D100", 2, dword=True)
68
+ signed = plc.read("D100", 3, sint=True)
69
+
70
+ plc.write("D100", [10, 20, 30])
71
+ plc.write("M0", [True, False])
72
+ plc.write("D100", [-1, -32768, 32767], sint=True)
73
+
74
+ try:
75
+ plc.remote_run(clear=0, force=False)
76
+ except BusyError:
77
+ pass
78
+ except PLCProtocolError as exc:
79
+ print(exc.end_code, exc.message)
80
+ ```
81
+
82
+ `is_supported_version()` and `is_version_compatible()` treat `dev` builds as compatible by default so local gomc-rest main builds can pass version checks during development.
83
+
84
+ ## Supported gomc-rest versions
85
+
86
+ This client supports gomc-rest `v0.6.0` and later.
87
+
88
+ Servers older than `v0.6.0` are not supported. In particular, servers without the `/version` endpoint are out of scope for this client.
89
+
90
+ This client expects the server to expose both `/version` and `/metrics`.
91
+
92
+ If you need to verify the support policy at runtime, call `plc.is_supported_version()` or compare against `MINIMUM_SUPPORTED_GOMC_REST_VERSION`.
93
+
94
+ ## API coverage
95
+
96
+ - GET /version
97
+ - GET /metrics
98
+ - GET /health
99
+ - GET /read
100
+ - POST /write
101
+ - POST /remote/run
102
+ - POST /remote/stop
103
+ - POST /remote/pause
104
+ - POST /remote/latch-clear
105
+ - POST /remote/reset
106
+
107
+ Remote-control endpoints require the gomc-rest server to start with `-enable-remote`.
108
+
109
+ ## Development
110
+
111
+ Run checks with uv:
112
+
113
+ ```bash
114
+ uv run pytest
115
+ uv run ruff check .
116
+ uv run ty check
117
+ uv build
118
+ ```
119
+
120
+ To publish to PyPI after configuring credentials:
121
+
122
+ ```bash
123
+ uv publish
124
+ ```
@@ -0,0 +1,26 @@
1
+ from .client import MINIMUM_SUPPORTED_GOMC_REST_VERSION, PLCClient
2
+ from .exceptions import (
3
+ BadRequestError,
4
+ BusyError,
5
+ ConnectionError,
6
+ ForbiddenError,
7
+ PLCError,
8
+ PLCProtocolError,
9
+ QueueClosedError,
10
+ RequestCanceledError,
11
+ RequestTimeoutError,
12
+ )
13
+
14
+ __all__ = [
15
+ "BadRequestError",
16
+ "BusyError",
17
+ "ConnectionError",
18
+ "ForbiddenError",
19
+ "MINIMUM_SUPPORTED_GOMC_REST_VERSION",
20
+ "PLCClient",
21
+ "PLCError",
22
+ "PLCProtocolError",
23
+ "QueueClosedError",
24
+ "RequestCanceledError",
25
+ "RequestTimeoutError",
26
+ ]