|
@@ -15,22 +15,31 @@
|
|
|
# See the License for the specific language governing permissions and
|
|
# See the License for the specific language governing permissions and
|
|
|
# limitations under the License.
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
|
|
+try:
|
|
|
|
|
+ from collections import OrderedDict
|
|
|
|
|
+except ImportError:
|
|
|
|
|
+ from ordereddict import OrderedDict # Python 2.6
|
|
|
|
|
+
|
|
|
from django.utils.translation import ugettext_lazy as _t
|
|
from django.utils.translation import ugettext_lazy as _t
|
|
|
|
|
|
|
|
from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection,\
|
|
from desktop.lib.conf import Config, UnspecifiedConfigSection, ConfigSection,\
|
|
|
coerce_json_dict, coerce_string
|
|
coerce_json_dict, coerce_string
|
|
|
|
|
|
|
|
|
|
|
|
|
-def get_interpreters():
|
|
|
|
|
|
|
+def get_interpreters(user=None):
|
|
|
|
|
+ if not INTERPRETERS.get():
|
|
|
|
|
+ _default_interpreters()
|
|
|
|
|
+
|
|
|
|
|
+ interpreters = INTERPRETERS.get()
|
|
|
|
|
+
|
|
|
return [{
|
|
return [{
|
|
|
- "name": INTERPRETERS.get()[i].NAME.get(),
|
|
|
|
|
|
|
+ "name": interpreters[i].NAME.get(),
|
|
|
"type": i,
|
|
"type": i,
|
|
|
- "interface": INTERPRETERS.get()[i].INTERFACE.get(),
|
|
|
|
|
- "options": INTERPRETERS.get()[i].OPTIONS.get()}
|
|
|
|
|
- for i in INTERPRETERS.get()
|
|
|
|
|
|
|
+ "interface": interpreters[i].INTERFACE.get(),
|
|
|
|
|
+ "options": interpreters[i].OPTIONS.get()}
|
|
|
|
|
+ for i in interpreters
|
|
|
]
|
|
]
|
|
|
|
|
|
|
|
-
|
|
|
|
|
INTERPRETERS = UnspecifiedConfigSection(
|
|
INTERPRETERS = UnspecifiedConfigSection(
|
|
|
"interpreters",
|
|
"interpreters",
|
|
|
help="One entry for each type of snippet. The first 5 will appear in the wheel.",
|
|
help="One entry for each type of snippet. The first 5 will appear in the wheel.",
|
|
@@ -92,3 +101,39 @@ GITHUB_CLIENT_SECRET = Config(
|
|
|
type=coerce_string,
|
|
type=coerce_string,
|
|
|
default=""
|
|
default=""
|
|
|
)
|
|
)
|
|
|
|
|
+
|
|
|
|
|
+def _default_interpreters():
|
|
|
|
|
+ INTERPRETERS.set_for_testing(OrderedDict((
|
|
|
|
|
+ ('hive', {
|
|
|
|
|
+ 'name': 'Hive', 'interface': 'hiveserver2', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('impala', {
|
|
|
|
|
+ 'name': 'Impala', 'interface': 'hiveserver2', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('spark', {
|
|
|
|
|
+ 'name': 'Scala', 'interface': 'livy', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('pyspark', {
|
|
|
|
|
+ 'name': 'PySpark', 'interface': 'livy', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('r', {
|
|
|
|
|
+ 'name': 'R', 'interface': 'livy', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('jar', {
|
|
|
|
|
+ 'name': 'Spark Submit Jar', 'interface': 'livy-batch', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('py', {
|
|
|
|
|
+ 'name': 'Spark Submit Python', 'interface': 'livy-batch', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('pig', {
|
|
|
|
|
+ 'name': 'Pig', 'interface': 'pig', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('text', {
|
|
|
|
|
+ 'name': 'Text', 'interface': 'text', 'options': {}
|
|
|
|
|
+ }),
|
|
|
|
|
+ ('markdown', {
|
|
|
|
|
+ 'name': 'Markdown', 'interface': 'text', 'options': {}
|
|
|
|
|
+ })
|
|
|
|
|
+ ))
|
|
|
|
|
+ )
|
|
|
|
|
+
|