def collectstatic(path, venv=False): with cd(path): if venv: with prefix(venv): try_to_execute('./manage.py collectstatic --noinput') else: try_to_execute('./manage.py collectstatic --noinput')
def configure(config_files, path): dist_files = get_dist_files(path) new_config_files = [] for f in dist_files: # copy dist file to installation sudo('cp %s %s' % (f, f.split('.dist')[0])) new_config_files.append(f.split('.dist')[0]) if not config_files: config_files = new_config_files old_config = False else: old_config = True for f in config_files: name = f.split('/')[-1] for d in dist_files: if name in d and old_config: # check if there are differences in between new # dist files and old ones try: run('diff %s %s.dist' % (d, f)) except: # if diff has an output same_dist = False else: same_dist = True if not same_dist: same_dist = confirm('Dist files differ. Apply old %s?' % ' '.join(config_files)) # copy file from previous installation if it exists # and the user tells you to (in case of differences) if same_dist and exists(f): warn('Copying old %s' % f.split('/')[-1]) sudo('cp %s %s' % (f, d.split('.dist')[0])) else: warn('Copying %s' % d) sudo('cp %s %s' % (d, d.split('.dist')[0])) for f in config_files: if not confirm( 'Please make sure %s is configured!' % d.split('.dist')[0]): return False with cd(path): while True: # we have to execute the following commands in order # to move on. In case they fail we have to do some more # editing in settings py probably. try: operations.try_to_execute('./manage.py syncdb --noinput') operations.try_to_execute('./manage.py migrate') operations.try_to_execute( './manage.py collectstatic --noinput') except Exception as e: if not confirm('%s. Retry?' % e): return False else: return True
def rollback_db(project_dir='/srv/', dump_path='/tmp/%s.sql' % project_name): config_files = get_dist_files('%s/%s/' % (project_dir, project_name)) db_settings = create_db_dict(config_files) database.recreate_mysql(db_settings) with cd('%s/%s/' % (project_dir, project_name)): operations.try_to_execute('./manage.py syncdb --noinput') operations.try_to_execute('./manage.py migrate') # translations operations.try_to_execute('./manage.py compilemessages') database.import_mysql(db_settings, dump_path)
def configure(config_files, path): dist_files = get_dist_files(path) new_config_files = [] for f in dist_files: # copy dist file to installation sudo('cp %s %s' % (f, f.split('.dist')[0])) new_config_files.append(f.split('.dist')[0]) if not config_files: config_files = new_config_files old_config = False else: old_config = True for f in config_files: name = f.split('/')[-1] for d in dist_files: if name in d and old_config: # check if there are differences in between new # dist files and old ones try: run('diff %s %s.dist' % (d, f)) except: # if diff has an output same_dist = False else: same_dist = True if not same_dist: same_dist = confirm('Dist files differ. Apply old %s?' % ' '.join(config_files)) # copy file from previous installation if it exists # and the user tells you to (in case of differences) if same_dist and exists(f): warn('Copying old %s' % f.split('/')[-1]) sudo('cp %s %s' % (f, d.split('.dist')[0])) else: warn('Copying %s' % d) sudo('cp %s %s' % (d, d.split('.dist')[0])) for f in config_files: if not confirm('Please make sure %s is configured!' % d.split('.dist')[0]): return False with cd(path): while True: # we have to execute the following commands in order # to move on. In case they fail we have to do some more # editing in settings py probably. try: operations.try_to_execute('./manage.py syncdb --noinput') operations.try_to_execute('./manage.py migrate') operations.try_to_execute('./manage.py collectstatic --noinput') except Exception as e: if not confirm('%s. Retry?' % e): return False else: return True