mirror of https://github.com/apache/cassandra
fix: show CQL help in cqlsh in web browser
patch by Robert Stupp; reviewed by Paulo Motta for CASSANDRA-7225
This commit is contained in:
parent
a013f3e05a
commit
8738087edd
11
bin/cqlsh.py
11
bin/cqlsh.py
|
|
@ -71,6 +71,7 @@ except ImportError:
|
|||
CQL_LIB_PREFIX = 'cassandra-driver-internal-only-'
|
||||
|
||||
CASSANDRA_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
|
||||
CASSANDRA_CQL_HTML_FALLBACK = 'https://cassandra.apache.org/doc/cql3/CQL-2.2.html'
|
||||
|
||||
if os.path.exists(CASSANDRA_PATH + '/doc/cql3/CQL.html'):
|
||||
# default location of local CQL.html
|
||||
|
|
@ -80,7 +81,7 @@ elif os.path.exists('/usr/share/doc/cassandra/CQL.html'):
|
|||
CASSANDRA_CQL_HTML = 'file:///usr/share/doc/cassandra/CQL.html'
|
||||
else:
|
||||
# fallback to online version
|
||||
CASSANDRA_CQL_HTML = 'https://cassandra.apache.org/doc/cql3/CQL-2.2.html'
|
||||
CASSANDRA_CQL_HTML = CASSANDRA_CQL_HTML_FALLBACK
|
||||
|
||||
# On Linux, the Python webbrowser module uses the 'xdg-open' executable
|
||||
# to open a file/URL. But that only works, if the current session has been
|
||||
|
|
@ -92,7 +93,9 @@ else:
|
|||
# >>> webbrowser._tryorder
|
||||
# >>> webbrowser._browser
|
||||
#
|
||||
if webbrowser._tryorder[0] == 'xdg-open' and os.environ.get('XDG_DATA_DIRS', '') == '':
|
||||
if len(webbrowser._tryorder) == 0:
|
||||
CASSANDRA_CQL_HTML = CASSANDRA_CQL_HTML_FALLBACK
|
||||
elif webbrowser._tryorder[0] == 'xdg-open' and os.environ.get('XDG_DATA_DIRS', '') == '':
|
||||
# only on Linux (some OS with xdg-open)
|
||||
webbrowser._tryorder.remove('xdg-open')
|
||||
webbrowser._tryorder.append('xdg-open')
|
||||
|
|
@ -2213,7 +2216,9 @@ class Shell(cmd.Cmd):
|
|||
urlpart = cqldocs.get_help_topic(t)
|
||||
if urlpart is not None:
|
||||
url = "%s#%s" % (CASSANDRA_CQL_HTML, urlpart)
|
||||
if self.browser is not None:
|
||||
if len(webbrowser._tryorder) == 0:
|
||||
self.printerr("*** No browser to display CQL help. URL for help topic %s : %s" % (t, url))
|
||||
elif self.browser is not None:
|
||||
webbrowser.get(self.browser).open_new_tab(url)
|
||||
else:
|
||||
webbrowser.open_new_tab(url)
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
from .cql3handling import simple_cql_types
|
||||
|
||||
|
||||
class CQL3HelpTopics(object):
|
||||
|
||||
|
|
@ -73,8 +71,10 @@ class CQL3HelpTopics(object):
|
|||
|
||||
def help_json(self):
|
||||
return 'json'
|
||||
|
||||
def help_select_json(self):
|
||||
return 'selectJson'
|
||||
|
||||
def help_insert_json(self):
|
||||
return 'insertJson'
|
||||
|
||||
|
|
@ -85,21 +85,27 @@ class CQL3HelpTopics(object):
|
|||
|
||||
def help_create_keyspace(self):
|
||||
return 'createKeyspaceStmt'
|
||||
|
||||
def help_alter_keyspace(self):
|
||||
return 'alterKeyspaceStmt'
|
||||
|
||||
def help_drop_keyspace(self):
|
||||
return 'dropKeyspaceStmt'
|
||||
|
||||
def help_create_table(self):
|
||||
return 'createTableStmt'
|
||||
help_create_columnfamily = help_create_table
|
||||
|
||||
def help_alter_table(self):
|
||||
return 'alterTableStmt'
|
||||
|
||||
def help_drop_table(self):
|
||||
return 'dropTableStmt'
|
||||
help_drop_columnfamily = help_drop_table
|
||||
|
||||
def help_create_index(self):
|
||||
return 'createIndexStmt'
|
||||
|
||||
def help_drop_index(self):
|
||||
return 'dropIndexStmt'
|
||||
|
||||
|
|
@ -108,27 +114,34 @@ class CQL3HelpTopics(object):
|
|||
|
||||
def help_create_type(self):
|
||||
return 'createTypeStmt'
|
||||
|
||||
def help_alter_type(self):
|
||||
return 'alterTypeStmt'
|
||||
|
||||
def help_drop_type(self):
|
||||
return 'dropTypeStmt'
|
||||
|
||||
def help_create_function(self):
|
||||
return 'createFunctionStmt'
|
||||
|
||||
def help_drop_function(self):
|
||||
return 'dropFunctionStmt'
|
||||
|
||||
def help_functions(self):
|
||||
return 'functions'
|
||||
|
||||
def help_create_aggregate(self):
|
||||
return 'createAggregateStmt'
|
||||
|
||||
def help_drop_aggregate(self):
|
||||
return 'dropAggregateStmt'
|
||||
|
||||
def help_aggregates(self):
|
||||
return 'aggregates'
|
||||
|
||||
def help_create_trigger(self):
|
||||
return 'createTriggerStmt'
|
||||
|
||||
def help_drop_trigger(self):
|
||||
return 'dropTriggerStmt'
|
||||
|
||||
|
|
@ -137,19 +150,24 @@ class CQL3HelpTopics(object):
|
|||
|
||||
def help_create_user(self):
|
||||
return 'createUserStmt'
|
||||
|
||||
def help_alter_user(self):
|
||||
return 'alterUserStmt'
|
||||
|
||||
def help_drop_user(self):
|
||||
return 'dropUserStmt'
|
||||
|
||||
def help_list_users(self):
|
||||
return 'listUsersStmt'
|
||||
|
||||
def help_permissions(self):
|
||||
return 'permissions'
|
||||
|
||||
def help_list_permissions(self):
|
||||
return 'listPermissionsStmt'
|
||||
|
||||
def help_grant(self):
|
||||
return 'grantRoleStmt'
|
||||
|
||||
def help_revoke(self):
|
||||
return 'revokeRoleStmt'
|
||||
|
|
|
|||
Loading…
Reference in New Issue