コード例 #1
0
    def handle(self, *args, **options):

        self.style = no_style()
        #manage.py execution specific variables
        #verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything except debug
        state.env.verbosity = int(options.get('verbosity', 1))

        #show_traceback = options.get('traceback', False)
        set_env.no_domain = True
        state.env.INTERACTIVE = options.get('interactive')
        if int(state.env.verbosity) < 2:
            with hide('warnings', 'running', 'stdout', 'stderr'):
                set_env()
        else:
            set_env()
        if not state.env.PIP_REQUIREMENTS: req_files = glob('req*')
        else: req_files = state.env.PIP_REQUIREMENTS
        dist_dir = os.path.join(os.getcwd(), 'dist')
        if not os.path.exists(dist_dir):
            os.mkdir(dist_dir)
        for r in req_files:
            bundle = ''.join([r.split('.')[0], '.zip'])
            command = 'pip bundle -r %s %s/%s' % (r, dist_dir, bundle)
            if state.env.verbosity: print command
            if int(state.env.verbosity) < 2:
                with hide('warnings', 'running', 'stdout', 'stderr'):
                    local(command)
            else:
                local(command)
コード例 #2
0
ファイル: bundle.py プロジェクト: depleater/woven
    def handle(self, *args, **options):

        self.style = no_style()
        # manage.py execution specific variables verbosity
        # 0 = No output at all,
        # 1 = woven output only,
        # 2 = Fabric outputlevel = everything except debug.
        state.env.verbosity = int(options.get('verbosity', 1))

        # show_traceback = options.get('traceback', False)
        set_env.no_domain = True
        state.env.INTERACTIVE = options.get('interactive')
        if int(state.env.verbosity) < 2:
            with hide('warnings', 'running', 'stdout', 'stderr'):
                set_env()
        else:
            set_env()
        if not state.env.PIP_REQUIREMENTS:
            req_files = glob('req*')
        else:
            req_files = state.env.PIP_REQUIREMENTS
        dist_dir = os.path.join(os.getcwd(), 'dist')
        if not os.path.exists(dist_dir):
            os.mkdir(dist_dir)
        for r in req_files:
            bundle = ''.join([r.split('.')[0], '.zip'])
            command = 'pip bundle -r %s %s/%s' % (r, dist_dir, bundle)
            if state.env.verbosity:
                print command
            if int(state.env.verbosity) < 2:
                with hide('warnings', 'running', 'stdout', 'stderr'):
                    local(command)
            else:
                local(command)
コード例 #3
0
ファイル: base.py プロジェクト: aweakley/woven
    def handle(self, *args, **options):
        """
        Initializes the fabric environment
        """
        self.style = no_style()
        #manage.py execution specific variables
        #verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything except debug
        state.env.verbosity = int(options.get('verbosity', 1))

        #show_traceback = options.get('traceback', False)
        state.env.INTERACTIVE = options.get('interactive')
        
        #Fabric options
        #Django passes in a dictionary instead of the optparse options objects
        for option in options:
            state.env[option] = options[option]
       
        #args will be tuple. We convert it to a comma separated string for fabric
        #if a role is used then we lookup the host list from the ROLEDEFS setting
        
        if args:
            comma_hosts = self.parse_host_args(*args)
            if hasattr(settings,'ROLEDEFS') and settings.ROLEDEFS: 
                all_role_hosts = []
                normalized_host_list = comma_hosts.split(',')
                for r in normalized_host_list:
                    role_host = settings.ROLEDEFS.get(r,'')
                    if role_host:
                        all_role_hosts+=role_host
                        state.env['roles'] = state.env['roles'] + [r]
                if all_role_hosts: comma_hosts = ','.join(all_role_hosts)
            if comma_hosts:
                state.env.hosts = comma_hosts
        if 'hosts' in state.env and isinstance(state.env['hosts'], str):
            state.env['hosts'] = state.env['hosts'].split(',')
        elif hasattr(settings,'HOSTS') and settings.HOSTS:
            state.env['hosts'] = settings.HOSTS
        else:
            print "Error: You must include a host or role in the command line or set HOSTS or ROLEDEFS in your settings file"
            sys.exit(1)
            
        #This next section is taken pretty much verbatim from fabric.main
        #so we follow an almost identical but more limited execution strategy
        
        #We now need to load django project woven settings into env
        #This is the equivalent to module level execution of the fabfile.py.
        #If we were using a fabfile.py then we would include set_env()

        if int(state.env.verbosity) < 2:
            with hide('warnings', 'running', 'stdout', 'stderr'):
                set_env(settings,state.env.setup)
        else: set_env(settings,state.env.setup)
        
        #Back to the standard execution strategy
        # Set current command name (used for some error messages)
        #state.env.command = self.name
        # Set host list (also copy to env)
        state.env.all_hosts = hosts = state.env.hosts
        # If hosts found, execute the function on each host in turn
        for host in hosts:
            # Preserve user
            prev_user = state.env.user
            # Split host string and apply to env dict
            #TODO - This section is replaced by network.interpret_host_string in Fabric 1.0
            username, hostname, port = normalize(host)
            state.env.host_string = host
            state.env.host = hostname
            state.env.user = username
            state.env.port = port

            # Actually run command
            if int(state.env.verbosity) < 2:
                with hide('warnings', 'running', 'stdout', 'stderr'):
                    self.handle_host(*args, **options)
            else:
                self.handle_host(*args, **options)
            # Put old user back
            state.env.user = prev_user
