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

aafm quietly fails to work when dir names include some chars #69

Open
archont00 opened this issue Oct 15, 2016 · 4 comments
Open

aafm quietly fails to work when dir names include some chars #69

archont00 opened this issue Oct 15, 2016 · 4 comments

Comments

@archont00
Copy link

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!
@archont00 archont00 changed the title aafm fails to work when dir names includes spaces aafm quietly fails to work when dir names includes spaces Oct 15, 2016
@archont00 archont00 changed the title aafm quietly fails to work when dir names includes spaces aafm quietly fails to work when dir names include some chars Oct 15, 2016
@archont00
Copy link
Author

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.

@yeoweizheng
Copy link

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])

@xeruf
Copy link

xeruf commented Jun 18, 2018

Yei it works! Thanks!

@xeruf
Copy link

xeruf commented Jun 19, 2018

I have now incorporated these changes into my fork, also escaping other chars like &

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants