Sfoglia il codice sorgente

[hbase] Use absolute root path for pointing to the example data

Romain Rigaux 11 anni fa
parent
commit
4c2d8e163f

+ 6 - 2
apps/hbase/src/hbase/management/commands/hbase_setup.py

@@ -16,11 +16,14 @@
 # limitations under the License.
 # limitations under the License.
 
 
 import logging
 import logging
+import os
 from datetime import datetime, timedelta
 from datetime import datetime, timedelta
 
 
 from django.core.management.base import NoArgsCommand
 from django.core.management.base import NoArgsCommand
 from django.utils.translation import ugettext as _
 from django.utils.translation import ugettext as _
 
 
+from desktop.lib.paths import get_apps_root
+
 from hbased.ttypes import AlreadyExists
 from hbased.ttypes import AlreadyExists
 from hbase.api import HbaseApi
 from hbase.api import HbaseApi
 
 
@@ -51,7 +54,8 @@ class Command(NoArgsCommand):
       pass
       pass
 
 
   def load_analytics_table(self, api, cluster_name):
   def load_analytics_table(self, api, cluster_name):
-    api.bulkUpload(cluster_name, 'analytics_demo', open('apps/hbase/example/analytics/hbase-analytics.tsv'))
+    table_data = os.path.join(get_apps_root(), 'hbase', 'example', 'analytics', 'hbase-analytics.tsv')
+    api.bulkUpload(cluster_name, 'analytics_demo', open(table_data))
 
 
   def create_binary_table(self, api, cluster_name):
   def create_binary_table(self, api, cluster_name):
     try:
     try:
@@ -68,7 +72,7 @@ class Command(NoArgsCommand):
     api.putRow(cluster_name, 'document_demo', tomorrow, {'doc:version': '<xml>I like HBase</xml>'})
     api.putRow(cluster_name, 'document_demo', tomorrow, {'doc:version': '<xml>I like HBase</xml>'})
     api.putRow(cluster_name, 'document_demo', tomorrow, {'doc:version': '<xml>I LOVE HBase</xml>'})
     api.putRow(cluster_name, 'document_demo', tomorrow, {'doc:version': '<xml>I LOVE HBase</xml>'})
 
 
-    root='apps/hbase/example/documents'
+    root = os.path.join(get_apps_root(), 'hbase', 'example', 'documents')
 
 
     api.putRow(cluster_name, 'document_demo', today, {'doc:img': open(root + '/hue-logo.png', "rb").read()})
     api.putRow(cluster_name, 'document_demo', today, {'doc:img': open(root + '/hue-logo.png', "rb").read()})
     api.putRow(cluster_name, 'document_demo', today, {'doc:html': open(root + '/gethue.com.html', "rb").read()})
     api.putRow(cluster_name, 'document_demo', today, {'doc:html': open(root + '/gethue.com.html', "rb").read()})

+ 13 - 6
desktop/core/src/desktop/lib/paths.py

@@ -24,13 +24,13 @@ import os
 
 
 """
 """
 The project directory structure:
 The project directory structure:
-    root/                               <-- Project root (build root, run root)
-        desktop/                        <-- Desktop root
-            apps/...
+    root/                                 <-- Project root (build root, run root)
+        apps/                             <-- Apps root
+            beeswax/
+        desktop/                          <-- Desktop root
             core/
             core/
-              src/desktop/lib/paths.py  <-- You're reading this file
-              ...
-            core-apps/...
+                src/desktop/lib/paths.py  <-- You're reading this file
+                ...
         ext/
         ext/
             thirdparty/...
             thirdparty/...
 """
 """
@@ -66,6 +66,13 @@ def get_desktop_root(*append):
   return __get_root("desktop", *append)
   return __get_root("desktop", *append)
 
 
 
 
+def get_apps_root(*append):
+  """
+  Returns the directory for apps.
+  """
+  return __get_root("apps", *append)
+
+
 def get_thirdparty_root(*append):
 def get_thirdparty_root(*append):
   """
   """
   Returns the ext/thirdparty directory.
   Returns the ext/thirdparty directory.