Compare commits
9 Commits
ee5bc790ea
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a11629f543 | |||
| 11f96a6069 | |||
| 421cc06d6c | |||
| aef2761f9f | |||
| 607430ca69 | |||
| f05ffdd86d | |||
| ddb5194320 | |||
| 003b2ff367 | |||
| a7178b6f86 |
23
README.md
23
README.md
@@ -2,6 +2,20 @@
|
||||
|
||||
Another attempt for a modern client library to the Mitel OM Application XML Interface.
|
||||
|
||||
## Install
|
||||
|
||||
Without any additional dependencies:
|
||||
|
||||
```
|
||||
pip install "mitel_ommclient2 @ git+https://git.clerie.de/clerie/mitel_ommclient2.git@main"
|
||||
```
|
||||
|
||||
Add dependencies to enable secret handling, if you need it.
|
||||
|
||||
```
|
||||
pip install "mitel_ommclient2[crypt] @ git+https://git.clerie.de/clerie/mitel_ommclient2.git@main"
|
||||
```
|
||||
|
||||
## Quicksart
|
||||
|
||||
Just some examples to give you an idea what this does.
|
||||
@@ -23,6 +37,15 @@ r = c.connection.request(m)
|
||||
|
||||
Consult class documentation for more in depth examples and options.
|
||||
|
||||
## Interactive CLI
|
||||
|
||||
The package installs a script called `ommclient2`.
|
||||
This allowes basic interactive testing of the library.
|
||||
|
||||
```
|
||||
ommclient2 --help
|
||||
```
|
||||
|
||||
## Attribution
|
||||
|
||||
This software is inspired by `python-mitel` by Thomas and n-st.
|
||||
|
||||
27
flake.lock
generated
Normal file
27
flake.lock
generated
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1665732960,
|
||||
"narHash": "sha256-WBZ+uSHKFyjvd0w4inbm0cNExYTn8lpYFcHEes8tmec=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4428e23312933a196724da2df7ab78eb5e67a88e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
||||
49
flake.nix
Normal file
49
flake.nix
Normal file
@@ -0,0 +1,49 @@
|
||||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
outputs = { self, nixpkgs, ... }: {
|
||||
packages.x86_64-linux = let
|
||||
pkgs = import nixpkgs {
|
||||
system = "x86_64-linux";
|
||||
};
|
||||
in {
|
||||
mitel-ommclient2 = pkgs.python3Packages.buildPythonPackage rec {
|
||||
pname = "mitel-ommclient2";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"doc"
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.python3Packages.sphinxHook
|
||||
];
|
||||
|
||||
format = "pyproject";
|
||||
|
||||
buildInputs = [ pkgs.python3Packages.hatchling ];
|
||||
propagatedBuildInputs = [ pkgs.python3Packages.rsa ];
|
||||
|
||||
pythonImportsCheck = [ "mitel_ommclient2" ];
|
||||
};
|
||||
default = self.packages.x86_64-linux.mitel-ommclient2;
|
||||
};
|
||||
|
||||
apps.x86_64-linux = {
|
||||
ommclient2 = {
|
||||
type = "app";
|
||||
program = self.packages.x86_64-linux.mitel-ommclient2 + "/bin/ommclient2";
|
||||
};
|
||||
default = self.apps.x86_64-linux.ommclient2;
|
||||
};
|
||||
|
||||
hydraJobs = {
|
||||
inherit (self)
|
||||
packages;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from mitel_ommclient2 import OMMClient2
|
||||
from mitel_ommclient2.exceptions import ENoEnt
|
||||
from mitel_ommclient2.messages import GetAccount, Ping
|
||||
import time
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import time
|
||||
import traceback
|
||||
|
||||
from . import OMMClient2
|
||||
from .exceptions import EAuth, ENoEnt
|
||||
from .messages import GetAccount, Ping
|
||||
|
||||
# exit handling with argparse is a bit broken even with exit_on_error=False, so we hack this
|
||||
def error_instead_exit(self, message):
|
||||
raise argparse.ArgumentError(None, message)
|
||||
@@ -22,8 +22,7 @@ def format_list(v):
|
||||
|
||||
return fl
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def main():
|
||||
connect_parser = argparse.ArgumentParser(prog='ommclient2')
|
||||
connect_parser.add_argument("-n", dest="hostname", default="127.0.0.1")
|
||||
connect_parser.add_argument("-u", dest="username", default="omm")
|
||||
@@ -41,7 +40,14 @@ if __name__ == "__main__":
|
||||
if not password:
|
||||
password = getpass.getpass(prompt="OMM password for {}@{}:".format(username, hostname))
|
||||
|
||||
c = OMMClient2(hostname, username, password, ommsync=ommsync)
|
||||
try:
|
||||
c = OMMClient2(hostname, username, password, ommsync=ommsync)
|
||||
except EAuth:
|
||||
print("Authentication failed")
|
||||
exit(1)
|
||||
except TimeoutError:
|
||||
print("OMM unreachable")
|
||||
exit(1)
|
||||
|
||||
parser = argparse.ArgumentParser(prog="ommclient2", add_help=False, exit_on_error=False)
|
||||
subparsers = parser.add_subparsers()
|
||||
@@ -178,3 +184,6 @@ if __name__ == "__main__":
|
||||
print("".join(traceback.format_exception(type(e), e, e.__traceback__)))
|
||||
continue
|
||||
print(format(r))
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -26,6 +26,7 @@ class Connection:
|
||||
self._host = host
|
||||
self._port = port
|
||||
self._socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self._socket.settimeout(2)
|
||||
|
||||
self._seq = 0 # state of the sequence number generator
|
||||
self._requests = {} # waiting area for pending responses
|
||||
|
||||
@@ -23,5 +23,8 @@ crypt = [
|
||||
"rsa",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
ommclient2 = "mitel_ommclient2.cli:main"
|
||||
|
||||
[project.urls]
|
||||
"Source" = "https://git.clerie.de/clerie/mitel_ommclient2"
|
||||
|
||||
Reference in New Issue
Block a user