File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,36 @@ PBPharoPipenvProcess >> initialize [
106106 self setDefaultEnvironmentVariables
107107]
108108
109+ { #category : #utils }
110+ PBPharoPipenvProcess >> installModule: aString in: aPBApplication [
111+ " Install the supplied module using `pipenv run pip install aString`"
112+ | pipenvPath proc arguments stdoutStream stderrStream |
113+
114+ pipenvPath := aPBApplication settings pipenvPath ifNil: [ self class pipenvPath ].
115+ arguments := { ' run' . ' pip' . ' install' . aString. }.
116+ stdoutStream := String new writeStream.
117+ stderrStream := String new writeStream.
118+ proc := OSSUnixSubprocess new
119+ command: pipenvPath fullName;
120+ arguments: arguments;
121+ workingDirectory: aPBApplication workingDirectory fullName;
122+ addAllEnvVariablesFromParentWithoutOverride;
123+ terminateOnShutdown;
124+ redirectStdout;
125+ redirectStderr;
126+ yourself .
127+ environmentVariables associationsDo: [ :assoc |
128+ proc environmentAt: assoc key put: assoc value ].
129+ proc run.
130+ proc
131+ waitForExitPollingEvery: (Delay forMilliseconds: 500 )
132+ doing: [ :aProcess :outStream :errStream |
133+ stdoutStream nextPutAll: outStream upToEnd.
134+ stderrStream nextPutAll: errStream upToEnd ].
135+ proc isSuccess ifFalse:
136+ [ self error: ' Unable to install module:' , aString asString ].
137+ ]
138+
109139{ #category : #testing }
110140PBPharoPipenvProcess >> isRunning [
111141 ^ process
Original file line number Diff line number Diff line change @@ -180,6 +180,13 @@ PBApplication >> initializeHandlers [
180180 executionHandler := PBExecutionHandler application: self
181181]
182182
183+ { #category : #utils }
184+ PBApplication >> installModule: aString [
185+ " Install the supplied module using `pipenv run pip install aString`"
186+
187+ PBPharoPipenvProcess new installModule: aString in: self
188+ ]
189+
183190{ #category : #testing }
184191PBApplication >> isPythonReady [
185192 " Ensures python webserver is ready for receiving commands"
You can’t perform that action at this time.
0 commit comments