Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

don't try to connect_telnet on Windows when '-p COMx' is specified #232

Closed
wants to merge 18 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions rshell/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,10 @@ def add_arg(*args, **kwargs):

def connect(port, baud=115200, user='micro', password='python', wait=0):
"""Tries to connect automagically via network or serial."""
if '/' in port:
# serial port name format:
# - On Linux: /dev/ttyUSBxx
# - On Windows: COMx
if '/' in port or re.match("COM\\d+", port, re.IGNORECASE):
connect_serial(port, baud=baud, wait=wait)
else:
try:
Expand Down Expand Up @@ -2312,6 +2315,7 @@ def do_cp(self, line):
This will cause directories and their contents to be recursively
copied.
"""
QUIET or self.print(f"Executing 'cp {line}' ...")
args = self.line_to_args(line)
if len(args.filenames) < 2:
print_err('Missing destination file')
Expand Down Expand Up @@ -2366,20 +2370,24 @@ def do_cp(self, line):
print_err(err.format(dst_filename))
return

pf = lambda *args : None
if not QUIET:
pf = lambda *args: self.print(' ' + ' '.join(str(arg) for arg in args))
rsync(src_filename, dst_filename, mirror=False, dry_run=False,
print_func=lambda *args: None, recursed=False, sync_hidden=args.all)
print_func=pf, recursed=False, sync_hidden=args.all)
else:
print_err("Omitting directory {}".format(src_filename))
continue
if mode_isdir(dst_mode):
dst_filename = dst_dirname + '/' + os.path.basename(src_filename)
else:
dst_filename = dst_dirname
self.print("Copying '{}' to '{}' ...".format(src_filename, dst_filename))
self.print(" Copying '{}' to '{}' ...".format(src_filename, dst_filename))
if not cp(src_filename, dst_filename):
err = "Unable to copy '{}' to '{}'"
print_err(err.format(src_filename, dst_filename))
break
return
QUIET or self.print(f"Done.")

argparse_date = (
add_arg(
Expand Down Expand Up @@ -2858,6 +2866,7 @@ def do_rm(self, line):
any contents) -r must be specified.

"""
QUIET or self.print(f"Executing 'rm {line}' ...")
args = self.line_to_args(line)
filenames = args.filename
# Process PATTERN
Expand All @@ -2872,10 +2881,12 @@ def do_rm(self, line):

for filename in filenames:
filename = resolve_path(filename)
QUIET or self.print(f" Removing '{filename}' ...")
if not rm(filename, recursive=args.recursive, force=args.force):
if not args.force:
print_err("Unable to remove '{}'".format(filename))
break
return
QUIET or self.print(f"Done.")

def do_shell(self, line):
"""!some-shell-command args
Expand Down Expand Up @@ -2937,13 +2948,17 @@ def do_rsync(self, line):

Synchronizes a destination directory tree with a source directory tree.
"""
QUIET or self.print(f"Executing 'rsync {line}' ...")
args = self.line_to_args(line)
src_dir = resolve_path(args.src_dir)
dst_dir = resolve_path(args.dst_dir)
verbose = not args.quiet
pf = print if args.dry_run or verbose else lambda *args : None
pf = lambda *args : None
if args.dry_run or verbose:
pf = lambda *args: self.print(' ' + ' '.join(str(arg) for arg in args))
rsync(src_dir, dst_dir, mirror=args.mirror, dry_run=args.dry_run,
print_func=pf, recursed=False, sync_hidden=args.all)
QUIET or self.print(f"Done.")


def real_main():
Expand Down