mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-13 01:02:16 +03:00
check package version bug fixed
This commit is contained in:
parent
70092dd737
commit
7100a6942f
1 changed files with 33 additions and 24 deletions
|
@ -21,36 +21,45 @@ class CheckPackage(AbstractPlugin):
|
||||||
package_version = str((self.data)['packageVersion'])
|
package_version = str((self.data)['packageVersion'])
|
||||||
dn = self.Ahenk.dn()
|
dn = self.Ahenk.dn()
|
||||||
res = {}
|
res = {}
|
||||||
|
|
||||||
|
result_message = "Paket yüklü"
|
||||||
if dn is None:
|
if dn is None:
|
||||||
dn = " "
|
dn = " "
|
||||||
|
res["package_name"] = package_name
|
||||||
|
res["dn"] = dn
|
||||||
result_code, result, p_err = self.execute('dpkg -s {} | grep Version'.format(package_name))
|
result_code, result, p_err = self.execute('dpkg -s {} | grep Version'.format(package_name))
|
||||||
data = result.split(': ')
|
data = result.split(': ')
|
||||||
self.logger.debug(data)
|
if data:
|
||||||
|
if data[0] == 'Version' : # Package is installed
|
||||||
if data[0] == 'Version': # Package is installed
|
if package_version is None or len(package_version) == 0:
|
||||||
if package_version is None or len(package_version) == 0:
|
self.logger.debug(package_version)
|
||||||
result = 1
|
result = 1
|
||||||
res['version'] = data[1]
|
result_message = "Paket yüklü"
|
||||||
elif data[1] is not None and (package_version + '\n') in data[
|
res['version'] = data[1]
|
||||||
1]: # Package version is the same with wanted version
|
res["res"] = result
|
||||||
|
elif package_version is not None and str((package_version + '\n')) == str(data[1]): # Package version is the same with wanted version
|
||||||
|
result = 1
|
||||||
|
result_message = "Paket yüklü"
|
||||||
|
res['version'] = data[1]
|
||||||
|
res["res"] = result
|
||||||
|
else:
|
||||||
|
self.logger.debug(package_version)
|
||||||
|
result = 2
|
||||||
|
result_message = "Paket farklı veriyonla yüklü"
|
||||||
|
res['version'] = data[1]
|
||||||
|
res["res"] = result
|
||||||
|
else: # Package is not installed
|
||||||
result = 0
|
result = 0
|
||||||
res['version'] = data[1]
|
result_message = "Paket yüklü değil"
|
||||||
else:
|
res['version'] = ''
|
||||||
result = 2
|
res["res"] = result
|
||||||
res['version'] = data[1]
|
|
||||||
else: # Package is not installed
|
|
||||||
result = 'Paket yüklü değil'
|
|
||||||
res['version'] = ''
|
|
||||||
|
|
||||||
res["dn"] = dn
|
self.logger.debug("Result is: - {}".format(result_message))
|
||||||
res["res"] = result
|
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
||||||
|
message='{0} - {1}'.format(package_name, result_message),
|
||||||
self.logger.debug("Result is: - {}".format(result))
|
data=json.dumps(res),
|
||||||
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
content_type=self.get_content_type().APPLICATION_JSON.value)
|
||||||
message='{0} - {1}'.format(package_name, result),
|
self.logger.debug("Package Info has sent")
|
||||||
data=json.dumps(res),
|
|
||||||
content_type=self.get_content_type().APPLICATION_JSON.value)
|
|
||||||
self.logger.debug("Package Info has sent")
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.debug(str(e))
|
self.logger.debug(str(e))
|
||||||
self.context.create_response(code=self.message_code.TASK_ERROR.value,
|
self.context.create_response(code=self.message_code.TASK_ERROR.value,
|
||||||
|
|
Loading…
Reference in a new issue