meshcore-cli 1.6.14__tar.gz → 1.6.15__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.5
2
2
  Name: meshcore-cli
3
- Version: 1.6.14
3
+ Version: 1.6.15
4
4
  Summary: Command line interface to meshcore companion radios and repeaters
5
5
  Project-URL: Homepage, https://github.com/fdlamotte/meshcore-cli
6
6
  Project-URL: Issues, https://github.com/fdlamotte/meshcore-cli/issues
@@ -11,7 +11,7 @@ Classifier: Operating System :: OS Independent
11
11
  Classifier: Programming Language :: Python :: 3
12
12
  Requires-Python: >=3.10
13
13
  Requires-Dist: bleak>=0.22
14
- Requires-Dist: meshcore>=2.3.22
14
+ Requires-Dist: meshcore>=2.3.23
15
15
  Requires-Dist: prompt-toolkit>=3.0.50
16
16
  Requires-Dist: requests>=2.28.0
17
17
  Requires-Dist: zeroconf>=0.131
@@ -17,12 +17,12 @@
17
17
 
18
18
  meshcore = python3Packages.buildPythonPackage rec {
19
19
  pname = "meshcore";
20
- version = "2.3.22";
20
+ version = "2.3.23";
21
21
  pyproject = true;
22
22
 
23
23
  src = python3Packages.fetchPypi {
24
24
  inherit pname version;
25
- sha256 = "sha256-dxiG5cJcteqXP0+XWVfnPpb0Mp+8oes5FvrFfBMzUBA=";
25
+ sha256 = "sha256-cU85RRdfpK6knerJ2/a5v5aXqpgdBRchIBSMQ3Vs1jM=";
26
26
  };
27
27
 
28
28
  build-system = [ python3Packages.hatchling ];
@@ -32,6 +32,7 @@
32
32
  python3Packages.pycayennelpp
33
33
  python3Packages.pyserial-asyncio-fast
34
34
  python3Packages.pycryptodome
35
+ python3Packages.zeroconf
35
36
  ];
36
37
 
