aafm
aafm copied to clipboard
aafm quietly fails to work when dir names include some chars
Note that it fails quietly, which is pretty dangerous in case of copying whole directory structure. Due to this bug, such a directory appears empty even when there are files in it.
EXECUTE ('adb', '-s', '343637ff', 'shell', 'ls', '-l', '-a', '/mnt/sdcard/z_Various/AppsOther/swyping for AOSP keyboard/')
/mnt/sdcard/z_Various/AppsOther/swyping: No such file or directory wasn't matched, please report to the developer!
for: No such file or directory wasn't matched, please report to the developer!
AOSP: No such file or directory wasn't matched, please report to the developer!
keyboard/: No such file or directory wasn't matched, please report to the developer!
Okay, it fails to work also when other chars are in the file names: space, (, ), & and possibly others. When tested in CLI (bash) with back-slash escaping, then adb command works. Putting the path/file in single quotes is not enough.
I faced the same issue when accessing folders with special characters. A crude workaround would be to replace the shell arguments with back-slash escaping (for adb shell commands only, not for push/pull requests), and to add double-quotes around the path name. Modifying the execute
function in Aafm.py
to the following has worked so far for me:
def execute(self, *args):
args_list = list(args)
command = ""
is_file_transfer = False
for i in range(len(args_list)):
if args_list[i] == "push" or args_list[i] == "pull":
is_file_transfer = True
if args_list[i][0] == "/":
args_list[i] = r'"' + args_list[i] + r'"'
if is_file_transfer == False:
args_list[i] = args_list[i].replace(r" ",r"\ ")
args_list[i] = args_list[i].replace(r"'",r"\'")
command = command + args_list[i] + " "
print command
proc = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
return filter(None, [line.rstrip('\r\n') for line in proc.stdout])
Yei it works! Thanks!
I have now incorporated these changes into my fork, also escaping other chars like &