eva-shell 0.2.37__tar.gz → 0.2.38__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eva-shell
3
- Version: 0.2.37
3
+ Version: 0.2.38
4
4
  Summary: EVA ICS v4 shell
5
5
  Home-page: https://github.com/eva-ics/eva4
6
6
  Author: Bohemia Automation / Altertech
@@ -1,3 +1,3 @@
1
- __version__ = '0.2.37'
1
+ __version__ = '0.2.38'
2
2
 
3
3
  DEFAULT_REPOSITORY_URL = 'https://pub.bma.ai/eva4'
@@ -12,7 +12,7 @@ neotermcolor.readline_always_safe = True
12
12
 
13
13
  from .sharedobj import common, current_command
14
14
  from .tools import print_tb, err, is_local_shell
15
- from .compl import ComplOID, ComplSvc, ComplNode, ComplDeployFile, ComplDobj
15
+ from .compl import ComplOID, ComplSvc, ComplNode, ComplDeployFile, ComplAnyFile, ComplDobj
16
16
  from .compl import ComplOIDtp, ComplSvcRpcMethod, ComplSvcRpcParams, ComplEdit
17
17
  from .client import call_rpc, DEFAULT_DB_SERVICE, DEFAULT_REPL_SERVICE
18
18
  from .client import DEFAULT_ACL_SERVICE, DEFAULT_AUTH_SERVICE
@@ -523,6 +523,12 @@ def append_svc_cli(root_sp):
523
523
  'purge', help='purge service (destroy and delete all service data)')
524
524
  p.add_argument('i', metavar='SVC').completer = ComplSvc()
525
525
 
526
+ p = sp.add_parser('flash', help='flash the service binary')
527
+ p.add_argument('i', metavar='SVC').completer = ComplSvc()
528
+ p.add_argument(
529
+ 'file', metavar='FILE',
530
+ help='service file to reflash with').completer = ComplAnyFile()
531
+
526
532
 
527
533
  def append_acl_cli(root_sp):
528
534
  ap = root_sp.add_parser('acl', help='ACL commands')
@@ -820,6 +826,12 @@ def append_item_cli(root_sp):
820
826
 
821
827
  p = sp.add_parser('create', help='create an item')
822
828
  p.add_argument('i', metavar='OID').completer = ComplOID()
829
+ p.add_argument(
830
+ '-p',
831
+ '--python',
832
+ help=
833
+ 'For Python lmacro: assign eva.controller.py as action svc and edit code after creation',
834
+ action='store_true')
823
835
 
824
836
  p = sp.add_parser('destroy', help='destroy item(s)')
825
837
  p.add_argument('i', metavar='MASK').completer = ComplOID()
@@ -832,6 +844,10 @@ def append_item_cli(root_sp):
832
844
 
833
845
  p = sp.add_parser('edit', help='edit item config')
834
846
  p.add_argument('i', metavar='OID').completer = ComplOID()
847
+ p.add_argument('-p',
848
+ '--python',
849
+ help='For Python lmacro: edit code',
850
+ action='store_true')
835
851
 
836
852
  p = sp.add_parser('set', help='set item state')
837
853
  p.add_argument('i', metavar='OID').completer = ComplOID()
@@ -1183,6 +1199,7 @@ def append_cloud_cli(root_sp):
1183
1199
  help='update without any confirmations',
1184
1200
  action='store_true')
1185
1201
 
1202
+
1186
1203
  def append_video_cli(root_sp):
1187
1204
  ap_generator = root_sp.add_parser('video', help='video commands')
1188
1205
  sp_generator = ap_generator.add_subparsers(dest='_subc', help='sub command')
@@ -1192,12 +1209,8 @@ def append_video_cli(root_sp):
1192
1209
 
1193
1210
  p = sp.add_parser('create', help='create a video recording')
1194
1211
  p.add_argument('i', metavar='source')
1195
- p.add_argument('--keep',
1196
- type=float,
1197
- help='Keep (seconds)')
1198
- p.add_argument('--enabled',
1199
- help='Enable recording',
1200
- action='store_true')
1212
+ p.add_argument('--keep', type=float, help='Keep (seconds)')
1213
+ p.add_argument('--enabled', help='Enable recording', action='store_true')
1201
1214
  p.add_argument(
1202
1215
  '-a',
1203
1216
  '--video-svc',
@@ -1243,7 +1256,8 @@ def append_video_cli(root_sp):
1243
1256
  help=f'video service (default: {DEFAULT_VIDEO_SERVICE})',
1244
1257
  default=DEFAULT_VIDEO_SERVICE).completer = ComplSvc('videosrv')
1245
1258
 
1246
- p = sp.add_parser('export', help='export video recording config(s) to a deployment file')
1259
+ p = sp.add_parser(
1260
+ 'export', help='export video recording config(s) to a deployment file')
1247
1261
  p.add_argument('i', metavar='MASK')