37
38
  pythonImportsCheck = [ "meshcore" ];
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "meshcore-cli"
7
- version = "1.6.14"
7
+ version = "1.6.15"
8
8
  authors = [
9
9
  { name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
10
10
  ]
@@ -17,7 +17,7 @@ classifiers = [
17
17
  ]
18
18
  license = "MIT"
19
19
  license-files = ["LICEN[CS]E*"]
20
- dependencies = [ "meshcore >= 2.3.22",
20
+ dependencies = [ "meshcore >= 2.3.23",
21
21
  "bleak >= 0.22",
22
22
  "zeroconf >= 0.131",
23
23
  "prompt_toolkit >= 3.0.50",
@@ -1,6 +1,6 @@
1
1
  # Some example scripts to interact with meshcore-cli
2
2
 
3
- Since version 1.16 it is possible to interact with external scripts through a redirection mechanism.
3
+ Since version 1.6.0 it is possible to interact with external scripts through a redirection mechanism.
4
4
 
5
5
  Result of meshcore-cli commands can be redirected to files or processes, starting your lines with `|`, `>` or `>>`. While it is possible to inject the stdout from a command inside the meshcore-cli line using `<|`
6
6
 
@@ -42,7 +42,7 @@ except ImportError:
42
42
  from meshcore import MeshCore, EventType, logger
43
43
 
44
44
  # Version
45
- VERSION = "v1.6.14"
45
+ VERSION = "v1.6.15"
46
46
 
47
47
  # default ble address is stored in a config file
48
48
  MCCLI_CONFIG_DIR = os.path.expanduser("~/.config/meshcore/")
@@ -266,7 +266,7 @@ async def run_timer(mc, timer):
266
266
  try:
267
267
  if timer["scope"] != base:
268
268
  await set_scope(mc, timer["scope"])
269
- await process_redirected_line(mc, timer["cmd"], timer["contact"], timer["scope"], None, base, json_output=timer["json"], sink=sys.stdout)
269
+ await process_redirected_line(mc, timer["cmd"], timer["contact"], timer["scope"], None, base, json_output=timer["json"], sink=sys.stdout, stream=timer["stream"])
270
270
  except Exception as e:
271
271
  logger.error(f"Timer {timer['id']}: {e}")
272
272
  finally:
@@ -278,6 +278,8 @@ async def run_timer(mc, timer):
278
278
  timer["remaining"] -= 1
279
279
  if timer["remaining"] <= 0:
280
280
  TIMERS.pop(timer["id"], None)
281
+ if timer["fin"]:
282
+ print(f"Timer {timer['id']} finished")
281
283
  return
282
284
 
283
285
  async def write_handler(handler):
@@ -831,7 +833,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
831
833
  "handler_attach": {"rxlog":None, "msgs":None, "chan_data":None, "telemetry":None},
832
834
  "handler_detach": None,
833
835
  "handlers": None,
834
- "timer": OptionsCompleter(["-j", "-x", "-n", "-c", "-s"]),
836
+ "timer": OptionsCompleter(["-j", "-x", "-n", "-c", "-s", "-u", "-f"]),
835
837
  "timer_cancel": None,
836
838
  "timers": None,
837
839
  "login" : contact_list,
@@ -1038,7 +1040,7 @@ def make_completion_dict(contacts, pending=None, to=None, channels=None):
1038
1040
  "unsub_telemetry" : None,
1039
1041
  "req_binary" : None,
1040
1042
  "forget_password" : None,
1041
- "timer" : OptionsCompleter(["-j", "-x", "-n", "-s"]),
1043
+ "timer" : OptionsCompleter(["-j", "-x", "-n", "-s", "-u", "-f"]),
1042
1044
  }
1043
1045
 
1044
1046
  client_completion_list = dict(contact_completion_list)
@@ -1401,8 +1403,8 @@ if platform.system() == "Darwin" or platform.system() == "Windows":
1401
1403
  else:
1402
1404
  interactive_loop.classic = False
1403
1405
 
1404
- async def process_redirected_line(mc, line, contact=None, scope="*", prev_contact=None, prev_scope="*", json_output=False, sink=sys.stdout, end="\n"):
1405
- if line.startswith("@") and len(line) > 1: # alias => replace and resolve parameters
1406
+ async def process_redirected_line(mc, line, contact=None, scope="*", prev_contact=None, prev_scope="*", json_output=False, sink=sys.stdout, end="\n", stream=True):
1407
+ if line.startswith("@") and line[1:2].isalnum(): # alias => replace and resolve parameters
1406
1408
  try:
1407
1409
  args = shlex.split(line[1:])
1408
1410
  alias = ALIASES[args[0]]
@@ -1455,8 +1457,11 @@ async def process_redirected_line(mc, line, contact=None, scope="*", prev_contac
1455
1457
  line = line[1:].strip()
1456
1458
  try:
1457
1459
  pcom, mcline = split_first_token(line)
1458
- with subprocess.Popen(shlex.split(pcom, posix=True), stdin=subprocess.PIPE, stdout=sink,text=True) as process:
1460
+ with subprocess.Popen(shlex.split(pcom, posix=True), stdin=subprocess.PIPE, stdout=sink if stream else subprocess.PIPE, text=True) as process:
1459
1461
  (new_contact, new_scope, last_ack) = await process_redirected_line(mc, mcline, contact, scope, prev_contact, prev_scope, json_output=json_output, sink=process.stdin)
1462
+ if not stream:
1463
+ process.stdin.close()
1464
+ sink.write(process.stdout.read())
1460
1465
  except ValueError:
1461
1466
  logger.error("Couldn't parse name")
1462
1467
  except FileNotFoundError:
@@ -4582,6 +4587,8 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4582
4587
  argnum = 2
4583
4588
  if cmds[2] == "":
4584
4589
  ALIASES.pop(cmds[1], None)
4590
+ elif not cmds[1][:1].isalnum():
4591
+ logger.error("Alias key must start with a letter or digit")
4585
4592
  else:
4586
4593
  ALIASES[cmds[1]] = cmds[2]
4587
4594
  elif len(cmds) > 1: # get value if exists
@@ -4697,7 +4704,7 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4697
4704
  output_str += json.dumps(HANDLERS, default=str)+end
4698
4705
 
4699
4706
  case "timer":
4700
- argnum = 2 # [-j] [-x] [-n<count>] [-c<contact>] [-s<scope>] secs line
4707
+ argnum = 2 # [-j] [-x] [-n<count>] [-c<contact>] [-s<scope>] [-u] [-f] secs line
4701
4708
  t_contact = None
4702
4709
  t_scope = set_scope.current_scope
4703
4710
  if t_scope is None:
@@ -4705,6 +4712,8 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4705
4712
  t_json = json_output
4706
4713
  t_count = None # None = runs until cancelled
4707
4714
  t_exec = False # -x : first run without delay
4715
+ t_stream = False # -u : unbuffered, pipe output goes under the prompt
4716
+ t_fin = False # -f : tell when the timer has finished (with -n)
4708
4717
  valid = True
4709
4718
 
4710
4719
  args = cmds[1:]
@@ -4750,6 +4759,12 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4750
4759
  "type": 0,
4751
4760
  "chan_nb": chan["channel_idx"],}
4752
4761
 
4762
+ if args[0].startswith("-u"): # unbuffered: streaming
4763
+ t_stream = True
4764
+
4765
+ if args[0].startswith("-f"): # inform when the timer finishes
4766
+ t_fin = True
4767
+
4753
4768
  if args[0].startswith("-s"): # scope
4754
4769
  t_scope = args[0][2:]
4755
4770
 
@@ -4765,6 +4780,8 @@ async def next_cmd(mc, cmds, json_output=False, sink=sys.stdout, end="\n"):
4765
4780
  timer["contact"] = t_contact
4766
4781
  timer["json"] = t_json
4767
4782
  timer["exec"] = t_exec
4783
+ timer["stream"] = t_stream
4784
+ timer["fin"] = t_fin
4768
4785
  timer["count"] = t_count
4769
4786
  timer["remaining"] = t_count
4770
4787
  timer["task"] = asyncio.create_task(run_timer(mc, timer))
@@ -4967,6 +4984,7 @@ def command_usage() :
4967
4984
  -a <address> : specifies device address (can be a name)
4968
4985
  -d <name> : filter meshcore devices with name or address
4969
4986
  -P : forces pairing via the OS
4987
+ --pin <pin> : forces pairing via the OS using this pin
4970
4988
  -t <hostname> : connects via tcp/ip
4971
4989
  -p <port> : specifies tcp port (default 5000)
4972
4990
  -s <port>[:opts]: use serial port <port>
@@ -5323,7 +5341,7 @@ meshcore-cli lets you attach shell process to msg rx_log chan_data or telemetry
5323
5341
  """)
5324
5342
 
5325
5343
  elif "timer" in cmdname:
5326
- print("""timer [-j] [-x] [-n<count>] [-c<contact>] [-s<scope>] <s> <line>: runs line every s seconds (s can be postfixed with s, m, h or d)
5344
+ print("""timer [-j] [-x] [-n<count>] [-c<contact>] [-s<scope>] [-u] [-f] <s> <line>: runs line every s seconds (s can be postfixed with s, m, h or d)
5327
5345
 
5328
5346
  * args:
5329
5347
  - `-j` forces json output for the timed line.
@@ -5331,7 +5349,8 @@ meshcore-cli lets you attach shell process to msg rx_log chan_data or telemetry
5331
5349
  - `-n` runs the line `count` times, then disarms the timer (default: runs until cancelled).
5332
5350
  - `-c` sets the contact the line is run from (`~` for root).
5333
5351
  - `-s` sets the scope for the line, defaults to the current scope.
5334
-
5352
+ - `-u` will execute the command unbuffered in case of redirection (buffering is necessary to easily print output above prompt).
5353
+ - `-f` prints a message when the timer has finished.
5335
5354
  * `timer_cancel <n>` cancels timer number `n`
5336
5355
  * `timers` lists current timers
5337
5356
 
@@ -5870,7 +5889,7 @@ async def main(argv):
5870
5889
  address = f.readline().strip()
5871
5890
 
5872
5891
  try:
5873
- opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:fjDhvSlT:Pc:Crqi")
5892
+ opts, args = getopt.getopt(argv, "a:d:s:ht:p:b:fjDhvSlT:Pc:Crqi", ["pin="])
5874
5893
  except getopt.GetoptError:
5875
5894
  print("Unrecognized option, use -h to get more help")
5876
5895
  command_usage()
@@ -5892,6 +5911,8 @@ async def main(argv):
5892
5911
  address = arg
5893
5912
  case "-P" : # pairing
5894
5913
  pin = True
5914
+ case "--pin" : # pairing with a given pin
5915
+ pin = arg
5895
5916
  case "-s" : # serial port
5896
5917
  if ":" in arg:
5897
5918
  serial_opts=arg.split(":",1)[1].split(',')
File without changes
File without changes
File without changes
File without changes