def synchronize(self, *args, **options): if REMOTE is None: # Because of BaseCommand bug (#18387, fixed in Django 1.5), we cannot use CommandError # in tests. Hence this hook. exception_class = options.get("exception_class", CommandError) raise exception_class("No REMOTE database specified in settings.") since = app_options.last_check last_time = datetime.now() logs = ChangeLog.objects.filter(date__gt=since).select_related().order_by("date", "pk") # Don't synchronize if object should be added/changed and later deleted; to_del = {} for log in logs: if log.action == DELETION: to_del[(log.content_type, log.object_id)] = log.date for log in logs: last_time = log.date del_time = to_del.get((log.content_type, log.object_id)) if last_time == del_time and log.action == DELETION: ACTIONS[log.action](log.content_type, log.object_id, log) # delete record so that next actions with the same time can be performed del to_del[(log.content_type, log.object_id)] if del_time is None or last_time > del_time: ACTIONS[log.action](log.content_type, log.object_id, log) if len(logs): app_options.last_check = last_time return _t("Synchronization performed successfully.") else: return _t("No changes since last synchronization.")
def clean(self): self.qtable_list = None if filter(None, [ not f.is_valid() for f in self.forms ]): return qt_by_name = { } # Dictionary of name -> [ QTable list ] n_display = 0 for form in self.forms: if form.cleaned_data['display']: n_display += 1 # Gather a list of QTables (qtable_list) involved, and check for naming collision if form.cleaned_data['source'] != 'table': continue curr = form.qtable qt_list = qt_by_name.get(curr.name, [ ]) for qt in qt_list: # Error if a table has alias but another doesn't. (Tables with the same name.) if bool(curr.alias) ^ bool(qt.alias): raise forms.ValidationError(_t('Ambiguous table "%(table)s" without alias') % {'table': qt.name}) if curr.alias == qt.alias: # Duplicate. Don't update. break else: qt_list.append(curr) qt_by_name[curr.name] = qt_list self.qtable_list = sum([ tbl_list for tbl_list in qt_by_name.values() ], [ ]) if not self.qtable_list: raise forms.ValidationError(_t('Not selecting from any table column')) if n_display == 0: raise forms.ValidationError(_t('Not displaying any selection'))
def add_arguments(self, parser): parser.add_argument("--dn", help=_t("Whether or not the user should be imported by " "distinguished name."), action="store_true", default=False) parser.add_argument("--sync-groups", help=_t("Sync groups of the users."), action="store_true", default=False) parser.add_argument("--server", help=_t("Server to connect to."), action="store", default=None)
def old(self): if delimiter.isdigit(): try: chr(int(delimiter)) return int(delimiter) except ValueError: raise forms.ValidationError(_t('Delimiter value must be smaller than 256.')) val = delimiter.decode('string_escape') if len(val) != 1: raise forms.ValidationError(_t('Delimiter must be exactly one character.')) return ord(val)
def _display_check(self): """Reconcile 'display' with 'source'""" src = self.cleaned_data.get('source') if not self.cleaned_data.get('display'): if src and src != 'table': raise forms.ValidationError(_t('Source must be "table" when not displaying column')) self.cleaned_data['source'] = 'table' if self.cleaned_data.get('col_alias'): raise forms.ValidationError(_t('Column alias not applicable when not displaying column')) else: if not src: raise forms.ValidationError(_t('Source value missing'))
def clean(self): if self.errors: return # Verify unary operators constraints check_right = True op = self.cleaned_data['op'] if op in common.RELATION_OPS_UNARY: if self.cleaned_data.get('r_source') or self.cleaned_data.get('r_cond'): raise forms.ValidationError(_t('Operator %(operator)s does not take the right operand') % {'operator': op}) check_right = False else: if not self.cleaned_data.get('l_source') or not self.cleaned_data.get('r_source'): raise forms.ValidationError(_t('Operator %(operator)s takes both operands') % {'operator': op}) # Verify the lhs values match the source l_source = self.cleaned_data['l_source'] l_constant = self.cleaned_data.get('l_constant') _field_source_check(l_source, _t('Constant (Left)'), l_constant, is_from_table=False) l_table = self.cleaned_data.get('l_table') _field_source_check(l_source, _t('Table (Left)'), l_table, is_from_table=True) l_col = self.cleaned_data.get('l_col') _field_source_check(l_source, _t('Column (Left)'), l_col, is_from_table=True) if check_right: # Verify the rhs values match the source r_source = self.cleaned_data['r_source'] r_constant = self.cleaned_data.get('r_constant') _field_source_check(r_source, _t('Constant (Right)'), r_constant, is_from_table=False) r_table = self.cleaned_data.get('r_table') _field_source_check(r_source, _t('Table (Right)'), r_table, is_from_table=True) r_col = self.cleaned_data.get('r_col') _field_source_check(r_source, _t('Column (Right)'), r_col, is_from_table=True) return self.cleaned_data
def _field_source_check(true_source, field_name, field_value, is_from_table): """ Some fields come from a table (is_from_table). And they should be specified iff the true_source (what the user selected) says "table". The same holds for constant source. This function verifies that constraint and would raise ValidationError. Returns whether this field is required. """ if bool(true_source == 'table') ^ bool(is_from_table): if field_value: raise forms.ValidationError(_t('%(field)s value not applicable with %(source)s source') % {'field': field_name, 'source': true_source}) return False elif not field_value: raise forms.ValidationError(_t('%(field)s value missing') % {'field': field_name}) return True
def clean(self): # ChoiceOrOtherField doesn't work with required=True delimiter = self.cleaned_data.get('delimiter') if not delimiter: raise forms.ValidationError(_t('Delimiter value is required.')) _clean_terminator(delimiter) return self.cleaned_data
def _extract_condition(union_mform, table_alias_dict): """ Extract LogicalUnion's from each form in union_mform, and recurse into the child union. Returns a LogicalUnion. """ global SUB_UNION_PREFIX if not union_mform.is_valid(): assert False, _t('UnionMultiForm is not valid') return None op = union_mform.bool.cleaned_data['bool'] res = report_gen.LogicalUnion(op) for cond_form in union_mform.conds.forms: res.add_cond(cond_form.get_boolean_condition(table_alias_dict)) n_children = union_mform.mgmt.form_counts() for i in range(0, n_children): child_name = '%s%d' % (SUB_UNION_PREFIX, i) try: sub_form = getattr(union_mform, child_name) res.add_subunion(_extract_condition(sub_form, table_alias_dict)) except AttributeError: LOG.debug('Subform not found: %s %s' % (union_mform, child_name)) continue return res
def add_arguments(self, parser): parser.add_argument("--dn", help=_t("Whether or not the user should be imported by " "distinguished name."), action="store_true", default=False) parser.add_argument("--import-members", help=_t("Import users from the group."), action="store_true", default=False) parser.add_argument("--import-members-recursive", help=_t("Import users from the group, but also do so recursively."), action="store_true", default=False) parser.add_argument("--sync-users", help=_t("Sync users in the group."), action="store_true", default=False) parser.add_argument("--server", help=_t("Server to connect to."), action="store", default=None)
def config_validator(user): res = [] yarn_cluster = cluster.get_cluster_conf_for_job_submission() if yarn_cluster.SECURITY_ENABLED.get() and not os.path.exists(SQOOP_CONF_DIR.get()): res.append((NICE_NAME, _t("The app won't work without a valid %s property.") % SQOOP_CONF_DIR.grab_key)) return res
def clean(self): if self.errors: return save = self.cleaned_data.get('save') name = self.cleaned_data.get('name') if save and len(name) == 0: # Bother with name iff we're saving raise forms.ValidationError(_t('Please enter a name')) return self.cleaned_data
def clean_target_table(self): tbl = self.cleaned_data.get('target_table') if tbl: try: db_utils.meta_client().get_table("default", tbl) raise forms.ValidationError(_t('Table already exists')) except hive_metastore.ttypes.NoSuchObjectException: pass return tbl
def check_hue_permission(self, perm=None, app=None, action=None): """ Raises a PopupException if permission is denied. Either perm or both app and action are required. """ if perm is None: perm = self._lookup_permission(app, action) if self.has_hue_permission(perm): return else: raise PopupException(_t("You do not have permissions to %(description)s.") % dict(description=perm.description))
def fixup_union(parent_mform, subform_name, data, is_root=False): """ Create child union mforms dynamically. Note that the parent_mform may be invalid. The parent_mform is a MultiForm, in which the subform_name is a UnionMultiForm we need to fix. This method performs this dynamic construction of the child UnionMultiForm. Note that it applies to existing child forms (i.e. the child form exists and the user is submitting the query), as well as a newly added child (i.e. the user just clicked 'ADD' to add a sub-condition). We figure out the number of children from the mgmt form. Note that this is actually a count of the number of children we have ever had. It is a max of the number of children, some of which may have been deleted. For each child <i>, our strategy is to test if 'sub<i>' exists in the POST data. If so, we create a sub-UnionMultiForm for that child. And we do it recursively. """ global SUB_UNION_PREFIX union_mform = getattr(parent_mform, subform_name) mgmt_form = union_mform.mgmt if not mgmt_form.is_valid(): raise forms.ValidationError(_t('Missing ManagementForm for conditions')) n_children = mgmt_form.form_counts() # This removes our current subform (union_mform) and any children. if mgmt_form.cleaned_data['remove']: parent_mform.remove_subform(subform_name) LOG.debug('Removed subform: %s' % (union_mform,)) # If we just removed the root union, add back an empty one. if is_root: parent_mform.add_subform('union', UnionMultiForm, data=None) LOG.debug('Adding root union back') return # Note that some of the n_children could be non-existent (i.e. deleted) for i in range(0, n_children): child_name = '%s%d' % (SUB_UNION_PREFIX, i) if not union_mform.has_subform_data(child_name, data): LOG.debug('Skipping over non-existent subform: %s %s' % (union_mform, child_name)) continue union_mform.add_subform(child_name, UnionMultiForm, data) LOG.debug('Instantiating subform: %s %s' % (union_mform, child_name)) # The child may have grand-children fixup_union(union_mform, child_name, data) if mgmt_form.cleaned_data['add']: id = mgmt_form.new_form_id() child_name = '%s%d' % (SUB_UNION_PREFIX, id) union_mform.add_subform(child_name, UnionMultiForm) LOG.debug('Added subform: %s %s' % (union_mform, child_name))
def __init__(self, table_obj, *args, **kwargs): """ @param table_obj is a hive_metastore.thrift Table object, used to add fields corresponding to partition keys. """ super(LoadDataForm, self).__init__(*args, **kwargs) self.partition_columns = dict() for i, column in enumerate(table_obj.partition_keys): # We give these numeric names because column names # may be unpleasantly arbitrary. name = "partition_%d" % i char_field = forms.CharField(required=True, label=_t("%(column_name)s (partition key with type %(column_type)s)") % {'column_name': column.name, 'column_type': column.type}) self.fields[name] = char_field self.partition_columns[name] = column.name
def _make_selection(self, table_alias_dict, is_left): if is_left: prefix = 'l_' else: prefix = 'r_' source = self.cleaned_data[prefix + 'source'] if source == 'table': table = self.cleaned_data[prefix + 'table'] col = self.cleaned_data[prefix + 'col'] try: return report_gen.ColumnSelection(table_alias_dict[table], col) except KeyError: raise forms.ValidationError(_t('Unknown table "%(table)s" in condition') % {'table': table}) constant = self.cleaned_data[prefix + 'constant'] return report_gen.ConstSelection(constant)
def clean(self): self.qtable = None self.selection = None self._display_check() if self.cleaned_data.get('sort') and not self.cleaned_data['sort_hql']: raise KeyError() # Verify that the 'source' field is consistent with the other fields source = self.cleaned_data.get('source') if not source: return None # No point since we can't get source constant_val = self.cleaned_data.get('constant') _field_source_check(source, _t('Constant'), constant_val, is_from_table=False) table_val = self.cleaned_data.get('table') _field_source_check(source, _t('From table'), table_val, is_from_table=True) col_val = self.cleaned_data.get('col') _field_source_check(source, _t('From column'), col_val, is_from_table=True) if self.cleaned_data.get('sort', '') and not self.cleaned_data.get('sort_order', ''): raise forms.ValidationError(_t('Sort order missing')) if table_val: # Column must belong to the table self.qtable = report_gen.QTable(table_val, self.cleaned_data.get('table_alias')) if col_val == '*': if self.cleaned_data.get('col_alias'): raise forms.ValidationError(_t('Alias not applicable for selecting "*"')) elif col_val not in self.qtable.get_columns(): raise forms.ValidationError(_t('Invalid column name "%(column)s"') % {'column': col_val}) # ColumnSelection object self.selection = report_gen.ColumnSelection(self.qtable, col_val, self.cleaned_data.get('col_alias')) else: # ConstSelection object self.selection = report_gen.ConstSelection(constant_val, self.cleaned_data.get('col_alias')) self.selection.distinct = self.cleaned_data.get('distinct', False) self.selection.set_aggregation(self.cleaned_data.get('agg', '')) if self.errors: delattr(self, 'selection') return self.cleaned_data
help_text=_t("Specify if column_type is char")) varchar_length = forms.IntegerField( required=False, initial=1, widget=NumberInput(attrs={ 'min': 1, 'max': 65355 }), validators=[MinValueValidator(1), MaxValueValidator(65355)], help_text=_t("Specify if column_is varchar")) ColumnTypeFormSet = simple_formset_factory(ColumnTypeForm, initial=[{}], add_label=_t("Add a column")) # Default to no partitions PartitionTypeFormSet = simple_formset_factory(PartitionTypeForm, add_label=_t("Add a partition")) def _clean_databasename(name): try: if name in db.get_databases(): # Will always fail raise forms.ValidationError( _('Database "%(name)s" already exists.') % {'name': name}) except Exception: return name class CreateDatabaseForm(DependencyAwareForm):
def __init__(self, *args, **kwargs): forms.Form.__init__(self, *args, **kwargs) self.fields['save'].label = _t('Save') self.fields['save'].widget.label = _('Save') self.fields['saveas'].label = _t('Save As') self.fields['saveas'].widget.label = _('Save As')
from desktop import appmanager from desktop.conf import is_oozie_enabled, has_connectors, is_cm_managed from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection, coerce_json_dict, coerce_bool, coerce_csv if sys.version_info[0] > 2: from django.utils.translation import gettext_lazy as _t, gettext as _ else: from django.utils.translation import ugettext_lazy as _t, ugettext as _ LOG = logging.getLogger(__name__) # Not used when connector are on INTERPRETERS_CACHE = None SHOW_NOTEBOOKS = Config(key="show_notebooks", help=_t("Show the notebook menu or not"), type=coerce_bool, default=True) def _remove_duplications(a_list): return list(OrderedDict.fromkeys(a_list)) def check_has_missing_permission(user, interpreter, user_apps=None): # TODO: port to cluster config if user_apps is None: user_apps = appmanager.get_apps_dict(user) # Expensive method return (interpreter == 'hive' and 'hive' not in user_apps) or \ (interpreter == 'impala' and 'impala' not in user_apps) or \ (interpreter == 'pig' and 'pig' not in user_apps) or \
import logging import os import sys from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import Config, validate_thrift_transport, coerce_bool from desktop.lib.exceptions import StructuredThriftTransportException LOG = logging.getLogger(__name__) HBASE_CLUSTERS = Config( key="hbase_clusters", default="(Cluster|localhost:9090)", help=_t("Comma-separated list of HBase Thrift servers for clusters in the format of '(name|host:port)'. Use full hostname with security." "Prefix hostname with https:// if using SSL and http mode with impersonation."), type=str ) TRUNCATE_LIMIT = Config( key="truncate_limit", default="500", help=_t("Hard limit of rows or columns per row fetched before truncating."), type=int ) THRIFT_TRANSPORT = Config( key="thrift_transport", default="buffered", help=_t("'buffered' is the default of the HBase Thrift Server and supports security. " + "'framed' can be used to chunk up responses, " +
class UserChangeForm(django.contrib.auth.forms.UserChangeForm): """ This is similar, but not quite the same as djagno.contrib.auth.forms.UserChangeForm and UserCreationForm. """ username = forms.RegexField( label=_t("Username"), max_length=30, regex='^%s$' % (get_username_re_rule(), ), help_text=_t( "Required. 30 characters or fewer. No whitespaces or colons."), error_messages={'invalid': _t("Whitespaces and ':' not allowed")}) password1 = forms.CharField(label=_t("Password"), widget=forms.PasswordInput, required=False, validators=get_password_validators()) password2 = forms.CharField(label=_t("Password confirmation"), widget=forms.PasswordInput, required=False, validators=get_password_validators()) password_old = forms.CharField(label=_t("Previous Password"), widget=forms.PasswordInput, required=False) ensure_home_directory = forms.BooleanField( label=_t("Create home directory"), help_text=_t("Create home directory if one doesn't already exist."), initial=True, required=False) class Meta(django.contrib.auth.forms.UserChangeForm.Meta): fields = [ "username", "first_name", "last_name", "email", "ensure_home_directory" ] def __init__(self, *args, **kwargs): super(UserChangeForm, self).__init__(*args, **kwargs) if self.instance.id: self.fields['username'].widget.attrs['readonly'] = True if desktop_conf.AUTH.BACKEND.get( ) == 'desktop.auth.backend.LdapBackend': self.fields['password1'].widget.attrs['readonly'] = True self.fields['password2'].widget.attrs['readonly'] = True self.fields['password_old'].widget.attrs['readonly'] = True def clean_password(self): return self.cleaned_data["password"] def clean_password2(self): password1 = self.cleaned_data.get("password1", "") password2 = self.cleaned_data["password2"] if password1 != password2: raise forms.ValidationError(_t("Passwords do not match.")) return password2 def clean_password1(self): password = self.cleaned_data.get("password1", "") if self.instance.id is None and password == "": raise forms.ValidationError( _("You must specify a password when creating a new user.")) return self.cleaned_data.get("password1", "") def clean_password_old(self): if self.instance.id is not None: password1 = self.cleaned_data.get("password1", "") password_old = self.cleaned_data.get("password_old", "") if password1 != '' and not self.instance.check_password( password_old): raise forms.ValidationError( _("The old password does not match the current password.")) return self.cleaned_data.get("password_old", "") def save(self, commit=True): """ Update password if it's set. """ user = super(UserChangeForm, self).save(commit=False) if self.cleaned_data["password1"]: user.set_password(self.cleaned_data["password1"]) if commit: user.save() # groups must be saved after the user self.save_m2m() return user
#!/usr/bin/env python # Licensed to Cloudera, Inc. under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. Cloudera, Inc. licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config SERVER_URL = Config( key="server_url", default='http://localhost:12000/sqoop', help=_t("The sqoop server URL."))
import sys from desktop.lib.conf import Config from liboozie.conf import get_oozie_status from pig.settings import NICE_NAME if sys.version_info[0] > 2: from django.utils.translation import gettext as _, gettext_lazy as _t else: from django.utils.translation import ugettext as _, ugettext_lazy as _t LOCAL_SAMPLE_DIR = Config( key="local_sample_dir", default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"), help=_t("Path to directory with piggybank.jar on local filesystem."), private=True) REMOTE_SAMPLE_DIR = Config( key="remote_data_dir", default="/user/hue/pig/examples", help=_t("Location on HDFS where the Pig examples are stored.")) def config_validator(user): res = [] if not 'test' in sys.argv: # Avoid tests hanging status = get_oozie_status(user) if 'NORMAL' not in status:
from django.utils.translation import ugettext_lazy as _t from desktop import appmanager from desktop.conf import is_hue4 from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection,\ coerce_json_dict, coerce_bool, coerce_csv def is_oozie_enabled(): """Oozie needs to be available as it is the backend.""" return len([app for app in appmanager.DESKTOP_MODULES if app.name == 'oozie']) > 0 and is_hue4() SHOW_NOTEBOOKS = Config( key="show_notebooks", help=_t("Show the notebook menu or not"), type=coerce_bool, default=True ) def _remove_duplications(a_list): return list(OrderedDict.fromkeys(a_list)) def get_ordered_interpreters(user=None): if not INTERPRETERS.get(): _default_interpreters(user) interpreters = INTERPRETERS.get() interpreters_shown_on_wheel = _remove_duplications(INTERPRETERS_SHOWN_ON_WHEEL.get())
class ImportWorkflowForm(WorkflowForm): definition_file = forms.FileField(label=_t("Local workflow.xml file")) resource_archive = forms.FileField( label=_t("Workflow resource archive (zip)"), required=False)
def clean_password2(self): password1 = self.cleaned_data.get("password1", "") password2 = self.cleaned_data["password2"] if password1 != password2: raise forms.ValidationError(_t("Passwords do not match.")) return password2
from builtins import str from past.utils import old_div import logging import os.path from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.conf import default_ssl_cacerts, default_ssl_validate, AUTH_PASSWORD as DEFAULT_AUTH_PASSWORD,\ AUTH_USERNAME as DEFAULT_AUTH_USERNAME from desktop.lib.conf import ConfigSection, Config, coerce_bool, coerce_csv, coerce_password_from_script LOG = logging.getLogger(__name__) HIVE_DISCOVERY_LLAP = Config( key="hive_discovery_llap", help=_t( "Have Hue determine Hive Server Interactive endpoint from zookeeper"), default="false", type=coerce_bool) HIVE_DISCOVERY_HS2 = Config( key="hive_discovery_hs2", help=_t( "Determines whether we pull a random HiveServer2 from the list in zookeeper. This HS2 instance is cached until hue is restarted." ), default="false", type=coerce_bool) HIVE_DISCOVERY_LLAP_HA = Config( key="hive_discovery_llap_ha", help=_t( "If you have more than one HSI server, it has a different znode setup. This will trigger the code to check for the Active HSI Server"
if clusters['default'].HOST_PORTS.get() != 'localhost:2181': return '%s/solr' % clusters['default'].HOST_PORTS.get() except: LOG.warn('Failed to get Zookeeper ensemble') try: from search.conf import SOLR_URL parsed = urlparse(SOLR_URL.get()) return "%s:2181/solr" % (parsed.hostname or 'localhost') except: LOG.warn('Failed to get Solr url') ENABLE_NEW_IMPORTER = Config( key="enable_new_importer", help=_t("Flag to turn on the new metadata importer."), type=bool, default=False) ENABLE_NEW_INDEXER = Config(key="enable_new_indexer", help=_t("Flag to turn on the new Solr indexer."), type=bool, default=True) CONFIG_INDEXER_LIBS_PATH = Config( key="config_indexer_libs_path", help=_t("oozie workspace template for indexing:"), type=str, default='/tmp/smart_indexer_lib') ENABLE_SQOOP = Config(key="enable_sqoop",
class UserProfile(models.Model): """ Extra settings / properties to store for each user. """ class CreationMethod(Enum): HUE = 1 EXTERNAL = 2 user = models.OneToOneField(User, on_delete=models.CASCADE, unique=True) home_directory = models.CharField(editable=True, max_length=1024, null=True) creation_method = models.CharField(editable=True, null=False, max_length=64, default=CreationMethod.HUE.name) first_login = models.BooleanField( default=True, verbose_name=_t('First Login'), help_text=_t('If this is users first login.')) last_activity = models.DateTimeField(auto_now=True, db_index=True) hostname = models.CharField(editable=True, max_length=255, null=True) json_data = models.TextField(default='{}') def get_groups(self): return self.user.groups.all() def _lookup_permission(self, app, action): # We cache it instead of doing HuePermission.objects.get(app=app, action=action). To revert with Django 1.6 perms = cache.get('perms') if not perms: perms = dict([('%s:%s' % (p.app, p.action), p) for p in HuePermission.objects.all()]) cache.set('perms', perms, 60 * 60) return perms.get('%s:%s' % (app, action)) def has_hue_permission(self, action=None, app=None, perm=None): if perm is None: try: perm = self._lookup_permission(app, action) except HuePermission.DoesNotExist: LOG.exception( "Permission object %s - %s not available. Was Django migrate command run after installation?" % (app, action)) return self.user.is_superuser if self.user.is_superuser: return True if ENABLE_CONNECTORS.get() and app in ('jobbrowser', 'metastore', 'filebrowser', 'indexer', 'useradmin', 'notebook'): if app == 'useradmin' and action in ( 'superuser', 'access_view:useradmin:edit_user'): # Not implemented yet return False else: return True group_ids = self.user.groups.values_list('id', flat=True) return GroupPermission.objects.filter(group__id__in=group_ids, hue_permission=perm).exists() def get_permissions(self): return HuePermission.objects.filter(groups__user=self.user) def check_hue_permission(self, perm=None, app=None, action=None): """ Raises a PopupException if permission is denied. Either perm or both app and action are required. """ if perm is None: perm = self._lookup_permission(app, action) if self.has_hue_permission(perm): return else: raise PopupException( _t("You do not have permissions to %(description)s.") % {'description': perm.description}) @property def data(self): if not self.json_data: self.json_data = json.dumps({}) return json.loads(self.json_data) def update_data(self, val): data_dict = self.data data_dict.update(val) self.json_data = json.dumps(data_dict)
def __init__(self, *args, **kwargs): super(LdapAuthenticationForm, self).__init__(*args, **kwargs) self.fields['server'] = ChoiceField(choices=get_server_choices()) self.error_messages['invalid_login'] = _t("Invalid username or password, or your LDAP groups not allowed")
def dict_list_map(value): if isinstance(value, str): d = {} for k, v in json.loads(value).iteritems(): d[k] = (v,) return d elif isinstance(value, dict): return value return None XMLSEC_BINARY = Config( key="xmlsec_binary", default="/usr/local/bin/xmlsec1", type=str, help=_t("Xmlsec1 binary path. This program should be executable by the user running Hue."), ) CREATE_USERS_ON_LOGIN = Config( key="create_users_on_login", default=True, type=coerce_bool, help=_t("Create users from IdP on login.") ) ATTRIBUTE_MAP_DIR = Config( key="attribute_map_dir", default=os.path.abspath(os.path.join(BASEDIR, "..", "..", "attribute-maps")), type=str, private=True, help=_t("Attribute map directory contains files that map SAML attributes to pysaml2 attributes."), ) ALLOW_UNSOLICITED = Config(
from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection, coerce_bool from desktop.appmanager import get_apps_dict from notebook.conf import get_ordered_interpreters def is_enabled(): """Automatic when search is enabled.""" apps = get_apps_dict() return 'search' in apps or HAS_SQL_ENABLED.get() IS_ENABLED = Config( key="is_enabled", help=_t("Activate the Dashboard link in the menu."), dynamic_default=is_enabled, type=coerce_bool ) HAS_SQL_ENABLED = Config( key="has_sql_enabled", help=_t("Activate the SQL Dashboard (beta)."), default=False, type=coerce_bool ) HAS_QUERY_BUILDER_ENABLED = Config( key="has_query_builder_enabled", help=_t("Activate the Query Builder (beta)."), default=False,
("column_type", "map", "map_key_type"), ("column_type", "map", "map_value_type"), ] column_name = common.HiveIdentifierField(label=_t('Column Name'), required=True) column_type = forms.ChoiceField(label=_t('Column Type'), required=True, choices=common.to_choices(HIVE_TYPES)) array_type = forms.ChoiceField(required=False, choices=common.to_choices(HIVE_PRIMITIVE_TYPES), label=_t("Array Value Type")) map_key_type = forms.ChoiceField(required=False, choices=common.to_choices(HIVE_PRIMITIVE_TYPES), help_text=_t("Specify if column_type is map.")) map_value_type = forms.ChoiceField(required=False, choices=common.to_choices(HIVE_PRIMITIVE_TYPES), help_text=_t("Specify if column_type is map.")) ColumnTypeFormSet = simple_formset_factory(ColumnTypeForm, initial=[{}], add_label=_t("add a column")) # Default to no partitions PartitionTypeFormSet = simple_formset_factory(PartitionTypeForm, add_label=_t("add a partition")) class LoadDataForm(forms.Form): """Form used for loading data into an existing table.""" path = PathField(label=_t("Path")) overwrite = forms.BooleanField(required=False, initial=False, label=_t("Overwrite?")) def __init__(self, table_obj, *args, **kwargs): """ @param table_obj is a hive_metastore.thrift Table object, used to add fields corresponding to partition keys. """ super(LoadDataForm, self).__init__(*args, **kwargs)
import logging from django.utils.translation import ugettext_lazy as _t from desktop.lib.conf import Config, ConfigSection, coerce_bool LOG = logging.getLogger(__name__) def has_kafka(): return KAFKA.IS_ENABLED.get() def has_kafka_api(): return bool(KAFKA.API_URL.get()) KAFKA = ConfigSection( key='kafka', help=_t("""Configuration options for Kafka API integration"""), members=dict( IS_ENABLED=Config(key="is_enabled", help=_t("Enable the Kafka integration."), type=coerce_bool, default=False), API_URL=Config(key='api_url', help=_t('Base URL of Kafka REST API.'), default=None), ))
from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.conf import default_ssl_cacerts, default_ssl_validate, AUTH_PASSWORD as DEFAULT_AUTH_PASSWORD,\ AUTH_USERNAME as DEFAULT_AUTH_USERNAME from desktop.lib.conf import ConfigSection, Config, coerce_bool, coerce_password_from_script from desktop.lib.exceptions import StructuredThriftTransportException from beeswax.settings import NICE_NAME LOG = logging.getLogger(__name__) HIVE_SERVER_HOST = Config( key="hive_server_host", help=_t("Host where HiveServer2 server is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost") HIVE_SERVER_PORT = Config( key="hive_server_port", help=_t("Configure the port the HiveServer2 server runs on."), default=10000, type=int) HIVE_CONF_DIR = Config( key='hive_conf_dir', help=_t('Hive configuration directory, where hive-site.xml is located.'), default=os.environ.get("HIVE_CONF_DIR", '/etc/hive/conf')) HIVE_SERVER_BIN = Config( key="hive_server_bin",
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import socket from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import ConfigSection, Config, coerce_bool from impala.settings import NICE_NAME SERVER_HOST = Config(key="server_host", help=_t("Host of the Impala Server."), default="localhost") SERVER_PORT = Config(key="server_port", help=_t("Port of the Impala Server."), default=21050, type=int) IMPALA_PRINCIPAL = Config( key='impala_principal', help=_t( "Kerberos principal name for Impala. Typically 'impala/hostname.foo.com'." ), type=str, default="impala/%s" % socket.getfqdn())
class Meta: abstract = True verbose_name = _t('connector') verbose_name_plural = _t('connectors') unique_together = ('name', )
import os.path from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config, coerce_bool from desktop.lib import paths from liboozie.conf import get_oozie_status from oozie.settings import NICE_NAME DEFINITION_XSLT_DIR = Config( key="definition_xslt_dir", default=os.path.join(os.path.dirname(__file__), "importlib", "xslt"), help=_t( "Location on local FS where the xslt files are stored for workflow import." ), private=True) DEFINITION_XSLT2_DIR = Config( key="definition_xslt2_dir", default=os.path.join(os.path.dirname(__file__), "importlib", "xslt2"), help=_t( "Location on local FS where the xslt files are stored for workflow import." ), private=True) LOCAL_SAMPLE_DIR = Config( key="local_data_dir", default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"), help=_t("Location on local filesystem where the examples are stored."),
class CreateTableForm(DependencyAwareForm): """ Form used in the create table page """ dependencies = [] # Basic Data name = common.HiveIdentifierField(label=_t("Table Name"), required=True) comment = forms.CharField(label=_t("Description"), required=False) # Row Formatting row_format = forms.ChoiceField(required=True, choices=common.to_choices( ["Delimited", "SerDe"]), initial="Delimited") # Delimited Row # These initials are per LazySimpleSerDe.DefaultSeparators field_terminator = ChoiceOrOtherField(label=_t("Field terminator"), required=False, initial=TERMINATOR_CHOICES[0][0], choices=TERMINATOR_CHOICES) collection_terminator = ChoiceOrOtherField( label=_t("Collection terminator"), required=False, initial=TERMINATOR_CHOICES[1][0], choices=TERMINATOR_CHOICES) map_key_terminator = ChoiceOrOtherField(label=_t("Map key terminator"), required=False, initial=TERMINATOR_CHOICES[2][0], choices=TERMINATOR_CHOICES) dependencies += [ ("row_format", "Delimited", "field_terminator"), ("row_format", "Delimited", "collection_terminator"), ("row_format", "Delimited", "map_key_terminator"), ] # Serde Row serde_name = forms.CharField(required=False, label=_t("SerDe Name")) serde_properties = forms.CharField( required=False, help_text=_t( "Comma-separated list of key-value pairs. E.g. 'p1=v1, p2=v2'")) dependencies += [ ("row_format", "SerDe", "serde_name"), ("row_format", "SerDe", "serde_properties"), ] # File Format file_format = forms.ChoiceField( required=False, initial="TextFile", choices=common.to_choices(["TextFile", "SequenceFile", "InputFormat"]), widget=forms.RadioSelect) input_format_class = forms.CharField(required=False, label=_t("InputFormat Class")) output_format_class = forms.CharField(required=False, label=_t("OutputFormat Class")) dependencies += [ ("file_format", "InputFormat", "input_format_class"), ("file_format", "InputFormat", "output_format_class"), ] # External? use_default_location = forms.BooleanField( required=False, initial=True, label=_t("Use default location.")) external_location = forms.CharField( required=False, help_text=_t("Path to HDFS directory or file of table data.")) dependencies += [("use_default_location", False, "external_location")] def clean_field_terminator(self): return _clean_terminator(self.cleaned_data.get('field_terminator')) def clean_collection_terminator(self): return _clean_terminator( self.cleaned_data.get('collection_terminator')) def clean_map_key_terminator(self): return _clean_terminator(self.cleaned_data.get('map_key_terminator')) def clean_name(self): return _clean_tablename(self.db, self.cleaned_data['name'], self.database)
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config, coerce_bool, validate_path OOZIE_URL = Config( key='oozie_url', help=_t('URL of Oozie server. This is required for job submission.'), default='http://localhost:11000/oozie', type=str) SECURITY_ENABLED = Config( key="security_enabled", help=_t( "Whether Oozie requires client to perform Kerberos authentication."), default=False, type=coerce_bool) REMOTE_DEPLOYMENT_DIR = Config( key="remote_deployement_dir", default="/user/hue/oozie/deployments", help=_t( "Location on HDFS where the workflows/coordinators are deployed when submitted by a non-owner."
class SavedQuery(models.Model): """ Stores the query that people have save or submitted. Note that this used to be called QueryDesign. Any references to 'design' probably mean a SavedQuery. """ DEFAULT_NEW_DESIGN_NAME = _('My saved query') AUTO_DESIGN_SUFFIX = _(' (new)') TYPES = QUERY_TYPES TYPES_MAPPING = { 'beeswax': HQL, 'hql': HQL, 'impala': IMPALA, 'rdbms': RDBMS, 'spark': SPARK } type = models.IntegerField(null=False) owner = models.ForeignKey(User, db_index=True) # Data is a json of dictionary. See the beeswax.design module. data = models.TextField(max_length=65536) name = models.CharField(max_length=80) desc = models.TextField(max_length=1024) mtime = models.DateTimeField(auto_now=True) # An auto design is a place-holder for things users submit but not saved. # We still want to store it as a design to allow users to save them later. is_auto = models.BooleanField(default=False, db_index=True) is_trashed = models.BooleanField(default=False, db_index=True, verbose_name=_t('Is trashed'), help_text=_t('If this query is trashed.')) is_redacted = models.BooleanField(default=False) doc = generic.GenericRelation(Document, related_name='hql_doc') class Meta: ordering = ['-mtime'] def get_design(self): try: return HQLdesign.loads(self.data) except ValueError: # data is empty pass def clone(self, new_owner=None): if new_owner is None: new_owner = self.owner design = SavedQuery(type=self.type, owner=new_owner) design.data = self.data design.name = self.name design.desc = self.desc design.is_auto = self.is_auto return design @classmethod def create_empty(cls, app_name, owner, data): query_type = SavedQuery.TYPES_MAPPING[app_name] design = SavedQuery(owner=owner, type=query_type) design.name = SavedQuery.DEFAULT_NEW_DESIGN_NAME design.desc = '' if global_redaction_engine.is_enabled(): design.data = global_redaction_engine.redact(data) else: design.data = data design.is_auto = True design.save() Document.objects.link(design, owner=design.owner, extra=design.type, name=design.name, description=design.desc) design.doc.get().add_to_history() return design @staticmethod def get(id, owner=None, type=None): """ get(id, owner=None, type=None) -> SavedQuery object Checks that the owner and type match (when given). May raise PopupException (type/owner mismatch). May raise SavedQuery.DoesNotExist. """ try: design = SavedQuery.objects.get(id=id) except SavedQuery.DoesNotExist, err: msg = _('Cannot retrieve query id %(id)s.') % {'id': id} raise err if owner is not None and design.owner != owner: msg = _('Query id %(id)s does not belong to user %(user)s.') % { 'id': id, 'user': owner } LOG.error(msg) raise PopupException(msg) if type is not None and design.type != type: msg = _('Type mismatch for design id %(id)s (owner %(owner)s) - Expected %(expected_type)s, got %(real_type)s.') % \ {'id': id, 'owner': owner, 'expected_type': design.type, 'real_type': type} LOG.error(msg) raise PopupException(msg) return design
return is_enabled() def get_optimizer_password_script(): '''Get default password from secured file''' global OPTIMIZER_AUTH_PASSWORD if OPTIMIZER_AUTH_PASSWORD is None: OPTIMIZER_AUTH_PASSWORD = OPTIMIZER.AUTH_KEY_SECRET_SCRIPT.get() return OPTIMIZER_AUTH_PASSWORD OPTIMIZER = ConfigSection( key='optimizer', help=_t("""Configuration options for Optimizer API"""), members=dict( INTERFACE=Config( key='interface', help=_t( 'Type of Optimizer to connect to, e.g. Navigator Optimizer...' ), default='optimizer'), HOSTNAME=Config( key='hostname', help=_t('Hostname to Optimizer API or compatible service.'), default='navoptapi.us-west-1.optimizer.altus.cloudera.com'), AUTH_KEY_ID=Config(key="auth_key_id", help=_t("The name of the key of the service."), private=False, default=None),
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config, coerce_bool, validate_path OOZIE_URL = Config( key='oozie_url', help=_t('URL of Oozie server. This is required for job submission. Empty value disables the config check.'), default='http://localhost:11000/oozie', type=str) SECURITY_ENABLED = Config( key="security_enabled", help=_t("Whether Oozie requires client to perform Kerberos authentication."), default=False, type=coerce_bool) REMOTE_DEPLOYMENT_DIR = Config( key="remote_deployement_dir", default="/user/hue/oozie/deployments/_$USER_-oozie-$JOBID-$TIME", help=_t("Location on HDFS where the workflows/coordinators are deployed when submitted by a non-owner." " Parameters are $TIME, $USER and $JOBID, e.g. /user/$USER/hue/deployments/$JOBID-$TIME"))
# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import Config from spark.settings import NICE_NAME JOB_SERVER_URL = Config(key="server_url", help=_t("URL of the Spark Job Server."), default="http://localhost:8090/") def get_spark_status(user): from spark.job_server_api import get_api status = None try: if not 'test' in sys.argv: # Avoid tests hanging status = str(get_api(user).get_status()) except ValueError: # No json returned status = 'OK' except: pass
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import socket from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import Config, coerce_bool from impala.settings import NICE_NAME SERVER_HOST = Config( key="server_host", help=_t("Host of the Impala Server."), default="localhost") SERVER_PORT = Config( key="server_port", help=_t("Port of the Impala Server."), default=21050, type=int) IMPALA_PRINCIPAL=Config( key='impala_principal', help=_t("Kerberos principal name for Impala. Typically 'impala/hostname.foo.com'."), type=str, default="impala/%s" % socket.getfqdn()) IMPERSONATION_ENABLED=Config(
from libzookeeper.conf import ENSEMBLE if sys.version_info[0] > 2: from urllib.parse import urlparse new_str = str from django.utils.translation import gettext_lazy as _t else: from django.utils.translation import ugettext_lazy as _t from urlparse import urlparse LOG = logging.getLogger(__name__) SSL_CERT_CA_VERIFY = Config( key="ssl_cert_ca_verify", help=_t("In secure mode (HTTPS), if Solr SSL certificates have to be verified against certificate authority"), dynamic_default=default_ssl_validate, type=coerce_bool ) def zkensemble_path(): """ Try to guess Solr path in ZooKeeper. """ try: parsed = urlparse(ENSEMBLE.get()) if parsed.port == 9983: # Standalone Solr cloud return '' except: LOG.warning('Failed to get Zookeeper ensemble path')
import os.path from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config, coerce_bool from desktop.lib import paths from liboozie.conf import get_oozie_status from oozie.settings import NICE_NAME DEFINITION_XSLT_DIR = Config( key="definition_xslt_dir", default=os.path.join(os.path.dirname(__file__), "importlib", "xslt"), help=_t("Location on local FS where the xslt files are stored for workflow import."), private=True ) LOCAL_SAMPLE_DIR = Config( key="local_data_dir", default=os.path.join(os.path.dirname(__file__), "..", "..", "examples"), help=_t("Location on local filesystem where the examples are stored."), private=True ) LOCAL_SAMPLE_DATA_DIR = Config( key="sample_data_dir", default=paths.get_thirdparty_root("sample_data"), help=_t("Location on local filesystem where the data for the examples is stored."), private=True
# Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.lib.conf import Config, coerce_bool, validate_path OOZIE_URL = Config( key='oozie_url', help=_t( 'URL of Oozie server. This is required for job submission. Empty value disables the config check.' ), default='http://localhost:11000/oozie', type=str) SECURITY_ENABLED = Config( key="security_enabled", help=_t( "Whether Oozie requires client to perform Kerberos authentication."), default=False, type=coerce_bool) REMOTE_DEPLOYMENT_DIR = Config( key="remote_deployement_dir", default="/user/hue/oozie/deployments/_$USER_-oozie-$JOBID-$TIME", help=_t(
# limitations under the License. import os.path import sys import beeswax.hive_site from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import ConfigSection, Config, coerce_bool from beeswax.settings import NICE_NAME HIVE_SERVER_HOST = Config( key="hive_server_host", help=_t("Host where HiveServer2 server is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost") HIVE_SERVER_PORT = Config( key="hive_server_port", help=_t("Configure the port the HiveServer2 server runs on."), default=10000, type=int) HIVE_CONF_DIR = Config( key='hive_conf_dir', help=_t('Hive configuration directory, where hive-site.xml is located.'), default=os.environ.get("HIVE_CONF_DIR", '/etc/hive/conf')) HIVE_SERVER_BIN = Config( key="hive_server_bin",
# limitations under the License. import os.path import sys import beeswax.hive_site from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import ConfigSection, Config, coerce_bool from beeswax.settings import NICE_NAME HIVE_SERVER_HOST = Config( key="hive_server_host", help=_t( "Host where HiveServer2 server is running. If Kerberos security is enabled, " "the fully-qualified domain name (FQDN) is required"), default="localhost") HIVE_SERVER_PORT = Config( key="hive_server_port", help=_t("Configure the port the HiveServer2 server runs on."), default=10000, type=int) HIVE_CONF_DIR = Config( key='hive_conf_dir', help=_t('Hive configuration directory, where hive-site.xml is located.'), default=os.environ.get("HIVE_CONF_DIR", '/etc/hive/conf')) HIVE_SERVER_BIN = Config(key="hive_server_bin",
class AuthenticationForm(AuthAuthenticationForm): """ Adds appropriate classes to authentication form """ username = CharField(label=_t("Username"), max_length=30, widget=TextInput(attrs={'class': 'input-large', 'maxlength': 30})) password = CharField(label=_t("Password"), widget=PasswordInput(attrs={'class': 'input-large', 'maxlength': 30}))
class AddLdapGroupsForm(forms.Form): groupname_pattern = forms.CharField( label=_t("Name"), max_length=256, help_text=_t("Required. 256 characters or fewer."), error_messages={'invalid': _t("256 characters or fewer.")}) dn = forms.BooleanField( label=_t("Distinguished name"), help_text=_t("Whether or not the group should be imported by " "distinguished name."), initial=False, required=False) import_members = forms.BooleanField( label=_t('Import new members'), help_text=_t('Import unimported or new users from the group.'), initial=False, required=False) ensure_home_directories = forms.BooleanField( label=_t('Create home directories'), help_text=_t( 'Create home directories for every member imported, if members are being imported.' ), initial=True, required=False) import_members_recursive = forms.BooleanField( label=_t('Import new members from all subgroups'), help_text=_t('Import unimported or new users from the all subgroups.'), initial=False, required=False) def __init__(self, *args, **kwargs): super(AddLdapGroupsForm, self).__init__(*args, **kwargs) if get_server_choices(): self.fields['server'] = forms.ChoiceField( choices=get_server_choices(), required=True) def clean(self): cleaned_data = super(AddLdapGroupsForm, self).clean() groupname_pattern = cleaned_data.get("groupname_pattern") dn = cleaned_data.get("dn") try: if dn: validate_dn(groupname_pattern) else: validate_groupname(groupname_pattern) except AssertionError, e: errors = self._errors.setdefault('groupname_pattern', ErrorList()) errors.append(e.message) raise forms.ValidationError(e.message) return cleaned_data
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import sys import socket from django.utils.translation import ugettext_lazy as _t, ugettext as _ from desktop.lib.conf import Config from impala.settings import NICE_NAME SERVER_HOST = Config( key="server_host", help=_t("Host of the Impala Server."), default="localhost") SERVER_PORT = Config( key="server_port", help=_t("Port of the Impala Server."), default=21050, type=int) SERVER_INTERFACE = Config( key="server_interface", help=_t("Beeswax or Hive Server 2 Thrift API used. Choices are: 'beeswax' or 'hiveserver2'."), default="hiveserver2") IMPALA_PRINCIPAL=Config( key='impala_principal',
from builtins import oct from builtins import object import logging import sys from django.utils.translation import ugettext as _, ugettext_lazy as _t from desktop.conf import default_ssl_validate from desktop.lib.conf import Config, coerce_bool, validate_path LOG = logging.getLogger(__name__) OOZIE_URL = Config( key='oozie_url', help=_t( 'URL of Oozie server. This is required for job submission. Empty value disables the config check.' ), default='http://localhost:11000/oozie', type=str) SECURITY_ENABLED = Config( key="security_enabled", help=_t( "Whether Oozie requires client to perform Kerberos authentication."), default=False, type=coerce_bool) REMOTE_DEPLOYMENT_DIR = Config( key="remote_deployement_dir", default="/user/hue/oozie/deployments/_$USER_-oozie-$JOBID-$TIME", help=_t(
def dict_list_map(value): if isinstance(value, str): d = json.loads(value) return {k: (v,) for k, v in d.iteritems()} elif isinstance(value, dict): return value return None XMLSEC_BINARY = Config( key="xmlsec_binary", default="/usr/local/bin/xmlsec1", type=str, help=_t("Xmlsec1 binary path. This program should be executable by the user running Hue."), ) CREATE_USERS_ON_LOGIN = Config( key="create_users_on_login", default=True, type=coerce_bool, help=_t("Create users from IdP on login.") ) ENTITY_ID = Config( key="entity_id", default="http://localhost:8888/saml2/metadata/", type=str, help=_t("Globally unique identifier of the entity."), ) ATTRIBUTE_MAP_DIR = Config( key="attribute_map_dir",
if clusters['default'].HOST_PORTS.get() != 'localhost:2181': return '%s/solr' % clusters['default'].HOST_PORTS.get() except: LOG.warn('Failed to get Zookeeper ensemble') try: from search.conf import SOLR_URL parsed = urlparse(SOLR_URL.get()) return "%s:2181/solr" % (parsed.hostname or 'localhost') except: LOG.warn('Failed to get Solr url') # Deprecated as always on ENABLE_NEW_INDEXER = Config(key="enable_new_indexer", help=_t("Flag to turn on the new Solr indexer."), type=bool, default=True) ENABLE_SCALABLE_INDEXER = Config( key="enable_scalable_indexer", help=_t("Flag to turn on the Morphline Solr indexer."), type=bool, default=True) CONFIG_INDEXER_LIBS_PATH = Config( key="config_indexer_libs_path", help=_t("Filesystem directory containing Solr Morphline indexing libs."), type=str, default='/tmp/smart_indexer_lib')