def reset_repository(repository_root): ''' Elimina las distribuciones existentes en un repositorio. ''' os.chdir(repository_root) dists = list_items(os.path.join(repository_root, 'dists'), True, False) for dist in dists: local("reprepro removefilter %s \'Section\'" % dist)
def push(message='updating...', branch='master', should_commit=True): """ push changes :param message :return: """ if should_commit is True: commit(message) local("git push -u origin %s" % branch)
def commit(message='updating...'): """ commit changes to staging area :param message: :return: """ local("git add --all") with settings(warn_only=True): result = local("git commit -m '%s'" % message, capture=True) if result.failed and not confirm("Tests failed. Continue anyway?"): abort("Aborting at your behest")
def include_deb(repository_root, distribution, comp = None, package_path = None): ''' Indexes a debian package (.deb) in the selected repository. :param repository_root: path of the repository used. :param distribution: distribution where the package will be indexed. :param package_path: Either the path of a single .deb package or a directory with many .deb packages. ''' # Esto puede ser un problema si despues se ejecuta otro proceso # sin especificar la ubicacion os.chdir(repository_root) if os.path.isdir(package_path): local("reprepro -C %s includedeb %s %s/*.deb" % (comp, distribution, package_path)) elif os.path.isfile(package_path): local('reprepro -C %s includedeb %s %s' % (comp, distribution, package_path))
def create_repository(repository_root, distributions_path): ''' Creates and initializes a packages repository from a `distributions` configuration file. :param repository_root: path where the repository will be created. :param distributions_path: path to the `distributions` configuration file. ''' conf_dir = os.path.join(repository_root, 'conf') dist_dst = os.path.join(conf_dir, 'distributions') if not os.path.isdir(repository_root): os.makedirs(conf_dir) shutil.copyfile(distributions_path, dist_dst) os.chdir(repository_root) local("reprepro -VVV export") with open(os.path.join(repository_root, 'distributions'), 'w') as f: for dist in list_items(os.path.join(repository_root, 'dists'), True, False): f.write('%s dists/%s/Release\n' % (dist, dist))
def documentation(): local("rm -Rf docs/modules/") local("rm -Rf docs/_build/html/") local( "DJANGO_SETTINGS_MODULE=sillywalks.settings ve/bin/sphinx-build -aE docs/ docs/_build/html/" ) print "View the documentation here: file://%s" % os.path.join( PROJECT_ROOT, 'docs', '_build', 'html', 'index.html')
def bootstrap(): # Create new virtual environment in a new location. We will atomically swap the current virtualenv with the new once at the end of this process. local("rm -Rf .ve~/") local('virtualenv .ve~') # hack activate so it uses project directory instead of ve in prompt local( 'sed \'s/(`basename \\\\"\\$VIRTUAL_ENV\\\\\"`)/(`basename \\\\`dirname \\\\"$VIRTUAL_ENV\\\\"\\\\``)/g\' .ve~/bin/activate > .ve~/bin/activate.tmp' ) local('mv .ve~/bin/activate.tmp .ve~/bin/activate') # PIP install requirements local( "pip install -I --source=.ve~/src/ --environment=.ve~/ -r REQUIREMENTS" ) # Cleanup pip install process local("rm -Rf build/") # Add local src folders to python path. local("echo '%s' >> .ve~/lib/%s/site-packages/easy-install.pth" % ('\n'.join([os.path.join(PROJECT_ROOT, x) for x in LOCAL_PACKAGES]), PY_VERSION)) # Apply patches. for patch in glob.glob( os.path.join(PROJECT_ROOT, 'dist', 'patches', '*.patch')): dirname, filename = os.path.split(patch) application_name = filename.split('.patch')[0] application_path = os.path.join(PROJECT_ROOT, '.ve~', 'src', application_name) if os.path.exists(application_path): print 'Patching %s...' % application_name local("cd %s; patch -p0 < %s" % (application_path, patch)) # Cleanup and .pyc files that got generated so that we do not have any corrupt pyc files hanging out with the .ve~ path. local("find .ve~/ -type f -name '*.pyc' -print0 | xargs -0 rm -f") # Prepare the temporary virtualenv to take the place of the primary virtualenv by replacing the paths local("find .ve~/ -type f -print0 | xargs -0 sed -i 's/\.ve~/ve/g'") # Atomically move the new virtualenv into place, and move the old virtualenv into a backup location. local("mv ve/ .ve.old~/ 2> /dev/null; mv .ve~/ ve/")
def documentation(): local("rm -Rf docs/modules/") local("rm -Rf docs/_build/html/") local("DJANGO_SETTINGS_MODULE=sillywalks.settings ve/bin/sphinx-build -aE docs/ docs/_build/html/") print "View the documentation here: file://%s" % os.path.join(PROJECT_ROOT, 'docs', '_build', 'html', 'index.html')
def bootstrap(): # Create new virtual environment in a new location. We will atomically swap the current virtualenv with the new once at the end of this process. local("rm -Rf .ve~/") local('virtualenv .ve~') # hack activate so it uses project directory instead of ve in prompt local('sed \'s/(`basename \\\\"\\$VIRTUAL_ENV\\\\\"`)/(`basename \\\\`dirname \\\\"$VIRTUAL_ENV\\\\"\\\\``)/g\' .ve~/bin/activate > .ve~/bin/activate.tmp') local('mv .ve~/bin/activate.tmp .ve~/bin/activate') # PIP install requirements local("pip install -I --source=.ve~/src/ --environment=.ve~/ -r REQUIREMENTS") # Cleanup pip install process local("rm -Rf build/") # Add local src folders to python path. local("echo '%s' >> .ve~/lib/%s/site-packages/easy-install.pth" % ('\n'.join([ os.path.join(PROJECT_ROOT, x) for x in LOCAL_PACKAGES ]), PY_VERSION)) # Apply patches. for patch in glob.glob(os.path.join(PROJECT_ROOT, 'dist', 'patches', '*.patch')): dirname, filename = os.path.split(patch) application_name = filename.split('.patch')[0] application_path = os.path.join(PROJECT_ROOT, '.ve~', 'src', application_name) if os.path.exists(application_path): print 'Patching %s...' % application_name local("cd %s; patch -p0 < %s" % (application_path, patch)) # Cleanup and .pyc files that got generated so that we do not have any corrupt pyc files hanging out with the .ve~ path. local("find .ve~/ -type f -name '*.pyc' -print0 | xargs -0 rm -f") # Prepare the temporary virtualenv to take the place of the primary virtualenv by replacing the paths local("find .ve~/ -type f -print0 | xargs -0 sed -i 's/\.ve~/ve/g'") # Atomically move the new virtualenv into place, and move the old virtualenv into a backup location. local("mv ve/ .ve.old~/ 2> /dev/null; mv .ve~/ ve/")
def serve(): local("python app.py")
def run(): """ run application """ local('nodemon app.js')
def pull(): """ update environment :return: """ local("git pull")
def bootstrap(): local("rm -Rf ve/") local('virtualenv ve') # hack activate so it uses project directory instead of ve in prompt local('sed \'s/(`basename \\\\"\\$VIRTUAL_ENV\\\\\"`)/(`basename \\\\`dirname \\\\"$VIRTUAL_ENV\\\\"\\\\``)/g\' ve/bin/activate > ve/bin/activate.tmp') local('mv ve/bin/activate.tmp ve/bin/activate') # PIP install requirements local("pip install -I --source=ve/src/ --environment=ve/ -r REQUIREMENTS") # Cleanup pip install process local("rm -Rf build/") # Add local src folders to python path. local("echo '%s' >> ve/lib/python2.5/site-packages/easy-install.pth" % PROJECT_ROOT)