<commit_before>import fabric.api

from fab_deploy.file import link, unlink
from fab_deploy.package import package_install, package_update
from fab_deploy.system import service
from fab_deploy.utils import detect_os

def _nginx_is_installed():
	with fabric.api.settings(fabric.api.hide('running','stdout','stderr'), warn_only=True):
		output = fabric.api.run('dpkg-query --show nginx')
	return output.succeeded

def nginx_install():
	""" Install nginx. """
	if _nginx_is_installed():
		fabric.api.warn(fabric.colors.yellow('Nginx is already installed'))
		return

	os = detect_os()
	options = {'lenny': '-t lenny-backports'}

	fabric.api.sudo('add-apt-repository ppa:nginx/stable')
	package_update()
	package_install(['nginx','libxml2','libxml2-dev'], options.get(os,''))
	#run('rm -f /etc/nginx/sites-enabled/default')

def nginx_setup():
	""" Setup nginx. """
	nginx_file = '/etc/nginx/nginx.conf'
	unlink(nginx_file,use_sudo=True)
	if fabric.contrib.files.exists(nginx_file):
		fabric.api.sudo('mv %s %s.bkp' % (nginx_file,nginx_file))
	else:
		link('/srv/active/deploy/nginx.conf',nginx_file,use_sudo=True)

def nginx_service(command):
	""" Run a nginx service """
	if not _nginx_is_installed():
		fabric.api.warn(fabric.colors.yellow('Nginx must be installed'))
		return

	service('nginx',command)
	nginx_message(command)

def nginx_start():
	""" Start Nginx """
	nginx_service('start')

def nginx_stop():
	""" Stop Nginx """
	nginx_service('stop')

def nginx_restart():<commit_msg>Fixed nginx setup.<commit_after>import fabric.api

from fab_deploy.file import link, unlink
from fab_deploy.package import package_install, package_update
from fab_deploy.system import service
from fab_deploy.utils import detect_os

def _nginx_is_installed():
	with fabric.api.settings(fabric.api.hide('running','stdout','stderr'), warn_only=True):
		output = fabric.api.run('dpkg-query --show nginx')
	return output.succeeded

def nginx_install():
	""" Install nginx. """
	if _nginx_is_installed():
		fabric.api.warn(fabric.colors.yellow('Nginx is already installed'))
		return

	os = detect_os()
	options = {'lenny': '-t lenny-backports'}

	fabric.api.sudo('add-apt-repository ppa:nginx/stable')
	package_update()
	package_install(['nginx','libxml2','libxml2-dev'], options.get(os,''))
	#run('rm -f /etc/nginx/sites-enabled/default')

def nginx_setup():
	""" Setup nginx. """
	nginx_file = '/etc/nginx/nginx.conf'
	unlink(nginx_file,use_sudo=True,silent=True)
	if fabric.contrib.files.exists(nginx_file):
		fabric.api.sudo('mv %s %s.bkp' % (nginx_file,nginx_file))
	link('/srv/active/deploy/nginx.conf',nginx_file,use_sudo=True)

def nginx_service(command):
	""" Run a nginx service """
	if not _nginx_is_installed():
		fabric.api.warn(fabric.colors.yellow('Nginx must be installed'))
		return

	service('nginx',command)
	nginx_message(command)

def nginx_start():
	""" Start Nginx """
	nginx_service('start')

def nginx_stop():
	""" Stop Nginx """
	nginx_service('stop')

def nginx_restart():
{'fraction_non_alphanumeric': 0.15699429721569944, 'fraction_numerical': 0.0013418316001341832, 'mean_word_length': 5.886836027713626, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6313463', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1056, 'n_words': 198}