# Path: provy/core/runner.py
# def run(provfile_path, server_name, password, extra_options):
#     module_name = provyfile_module_from(provfile_path)
#     prov = import_module(module_name)
#     servers = get_servers_for(prov, server_name)
# 
#     build_prompt_options(servers, extra_options)
# 
#     for server in servers:
#         provision_server(server, provfile_path, password, prov)
# 
# Path: provy/core/utils.py
# def provyfile_path_from(args):
#     if args:
#         path = args[0]
#         if not os.path.exists(path):
#             raise IOError('provy file "%s" does not exist.' % path)
#         if os.path.isabs(path):
#             raise ValueError('provy file "%s" is absolute. Please provide a path that is relative to the current working directory.')
#         return path
#     elif os.path.exists('provyfile.py'):
#         return 'provyfile.py'
#     elif os.path.exists('provy_file.py'):
#         return 'provy_file.py'
#     raise IOError('No provyfile was found. Please specify an existant provyfile path, or create either a "provyfile.py" or "provy_file.py"')


import sys
import os
import re
from os.path import exists, abspath, splitext
from optparse import OptionParser
from provy.core import run
from provy.core.utils import provyfile_path_from

    (options, args) = parser.parse_args()

    return (options, args)


def __get_provy_file_path(provyfile_name):
    path = abspath(provyfile_name)
    if not exists(path):
        return None
    return splitext(path.replace(abspath('.'), '').lstrip('/').rstrip('/'))[0]


def main():
    sys.path.insert(0, os.curdir)

    extra_options = __get_extra_options()
    (options, args) = __get_arguments()

    provyfile_path = provyfile_path_from(args)

    if options.server is None and provyfile_path:
        # TODO: Improve this code to 'find' the set of servers defined in the
        # provyfile and run with the defined server set (if only one is defined)
        print "\nInfo: Provy is running using the 'test' set of servers.\n"
        options.server = 'test'

    run(provyfile_path, options.server, options.password, extra_options)

if __name__ == '__main__':

# Path: provy/core/runner.py
# def run(provfile_path, server_name, password, extra_options):
#     module_name = provyfile_module_from(provfile_path)
#     prov = import_module(module_name)
#     servers = get_servers_for(prov, server_name)
# 
#     build_prompt_options(servers, extra_options)
# 
#     for server in servers:
#         provision_server(server, provfile_path, password, prov)
# 
# Path: provy/core/utils.py
# def provyfile_path_from(args):
#     if args:
#         path = args[0]
#         if not os.path.exists(path):
#             raise IOError('provy file "%s" does not exist.' % path)
#         if os.path.isabs(path):
#             raise ValueError('provy file "%s" is absolute. Please provide a path that is relative to the current working directory.')
#         return path
#     elif os.path.exists('provyfile.py'):
#         return 'provyfile.py'
#     elif os.path.exists('provy_file.py'):
#         return 'provy_file.py'
#     raise IOError('No provyfile was found. Please specify an existant provyfile path, or create either a "provyfile.py" or "provy_file.py"')


# Path: provy/console.py
import sys
import os
import re
from os.path import exists, abspath, splitext
from optparse import OptionParser
from provy.core import run
from provy.core.utils import provyfile_path_from


    (options, args) = parser.parse_args()

    return (options, args)


def __get_provy_file_path(provyfile_name):
    path = abspath(provyfile_name)
    if not exists(path):
        return None
    return splitext(path.replace(abspath('.'), '').lstrip('/').rstrip('/'))[0]


def main():
    sys.path.insert(0, os.curdir)

    extra_options = __get_extra_options()
    (options, args) = __get_arguments()

    provyfile_path = provyfile_path_from(args)

    if options.server is None and provyfile_path:
        # TODO: Improve this code to 'find' the set of servers defined in the
        # provyfile and run with the defined server set (if only one is defined)
        print "\nInfo: Provy is running using the 'test' set of servers.\n"
        options.server = 'test'

    run(provyfile_path, options.server, options.password, extra_options)

if __name__ == '__main__':

    main()