1248
1262
  p.add_argument(
1249
1263
  '-a',
@@ -1253,7 +1267,8 @@ def append_video_cli(root_sp):
1253
1267
  p.add_argument('-o', '--output', metavar='FILE',
1254
1268
  help='output file').completer = ComplDeployFile()
1255
1269
 
1256
- p = sp.add_parser('deploy', help='deploy video recording(s) from a deployment file')
1270
+ p = sp.add_parser('deploy',
1271
+ help='deploy video recording(s) from a deployment file')
1257
1272
  p.add_argument(
1258
1273
  '-a',
1259
1274
  '--video-svc',
@@ -1262,8 +1277,8 @@ def append_video_cli(root_sp):
1262
1277
  p.add_argument('-f', '--file', metavar='FILE',
1263
1278
  help='deployment file').completer = ComplDeployFile()
1264
1279
 
1265
- p = sp.add_parser('undeploy',
1266
- help='undeploy video recordings(s) using a deployment file')
1280
+ p = sp.add_parser(
1281
+ 'undeploy', help='undeploy video recordings(s) using a deployment file')
1267
1282
  p.add_argument(
1268
1283
  '-a',
1269
1284
  '--video-svc',
@@ -1272,6 +1287,7 @@ def append_video_cli(root_sp):
1272
1287
  p.add_argument('-f', '--file', metavar='FILE',
1273
1288
  help='deployment file').completer = ComplDeployFile()
1274
1289
 
1290
+
1275
1291
  def append_generator_cli(root_sp):
1276
1292
  source_types = [
1277
1293
  'random', 'random_float', 'counter', 'time', 'wave', 'udp_float'
@@ -13,13 +13,11 @@ from rapidtables import format_table, FORMAT_GENERATOR, FORMAT_GENERATOR_COLS
13
13
  from .tools import print_result, ok
14
14
  from .tools import edit_config, edit_remote_file, read_file, write_file
15
15
  from .tools import print_action_result, format_value, prepare_time, err, warn
16
- from .tools import get_node_svc_info, edit_file, get_term_size, exec_cmd, xc
16
+ from .tools import get_node_svc_info, get_term_size, exec_cmd, xc
17
17
  from .tools import get_my_ip, check_local_shell
18
18
  from .client import call_rpc, DEFAULT_REPL_SERVICE, connect
19
19
  from .sharedobj import common, current_command
20
20
 
21
- from . import DEFAULT_REPOSITORY_URL
22
-
23
21
 
24
22
  def eva_control_c(c, pfx=''):
25
23
  check_local_shell()
@@ -27,6 +25,12 @@ def eva_control_c(c, pfx=''):
27
25
  os.system(cmd)
28
26
 
29
27
 
28
+ def format_python_fname(i):
29
+ short_id = i.rsplit('/', 1)[-1].rsplit(':', 1)[-1]
30
+ fname = f'xc/py/{short_id}.py'
31
+ return fname
32
+
33
+
30
34
  class CLI:
31
35
 
32
36
  def __init__(self, *args, **kwargs):
@@ -661,6 +665,11 @@ class CLI:
661
665
  call_rpc('svc.restart', dict(i=i))
662
666
  ok()
663
667
 
668
+ def svc_flash(self, i, file):
669
+ binary = open(file, 'rb').read()
670
+ call_rpc('svc.flash', dict(i=i, binary=binary))
671
+ ok()
672
+
664
673
  def svc_destroy(self, i):
665
674
  call_rpc('svc.undeploy', dict(svcs=[i]))
666
675
  ok()
@@ -1134,8 +1143,13 @@ class CLI:
1134
1143
  print(f'{len(items)} item(s) undeployed')
1135
1144
  print()
1136
1145
 
1137
- def item_create(self, i):
1138
- call_rpc('item.create', dict(i=i))
1146
+ def item_create(self, i, python=False):
1147
+ if python:
1148
+ cfg = {'oid': i, 'action': {'svc': 'eva.controller.py'}}
1149
+ call_rpc('item.deploy', dict(items=[cfg]))
1150
+ return self.edit(format_python_fname(i), 'eva.filemgr.main')
1151
+ else:
1152
+ call_rpc('item.create', dict(i=i))
1139
1153
  ok()
1140
1154
 
1141
1155
  def item_destroy(self, i):
@@ -1146,7 +1160,10 @@ class CLI:
1146
1160
  call_rpc('item.enable', dict(i=i))
1147
1161
  ok()
1148
1162
 
1149
- def item_edit(self, i):
1163
+ def item_edit(self, i, python=False):
1164
+
1165
+ if python:
1166
+ return self.edit(format_python_fname(i), 'eva.filemgr.main')
1150
1167
 
1151
1168
  def deploy_edited_item(cfg, i):
1152
1169
  call_rpc('item.deploy', dict(items=[cfg]))
@@ -96,6 +96,38 @@ class ComplSvcRpcParams:
96
96
  if p.startswith(prefix) and not p in pp:
97
97
  yield f'{p}='
98
98
 
99
+ class ComplAnyFile:
100
+
101
+ def __call__(self, prefix, **kwargs):
102
+ import glob
103
+ expanded = None
104
+
105
+ def expand_user(pfx):
106
+ nonlocal expanded
107
+ if pfx.startswith('~'):
108
+ expanded = os.path.expanduser('~')
109
+ return expanded + pfx[1:]
110
+ else:
111
+ return pfx
112
+
113
+ def contract_user(pfx):
114
+ nonlocal expanded
115
+ if expanded is None:
116
+ return pfx
117
+ else:
118
+ return '~' + pfx[len(expanded):]
119
+
120
+ if not prefix:
121
+ masks = ['*']
122
+ else:
123
+ prefix = expand_user(prefix)
124
+ masks = [f'{prefix}*']
125
+ for mask in masks:
126
+ for f in glob.glob(mask):
127
+ yield contract_user(f)
128
+ for f in glob.glob(f'{prefix}*'):
129
+ if os.path.isdir(f):
130
+ yield contract_user(f'{f}/')
99
131
 
100
132
  class ComplDeployFile:
101
133
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: eva-shell
3
- Version: 0.2.37
3
+ Version: 0.2.38
4
4
  Summary: EVA ICS v4 shell
5
5
  Home-page: https://github.com/eva-ics/eva4
6
6
  Author: Bohemia Automation / Altertech
@@ -1,4 +1,4 @@
1
- __version__ = '0.2.37'
1
+ __version__ = '0.2.38'
2
2
 
3
3
  import setuptools
4
4
 
File without changes
File without changes
File without changes
File without changes