diff --git a/serverStatus/static/serverStatus/serverStatus.js b/serverStatus/static/serverStatus/serverStatus.js
index 5dca427db..f8b6c11fb 100755
--- a/serverStatus/static/serverStatus/serverStatus.js
+++ b/serverStatus/static/serverStatus/serverStatus.js
@@ -789,7 +789,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
$scope.currentPage = 1;
$scope.recordsToShow = 10;
- $scope.fetchPackages = function () {
+ $scope.fetchPackages = function (type = 'installed') {
$scope.cyberpanelLoading = false;
var config = {
@@ -800,7 +800,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
var data = {
page: $scope.currentPage,
- recordsToShow: $scope.recordsToShow
+ recordsToShow: $scope.recordsToShow,
+ type: type
};
dataurl = "/serverstatus/fetchPackages";
@@ -833,6 +834,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
};
+ $scope.fetchPackages('upgrade');
$scope.killProcess = function (pid) {
diff --git a/serverStatus/templates/serverStatus/packageManager.html b/serverStatus/templates/serverStatus/packageManager.html
index c9d7afe9d..02dbb64eb 100755
--- a/serverStatus/templates/serverStatus/packageManager.html
+++ b/serverStatus/templates/serverStatus/packageManager.html
@@ -22,7 +22,7 @@
- - Updates
+ - Updates
- All Packages
- Settings
| {% trans "Package" %} |
- {% trans "Description" %} |
- {% trans "Status" %} |
{% trans "Version" %} |
+ {% trans "Upgrade" %} |
+ {% trans "Actions" %} |
|
- |
- |
|
+ |
+ Upgrade |
diff --git a/serverStatus/views.py b/serverStatus/views.py
index 02f868b07..f6a2c3812 100755
--- a/serverStatus/views.py
+++ b/serverStatus/views.py
@@ -728,18 +728,25 @@ def fetchPackages(request):
data = json.loads(request.body)
page = int(str(data['page']).rstrip('\n'))
recordsToShow = int(data['recordsToShow'])
-
- packageInformation = '/home/cyberpanel/OSPackages'
- f = open(packageInformation, "w")
+ type = data['type']
if ProcessUtilities.decideDistro() == ProcessUtilities.ubuntu:
- command = 'dpkg-query -f \'{"status":"${db:Status-Abbrev}","package":"${binary:Package}","version":"${Version}","description":"${binary:Summary}"}\n\' -W'
- subprocess.call(shlex.split(command), stdout=f)
+ command = 'apt list --installed'
+ packages = ProcessUtilities.outputExecutioner(command).split('\n')
+ packages = packages[4:]
- packages = ProcessUtilities.outputExecutioner('cat %s' % (packageInformation)).split('\n')
+ upgradePackages = []
- # if os.path.exists(ProcessUtilities.debugPath):
- # logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
+ if type == 'upgrade':
+ for pack in packages:
+ if pack.find('upgradable') > -1:
+ upgradePackages.append(pack)
+
+ packages = upgradePackages
+
+
+ #if os.path.exists(ProcessUtilities.debugPath):
+ # logging.CyberCPLogFileWriter.writeToFile('All packages: %s' % (str(packages)))
from s3Backups.s3Backups import S3Backups
@@ -751,20 +758,30 @@ def fetchPackages(request):
checker = 0
counter = 0
- # if os.path.exists(ProcessUtilities.debugPath):
- # logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
+ if os.path.exists(ProcessUtilities.debugPath):
+ logging.CyberCPLogFileWriter.writeToFile('Final packages: %s' % (str(finalPackages)))
+
import re
for items in finalPackages:
- items = re.sub(r'("[\s\w]*)"([\s\w])*"([\s\w]*)',r"\1\2\3", items)
try:
+ nowSplitted = items.split('now')
+
+ upgrade = 'Not Needed'
+
+ if nowSplitted[1].split(' ')[3].find('upgradable') > -1:
+ upgrade = nowSplitted[1].split(' ')[3]
+
+ dic = {'package': nowSplitted[0].split('/')[0], 'version': '%s %s' % (nowSplitted[1].split(' ')[1], nowSplitted[1].split(' ')[2]), 'upgrade': upgrade}
+
counter = counter + 1
if checker == 0:
- json_data = json_data + items
+ json_data = json_data + json.dumps(dic)
checker = 1
else:
- json_data = json_data + ',' + items
- except:
- logging.CyberCPLogFileWriter.writeToFile(items)
+ json_data = json_data + ',' + json.dumps(dic)
+
+ except BaseException as msg:
+ logging.CyberCPLogFileWriter.writeToFile('[ERROR] %s. [fetchPackages:773]' % (str(msg)))
json_data = json_data + ']'
diff --git a/static/serverStatus/serverStatus.js b/static/serverStatus/serverStatus.js
index 5dca427db..f8b6c11fb 100644
--- a/static/serverStatus/serverStatus.js
+++ b/static/serverStatus/serverStatus.js
@@ -789,7 +789,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
$scope.currentPage = 1;
$scope.recordsToShow = 10;
- $scope.fetchPackages = function () {
+ $scope.fetchPackages = function (type = 'installed') {
$scope.cyberpanelLoading = false;
var config = {
@@ -800,7 +800,8 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
var data = {
page: $scope.currentPage,
- recordsToShow: $scope.recordsToShow
+ recordsToShow: $scope.recordsToShow,
+ type: type
};
dataurl = "/serverstatus/fetchPackages";
@@ -833,6 +834,7 @@ app.controller('listOSPackages', function ($scope, $http, $timeout) {
};
+ $scope.fetchPackages('upgrade');
$scope.killProcess = function (pid) {