From dc1fc60e39640c4ce494f68ae8e6a4ff30325c17 Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 13:55:37 -0400 Subject: [PATCH 1/6] force required number of save creds/config inputs --- plotly/plotly_user_aux/saveplotlyconfig.m | 8 ++++++++ plotly/plotly_user_aux/saveplotlycredentials.m | 11 ++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/plotly/plotly_user_aux/saveplotlyconfig.m b/plotly/plotly_user_aux/saveplotlyconfig.m index bbfe409e..d89254d6 100644 --- a/plotly/plotly_user_aux/saveplotlyconfig.m +++ b/plotly/plotly_user_aux/saveplotlyconfig.m @@ -3,6 +3,14 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain) % Plotly config info are saved as JSON strings % in ~/.plotly/.config +% catch missing input arguments +if nargin < 1 + error('plotly:saveconfig', ... + ['Incorrect number of inputs. Please save your configuration ', ... + 'as follows: >> saveplotlyconfig(plotly_domain,', ... + '[optional]plotly_streaming_domain)']); +end + % if the config file exists, then load it up try config = loadplotlyconfig(); diff --git a/plotly/plotly_user_aux/saveplotlycredentials.m b/plotly/plotly_user_aux/saveplotlycredentials.m index 92ddba31..d2ddf216 100644 --- a/plotly/plotly_user_aux/saveplotlycredentials.m +++ b/plotly/plotly_user_aux/saveplotlycredentials.m @@ -3,6 +3,14 @@ function saveplotlycredentials(username, api_key, stream_ids) % Plotly credentials are saved as JSON strings % in ~/.plotly/.credentials +% catch missing input arguments +if nargin < 2 + error('plotly:savecredentials', ... + ['Incorrect number of inputs. Please save your credentials ', ... + 'as follows: >> saveplotlycredentials(username, api_key,', ... + '[optional]stream_ids)']); +end + % if the credentials file exists, then load it up try creds = loadplotlycredentials(); @@ -45,9 +53,6 @@ function saveplotlycredentials(username, api_key, stream_ids) creds.username = username; creds.api_key = api_key; creds.stream_ids = stream_ids; - otherwise %need to specify both the username and api_key - error('plotly:savecredentials',... - 'Please specify your username and api_key'); end creds_string = m2json(creds); From b78a90b15181e8b6a6892f6660932b752cebc709 Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 12:43:15 -0400 Subject: [PATCH 2/6] add signin on config/credentials save --- plotly/plotly_user_aux/saveplotlyconfig.m | 4 ++++ plotly/plotly_user_aux/saveplotlycredentials.m | 3 +++ 2 files changed, 7 insertions(+) diff --git a/plotly/plotly_user_aux/saveplotlyconfig.m b/plotly/plotly_user_aux/saveplotlyconfig.m index d89254d6..dd1e1c0f 100644 --- a/plotly/plotly_user_aux/saveplotlyconfig.m +++ b/plotly/plotly_user_aux/saveplotlyconfig.m @@ -45,12 +45,16 @@ function saveplotlyconfig(plotly_domain,plotly_streaming_domain) 'chris@plot.ly for support.']); end +% get user credenitals +[username, api_key] = signin; switch nargin case 1 config.plotly_domain = plotly_domain; + signin(username, api_key, plotly_domain); case 2 config.plotly_domain = plotly_domain; + signin(username, api_key, plotly_domain); config.plotly_streaming_domain= plotly_streaming_domain; otherwise %if neither endpoints are specified, no worries! end diff --git a/plotly/plotly_user_aux/saveplotlycredentials.m b/plotly/plotly_user_aux/saveplotlycredentials.m index d2ddf216..2c968547 100644 --- a/plotly/plotly_user_aux/saveplotlycredentials.m +++ b/plotly/plotly_user_aux/saveplotlycredentials.m @@ -61,4 +61,7 @@ function saveplotlycredentials(username, api_key, stream_ids) fprintf(fileIDCred,'%s',creds_string); fclose(fileIDCred); +%signin using newly saved credentials +signin(username, api_key); + end From 23aae5731417af1112d2df17ac6fb6e2f8020cd5 Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 13:57:27 -0400 Subject: [PATCH 3/6] remove signin (handled by save creds/config) --- plotlysetup.m | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/plotlysetup.m b/plotlysetup.m index 85e1a6b0..65e6f108 100644 --- a/plotlysetup.m +++ b/plotlysetup.m @@ -139,7 +139,10 @@ function plotlysetup(username, api_key, varargin) try %save user credentials fprintf('Saving username/api_key credentials ... '); - saveplotlycredentials(username,api_key); + + %update: as of v.2.1.7, This also signs in the user + saveplotlycredentials(username, api_key); + %worked! fprintf('Done\n'); catch exception %writing credentials file permission problem catch... @@ -168,13 +171,19 @@ function plotlysetup(username, api_key, varargin) if strcmp(varargin{n},'stream_ids') fprintf('Saving stream_ids credentials ... '); - saveplotlycredentials(username,api_key,varargin{n+1}); + + %update: as of v.2.1.7, This also signs in the user + saveplotlycredentials(username, api_key, varargin{n+1}); + %worked! fprintf('Done\n'); end if strcmp(varargin{n},'plotly_domain') fprintf('Saving plotly_domain configuration ... '); + + %update: as of v.2.1.7, This also signs in the user saveplotlyconfig(varargin{n+1}); + %worked! fprintf('Done\n'); end @@ -185,7 +194,10 @@ function plotlysetup(username, api_key, varargin) catch config.plotly_domain = ''; end + + %update: as of v.2.1.7, This also signs in the user saveplotlyconfig(config.plotly_domain,varargin{n+1}); + %worked! fprintf('Done\n'); end @@ -195,9 +207,6 @@ function plotlysetup(username, api_key, varargin) fprintf(['\n\n' exception.identifier exception.message '\n\n']); end -%sign in the user -signin(username,api_key); - %greet the people! fprintf('\nWelcome to Plotly! If you are new to Plotly please enter: >> plotlyhelp to get started!\n\n') From 4e289f316c0e4bf243da6d873820dd897193e6b1 Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 15:15:13 -0400 Subject: [PATCH 4/6] add save config/credentials message --- plotlysetup.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plotlysetup.m b/plotlysetup.m index 199b07df..2bfa0fea 100644 --- a/plotlysetup.m +++ b/plotlysetup.m @@ -219,7 +219,10 @@ function plotlysetup(username, api_key, varargin) 'the Plotly folder to your MATLAB path manually by running: \n\n',... '>> plotly_path = fullfile(pwd, ''plotly'')\n',... '>> addpath(genpath(plotly_path))\n\n',... - 'Questions? Chuck@plotly']; - + 'You can save your credentials by running:\n\n', ... + '>>saveplotlycredentials(''your_username'', ''your_api_key'')\n\n',... + 'You can save your domain configuration by running:\n\n',... + '>>saveplotlyconfig(''your_base_domain'')\n\n',... + 'Questions? Chuck@plotly\n\n']; end From 6f5c53eba6c4804ed9ad76dc5df231fd078a2c9f Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 15:17:30 -0400 Subject: [PATCH 5/6] Update README.md version bump --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d8edec0..ae3c3a77 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## MATLAB PLOTLY API WRAPPER 2.1.6 +## MATLAB PLOTLY API WRAPPER 2.1.7 ### NUTSHELL: From 4c707a9c90d558145041ed6c34910c05da1d2334 Mon Sep 17 00:00:00 2001 From: BRONSOLO Date: Tue, 12 May 2015 15:17:53 -0400 Subject: [PATCH 6/6] Update plotly_version.m version bump --- plotly/plotly_aux/plotly_version.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plotly/plotly_aux/plotly_version.m b/plotly/plotly_aux/plotly_version.m index 910dba49..59ad4be3 100644 --- a/plotly/plotly_aux/plotly_version.m +++ b/plotly/plotly_aux/plotly_version.m @@ -1,3 +1,3 @@ function version = plotly_version() - version = '2.1.6'; + version = '2.1.7'; end