Replace sys.exit() calls in tasks.py

Now just return the exit code from main() and only do sys.exit() when
tasks.py is called directly.
Don't support using tasks.py directly in the deploy directory

By simplifying the tasklib import statement.
Replace sys.exit() with raise XYZError in tasklib

Makes for cleaner code and easier testing.