Exemplo n.º 1
0
def diagnostics():
    results = {}
    results['enabled_trac'] = options.value('enabled_trac', 'no') != 'no'

    if not results['enabled_trac']:
        results['enabled_trac_label'] = 'disabled'
        results['trac_all_label'] = 'disabled'
        return results

    results['installed_trac'] = trac.has_trac_admin()

    results['trac_acl_hook'] = options.value('acl_hook', '') != ''
    results['trac_acl_hook_recommendation'] = ', '.join(generate_acl_list())
    results['trac_sync_access'] = True
    try:
        have_trac_sync_access()
    except SyncError as e:
        results['trac_sync_access'] = False
        results['trac_sync_access_msg'] = str(e)

    # don't check for existence, submin creates it as needed
    try:
        trac_dir = options.env_path('trac_dir')
    except UnknownKeyError:
        results['trac_dir_set'] = False
    else:
        results['trac_dir_set'] = True
        results['trac_dir'] = trac_dir

        envs = list(missing_config_envs(trac_dir))

        missing_config = [{
            'trac_env': x[0],
            'missing_configs': x[2]
        } for x in envs if x[1]]
        results['trac_envs_missing_config'] = missing_config
        results['trac_envs_complete'] = 0 == len(missing_config)

        # pre-fill label because add_labels cannot deal with this granularity
        for env in missing_config:
            for section in env['missing_configs']:
                for option in env['missing_configs'][section]:
                    if option['fatal']:
                        results['trac_envs_complete_label'] = 'fail'
                        break
                    results['trac_envs_complete_label'] = 'warn'

        orphaned = [x[0] for x in envs if not x[1]]
        results['trac_envs_orphaned'] = orphaned
        results['trac_envs_all_connected'] = 0 == len(orphaned)

    try:
        htpasswd_file = options.env_path("htpasswd_file")
        results['trac_htpasswd_file'] = htpasswd_file
        results['trac_htpasswd_dir_exists'] = os.path.exists(
            htpasswd_file.dirname())
        results['trac_htpasswd_dir'] = htpasswd_file.dirname()
    except UnknownKeyError:
        results['trac_htpasswd_file'] = ""

    results['trac_base_url'] = options.url_path('base_url_trac')

    return add_labels(results, 'trac_all', warnings, fails)
Exemplo n.º 2
0
	def testNotExists(self):
		options.set_value('env_path', '')
		exists = trac.has_trac_admin()
		self.assertEquals(exists, False)
Exemplo n.º 3
0
def exists():
    return trac.has_trac_admin()
Exemplo n.º 4
0
	def testExists(self):
		# Assumes trac-admin is actually installed, but since the rest of
		# the tests need trac-admin, this is not a big problem IMHO.
		# -- Michiel
		self.assertEquals(trac.has_trac_admin(), True)
Exemplo n.º 5
0
def diagnostics():
	results = {}
	results['enabled_trac'] = options.value('enabled_trac', 'no') != 'no'

	if not results['enabled_trac']:
		results['enabled_trac_label'] = 'disabled'
		results['trac_all_label'] = 'disabled'
		return results

	results['installed_trac'] = trac.has_trac_admin()

	results['trac_acl_hook'] = options.value('acl_hook', '') != ''
	results['trac_acl_hook_recommendation'] = ', '.join(generate_acl_list())
	results['trac_sync_access'] = True
	try:
		have_trac_sync_access()
	except SyncError as e:
		results['trac_sync_access'] = False
		results['trac_sync_access_msg' ] = str(e)

	# don't check for existence, submin creates it as needed
	try:
		trac_dir = options.env_path('trac_dir')
	except UnknownKeyError:
		results['trac_dir_set'] = False
	else:
		results['trac_dir_set'] = True
		results['trac_dir'] = trac_dir

		envs = list(missing_config_envs(trac_dir))

		missing_config = [
			{'trac_env': x[0], 'missing_configs': x[2]} for x in envs if x[1]
		]
		results['trac_envs_missing_config'] = missing_config
		results['trac_envs_complete'] = 0 == len(missing_config)

		# pre-fill label because add_labels cannot deal with this granularity
		for env in missing_config:
			for section in env['missing_configs']:
				for option in env['missing_configs'][section]:
					if option['fatal']:
						results['trac_envs_complete_label'] = 'fail'
						break
					results['trac_envs_complete_label'] = 'warn'

		orphaned = [x[0] for x in envs if not x[1]]
		results['trac_envs_orphaned'] = orphaned
		results['trac_envs_all_connected'] = 0 == len(orphaned)

	try:
		htpasswd_file = options.env_path("htpasswd_file")
		results['trac_htpasswd_file'] = htpasswd_file
		results['trac_htpasswd_dir_exists'] = os.path.exists(htpasswd_file.dirname())
		results['trac_htpasswd_dir'] = htpasswd_file.dirname()
	except UnknownKeyError:
		results['trac_htpasswd_file'] = ""

	results['trac_base_url'] = options.url_path('base_url_trac')
	
	return add_labels(results, 'trac_all', warnings, fails)
Exemplo n.º 6
0
def exists():
	return trac.has_trac_admin()
Exemplo n.º 7
0
 def testNotExists(self):
     options.set_value('env_path', '')
     exists = trac.has_trac_admin()
     self.assertEquals(exists, False)
Exemplo n.º 8
0
 def testExists(self):
     # Assumes trac-admin is actually installed, but since the rest of
     # the tests need trac-admin, this is not a big problem IMHO.
     # -- Michiel
     self.assertEquals(trac.has_trac_admin(), True)