mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-22 07:22:17 +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,33 +21,42 @@ 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
|
||||||
|
result_message = "Paket yüklü"
|
||||||
res['version'] = data[1]
|
res['version'] = data[1]
|
||||||
elif data[1] is not None and (package_version + '\n') in data[
|
res["res"] = result
|
||||||
1]: # Package version is the same with wanted version
|
elif package_version is not None and str((package_version + '\n')) == str(data[1]): # Package version is the same with wanted version
|
||||||
result = 0
|
result = 1
|
||||||
|
result_message = "Paket yüklü"
|
||||||
res['version'] = data[1]
|
res['version'] = data[1]
|
||||||
|
res["res"] = result
|
||||||
else:
|
else:
|
||||||
|
self.logger.debug(package_version)
|
||||||
result = 2
|
result = 2
|
||||||
|
result_message = "Paket farklı veriyonla yüklü"
|
||||||
res['version'] = data[1]
|
res['version'] = data[1]
|
||||||
|
res["res"] = result
|
||||||
else: # Package is not installed
|
else: # Package is not installed
|
||||||
result = 'Paket yüklü değil'
|
result = 0
|
||||||
|
result_message = "Paket yüklü değil"
|
||||||
res['version'] = ''
|
res['version'] = ''
|
||||||
|
|
||||||
res["dn"] = dn
|
|
||||||
res["res"] = result
|
res["res"] = result
|
||||||
|
|
||||||
self.logger.debug("Result is: - {}".format(result))
|
self.logger.debug("Result is: - {}".format(result_message))
|
||||||
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
||||||
message='{0} - {1}'.format(package_name, result),
|
message='{0} - {1}'.format(package_name, result_message),
|
||||||
data=json.dumps(res),
|
data=json.dumps(res),
|
||||||
content_type=self.get_content_type().APPLICATION_JSON.value)
|
content_type=self.get_content_type().APPLICATION_JSON.value)
|
||||||
self.logger.debug("Package Info has sent")
|
self.logger.debug("Package Info has sent")
|
||||||
|
|
Loading…
Reference in a new issue