def test_integer(self): self.mkdir('foo', 'bar') open(self.tmppath('foo', 'baz'), 'w').close() # We probably aren't root... my_user = os.getuid() my_group = -1 chown_r(self.tmppath('foo'), my_user, my_group)
def django_prepare(self): log.debug('Running DjangoApp prepare hook') if self.config is None: raise Exception("Config hasn't been loaded yet") if self.template_exists('apache2/wsgi-handler.wsgi.template'): self.template( 'apache2/wsgi-handler.wsgi.template', self.deploy_path(self.app + '.wsgi')) aconf = self.config.get(self.app) uses_sqlite = aconf.get('db', {}).get('engine', '').endswith('sqlite3') data_dir = os.path.join(self.root, 'data') media_dir = os.path.join(self.root, 'data', 'media') if uses_sqlite or self.has_media: if not os.path.exists(data_dir): os.mkdir(data_dir) if self.has_media and not os.path.exists(media_dir): os.mkdir(media_dir) chown_r(data_dir, 'www-data', 'www-data') self.prepare_logfiles() if self.migrate_on_deploy: self.migrate() if self.has_static: self.manage_py('collectstatic', '--noinput') self.call_compress() if self.compile_i18n: self.manage_py('compilemessages')
def test_simple(self): self.mkdir('foo', 'bar') open(self.tmppath('foo', 'baz'), 'w').close() # We probably aren't root... my_user = pwd.getpwuid(os.getuid())[0] my_group = grp.getgrgid(os.getgid())[0] chown_r(self.tmppath('foo'), my_user, my_group)
def migrate(self): log.info('Running migrations on %s', self.app) if self.config is None: raise Exception("Config hasn't been loaded yet") data_dir = os.path.join(self.root, 'data') aconf = self.config.get(self.app) if 'db' not in aconf: return uses_sqlite = aconf.db.engine.endswith('sqlite3') new_db = False if uses_sqlite: if not os.path.exists(aconf.db.name): new_db = True self.run_migrate_commands() if new_db: seed_data = self.deploy_path(self.app, 'seed_data.json') if os.path.exists(seed_data): self.manage_py('loaddata', seed_data) if os.path.exists(data_dir): chown_r(data_dir, 'www-data', 'www-data')
def datadir_prepare(self): log.debug('Running DataDirApp prepare hook') if self.config is None: raise Exception("Config hasn't been loaded yet") if not os.path.exists(self.data_dir): os.mkdir(self.data_dir) chown_r(self.data_dir, 'www-data', 'www-data')
def prepare(self): super(Hooks, self).prepare() data_dir = os.path.join(self.root, 'data') webapp_dir = glob.glob(self.deploy_path('virtualenv', 'lib', 'python2.*', 'site-packages', 'graphite_web-*', 'webapp')) os.symlink(data_dir, self.deploy_path('storage')) os.symlink(webapp_dir[0], self.deploy_path('webapp')) os.symlink(self.deploy_path(self.app, 'conf'), self.deploy_path('conf')) log_dir = self.config.graphite.path.log_dir if not os.path.exists(log_dir): os.mkdir(log_dir) if not os.path.exists(os.path.join(log_dir, 'info.log')): touch(os.path.join(log_dir, 'info.log')) if not os.path.exists(os.path.join(log_dir, 'exception.log')): touch(os.path.join(log_dir, 'exception.log')) chown_r(log_dir, 'www-data', 'www-data')
def django_deployed(self): data_dir = os.path.join(self.root, 'data') if os.path.exists(data_dir): chown_r(data_dir, 'www-data', 'www-data')
def datadir_deployed(self): if os.path.exists(self.data_dir): chown_r(self.data_dir, 'www-data', 'www-data')