Skip to content

Commit

Permalink
Merge pull request #1830 from OpenC3/pip-uninstall
Browse files Browse the repository at this point in the history
Fix pip uninstall, improve package status
  • Loading branch information
jmthomas authored Jan 21, 2025
2 parents f49c5cc + 796abd3 commit 2688982
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# GNU Affero General Public License for more details.

# Modified by OpenC3, Inc.
# All changes Copyright 2024, OpenC3, Inc.
# All changes Copyright 2025, OpenC3, Inc.
# All Rights Reserved
#
# This file may also be used under the terms of a commercial license
Expand All @@ -36,9 +36,6 @@
<rux-progress :value="progress"></rux-progress>
</v-col>
</v-row>
<v-alert v-model="showAlert" closable :type="alertType">{{
alert
}}</v-alert>
<v-list
v-if="Object.keys(processes).length > 0"
class="list"
Expand Down Expand Up @@ -148,9 +145,6 @@ export default {
gems: [],
python: [],
processes: {},
alert: '',
alertType: 'success',
showAlert: false,
}
},
mounted() {
Expand All @@ -173,10 +167,11 @@ export default {
(response) => {
this.processes = response.data
if (Object.keys(this.processes).length > 0) {
// process_manager.rb script operates on a 5 second cycle
setTimeout(() => {
this.updateProcesses()
this.update()
}, 10000)
}, 2500)
}
},
)
Expand Down Expand Up @@ -212,42 +207,45 @@ export default {
})
Promise.all(promises)
.then((responses) => {
this.progress = 100
this.alert = `Uploaded ${responses.length} package${
responses.length > 1 ? 's' : ''
}`
this.alertType = 'success'
this.showAlert = true
this.$notify.normal({
body: `Uploaded ${responses.length} package${
responses.length > 1 ? 's' : ''
}`,
})
this.loadingPackage = false
this.files = []
setTimeout(() => {
this.showAlert = false
this.updateProcesses()
}, 5000)
this.update()
}, 2500)
})
.catch((error) => {
this.loadingPackage = false
})
}
},
deletePackage: function (pkg) {
deletePackage(pkg) {
this.$dialog
.confirm(`Are you sure you want to remove: ${pkg}`, {
okText: 'Delete',
cancelText: 'Cancel',
})
.then(function (dialog) {
.then((dialog) => {
return Api.delete(`/openc3-api/packages/${pkg}`)
})
.then((response) => {
this.alert = `Removed package ${pkg}`
this.alertType = 'success'
this.showAlert = true
this.$notify.normal({
body: `Removed package ${pkg}`,
})
setTimeout(() => {
this.showAlert = false
}, 5000)
this.update()
this.updateProcesses()
}, 2500)
})
// Error will probably never happen because we spawn the package removal
// and then wait for the response which happens in the background
.catch((error) => {
this.$notify.serious({
body: `Failed to remove package ${pkg}`,
})
})
},
},
Expand Down
2 changes: 1 addition & 1 deletion openc3/bin/pipinstall
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ else
echo "Command failed - retrying with --no-index"
pip3 install --no-index "$@"
if [ $? -eq 0 ]; then
echo "ERROR: pip install failed"
echo "ERROR: pip3 install failed"
fi
fi
10 changes: 10 additions & 0 deletions openc3/bin/pipuninstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
python3 -m venv $PYTHONUSERBASE
source $PYTHONUSERBASE/bin/activate
echo "pip3 uninstall $@"
pip3 uninstall "$@"
if [ $? -eq 0 ]; then
echo "Command succeeded"
else
echo "ERROR: pip3 uninstall failed"
fi
3 changes: 2 additions & 1 deletion openc3/lib/openc3/models/python_package_model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def self.install(name_or_path, scope:)
def self.destroy(name, scope:)
package_name, version = self.extract_name_and_version(name)
Logger.info "Uninstalling package: #{name}"
result = OpenC3::ProcessManager.instance.spawn(["pip", "uninstall", package_name, "-y"], "package_uninstall", name, Time.now + 3600.0, scope: scope)
pip_args = ["-y", package_name]
result = OpenC3::ProcessManager.instance.spawn(["/openc3/bin/pipuninstall"] + pip_args, "package_uninstall", name, Time.now + 3600.0, scope: scope)
return result.name
end

Expand Down

0 comments on commit 2688982

Please sign in to comment.