Repository: cassandra Updated Branches: refs/heads/trunk 2cc34dfef -> f55df0b85
fix: show CQL help in cqlsh in web browser patch by Robert Stupp; reviewed by Paulo Motta for CASSANDRA-7225 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/8738087e Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/8738087e Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/8738087e Branch: refs/heads/trunk Commit: 8738087edd79f2bd2007df0829087f7637aa8aa3 Parents: a013f3e Author: Robert Stupp <sn...@snazy.de> Authored: Tue Dec 1 10:39:05 2015 +0100 Committer: Robert Stupp <sn...@snazy.de> Committed: Tue Dec 1 10:39:05 2015 +0100 ---------------------------------------------------------------------- bin/cqlsh.py | 11 ++++++++--- pylib/cqlshlib/helptopics.py | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/8738087e/bin/cqlsh.py ---------------------------------------------------------------------- diff --git a/bin/cqlsh.py b/bin/cqlsh.py index e7dc121..027a45e 100644 --- a/bin/cqlsh.py +++ b/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) http://git-wip-us.apache.org/repos/asf/cassandra/blob/8738087e/pylib/cqlshlib/helptopics.py ---------------------------------------------------------------------- diff --git a/pylib/cqlshlib/helptopics.py b/pylib/cqlshlib/helptopics.py index c2eebe3..279063b 100644 --- a/pylib/cqlshlib/helptopics.py +++ b/pylib/cqlshlib/helptopics.py @@ -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'