def push(): """ Build docs and zip for upload to RTD """ build(clean='yes') v = get_version('short') local("cd docs/_build/html && zip -r ../%s.zip ." % v)
def check_settings(): """ Validate the users settings conf prior to deploy. """ valid = True if not get_version() >= '1.0': print "FABRIC ERROR: Woven is only compatible with Fabric < 1.0" valid = False if not env.MEDIA_ROOT or not env.MEDIA_URL: print "MEDIA ERROR: You must define a MEDIA_ROOT & MEDIA_URL " \ "in your settings.py" print "even if plan to deploy your media separately to your project" valid = False if not env.TEMPLATE_DIRS: print "TEMPLATES_DIRS ERROR: You must define a TEMPLATES_DIRS " \ "in your settings.py" valid = False if env.DEFAULT_DATABASE_ENGINE in [ 'django.db.backends.', 'django.db.backends.dummy', ]: print "DATABASE SETTINGS ERROR: The default database engine " \ "has not been defined in your settings.py file" print "At a minimum you must define an sqlite3 database for " \ "woven to deploy," print "or define a database backend is managed outside of woven." valid = False if not valid: sys.exit(1)
#!/usr/bin/env python import sys from setuptools import setup, find_packages from fabric.version import get_version readme = open('README').read() v = get_version('short') long_description = """ To find out what's new in this version of Fabric, please see `the changelog <http://docs.fabfile.org/en/%s/changelog.html>`_. You can also install the `in-development version <https://github.com/fabric/fabric/tarball/master#egg=fabric-dev>`_ using pip, with `pip install fabric==dev`. ---- %s ---- For more information, please see the Fabric website or execute ``fab --help``. """ % (v, readme) setup( name='Fabric',
year = datetime.now().year copyright = u'%d, Christian Vest Hansen and Jeffrey E. Forcier' % year # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # Add this checkout's local Fabric module to sys.path. Allows use of # fabric.version in here, and ensures that the autodoc stuff also works. sys.path.insert(0, os.path.abspath(os.path.join(os.getcwd(), '..'))) from fabric.version import get_version # Get version info # # Branch-only name version = get_version('branch') # The full human readable version, including alpha/beta/rc tags. release = get_version('normal') # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call. #today_fmt = '%B %d, %Y' # List of documents that shouldn't be included in the build.
'passwords': {}, 'path': '', 'path_behavior': 'append', 'port': None, 'real_fabfile': None, 'roles': [], 'roledefs': {}, 'skip_bad_hosts': False, # -S so sudo accepts passwd via stdin, -p with our known-value prompt for # later detection (thus %s -- gets filled with env.sudo_prompt at runtime) 'sudo_prefix': "sudo -S -p '%s' ", 'sudo_prompt': 'sudo password:'******'use_exceptions_for': {'network': False}, 'use_shell': True, 'user': None, 'version': get_version('short') }) # Fill in exceptions settings exceptions = ['network'] exception_dict = {} for e in exceptions: exception_dict[e] = False env.use_exceptions_for = _AliasDict(exception_dict, aliases={'everything': exceptions}) # Add in option defaults for option in env_options: env[option.dest] = option.default
] # # Environment dictionary - actual dictionary object # # Global environment dict. Currently a catchall for everything: config settings # such as global deep/broad mode, host lists, username etc. # Most default values are specified in `env_options` above, in the interests of # preserving DRY. env = _AttributeDict({ # Version number for --version 'version': get_version(), 'sudo_prompt': 'sudo password:'******'again_prompt': 'Sorry, try again.\n', 'use_shell': True, 'roledefs': {}, 'cwd': '' }) # Add in option defaults for option in env_options: env[option.dest] = option.default # # Command dictionary #
long_description = """ To find out what's new in this version of Fabric, please see `the changelog <http://docs.fabfile.org/changes/%s.html>`_. You can also install the `in-development version <https://github.com/bitprophet/fabric/tarball/master#egg=fabric-dev>`_ using pip, with `pip install fabric==dev`. ---- %s ---- For more information, please see the Fabric website or execute ``fab --help``. """ % (get_version('short'), readme) setup( name='Fabric', version=get_version('short'), description='Fabric is a simple, Pythonic tool for remote execution and deployment.', long_description=long_description, author='Jeff Forcier', author_email='*****@*****.**', url='http://fabfile.org', packages=find_packages(), test_suite='nose.collector', tests_require=['nose', 'fudge'], install_requires=['pycrypto >= 1.9', 'paramiko >=1.7.6'], entry_points={ 'console_scripts': [
copyright = u'2009, Christian Vest Hansen and Jeffrey E. Forcier' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # Preserve original path oldpath = sys.path[:] # Nab path containing 'fabric' checkout sys.path.insert(0, os.path.abspath(os.path.join('..', '..', __file__))) # Import from fabric.version import get_version # Get version info # # The short X.Y version. version = get_version(line_only=True) # The full version, including alpha/beta/rc tags. release = get_version(verbose=True) # Restore old path sys.path = oldpath[:] # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. #language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: #today = '' # Else, today_fmt is used as the format for a strftime call.
def deploy(self,patch=False): """ Deploy your project """ if not self.local_path: if env.verbosity: print "Warning: No %s set in project settings. Skipping %s..."% (self.setting,self.deploy_type) return False if self.installed and not patch and self.versioned: if env.verbosity: print env.host,"Warning: %s version %s already deployed. Skipping..."% (self.deploy_type,self.fullname) return False elif not self.installed and not patch: run('mkdir -p '+self.deploy_root) #Webserver must be able to write into the public directory in the case of fileuploads #TODO - Make this optional?? if self.deploy_type == 'public': sudo("chown -R www-data:sudo %s" % self.deploy_root[:-1]) #strip trailing / sudo("chmod -R ug+w %s"% self.deploy_root[:-1]) elif not self.installed and patch and self.versioned: if env.verbosity: print env.host,"Warning: Cannot patch %s. This version %s does not exist. Skipping.."% (self.deploy_type,self.fullname) return False l = local('ls '+self.local_path).rstrip() if not l: if env.verbosity: print "Warning: Theres are no files to deploy for %s. Skipping.."% self.deploy_type return False #bug in fabric 0.9 on rsync on alternate port fixed in 1.0 fab_vers = int(get_version(form='short')[0]) if fab_vers < 1: extra_opts = '--rsh="ssh -p%s"'% env.port #to save a bit of network usage if there is an existing version we will copy that first if self.versioned: av = active_version() if av and not patch: delete=True av_root = self.deploy_root.replace(self.fullname,av) dest_root = self.deploy_root.replace(self.deploy_type+'/','') run('cp -R %s %s'% (av_root,dest_root)) elif patch: delete=False else: delete=True else: delete = False if self.dest_path_postfix: self.last_postfix = self.dest_path_postfix.split('/')[-2] #since -1 will be trailing slash and thus empty postfix = self.dest_path_postfix.replace(self.last_postfix+'/','') remote_dir = self.deploy_root[:-1]+postfix run('mkdir -p '+remote_dir) else: self.last_postfix = self.deploy_type remote_dir = env.deployment_root+'/'.join(['env',self.fullname]) staging_dir = self.stage_local_files() rsync_project(local_dir=os.path.join(staging_dir,self.last_postfix),remote_dir=remote_dir, extra_opts=extra_opts,exclude=self.rsync_exclude,delete=delete) #delete orphaned .pyc - specific to projects & remove 'woven' from installed apps if self.deploy_type == 'project': run("find %s -name '*.pyc' -delete"% self.deploy_root) set_server_state(self.state+self.fullname) if env.verbosity: if patch: print env.host,"PATCHED %s "% (self.deploy_type) else: print env.host,"DEPLOYED %s "% (self.deploy_type)
"port": default_port, "real_fabfile": None, "roles": [], "roledefs": {}, "skip_bad_hosts": False, "ssh_config_path": default_ssh_config_path, # -S so sudo accepts passwd via stdin, -p with our known-value prompt for # later detection (thus %s -- gets filled with env.sudo_prompt at runtime) "sudo_prefix": "sudo -S -p '%(sudo_prompt)s' ", "sudo_prompt": "sudo password:"******"sudo_user": None, "use_exceptions_for": {"network": False}, "use_shell": True, "use_ssh_config": False, "user": None, "version": get_version("short"), } ) # Fill in exceptions settings exceptions = ["network"] exception_dict = {} for e in exceptions: exception_dict[e] = False env.use_exceptions_for = _AliasDict(exception_dict, aliases={"everything": exceptions}) # Add in option defaults for option in env_options: env[option.dest] = option.default
def deploy_files(local_dir, remote_dir, pattern = '',rsync_exclude=['*.pyc','.*'], use_sudo=False): """ Generic deploy function for cases where one or more files are being deployed to a host. Wraps around ``rsync_project`` and stages files locally and/or remotely for network efficiency. ``local_dir`` is the directory that will be deployed. ``remote_dir`` is the directory the files will be deployed to. Directories will be created if necessary. Note: Unlike other ways of deploying files, all files under local_dir will be deployed into remote_dir. This is the equivalent to cp -R local_dir/* remote_dir. ``pattern`` finds all the pathnames matching a specified glob pattern relative to the local_dir according to the rules used by the Unix shell. ``pattern`` enhances the basic functionality by allowing the python | to include multiple patterns. eg '*.txt|Django*' ``rsync_exclude`` as per ``rsync_project`` Returns a list of directories and files created on the host. """ #normalise paths if local_dir[-1] == os.sep: local_dir = local_dir[:-1] if remote_dir[-1] == '/': remote_dir = remote_dir[:-1] created_list = [] staging_dir = local_dir #resolve pattern into a dir:filename dict local_files = _get_local_files(local_dir,pattern) #If we are only copying specific files or rendering templates we need to stage locally if local_files: staging_dir = _stage_local_files(local_dir, local_files) remote_staging_dir = '/home/%s/.staging'% env.user if not exists(remote_staging_dir): run(' '.join(['mkdir -pv',remote_staging_dir])).split('\n') created_list = [remote_staging_dir] #bug in fabric 0.9 on rsync on alternate port fixed in 1.0 fab_vers = int(get_version(form='short')[0]) if fab_vers < 1: extra_opts = '--rsh="ssh -p%s"'% env.port else: extra_opts = None #upload into remote staging rsync_project(local_dir=staging_dir,remote_dir=remote_staging_dir,extra_opts=extra_opts,exclude=rsync_exclude,delete=True) #create the final destination created_dir_list = mkdirs(remote_dir, use_sudo) func = use_sudo and sudo or run #cp recursively -R from the staging to the destination and keep a list remote_base_path = '/'.join([remote_staging_dir,os.path.basename(local_dir),'*']) copy_file_list = func(' '.join(['cp -Ruv',remote_base_path,remote_dir])).split('\n') if copy_file_list[0]: created_list += [file.split(' ')[2][1:-1] for file in copy_file_list if file] #cleanup any tmp staging dir if staging_dir <> local_dir: shutil.rmtree(staging_dir,ignore_errors=True) return created_list
#!/usr/bin/env python import sys from setuptools import setup, find_packages from fabric.version import get_version readme = open("README").read() v = get_version("short") long_description = """ To find out what's new in this version of Fabric, please see `the changelog <http://docs.fabfile.org/en/%s/changelog.html>`_. You can also install the `in-development version <https://github.com/fabric/fabric/tarball/master#egg=fabric-dev>`_ using pip, with `pip install fabric==dev`. ---- %s ---- For more information, please see the Fabric website or execute ``fab --help``. """ % ( v, readme, )
#!/usr/bin/env python from setuptools import setup, find_packages from fabric.version import get_version setup( name='Fabric', version=get_version(), description='Fabric is a simple, Pythonic tool for remote execution and deployment.', long_description=open('README').read() + """ For more information, please see the Fabric website or execute ``fab --help``. """, author='Jeff Forcier', author_email='*****@*****.**', url='http://fabfile.org', packages=find_packages(), install_requires=['pycrypto >=1.9'], entry_points={ 'console_scripts': [ 'fab = fabric.main:main', ] }, classifiers=[ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: BSD License', 'Operating System :: MacOS :: MacOS X',
%s ---- For more information, please see the Fabric website or execute ``fab --help``. """ % (readme) if sys.version_info[:2] < (2, 6): install_requires = ['paramiko>=1.10,<1.13'] else: install_requires = ['paramiko>=1.10,<2.0'] setup( name='Fabric', version=get_version('short'), description= 'Fabric is a simple, Pythonic tool for remote execution and deployment.', long_description=long_description, author='Jeff Forcier', author_email='*****@*****.**', url='http://fabfile.org', packages=find_packages(), test_suite='nose.collector', tests_require=['nose', 'fudge<1.0', 'jinja2'], install_requires=install_requires, entry_points={'console_scripts': [ 'fab = fabric.main:main', ]}, classifiers=[ 'Development Status :: 5 - Production/Stable',
'path_behavior': 'append', 'port': None, 'real_fabfile': None, 'roles': [], 'roledefs': {}, 'skip_bad_hosts': False, # -S so sudo accepts passwd via stdin, -p with our known-value prompt for # later detection (thus %s -- gets filled with env.sudo_prompt at runtime) 'sudo_prefix': "sudo -S -p '%s' ", 'sudo_prompt': 'sudo password:'******'use_exceptions_for': { 'network': False }, 'use_shell': True, 'user': None, 'version': get_version('short') }) # Fill in exceptions settings exceptions = ['network'] exception_dict = {} for e in exceptions: exception_dict[e] = False env.use_exceptions_for = _AliasDict(exception_dict, aliases={'everything': exceptions}) # Add in option defaults for option in env_options: env[option.dest] = option.default #
local('git submodule update --init --recursive') fuller_log = local('git log -n1 --pretty=fuller', capture=True) hist.log_latest(repo_url, refspec, repo_dir, fuller_log) if repo_dir in local_clones: del local_clones[repo_dir] # delete all undocumented local clones for lc in local_clones.keys(): with lcd(clone_basepath_local): local('rm -rf %s' % lc) if save_history: cuisine.file_write(remote_hist_path, hist.dump()) if( get_version() >= '1.6.2' ): # signature changed in this version passwrd = get_password( user, host, port ) else: passwrd = get_password() prompts = [ 'Are you sure you want to continue connecting', ".* password:"******"-p %s" % port hostcheck_string = "-o StrictHostKeyChecking=%s" % ('yes' if check_hostkey else 'no') gateway_string = "" if not env.gateway else "%s ssh" % env.gateway rsh_parts = [ port_string, hostcheck_string, gateway_string ] rsh_string = "--rsh='ssh %s'" % " ".join(rsh_parts) user_at_host = "%s@%s" % (user, host)