3737import org .apache .commons .cli .ParseException ;
3838import org .scijava .Context ;
3939import org .scijava .command .CommandService ;
40- import org .scijava .jupyter .commands .InstallScijavaKernel ;
4140import org .scijava .jupyter .kernel .ScijavaKernel ;
4241import org .scijava .jupyter .kernel .configuration .ScijavaKernelConfigurationFile ;
4342import org .scijava .jupyter .kernel .evaluator .ScijavaEvaluator ;
@@ -63,48 +62,6 @@ public class DefaultJupyterService extends AbstractService implements JupyterSer
6362 @ Parameter
6463 private transient CommandService command ;
6564
66- /* Install kernel */
67- @ Override
68- public void installKernel (String ... args ) {
69- Map <String , Object > parameters = parseArgumentsInstall (args );
70- // TODO : Ensure parameters contains the appropriate keys.
71-
72- installKernel ((String ) parameters .get ("logLevel" ),
73- (String ) parameters .get ("pythonBinaryPath" ),
74- (String ) parameters .get ("classpath" ),
75- (String ) parameters .get ("javaBinaryPath" ));
76- }
77-
78- @ Override
79- public void installKernel (String logLevel , String pythonBinaryPath ) {
80- installKernel (logLevel , Paths .get (pythonBinaryPath ));
81- }
82-
83- @ Override
84- public void installKernel (String logLevel , Path pythonBinaryPath ) {
85- installKernel (logLevel , pythonBinaryPath .toFile ());
86- }
87-
88- @ Override
89- public void installKernel (String logLevel , File pythonBinaryPath ) {
90- installKernel (logLevel , pythonBinaryPath , null , null );
91- }
92-
93- @ Override
94- public void installKernel (String logLevel , String pythonBinaryPath , String classpath , String javaBinaryPath ) {
95- installKernel (logLevel , new File (pythonBinaryPath ), classpath , javaBinaryPath );
96- }
97-
98- @ Override
99- public void installKernel (String logLevel , File pythonBinaryPath , String classpath , String javaBinaryPath ) {
100- Map <String , Object > parameters = new HashMap <>();
101- parameters .put ("logLevel" , logLevel );
102- parameters .put ("pythonBinaryPath" , pythonBinaryPath );
103- parameters .put ("classpath" , classpath );
104- parameters .put ("javaBinaryPath" , new File (javaBinaryPath ));
105- command .run (InstallScijavaKernel .class , true , parameters );
106- }
107-
10865 /* Run kernel */
10966 @ Override
11067 public void runKernel (String ... args ) {
@@ -175,46 +132,4 @@ private Map<String, Object> parseArgumentsRun(final String... args) {
175132 return null ;
176133 }
177134
178- private Map <String , Object > parseArgumentsInstall (final String ... args ) {
179- if (args .length > 0 ) {
180- try {
181-
182- Options options = new Options ();
183- options .addOption ("pythonBinaryPath" , true , "Python Binary Path" );
184- options .addOption ("verbose" , true , "Verbose Mode" );
185- options .addOption ("classpath" , true , "Additional JAVA classpath ?" );
186- options .addOption ("javaBinaryPath" , true , "Java Binary Path" );
187-
188- CommandLineParser parser = new DefaultParser ();
189- CommandLine cmd = parser .parse (options , args );
190-
191- Map <String , Object > parameters = new HashMap <>();
192-
193- parameters .put ("pythonBinaryPath" , cmd .getOptionValue ("pythonBinaryPath" ));
194-
195- parameters .put ("logLevel" , cmd .getOptionValue ("verbose" ));
196-
197- if (cmd .getOptionValue ("classpath" ) != null ) {
198- parameters .put ("classpath" , cmd .getOptionValue ("classpath" ));
199- } else {
200- parameters .put ("classpath" , null );
201- }
202-
203- if (cmd .getOptionValue ("javaBinaryPath" ) != null ) {
204- parameters .put ("javaBinaryPath" , cmd .getOptionValue ("javaBinaryPath" ));
205- } else {
206- parameters .put ("javaBinaryPath" , null );
207- }
208-
209- return parameters ;
210-
211- } catch (ParseException ex ) {
212- log .error ("Error parsing arguments : " + ex .toString ());
213- }
214- } else {
215- log .error ("No parameters passed to the Scijava kernel." );
216- }
217- return null ;
218- }
219-
220135}
0 commit comments