コード例 #4
0
ファイル: fabfile.py プロジェクト: zbrdge/woven
from dep import test_dep_backup_file

#Set the environ for Django
settings_module = os.environ[
    'DJANGO_SETTINGS_MODULE'] = 'example_project.setting'

env.INTERACTIVE = False
#Normally you would run fab or manage.py under the setup.py path
#since we are testing outside the normal working directory we need to pass it in
setup_dir = os.path.join(
    os.path.split(os.path.realpath(__file__))[0], 'simplest_example')
sys.path.insert(0, setup_dir)

env.verbosity = 2
#Most high level api functions require set_env to set the necessary woven environment
set_env(setup_dir=setup_dir)


def _run_tests(key=''):
    #Get a list of functions from fabric
    tests = commands.keys()
    for t in tests:
        if key:
            test_prefix = 'test_' + key + '_'
        else:
            test_prefix = 'test_'
        if test_prefix in t and len(t) > 10:
            print string.upper(t)
            commands[t]()
            print string.upper(t), 'COMPLETE'
コード例 #5
0
ファイル: env.py プロジェクト: zbrdge/woven
def test_env_set_env():
    print "TEST SET ENV"
    set_env()
コード例 #6
0
ファイル: fabfile.py プロジェクト: depleater/woven
        'example_project.setting'

env.INTERACTIVE = False

# Normally you would run fab or manage.py under the setup.py path.
#
# Since we are testing outside the normal working directory we need to
# pass it in.
setup_dir = os.path.join(
        os.path.split(os.path.realpath(__file__))[0], 'simplest_example')
sys.path.insert(0, setup_dir)

env.verbosity = 2
# Most high level API functions require set_env to set the necessary
# woven environment.
set_env(setup_dir=setup_dir)


def _run_tests(key=''):
    # Get a list of functions from Fabric.
    tests = commands.keys()
    for t in tests:
        if key:
            test_prefix = 'test_' + key + '_'
        else:
            test_prefix = 'test_'
        if test_prefix in t and len(t) > 10:
            print string.upper(t)
            commands[t]()
            print string.upper(t), 'COMPLETE'
コード例 #7
0
ファイル: env.py プロジェクト: andreypaa/woven
def test_env_set_env():
    print "TEST SET ENV"
    set_env()
コード例 #8
0
ファイル: base.py プロジェクト: pombredanne/woven
    def handle(self, *args, **options):
        """
        Initializes the fabric environment
        """
        self.style = no_style()
        #manage.py execution specific variables
        #verbosity 0 = No output at all, 1 = woven output only, 2 = Fabric outputlevel = everything except debug
        state.env.verbosity = int(options.get('verbosity', 1))

        #show_traceback = options.get('traceback', False)
        state.env.INTERACTIVE = options.get('interactive')

        #Fabric options
        #Django passes in a dictionary instead of the optparse options objects
        for option in options:
            state.env[option] = options[option]

        #args will be tuple. We convert it to a comma separated string for fabric
        all_role_hosts = []

        if args:
            #subclasses can implement parse_host_args to strip out subcommands
            comma_hosts = self.parse_host_args(*args)
            normalized_host_list = comma_hosts.split(',')
            for r in normalized_host_list:
                #define a list of hosts for given roles
                if hasattr(settings, 'ROLEDEFS') and settings.ROLEDEFS.get(r):
                    all_role_hosts += settings.ROLEDEFS[r]
                    state.env['roles'] = state.env['roles'] + [r]
                #simple single host
                else:
                    all_role_hosts.append(r)

        #if no args are given we'll use either a 'default' roledef/role_node
        #or as last resort we'll use a simple HOSTS list
        elif hasattr(settings,
                     'ROLEDEFS') and settings.ROLEDEFS.get('default'):
            all_role_hosts = settings.ROLEDEFS['default']
            state.env['roles'] = ['default']
        elif hasattr(settings, 'HOSTS') and settings.HOSTS:
            all_role_hosts = settings.HOSTS
        else:
            print "Error: You must include a host or role in the command line or set HOSTS or ROLEDEFS in your settings file"
            sys.exit(1)
        state.env['hosts'] = all_role_hosts

        #This next section is taken pretty much verbatim from fabric.main
        #so we follow an almost identical but more limited execution strategy

        #We now need to load django project woven settings into env
        #This is the equivalent to module level execution of the fabfile.py.
        #If we were using a fabfile.py then we would include set_env()

        if int(state.env.verbosity) < 2:
            with hide('warnings', 'running', 'stdout', 'stderr'):
                set_env(settings, state.env.setup)
        else:
            set_env(settings, state.env.setup)

        #Back to the standard execution strategy
        # Set host list (also copy to env)
        state.env.all_hosts = hosts = state.env.hosts
        # If hosts found, execute the function on each host in turn
        for host in hosts:
            # Preserve user
            prev_user = state.env.user
            # Split host string and apply to env dict
            #TODO - This section is replaced by network.interpret_host_string in Fabric 1.0
            username, hostname, port = normalize(host)
            state.env.host_string = host
            state.env.host = hostname
            state.env.user = username
            state.env.port = port

            # Actually run command
            if int(state.env.verbosity) < 2:
                with hide('warnings', 'running', 'stdout', 'stderr'):
                    self.handle_host(*args, **options)
            else:
                self.handle_host(*args, **options)
            # Put old user back
            state.env.user = prev_user
