gnetclisdk 1.0.1__tar.gz → 1.0.2__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gnetclisdk
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Client for Gnetcli GRPC-server
5
5
  Home-page: https://github.com/annetutil/gnetcli
6
6
  Author: Alexander Balezin
@@ -13,13 +13,16 @@ Classifier: Programming Language :: Python :: 3.8
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Description-Content-Type: text/markdown
16
+ Requires-Dist: protobuf==4.24.4
17
+ Requires-Dist: grpcio==1.59.2
18
+ Requires-Dist: googleapis-common-protos==1.61.0
16
19
 
17
- ## python client for Gnetcli server
20
+ ## Python client for Gnetcli GRPC server
18
21
 
19
- Install Gnetcli GRPC-server.
20
- - Download latest release from https://github.com/annetutil/gnetcli/releases/
21
- - `tar -xzvf gnetcli_server-v1.0.0-darwin-amd64.tar.gz` (If see 'cannot be opened because the developer cannot be verified', then call `sudo xattr -d com.apple.quarantine gnetcli_server`)
22
- - `./gnetcli_server -debug`
22
+ Gnetcli provides a universal way to execute arbitrary commands using a CLI,
23
+ eliminating the need for screen scraping with expect.
24
+
25
+ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
23
26
 
24
27
  Example:
25
28
 
@@ -36,6 +39,7 @@ async def example():
36
39
  asyncio.run(example())
37
40
  ```
38
41
 
42
+ Output:
39
43
  ```
40
44
  err=b'' status=0 out=b'2023-11-10 09:31:58\nFriday\nTime Zone(UTC) : UTC'
41
45
  ```
@@ -1,9 +1,9 @@
1
- ## python client for Gnetcli server
1
+ ## Python client for Gnetcli GRPC server
2
2
 
3
- Install Gnetcli GRPC-server.
4
- - Download latest release from https://github.com/annetutil/gnetcli/releases/
5
- - `tar -xzvf gnetcli_server-v1.0.0-darwin-amd64.tar.gz` (If see 'cannot be opened because the developer cannot be verified', then call `sudo xattr -d com.apple.quarantine gnetcli_server`)
6
- - `./gnetcli_server -debug`
3
+ Gnetcli provides a universal way to execute arbitrary commands using a CLI,
4
+ eliminating the need for screen scraping with expect.
5
+
6
+ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
7
7
 
8
8
  Example:
9
9
 
@@ -20,6 +20,7 @@ async def example():
20
20
  asyncio.run(example())
21
21
  ```
22
22
 
23
+ Output:
23
24
  ```
24
25
  err=b'' status=0 out=b'2023-11-10 09:31:58\nFriday\nTime Zone(UTC) : UTC'
25
26
  ```
@@ -4,9 +4,9 @@ import os.path
4
4
  import uuid
5
5
  from abc import ABC, abstractmethod
6
6
  from contextlib import asynccontextmanager
7
- from dataclasses import dataclass
7
+ from dataclasses import dataclass, field
8
8
  from functools import partial
9
- from typing import Any, AsyncIterator, List, Optional, Tuple
9
+ from typing import Any, AsyncIterator, List, Optional, Tuple, Dict
10
10
 
11
11
  import grpc
12
12
  from google.protobuf.message import Message
@@ -49,6 +49,19 @@ class Credentials:
49
49
  return pb
50
50
 
51
51
 
52
+ @dataclass
53
+ class File:
54
+ content: bytes
55
+ status: server_pb2.FileStatus
56
+
57
+
58
+ @dataclass
59
+ class HostParams:
60
+ device: str
61
+ port: Optional[int] = None
62
+ credentials: Optional[Credentials] = None
63
+
64
+
52
65
  def make_auth(auth_token: str) -> ClientAuthentication:
53
66
  if auth_token.lower().startswith("oauth"):
54
67
  authentication = OAuthClientAuthentication(auth_token.split(" ")[1])
@@ -102,22 +115,18 @@ class Gnetcli:
102
115
  self,
103
116
  hostname: str,
104
117
  cmd: str,
105
- device: str,
106
118
  trace: bool = False,
107
119
  qa: Optional[List[QA]] = None,
108
120
  read_timeout: float = 0.0,
109
121
  cmd_timeout: float = 0.0,
110
- credentials: Optional[Credentials] = None,
111
122
  ) -> Message:
112
123
  pbcmd = make_cmd(
113
124
  hostname=hostname,
114
- device=device,
115
125
  cmd=cmd,
116
126
  trace=trace,
117
127
  qa=qa,
118
128
  read_timeout=read_timeout,
119
129
  cmd_timeout=cmd_timeout,
120
- credentials=credentials,
121
130
  )
122
131
  if self._channel is None:
123
132
  _logger.debug("connect to %s", self._server)
@@ -198,32 +207,40 @@ class Gnetcli:
198
207
  finally:
199
208
  await sess.close()
200
209
 
201
- async def upload(self, hostname: str, file_path: str, data: bytes) -> Message:
202
- pbcmd = server_pb2.FileUploadRequest(host=hostname, path=file_path, data=data)
210
+ async def set_host_params(self, hostname: str, params: HostParams) -> None:
211
+ pbcmd = server_pb2.HostParams(
212
+ host=hostname,
213
+ port=params.port,
214
+ credentials=params.credentials.make_pb(),
215
+ device=params.device)
203
216
  _logger.debug("connect to %s", self._server)
204
217
  async with self._grpc_channel_fn(self._server, options=self._options) as channel:
205
- _logger.debug("upload %s to %s", file_path, hostname)
218
+ _logger.debug("set params for %s", hostname)
206
219
  stub = server_pb2_grpc.GnetcliStub(channel)
207
- response: Message = await grpc_call_wrapper(stub.Upload, pbcmd)
208
- return response
220
+ await grpc_call_wrapper(stub.SetupHostParams, pbcmd)
221
+ return
209
222
 
210
- async def download(self, hostname: str, file_path: str) -> Message:
211
- pbcmd = server_pb2.FileDownloadRequest(host=hostname, path=file_path)
223
+ async def upload(self, hostname: str, files: Dict[str, File]) -> None:
224
+ pbcmd = server_pb2.FileUploadRequest(host=hostname, files=make_files_request(files))
212
225
  _logger.debug("connect to %s", self._server)
213
226
  async with self._grpc_channel_fn(self._server, options=self._options) as channel:
214
- _logger.debug("download %s for %s", file_path, hostname)
227
+ _logger.debug("upload %s to %s", files.keys(), hostname)
215
228
  stub = server_pb2_grpc.GnetcliStub(channel)
216
- response: Message = await grpc_call_wrapper(stub.Download, pbcmd)
217
- return response
229
+ response: Message = await grpc_call_wrapper(stub.Upload, pbcmd)
230
+ _logger.debug("upload res %s", response)
231
+ return
218
232
 
219
- async def downloads(self, hostname: str, file_path: str) -> Message:
220
- pbcmd = server_pb2.FileDownloadRequest(host=hostname, path=file_path)
233
+ async def download(self, hostname: str, paths: List[str]) -> Dict[str, File]:
234
+ pbcmd = server_pb2.FileDownloadRequest(host=hostname, paths=paths)
221
235
  _logger.debug("connect to %s", self._server)
222
236
  async with self._grpc_channel_fn(self._server, options=self._options) as channel:
223
- _logger.debug("downloads %s for %s", file_path, hostname)
237
+ _logger.debug("download %s from %s", paths, hostname)
224
238
  stub = server_pb2_grpc.GnetcliStub(channel)
