Fix FreeBSD ports install issue

Fixes the port install issue (#7691). Current method uses shell pipe and wc to count the number of packages found. This errors out because piping requires use_unsafe_shell set to true.

Changed to use python's string count to count for newline '\n'.

Tested on FreeBSD 10.0-Release.