コード例 #9
0
ファイル: base.py プロジェクト: depleater/woven
    def handle(self, *args, **options):
        """
        Initializes the fabric environment.
        """
        self.style = no_style()
        # manage.py execution specific variables.
        # verbosity:
        # 0 = No output at all,
        # 1 = woven output only,
        # 2 = Fabric outputlevel = everything except debug.
        state.env.verbosity = int(options.get('verbosity', 1))

        # Show_traceback = options.get('traceback', False).
        state.env.INTERACTIVE = options.get('interactive')

        # Fabric options.
        # Django passes in a dictionary instead of the optparse options
        # objects.
        for option in options:
            state.env[option] = options[option]

        # args will be tuple. We convert it to a comma separated string
        # for fabric.
        all_role_hosts = []

        if args:
            # Subclasses can implement parse_host_args to strip out
            # subcommands.
            comma_hosts = self.parse_host_args(*args)
            normalized_host_list = comma_hosts.split(',')
            for r in normalized_host_list:
                # Define a list of hosts for given roles.
                if hasattr(settings, 'ROLEDEFS') and settings.ROLEDEFS.get(r):
                    all_role_hosts += settings.ROLEDEFS[r]
                    state.env['roles'] = state.env['roles'] + [r]
                # Simple single host.
                else:
                    all_role_hosts.append(r)

        # If no args are given we'll use either a 'default'
        # roledef/role_node - or as last resort we'll use a simple
        # HOSTS list.
        elif (hasattr(settings, 'ROLEDEFS') and
                settings.ROLEDEFS.get('default')):
            all_role_hosts = settings.ROLEDEFS['default']
            state.env['roles'] = ['default']
        elif hasattr(settings, 'HOSTS') and settings.HOSTS:
            all_role_hosts = settings.HOSTS
        else:
            print "Error: You must include a host or role in the command " \
                "line or set HOSTS or ROLEDEFS in your settings file."
            sys.exit(1)
        state.env['hosts'] = all_role_hosts

        # This next section is taken pretty much verbatim from
        # fabric.main, so we follow an almost identical but more limited
        # execution strategy.

        # We now need to load django project woven settings into env.
        # This is the equivalent to module level execution of the fabfile.py.
        # If we were using a fabfile.py then we would include set_env().

        if int(state.env.verbosity) < 2:
            with hide('warnings', 'running', 'stdout', 'stderr'):
                set_env(settings, state.env.setup)
        else:
            set_env(settings, state.env.setup)

        # Back to the standard execution strategy.
        # Set host list (also copy to env).
        state.env.all_hosts = hosts = state.env.hosts
        # If hosts found, execute the function on each host in turn.
        for host in hosts:
            # Preserve user.
            prev_user = state.env.user
            # Split host string and apply to env dict.
            #
            # TODO: This section is replaced by
            # network.interpret_host_string.
            # in Fabric 1.0.
            username, hostname, port = normalize(host)
            state.env.host_string = host
            state.env.host = hostname
            state.env.user = username
            state.env.port = port

            # Actually run command.
            if int(state.env.verbosity) < 2:
                with hide('warnings', 'running', 'stdout', 'stderr'):
                    self.handle_host(*args, **options)
            else:
                self.handle_host(*args, **options)
            # Put old user back.
            state.env.user = prev_user