225
- response: Message = await grpc_call_wrapper(stub.Downloads, pbcmd)
226
- return response
239
+ response: server_pb2.FilesResult = await grpc_call_wrapper(stub.Download, pbcmd)
240
+ res: Dict[str, File] = {}
241
+ for file in response.files:
242
+ res[file.path] = File(content=file.data, status=file.status)
243
+ return res
227
244
 
228
245
 
229
246
  class GnetcliSession(ABC):
@@ -321,23 +338,19 @@ class GnetcliSessionCmd(GnetcliSession):
321
338
  async def cmd(
322
339
  self,
323
340
  cmd: str,
324
- device: str,
325
341
  trace: bool = False,
326
342
  qa: Optional[List[QA]] = None,
327
343
  cmd_timeout: float = 0.0,
328
344
  read_timeout: float = 0.0,
329
- credentials: Optional[Credentials] = None,
330
345
  ) -> Message:
331
346
  _logger.debug("session cmd %r", cmd)
332
347
  pbcmd = make_cmd(
333
348
  hostname=self._hostname,
334
- device=device,
335
349
  cmd=cmd,
336
350
  trace=trace,
337
351
  qa=qa,
338
352
  read_timeout=read_timeout,
339
353
  cmd_timeout=cmd_timeout,
340
- credentials=credentials,
341
354
  )
342
355
  return await self._cmd(pbcmd)
343
356
 
@@ -352,7 +365,7 @@ class GnetcliSessionCmd(GnetcliSession):
352
365
  class GnetcliSessionNetconf(GnetcliSession):
353
366
  async def cmd(self, cmd: str, trace: bool = False, json: bool = False) -> Message:
354
367
  _logger.debug("netconf session cmd %r", cmd)
355
- cmdpb = server_pb2.CMDNetconf(host=self._hostname, credentials=self._credentials, cmd=cmd, json=json)
368
+ cmdpb = server_pb2.CMDNetconf(host=self._hostname, cmd=cmd, json=json)
356
369
  return await self._cmd(cmdpb)
357
370
 
358
371
  async def connect(self) -> None:
@@ -420,12 +433,10 @@ def format_long_msg(msg: str, max_len: int) -> str:
420
433
  def make_cmd(
421
434
  hostname: str,
422
435
  cmd: str,
423
- device: str,
424
436
  trace: bool = False,
425
437
  qa: Optional[List[QA]] = None,
426
438
  read_timeout: float = 0.0,
427
439
  cmd_timeout: float = 0.0,
428
- credentials: Optional[Credentials] = None,
429
440
  ) -> Message:
430
441
  qa_cmd: List[Message] = []
431
442
  if qa:
@@ -434,9 +445,6 @@ def make_cmd(
434
445
  qaitem.question = item.question
435
446
  qaitem.answer = item.answer
436
447
  qa_cmd.append(qaitem)
437
- credentialspb = None
438
- if credentials:
439
- credentialspb = credentials.make_pb()
440
448
  res = server_pb2.CMD(
441
449
  host=hostname,
442
450
  cmd=cmd,
@@ -444,7 +452,12 @@ def make_cmd(
444
452
  qa=qa_cmd,
445
453
  read_timeout=read_timeout,
446
454
  cmd_timeout=cmd_timeout,
447
- device=device,
448
- credentials=credentialspb,
449
455
  )
450
456
  return res # type: ignore
457
+
458
+
459
+ def make_files_request(files: Dict[str, File]) -> List[server_pb2.FileData]:
460
+ res: List[server_pb2.FileData] = []
461
+ for path, file in files.items():
462
+ res.append(server_pb2.FileData(path=path, data=file.content))
463
+ return res
@@ -0,0 +1,83 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: server.proto
5
+ # Protobuf Python Version: 5.27.2
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 27,
16
+ 2,
17
+ '',
18
+ 'server.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
26
+ from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
27
+
28
+
29
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cserver.proto\x12\x07gnetcli\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"&\n\x02QA\x12\x10\n\x08question\x18\x01 \x01(\t\x12\x0e\n\x06\x61nswer\x18\x02 \x01(\t\".\n\x0b\x43redentials\x12\r\n\x05login\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\xb4\x01\n\x03\x43MD\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0b\n\x03\x63md\x18\x02 \x01(\t\x12\r\n\x05trace\x18\x03 \x01(\x08\x12\x17\n\x02qa\x18\x04 \x03(\x0b\x32\x0b.gnetcli.QA\x12\x14\n\x0cread_timeout\x18\x05 \x01(\x01\x12\x13\n\x0b\x63md_timeout\x18\x06 \x01(\x01\x12\x15\n\rstring_result\x18\x08 \x01(\x08\x12(\n\x0bhost_params\x18\t \x01(\x0b\x32\x13.gnetcli.HostParams\"e\n\x06\x44\x65vice\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x11prompt_expression\x18\x02 \x01(\t\x12\x18\n\x10\x65rror_expression\x18\x03 \x01(\t\x12\x18\n\x10pager_expression\x18\x04 \x01(\t\"`\n\nCMDNetconf\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0b\n\x03\x63md\x18\x02 \x01(\t\x12\x0c\n\x04json\x18\x03 \x01(\x08\x12\x14\n\x0cread_timeout\x18\x04 \x01(\x01\x12\x13\n\x0b\x63md_timeout\x18\x05 \x01(\x01\"H\n\x0c\x43MDTraceItem\x12*\n\toperation\x18\x01 \x01(\x0e\x32\x17.gnetcli.TraceOperation\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\"o\n\nHostParams\x12\x0c\n\x04host\x18\x01 \x01(\t\x12)\n\x0b\x63redentials\x18\x02 \x01(\x0b\x32\x14.gnetcli.Credentials\x12\x0c\n\x04port\x18\x03 \x01(\x05\x12\x0e\n\x06\x64\x65vice\x18\x04 \x01(\t\x12\n\n\x02ip\x18\x05 \x01(\t\"\x81\x01\n\tCMDResult\x12\x0b\n\x03out\x18\x01 \x01(\x0c\x12\x0f\n\x07out_str\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\x0c\x12\x11\n\terror_str\x18\x04 \x01(\t\x12$\n\x05trace\x18\x05 \x03(\x0b\x32\x15.gnetcli.CMDTraceItem\x12\x0e\n\x06status\x18\x06 \x01(\x05\"G\n\x0c\x44\x65viceResult\x12(\n\x03res\x18\x01 \x01(\x0e\x32\x1b.gnetcli.DeviceResultStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"l\n\x13\x46ileDownloadRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\r\n\x05paths\x18\x02 \x03(\t\x12\x0e\n\x06\x64\x65vice\x18\x03 \x01(\t\x12(\n\x0bhost_params\x18\x05 \x01(\x0b\x32\x13.gnetcli.HostParams\"K\n\x08\x46ileData\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\x12#\n\x06status\x18\x03 \x01(\x0e\x32\x13.gnetcli.FileStatus\"}\n\x11\x46ileUploadRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x04 \x01(\t\x12 \n\x05\x66iles\x18\x03 \x03(\x0b\x32\x11.gnetcli.FileData\x12(\n\x0bhost_params\x18\x06 \x01(\x0b\x32\x13.gnetcli.HostParams\"/\n\x0b\x46ilesResult\x12 \n\x05\x66iles\x18\x01 \x03(\x0b\x32\x11.gnetcli.FileData*f\n\x0eTraceOperation\x12\x14\n\x10Operation_notset\x10\x00\x12\x15\n\x11Operation_unknown\x10\x01\x12\x13\n\x0fOperation_write\x10\x02\x12\x12\n\x0eOperation_read\x10\x03*H\n\x12\x44\x65viceResultStatus\x12\x11\n\rDevice_notset\x10\x00\x12\r\n\tDevice_ok\x10\x01\x12\x10\n\x0c\x44\x65vice_error\x10\x02*}\n\nFileStatus\x12\x15\n\x11\x46ileStatus_notset\x10\x00\x12\x11\n\rFileStatus_ok\x10\x01\x12\x14\n\x10\x46ileStatus_error\x10\x02\x12\x18\n\x14\x46ileStatus_not_found\x10\x03\x12\x15\n\x11\x46ileStatus_is_dir\x10\x04\x32\x8c\x05\n\x07Gnetcli\x12\x64\n\x0fSetupHostParams\x12\x13.gnetcli.HostParams\x1a\x16.google.protobuf.Empty\"$\x82\xd3\xe4\x93\x02\x1e\"\x19/api/v1/setup_host_params:\x01*\x12\x41\n\x04\x45xec\x12\x0c.gnetcli.CMD\x1a\x12.gnetcli.CMDResult\"\x17\x82\xd3\xe4\x93\x02\x11\"\x0c/api/v1/exec:\x01*\x12\x32\n\x08\x45xecChat\x12\x0c.gnetcli.CMD\x1a\x12.gnetcli.CMDResult\"\x00(\x01\x30\x01\x12R\n\tAddDevice\x12\x0f.gnetcli.Device\x1a\x15.gnetcli.DeviceResult\"\x1d\x82\xd3\xe4\x93\x02\x17\"\x12/api/v1/add_device:\x01*\x12W\n\x0b\x45xecNetconf\x12\x13.gnetcli.CMDNetconf\x1a\x12.gnetcli.CMDResult\"\x1f\x82\xd3\xe4\x93\x02\x19\"\x14/api/v1/exec_netconf:\x01*\x12@\n\x0f\x45xecNetconfChat\x12\x13.gnetcli.CMDNetconf\x1a\x12.gnetcli.CMDResult\"\x00(\x01\x30\x01\x12\\\n\x08\x44ownload\x12\x1c.gnetcli.FileDownloadRequest\x1a\x14.gnetcli.FilesResult\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x11/api/v1/downloads:\x01*\x12W\n\x06Upload\x12\x1a.gnetcli.FileUploadRequest\x1a\x16.google.protobuf.Empty\"\x19\x82\xd3\xe4\x93\x02\x13\"\x0e/api/v1/upload:\x01*B7Z5github.com/annetutil/gnetcli/pkg/server/proto;gnetclib\x06proto3')
30
+
31
+ _globals = globals()
32
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
33
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'server_pb2', _globals)
34
+ if not _descriptor._USE_C_DESCRIPTORS:
35
+ _globals['DESCRIPTOR']._loaded_options = None
36
+ _globals['DESCRIPTOR']._serialized_options = b'Z5github.com/annetutil/gnetcli/pkg/server/proto;gnetcli'
37
+ _globals['_GNETCLI'].methods_by_name['SetupHostParams']._loaded_options = None
38
+ _globals['_GNETCLI'].methods_by_name['SetupHostParams']._serialized_options = b'\202\323\344\223\002\036\"\031/api/v1/setup_host_params:\001*'
39
+ _globals['_GNETCLI'].methods_by_name['Exec']._loaded_options = None
40
+ _globals['_GNETCLI'].methods_by_name['Exec']._serialized_options = b'\202\323\344\223\002\021\"\014/api/v1/exec:\001*'
41
+ _globals['_GNETCLI'].methods_by_name['AddDevice']._loaded_options = None
42
+ _globals['_GNETCLI'].methods_by_name['AddDevice']._serialized_options = b'\202\323\344\223\002\027\"\022/api/v1/add_device:\001*'
43
+ _globals['_GNETCLI'].methods_by_name['ExecNetconf']._loaded_options = None
44
+ _globals['_GNETCLI'].methods_by_name['ExecNetconf']._serialized_options = b'\202\323\344\223\002\031\"\024/api/v1/exec_netconf:\001*'
45
+ _globals['_GNETCLI'].methods_by_name['Download']._loaded_options = None
46
+ _globals['_GNETCLI'].methods_by_name['Download']._serialized_options = b'\202\323\344\223\002\026\"\021/api/v1/downloads:\001*'
47
+ _globals['_GNETCLI'].methods_by_name['Upload']._loaded_options = None
48
+ _globals['_GNETCLI'].methods_by_name['Upload']._serialized_options = b'\202\323\344\223\002\023\"\016/api/v1/upload:\001*'
49
+ _globals['_TRACEOPERATION']._serialized_start=1311
50
+ _globals['_TRACEOPERATION']._serialized_end=1413
51
+ _globals['_DEVICERESULTSTATUS']._serialized_start=1415
52
+ _globals['_DEVICERESULTSTATUS']._serialized_end=1487
53
+ _globals['_FILESTATUS']._serialized_start=1489
54
+ _globals['_FILESTATUS']._serialized_end=1614
55
+ _globals['_QA']._serialized_start=84
56
+ _globals['_QA']._serialized_end=122
57
+ _globals['_CREDENTIALS']._serialized_start=124
58
+ _globals['_CREDENTIALS']._serialized_end=170
59
+ _globals['_CMD']._serialized_start=173
60
+ _globals['_CMD']._serialized_end=353
61
+ _globals['_DEVICE']._serialized_start=355
62
+ _globals['_DEVICE']._serialized_end=456
63
+ _globals['_CMDNETCONF']._serialized_start=458
64
+ _globals['_CMDNETCONF']._serialized_end=554
65
+ _globals['_CMDTRACEITEM']._serialized_start=556
66
+ _globals['_CMDTRACEITEM']._serialized_end=628
67
+ _globals['_HOSTPARAMS']._serialized_start=630
68
+ _globals['_HOSTPARAMS']._serialized_end=741
69
+ _globals['_CMDRESULT']._serialized_start=744
70
+ _globals['_CMDRESULT']._serialized_end=873
71
+ _globals['_DEVICERESULT']._serialized_start=875
72
+ _globals['_DEVICERESULT']._serialized_end=946
73
+ _globals['_FILEDOWNLOADREQUEST']._serialized_start=948
74
+ _globals['_FILEDOWNLOADREQUEST']._serialized_end=1056
75
+ _globals['_FILEDATA']._serialized_start=1058
76
+ _globals['_FILEDATA']._serialized_end=1133
77
+ _globals['_FILEUPLOADREQUEST']._serialized_start=1135
78
+ _globals['_FILEUPLOADREQUEST']._serialized_end=1260
79
+ _globals['_FILESRESULT']._serialized_start=1262
80
+ _globals['_FILESRESULT']._serialized_end=1309
81
+ _globals['_GNETCLI']._serialized_start=1617
82
+ _globals['_GNETCLI']._serialized_end=2269
83
+ # @@protoc_insertion_point(module_scope)
@@ -0,0 +1,190 @@
1
+ from google.api import annotations_pb2 as _annotations_pb2
2
+ from google.protobuf import empty_pb2 as _empty_pb2
3
+ from google.protobuf.internal import containers as _containers
4
+ from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper
5
+ from google.protobuf import descriptor as _descriptor
6
+ from google.protobuf import message as _message
7
+ from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union
8
+
9
+ DESCRIPTOR: _descriptor.FileDescriptor
10
+
11
+ class TraceOperation(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
12
+ __slots__ = ()
13
+ Operation_notset: _ClassVar[TraceOperation]
14
+ Operation_unknown: _ClassVar[TraceOperation]
15
+ Operation_write: _ClassVar[TraceOperation]
16
+ Operation_read: _ClassVar[TraceOperation]
17
+
18
+ class DeviceResultStatus(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
19
+ __slots__ = ()
20
+ Device_notset: _ClassVar[DeviceResultStatus]
21
+ Device_ok: _ClassVar[DeviceResultStatus]
22
+ Device_error: _ClassVar[DeviceResultStatus]
23
+
24
+ class FileStatus(int, metaclass=_enum_type_wrapper.EnumTypeWrapper):
25
+ __slots__ = ()
26
+ FileStatus_notset: _ClassVar[FileStatus]
27
+ FileStatus_ok: _ClassVar[FileStatus]
28
+ FileStatus_error: _ClassVar[FileStatus]
29
+ FileStatus_not_found: _ClassVar[FileStatus]
30
+ FileStatus_is_dir: _ClassVar[FileStatus]
31
+ Operation_notset: TraceOperation
32
+ Operation_unknown: TraceOperation
33
+ Operation_write: TraceOperation
34
+ Operation_read: TraceOperation
35
+ Device_notset: DeviceResultStatus
36
+ Device_ok: DeviceResultStatus
37
+ Device_error: DeviceResultStatus
38
+ FileStatus_notset: FileStatus
39
+ FileStatus_ok: FileStatus
40
+ FileStatus_error: FileStatus
41
+ FileStatus_not_found: FileStatus
42
+ FileStatus_is_dir: FileStatus
43
+
44
+ class QA(_message.Message):
45
+ __slots__ = ("question", "answer")
46
+ QUESTION_FIELD_NUMBER: _ClassVar[int]
47
+ ANSWER_FIELD_NUMBER: _ClassVar[int]
48
+ question: str
49
+ answer: str
50
+ def __init__(self, question: _Optional[str] = ..., answer: _Optional[str] = ...) -> None: ...
51
+
52
+ class Credentials(_message.Message):
53
+ __slots__ = ("login", "password")
54
+ LOGIN_FIELD_NUMBER: _ClassVar[int]
55
+ PASSWORD_FIELD_NUMBER: _ClassVar[int]
56
+ login: str
57
+ password: str
58
+ def __init__(self, login: _Optional[str] = ..., password: _Optional[str] = ...) -> None: ...
59
+
60
+ class CMD(_message.Message):
61
+ __slots__ = ("host", "cmd", "trace", "qa", "read_timeout", "cmd_timeout", "string_result", "host_params")
62
+ HOST_FIELD_NUMBER: _ClassVar[int]
63
+ CMD_FIELD_NUMBER: _ClassVar[int]
64
+ TRACE_FIELD_NUMBER: _ClassVar[int]
65
+ QA_FIELD_NUMBER: _ClassVar[int]
66
+ READ_TIMEOUT_FIELD_NUMBER: _ClassVar[int]
67
+ CMD_TIMEOUT_FIELD_NUMBER: _ClassVar[int]
68
+ STRING_RESULT_FIELD_NUMBER: _ClassVar[int]
69
+ HOST_PARAMS_FIELD_NUMBER: _ClassVar[int]
70
+ host: str
71
+ cmd: str
72
+ trace: bool
73
+ qa: _containers.RepeatedCompositeFieldContainer[QA]
74
+ read_timeout: float
75
+ cmd_timeout: float
76
+ string_result: bool
77
+ host_params: HostParams
78
+ def __init__(self, host: _Optional[str] = ..., cmd: _Optional[str] = ..., trace: bool = ..., qa: _Optional[_Iterable[_Union[QA, _Mapping]]] = ..., read_timeout: _Optional[float] = ..., cmd_timeout: _Optional[float] = ..., string_result: bool = ..., host_params: _Optional[_Union[HostParams, _Mapping]] = ...) -> None: ...
79
+
80
+ class Device(_message.Message):
81
+ __slots__ = ("name", "prompt_expression", "error_expression", "pager_expression")
82
+ NAME_FIELD_NUMBER: _ClassVar[int]
83
+ PROMPT_EXPRESSION_FIELD_NUMBER: _ClassVar[int]
84
+ ERROR_EXPRESSION_FIELD_NUMBER: _ClassVar[int]
85
+ PAGER_EXPRESSION_FIELD_NUMBER: _ClassVar[int]
86
+ name: str
87
+ prompt_expression: str
88
+ error_expression: str
89
+ pager_expression: str
90
+ def __init__(self, name: _Optional[str] = ..., prompt_expression: _Optional[str] = ..., error_expression: _Optional[str] = ..., pager_expression: _Optional[str] = ...) -> None: ...
91
+
92
+ class CMDNetconf(_message.Message):
93
+ __slots__ = ("host", "cmd", "json", "read_timeout", "cmd_timeout")
94
+ HOST_FIELD_NUMBER: _ClassVar[int]
95
+ CMD_FIELD_NUMBER: _ClassVar[int]
96
+ JSON_FIELD_NUMBER: _ClassVar[int]
97
+ READ_TIMEOUT_FIELD_NUMBER: _ClassVar[int]
98
+ CMD_TIMEOUT_FIELD_NUMBER: _ClassVar[int]
99
+ host: str
100
+ cmd: str
101
+ json: bool
102
+ read_timeout: float
103
+ cmd_timeout: float
104
+ def __init__(self, host: _Optional[str] = ..., cmd: _Optional[str] = ..., json: bool = ..., read_timeout: _Optional[float] = ..., cmd_timeout: _Optional[float] = ...) -> None: ...
105
+
106
+ class CMDTraceItem(_message.Message):
107
+ __slots__ = ("operation", "data")
108
+ OPERATION_FIELD_NUMBER: _ClassVar[int]
109
+ DATA_FIELD_NUMBER: _ClassVar[int]
110
+ operation: TraceOperation
111
+ data: bytes
112
+ def __init__(self, operation: _Optional[_Union[TraceOperation, str]] = ..., data: _Optional[bytes] = ...) -> None: ...
113
+
114
+ class HostParams(_message.Message):
115
+ __slots__ = ("host", "credentials", "port", "device", "ip")
116
+ HOST_FIELD_NUMBER: _ClassVar[int]
117
+ CREDENTIALS_FIELD_NUMBER: _ClassVar[int]
118
+ PORT_FIELD_NUMBER: _ClassVar[int]
119
+ DEVICE_FIELD_NUMBER: _ClassVar[int]
120
+ IP_FIELD_NUMBER: _ClassVar[int]
121
+ host: str
122
+ credentials: Credentials
123
+ port: int
124
+ device: str
125
+ ip: str
126
+ def __init__(self, host: _Optional[str] = ..., credentials: _Optional[_Union[Credentials, _Mapping]] = ..., port: _Optional[int] = ..., device: _Optional[str] = ..., ip: _Optional[str] = ...) -> None: ...
127
+
128
+ class CMDResult(_message.Message):
129
+ __slots__ = ("out", "out_str", "error", "error_str", "trace", "status")
130
+ OUT_FIELD_NUMBER: _ClassVar[int]
131
+ OUT_STR_FIELD_NUMBER: _ClassVar[int]
132
+ ERROR_FIELD_NUMBER: _ClassVar[int]
133
+ ERROR_STR_FIELD_NUMBER: _ClassVar[int]
134
+ TRACE_FIELD_NUMBER: _ClassVar[int]
135
+ STATUS_FIELD_NUMBER: _ClassVar[int]
136
+ out: bytes
137
+ out_str: str
138
+ error: bytes
139
+ error_str: str
140
+ trace: _containers.RepeatedCompositeFieldContainer[CMDTraceItem]
141
+ status: int
142
+ def __init__(self, out: _Optional[bytes] = ..., out_str: _Optional[str] = ..., error: _Optional[bytes] = ..., error_str: _Optional[str] = ..., trace: _Optional[_Iterable[_Union[CMDTraceItem, _Mapping]]] = ..., status: _Optional[int] = ...) -> None: ...
143
+
144
+ class DeviceResult(_message.Message):
145
+ __slots__ = ("res", "error")
146
+ RES_FIELD_NUMBER: _ClassVar[int]
147
+ ERROR_FIELD_NUMBER: _ClassVar[int]
148
+ res: DeviceResultStatus
149
+ error: str
150
+ def __init__(self, res: _Optional[_Union[DeviceResultStatus, str]] = ..., error: _Optional[str] = ...) -> None: ...
151
+
152
+ class FileDownloadRequest(_message.Message):
153
+ __slots__ = ("host", "paths", "device", "host_params")
154
+ HOST_FIELD_NUMBER: _ClassVar[int]
155
+ PATHS_FIELD_NUMBER: _ClassVar[int]
156
+ DEVICE_FIELD_NUMBER: _ClassVar[int]
157
+ HOST_PARAMS_FIELD_NUMBER: _ClassVar[int]
158
+ host: str
159
+ paths: _containers.RepeatedScalarFieldContainer[str]
160
+ device: str
161
+ host_params: HostParams
162
+ def __init__(self, host: _Optional[str] = ..., paths: _Optional[_Iterable[str]] = ..., device: _Optional[str] = ..., host_params: _Optional[_Union[HostParams, _Mapping]] = ...) -> None: ...
163
+
164
+ class FileData(_message.Message):
165
+ __slots__ = ("path", "data", "status")
166
+ PATH_FIELD_NUMBER: _ClassVar[int]
167
+ DATA_FIELD_NUMBER: _ClassVar[int]
168
+ STATUS_FIELD_NUMBER: _ClassVar[int]
169
+ path: str
170
+ data: bytes
171
+ status: FileStatus
172
+ def __init__(self, path: _Optional[str] = ..., data: _Optional[bytes] = ..., status: _Optional[_Union[FileStatus, str]] = ...) -> None: ...
173
+
174
+ class FileUploadRequest(_message.Message):
175
+ __slots__ = ("host", "device", "files", "host_params")
176
+ HOST_FIELD_NUMBER: _ClassVar[int]
177
+ DEVICE_FIELD_NUMBER: _ClassVar[int]
178
+ FILES_FIELD_NUMBER: _ClassVar[int]
179
+ HOST_PARAMS_FIELD_NUMBER: _ClassVar[int]
180
+ host: str
181
+ device: str
182
+ files: _containers.RepeatedCompositeFieldContainer[FileData]
183
+ host_params: HostParams
184
+ def __init__(self, host: _Optional[str] = ..., device: _Optional[str] = ..., files: _Optional[_Iterable[_Union[FileData, _Mapping]]] = ..., host_params: _Optional[_Union[HostParams, _Mapping]] = ...) -> None: ...
185
+
186
+ class FilesResult(_message.Message):
187
+ __slots__ = ("files",)
188
+ FILES_FIELD_NUMBER: _ClassVar[int]
189
+ files: _containers.RepeatedCompositeFieldContainer[FileData]
190
+ def __init__(self, files: _Optional[_Iterable[_Union[FileData, _Mapping]]] = ...) -> None: ...
@@ -1,10 +1,30 @@
1
1
  # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
2
2
  """Client and server classes corresponding to protobuf-defined services."""
3
3
  import grpc
4
+ import warnings
4
5
 
5
6
  from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
6
7
  from . import server_pb2 as server__pb2
7
8
 
9
+ GRPC_GENERATED_VERSION = '1.66.1'
10
+ GRPC_VERSION = grpc.__version__
11
+ _version_not_supported = False
12
+
13
+ try:
14
+ from grpc._utilities import first_version_is_lower
15
+ _version_not_supported = first_version_is_lower(GRPC_VERSION, GRPC_GENERATED_VERSION)
16
+ except ImportError:
17
+ _version_not_supported = True
18
+
19
+ if _version_not_supported:
20
+ raise RuntimeError(
21
+ f'The grpc package installed is at version {GRPC_VERSION},'
22
+ + f' but the generated code in server_pb2_grpc.py depends on'
23
+ + f' grpcio>={GRPC_GENERATED_VERSION}.'
24
+ + f' Please upgrade your grpc module to grpcio>={GRPC_GENERATED_VERSION}'
25
+ + f' or downgrade your generated code using grpcio-tools<={GRPC_VERSION}.'
26
+ )
27
+
8
28
 
9
29
  class GnetcliStub(object):
10
30
  """Missing associated documentation comment in .proto file."""
@@ -15,46 +35,57 @@ class GnetcliStub(object):
15
35
  Args:
16
36
  channel: A grpc.Channel.
17
37
  """
38
+ self.SetupHostParams = channel.unary_unary(
39
+ '/gnetcli.Gnetcli/SetupHostParams',
40
+ request_serializer=server__pb2.HostParams.SerializeToString,
41
+ response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
42
+ _registered_method=True)
18
43
  self.Exec = channel.unary_unary(
19
44
  '/gnetcli.Gnetcli/Exec',
20
45
  request_serializer=server__pb2.CMD.SerializeToString,
21
46
  response_deserializer=server__pb2.CMDResult.FromString,
22
- )
47
+ _registered_method=True)
23
48
  self.ExecChat = channel.stream_stream(
24
49
  '/gnetcli.Gnetcli/ExecChat',
25
50
  request_serializer=server__pb2.CMD.SerializeToString,
26
51
  response_deserializer=server__pb2.CMDResult.FromString,
27
- )
52
+ _registered_method=True)
28
53
  self.AddDevice = channel.unary_unary(
29
54
  '/gnetcli.Gnetcli/AddDevice',
30
55
  request_serializer=server__pb2.Device.SerializeToString,
31
56
  response_deserializer=server__pb2.DeviceResult.FromString,
32
- )
57
+ _registered_method=True)
33
58
  self.ExecNetconf = channel.unary_unary(
34
59
  '/gnetcli.Gnetcli/ExecNetconf',
35
60
  request_serializer=server__pb2.CMDNetconf.SerializeToString,
36
61
  response_deserializer=server__pb2.CMDResult.FromString,
37
- )
62
+ _registered_method=True)
38
63
  self.ExecNetconfChat = channel.stream_stream(
39
64
  '/gnetcli.Gnetcli/ExecNetconfChat',
40
65
  request_serializer=server__pb2.CMDNetconf.SerializeToString,
41
66
  response_deserializer=server__pb2.CMDResult.FromString,
42
- )
43
- self.Downloads = channel.unary_unary(
44
- '/gnetcli.Gnetcli/Downloads',
67
+ _registered_method=True)
68
+ self.Download = channel.unary_unary(
69
+ '/gnetcli.Gnetcli/Download',
45
70
  request_serializer=server__pb2.FileDownloadRequest.SerializeToString,
46
71
  response_deserializer=server__pb2.FilesResult.FromString,
47
- )
72
+ _registered_method=True)
48
73
  self.Upload = channel.unary_unary(
49
74
  '/gnetcli.Gnetcli/Upload',
50
75
  request_serializer=server__pb2.FileUploadRequest.SerializeToString,
51
76
  response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString,
52
- )
77
+ _registered_method=True)
53
78
 
54
79
 
55
80
  class GnetcliServicer(object):
56
81
  """Missing associated documentation comment in .proto file."""
57
82
 
83
+ def SetupHostParams(self, request, context):
84
+ """Missing associated documentation comment in .proto file."""
85
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
86
+ context.set_details('Method not implemented!')
87
+ raise NotImplementedError('Method not implemented!')
88
+
58
89
  def Exec(self, request, context):
59
90
  """Missing associated documentation comment in .proto file."""
60
91
  context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -85,7 +116,7 @@ class GnetcliServicer(object):
85
116
  context.set_details('Method not implemented!')
86
117
  raise NotImplementedError('Method not implemented!')
87
118
 
88
- def Downloads(self, request, context):
119
+ def Download(self, request, context):
89
120
  """Missing associated documentation comment in .proto file."""
90
121
  context.set_code(grpc.StatusCode.UNIMPLEMENTED)
91
122
  context.set_details('Method not implemented!')
@@ -100,6 +131,11 @@ class GnetcliServicer(object):
100
131
 
101
132
  def add_GnetcliServicer_to_server(servicer, server):
102
133
  rpc_method_handlers = {
134
+ 'SetupHostParams': grpc.unary_unary_rpc_method_handler(
135
+ servicer.SetupHostParams,
136
+ request_deserializer=server__pb2.HostParams.FromString,
137
+ response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
138
+ ),
103
139
  'Exec': grpc.unary_unary_rpc_method_handler(
104
140
  servicer.Exec,
105
141
  request_deserializer=server__pb2.CMD.FromString,
@@ -125,8 +161,8 @@ def add_GnetcliServicer_to_server(servicer, server):
125
161
  request_deserializer=server__pb2.CMDNetconf.FromString,
126
162
  response_serializer=server__pb2.CMDResult.SerializeToString,
127
163
  ),
128
- 'Downloads': grpc.unary_unary_rpc_method_handler(
129
- servicer.Downloads,
164
+ 'Download': grpc.unary_unary_rpc_method_handler(
165
+ servicer.Download,
130
166
  request_deserializer=server__pb2.FileDownloadRequest.FromString,
131
167
  response_serializer=server__pb2.FilesResult.SerializeToString,
132
168
  ),
@@ -139,12 +175,40 @@ def add_GnetcliServicer_to_server(servicer, server):
139
175
  generic_handler = grpc.method_handlers_generic_handler(
140
176
  'gnetcli.Gnetcli', rpc_method_handlers)
141
177
  server.add_generic_rpc_handlers((generic_handler,))
178
+ server.add_registered_method_handlers('gnetcli.Gnetcli', rpc_method_handlers)
142
179
 
143
180
 
144
181
  # This class is part of an EXPERIMENTAL API.
145
182
  class Gnetcli(object):
146
183
  """Missing associated documentation comment in .proto file."""
147
184
 
185
+ @staticmethod
186
+ def SetupHostParams(request,
187
+ target,
188
+ options=(),
189
+ channel_credentials=None,
190
+ call_credentials=None,
191
+ insecure=False,
192
+ compression=None,
193
+ wait_for_ready=None,
194
+ timeout=None,
195
+ metadata=None):
196
+ return grpc.experimental.unary_unary(
197
+ request,
198
+ target,
199
+ '/gnetcli.Gnetcli/SetupHostParams',
200
+ server__pb2.HostParams.SerializeToString,
201
+ google_dot_protobuf_dot_empty__pb2.Empty.FromString,
202
+ options,
203
+ channel_credentials,
204
+ insecure,
205
+ call_credentials,
206
+ compression,
207
+ wait_for_ready,
208
+ timeout,
209
+ metadata,
210
+ _registered_method=True)
211
+
148
212
  @staticmethod
149
213
  def Exec(request,
150
214
  target,
@@ -156,11 +220,21 @@ class Gnetcli(object):
156
220
  wait_for_ready=None,
157
221
  timeout=None,
158
222
  metadata=None):
159
- return grpc.experimental.unary_unary(request, target, '/gnetcli.Gnetcli/Exec',
223
+ return grpc.experimental.unary_unary(
224
+ request,
225
+ target,
226
+ '/gnetcli.Gnetcli/Exec',
160
227
  server__pb2.CMD.SerializeToString,
161
228
  server__pb2.CMDResult.FromString,
162
- options, channel_credentials,
163
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
229
+ options,
230
+ channel_credentials,
231
+ insecure,
232
+ call_credentials,
233
+ compression,
234
+ wait_for_ready,
235
+ timeout,
236
+ metadata,
237
+ _registered_method=True)
164
238
 
165
239
  @staticmethod
166
240
  def ExecChat(request_iterator,
@@ -173,11 +247,21 @@ class Gnetcli(object):
173
247
  wait_for_ready=None,
174
248
  timeout=None,
175
249
  metadata=None):
176
- return grpc.experimental.stream_stream(request_iterator, target, '/gnetcli.Gnetcli/ExecChat',
250
+ return grpc.experimental.stream_stream(
251
+ request_iterator,
252
+ target,
253
+ '/gnetcli.Gnetcli/ExecChat',
177
254
  server__pb2.CMD.SerializeToString,
178
255
  server__pb2.CMDResult.FromString,
179
- options, channel_credentials,
180
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
256
+ options,
257
+ channel_credentials,
258
+ insecure,
259
+ call_credentials,
260
+ compression,
261
+ wait_for_ready,
262
+ timeout,
263
+ metadata,
264
+ _registered_method=True)
181
265
 
182
266
  @staticmethod
183
267
  def AddDevice(request,
@@ -190,11 +274,21 @@ class Gnetcli(object):
190
274
  wait_for_ready=None,
191
275
  timeout=None,
192
276
  metadata=None):
193
- return grpc.experimental.unary_unary(request, target, '/gnetcli.Gnetcli/AddDevice',
277
+ return grpc.experimental.unary_unary(
278
+ request,
279
+ target,
280
+ '/gnetcli.Gnetcli/AddDevice',
194
281
  server__pb2.Device.SerializeToString,
195
282
  server__pb2.DeviceResult.FromString,
196
- options, channel_credentials,
197
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
283
+ options,
284
+ channel_credentials,
285
+ insecure,
286
+ call_credentials,
287
+ compression,
288
+ wait_for_ready,
289
+ timeout,
290
+ metadata,
291
+ _registered_method=True)
198
292
 
199
293
  @staticmethod
200
294
  def ExecNetconf(request,
@@ -207,11 +301,21 @@ class Gnetcli(object):
207
301
  wait_for_ready=None,
208
302
  timeout=None,
209
303
  metadata=None):
210
- return grpc.experimental.unary_unary(request, target, '/gnetcli.Gnetcli/ExecNetconf',
304
+ return grpc.experimental.unary_unary(
305
+ request,
306
+ target,
307
+ '/gnetcli.Gnetcli/ExecNetconf',
211
308
  server__pb2.CMDNetconf.SerializeToString,
212
309
  server__pb2.CMDResult.FromString,
213
- options, channel_credentials,
214
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
310
+ options,
311
+ channel_credentials,
312
+ insecure,
313
+ call_credentials,
314
+ compression,
315
+ wait_for_ready,
316
+ timeout,
317
+ metadata,
318
+ _registered_method=True)
215
319
 
216
320
  @staticmethod
217
321
  def ExecNetconfChat(request_iterator,
@@ -224,14 +328,24 @@ class Gnetcli(object):
224
328
  wait_for_ready=None,
225
329
  timeout=None,
226
330
  metadata=None):
227
- return grpc.experimental.stream_stream(request_iterator, target, '/gnetcli.Gnetcli/ExecNetconfChat',
331
+ return grpc.experimental.stream_stream(
332
+ request_iterator,
333
+ target,
334
+ '/gnetcli.Gnetcli/ExecNetconfChat',
228
335
  server__pb2.CMDNetconf.SerializeToString,
229
336
  server__pb2.CMDResult.FromString,
230
- options, channel_credentials,
231
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
337
+ options,
338
+ channel_credentials,
339
+ insecure,
340
+ call_credentials,
341
+ compression,
342
+ wait_for_ready,
343
+ timeout,
344
+ metadata,
345
+ _registered_method=True)
232
346
 
233
347
  @staticmethod
234
- def Downloads(request,
348
+ def Download(request,
235
349
  target,
236
350
  options=(),
237
351
  channel_credentials=None,
@@ -241,11 +355,21 @@ class Gnetcli(object):
241
355
  wait_for_ready=None,
242
356
  timeout=None,
243
357
  metadata=None):
244
- return grpc.experimental.unary_unary(request, target, '/gnetcli.Gnetcli/Downloads',
358
+ return grpc.experimental.unary_unary(
359
+ request,
360
+ target,
361
+ '/gnetcli.Gnetcli/Download',
245
362
  server__pb2.FileDownloadRequest.SerializeToString,
246
363
  server__pb2.FilesResult.FromString,
247
- options, channel_credentials,
248
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
364
+ options,
365
+ channel_credentials,
366
+ insecure,
367
+ call_credentials,
368
+ compression,
369
+ wait_for_ready,
370
+ timeout,
371
+ metadata,
372
+ _registered_method=True)
249
373
 
250
374
  @staticmethod
251
375
  def Upload(request,
@@ -258,8 +382,18 @@ class Gnetcli(object):
258
382
  wait_for_ready=None,
259
383
  timeout=None,
260
384
  metadata=None):
261
- return grpc.experimental.unary_unary(request, target, '/gnetcli.Gnetcli/Upload',
385
+ return grpc.experimental.unary_unary(
386
+ request,
387
+ target,
388
+ '/gnetcli.Gnetcli/Upload',
262
389
  server__pb2.FileUploadRequest.SerializeToString,
263
390
  google_dot_protobuf_dot_empty__pb2.Empty.FromString,
264
- options, channel_credentials,
265
- insecure, call_credentials, compression, wait_for_ready, timeout, metadata)
391
+ options,
392
+ channel_credentials,
393
+ insecure,
394
+ call_credentials,
395
+ compression,
396
+ wait_for_ready,
397
+ timeout,
398
+ metadata,
399
+ _registered_method=True)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: gnetclisdk
3
- Version: 1.0.1
3
+ Version: 1.0.2
4
4
  Summary: Client for Gnetcli GRPC-server
5
5
  Home-page: https://github.com/annetutil/gnetcli
6
6
  Author: Alexander Balezin
@@ -13,13 +13,16 @@ Classifier: Programming Language :: Python :: 3.8
13
13
  Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
15
  Description-Content-Type: text/markdown
16
+ Requires-Dist: protobuf==4.24.4
17
+ Requires-Dist: grpcio==1.59.2
18
+ Requires-Dist: googleapis-common-protos==1.61.0
16
19
 
17
- ## python client for Gnetcli server
20
+ ## Python client for Gnetcli GRPC server
18
21
 
19
- Install Gnetcli GRPC-server.
20
- - Download latest release from https://github.com/annetutil/gnetcli/releases/
21
- - `tar -xzvf gnetcli_server-v1.0.0-darwin-amd64.tar.gz` (If see 'cannot be opened because the developer cannot be verified', then call `sudo xattr -d com.apple.quarantine gnetcli_server`)
22
- - `./gnetcli_server -debug`
22
+ Gnetcli provides a universal way to execute arbitrary commands using a CLI,
23
+ eliminating the need for screen scraping with expect.
24
+
25
+ See documentation on [gnetcli server](https://annetutil.github.io/gnetcli/).
23
26
 
24
27
  Example:
25
28
 
@@ -36,6 +39,7 @@ async def example():
36
39
  asyncio.run(example())
37
40
  ```
38
41
 
42
+ Output:
39
43
  ```
40
44
  err=b'' status=0 out=b'2023-11-10 09:31:58\nFriday\nTime Zone(UTC) : UTC'
41
45
  ```
@@ -13,4 +13,5 @@ gnetclisdk.egg-info/dependency_links.txt
13
13
  gnetclisdk.egg-info/requires.txt
14
14
  gnetclisdk.egg-info/top_level.txt
15
15
  gnetclisdk/proto/server_pb2.py
16
+ gnetclisdk/proto/server_pb2.pyi
16
17
  gnetclisdk/proto/server_pb2_grpc.py
@@ -8,7 +8,7 @@ with open("requirements.txt") as f:
8
8
 
9
9
  setup(
10
10
  name="gnetclisdk",
11
- version="1.0.1",
11
+ version="1.0.2",
12
12
  description="Client for Gnetcli GRPC-server",
13
13
  long_description=readme,
14
14
  long_description_content_type="text/markdown",
@@ -1,66 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # source: server.proto
4
- """Generated protocol buffer code."""
5
- from google.protobuf import descriptor as _descriptor
6
- from google.protobuf import descriptor_pool as _descriptor_pool
7
- from google.protobuf import symbol_database as _symbol_database
8
- from google.protobuf.internal import builder as _builder
9
- # @@protoc_insertion_point(imports)
10
-
11
- _sym_db = _symbol_database.Default()
12
-
13
-
14
- from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
15
- from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
16
-
17
-
18
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cserver.proto\x12\x07gnetcli\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\"&\n\x02QA\x12\x10\n\x08question\x18\x01 \x01(\t\x12\x0e\n\x06\x61nswer\x18\x02 \x01(\t\".\n\x0b\x43redentials\x12\r\n\x05login\x18\x01 \x01(\t\x12\x10\n\x08password\x18\x02 \x01(\t\"\xc5\x01\n\x03\x43MD\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0b\n\x03\x63md\x18\x02 \x01(\t\x12\r\n\x05trace\x18\x03 \x01(\x08\x12\x17\n\x02qa\x18\x04 \x03(\x0b\x32\x0b.gnetcli.QA\x12\x14\n\x0cread_timeout\x18\x05 \x01(\x01\x12\x13\n\x0b\x63md_timeout\x18\x06 \x01(\x01\x12\x0e\n\x06\x64\x65vice\x18\x07 \x01(\t\x12\x15\n\rstring_result\x18\x08 \x01(\x08\x12)\n\x0b\x63redentials\x18\t \x01(\x0b\x32\x14.gnetcli.Credentials\"e\n\x06\x44\x65vice\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x19\n\x11prompt_expression\x18\x02 \x01(\t\x12\x18\n\x10\x65rror_expression\x18\x03 \x01(\t\x12\x18\n\x10pager_expression\x18\x04 \x01(\t\"\x8b\x01\n\nCMDNetconf\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0b\n\x03\x63md\x18\x02 \x01(\t\x12\x0c\n\x04json\x18\x03 \x01(\x08\x12\x14\n\x0cread_timeout\x18\x04 \x01(\x01\x12\x13\n\x0b\x63md_timeout\x18\x05 \x01(\x01\x12)\n\x0b\x43redentials\x18\x06 \x01(\x0b\x32\x14.gnetcli.Credentials\"H\n\x0c\x43MDTraceItem\x12*\n\toperation\x18\x01 \x01(\x0e\x32\x17.gnetcli.TraceOperation\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\"\x81\x01\n\tCMDResult\x12\x0b\n\x03out\x18\x01 \x01(\x0c\x12\x0f\n\x07out_str\x18\x02 \x01(\t\x12\r\n\x05\x65rror\x18\x03 \x01(\x0c\x12\x11\n\terror_str\x18\x04 \x01(\t\x12$\n\x05trace\x18\x05 \x03(\x0b\x32\x15.gnetcli.CMDTraceItem\x12\x0e\n\x06status\x18\x06 \x01(\x05\"G\n\x0c\x44\x65viceResult\x12(\n\x03res\x18\x01 \x01(\x0e\x32\x1b.gnetcli.DeviceResultStatus\x12\r\n\x05\x65rror\x18\x02 \x01(\t\"l\n\x13\x46ileDownloadRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\x0e\n\x06\x64\x65vice\x18\x03 \x01(\t\x12)\n\x0b\x63redentials\x18\x04 \x01(\x0b\x32\x14.gnetcli.Credentials\"x\n\x11\x46ileUploadRequest\x12\x0c\n\x04host\x18\x01 \x01(\t\x12\x0c\n\x04path\x18\x02 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x03 \x01(\x0c\x12\x0e\n\x06\x64\x65vice\x18\x04 \x01(\t\x12)\n\x0b\x63redentials\x18\x05 \x01(\x0b\x32\x14.gnetcli.Credentials\"(\n\nFileResult\x12\x0c\n\x04path\x18\x01 \x01(\t\x12\x0c\n\x04\x64\x61ta\x18\x02 \x01(\x0c\"1\n\x0b\x46ilesResult\x12\"\n\x05\x66iles\x18\x01 \x03(\x0b\x32\x13.gnetcli.FileResult*f\n\x0eTraceOperation\x12\x14\n\x10Operation_notset\x10\x00\x12\x15\n\x11Operation_unknown\x10\x01\x12\x13\n\x0fOperation_write\x10\x02\x12\x12\n\x0eOperation_read\x10\x03*H\n\x12\x44\x65viceResultStatus\x12\x11\n\rDevice_notset\x10\x00\x12\r\n\tDevice_ok\x10\x01\x12\x10\n\x0c\x44\x65vice_error\x10\x02\x32\xa7\x04\n\x07Gnetcli\x12\x41\n\x04\x45xec\x12\x0c.gnetcli.CMD\x1a\x12.gnetcli.CMDResult\"\x17\x82\xd3\xe4\x93\x02\x11\"\x0c/api/v1/exec:\x01*\x12\x32\n\x08\x45xecChat\x12\x0c.gnetcli.CMD\x1a\x12.gnetcli.CMDResult\"\x00(\x01\x30\x01\x12R\n\tAddDevice\x12\x0f.gnetcli.Device\x1a\x15.gnetcli.DeviceResult\"\x1d\x82\xd3\xe4\x93\x02\x17\"\x12/api/v1/add_device:\x01*\x12W\n\x0b\x45xecNetconf\x12\x13.gnetcli.CMDNetconf\x1a\x12.gnetcli.CMDResult\"\x1f\x82\xd3\xe4\x93\x02\x19\"\x14/api/v1/exec_netconf:\x01*\x12@\n\x0f\x45xecNetconfChat\x12\x13.gnetcli.CMDNetconf\x1a\x12.gnetcli.CMDResult\"\x00(\x01\x30\x01\x12]\n\tDownloads\x12\x1c.gnetcli.FileDownloadRequest\x1a\x14.gnetcli.FilesResult\"\x1c\x82\xd3\xe4\x93\x02\x16\"\x11/api/v1/downloads:\x01*\x12W\n\x06Upload\x12\x1a.gnetcli.FileUploadRequest\x1a\x16.google.protobuf.Empty\"\x19\x82\xd3\xe4\x93\x02\x13\"\x0e/api/v1/upload:\x01*B7Z5github.com/annetutil/gnetcli/pkg/server/proto;gnetclib\x06proto3')
19
-
20
- _globals = globals()
21
- _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
22
- _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'server_pb2', _globals)
23
- if _descriptor._USE_C_DESCRIPTORS == False:
24
- DESCRIPTOR._options = None
25
- DESCRIPTOR._serialized_options = b'Z5github.com/annetutil/gnetcli/pkg/server/proto;gnetcli'
26
- _GNETCLI.methods_by_name['Exec']._options = None
27
- _GNETCLI.methods_by_name['Exec']._serialized_options = b'\202\323\344\223\002\021\"\014/api/v1/exec:\001*'
28
- _GNETCLI.methods_by_name['AddDevice']._options = None
29
- _GNETCLI.methods_by_name['AddDevice']._serialized_options = b'\202\323\344\223\002\027\"\022/api/v1/add_device:\001*'
30
- _GNETCLI.methods_by_name['ExecNetconf']._options = None
31
- _GNETCLI.methods_by_name['ExecNetconf']._serialized_options = b'\202\323\344\223\002\031\"\024/api/v1/exec_netconf:\001*'
32
- _GNETCLI.methods_by_name['Downloads']._options = None
33
- _GNETCLI.methods_by_name['Downloads']._serialized_options = b'\202\323\344\223\002\026\"\021/api/v1/downloads:\001*'
34
- _GNETCLI.methods_by_name['Upload']._options = None
35
- _GNETCLI.methods_by_name['Upload']._serialized_options = b'\202\323\344\223\002\023\"\016/api/v1/upload:\001*'
36
- _globals['_TRACEOPERATION']._serialized_start=1221
37
- _globals['_TRACEOPERATION']._serialized_end=1323
38
- _globals['_DEVICERESULTSTATUS']._serialized_start=1325
39
- _globals['_DEVICERESULTSTATUS']._serialized_end=1397
40
- _globals['_QA']._serialized_start=84
41
- _globals['_QA']._serialized_end=122
42
- _globals['_CREDENTIALS']._serialized_start=124
43
- _globals['_CREDENTIALS']._serialized_end=170
44
- _globals['_CMD']._serialized_start=173
45
- _globals['_CMD']._serialized_end=370
46
- _globals['_DEVICE']._serialized_start=372
47
- _globals['_DEVICE']._serialized_end=473
48
- _globals['_CMDNETCONF']._serialized_start=476
49
- _globals['_CMDNETCONF']._serialized_end=615
50
- _globals['_CMDTRACEITEM']._serialized_start=617
51
- _globals['_CMDTRACEITEM']._serialized_end=689
52
- _globals['_CMDRESULT']._serialized_start=692
53
- _globals['_CMDRESULT']._serialized_end=821
54
- _globals['_DEVICERESULT']._serialized_start=823
55
- _globals['_DEVICERESULT']._serialized_end=894
56
- _globals['_FILEDOWNLOADREQUEST']._serialized_start=896
57
- _globals['_FILEDOWNLOADREQUEST']._serialized_end=1004
58
- _globals['_FILEUPLOADREQUEST']._serialized_start=1006
59
- _globals['_FILEUPLOADREQUEST']._serialized_end=1126
60
- _globals['_FILERESULT']._serialized_start=1128
61
- _globals['_FILERESULT']._serialized_end=1168
62
- _globals['_FILESRESULT']._serialized_start=1170
63
- _globals['_FILESRESULT']._serialized_end=1219
64
- _globals['_GNETCLI']._serialized_start=1400
65
- _globals['_GNETCLI']._serialized_end=1951
66
- # @@protoc_insertion_point(module_scope)
File without changes
File without changes
File without changes
File without changes