mirror of
https://github.com/Pardus-LiderAhenk/ahenk
synced 2024-11-21 22:02:15 +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'])
|
||||
dn = self.Ahenk.dn()
|
||||
res = {}
|
||||
|
||||
result_message = "Paket yüklü"
|
||||
if dn is None:
|
||||
dn = " "
|
||||
res["package_name"] = package_name
|
||||
res["dn"] = dn
|
||||
result_code, result, p_err = self.execute('dpkg -s {} | grep Version'.format(package_name))
|
||||
data = result.split(': ')
|
||||
self.logger.debug(data)
|
||||
|
||||
if data[0] == 'Version': # Package is installed
|
||||
if package_version is None or len(package_version) == 0:
|
||||
result = 1
|
||||
res['version'] = data[1]
|
||||
elif data[1] is not None and (package_version + '\n') in data[
|
||||
1]: # Package version is the same with wanted version
|
||||
if data:
|
||||
if data[0] == 'Version' : # Package is installed
|
||||
if package_version is None or len(package_version) == 0:
|
||||
self.logger.debug(package_version)
|
||||
result = 1
|
||||
result_message = "Paket yüklü"
|
||||
res['version'] = data[1]
|
||||
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
|
||||
res['version'] = data[1]
|
||||
else:
|
||||
result = 2
|
||||
res['version'] = data[1]
|
||||
else: # Package is not installed
|
||||
result = 'Paket yüklü değil'
|
||||
res['version'] = ''
|
||||
result_message = "Paket yüklü değil"
|
||||
res['version'] = ''
|
||||
res["res"] = result
|
||||
|
||||
res["dn"] = dn
|
||||
res["res"] = result
|
||||
|
||||
self.logger.debug("Result is: - {}".format(result))
|
||||
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
||||
message='{0} - {1}'.format(package_name, result),
|
||||
data=json.dumps(res),
|
||||
content_type=self.get_content_type().APPLICATION_JSON.value)
|
||||
self.logger.debug("Package Info has sent")
|
||||
self.logger.debug("Result is: - {}".format(result_message))
|
||||
self.context.create_response(code=self.message_code.TASK_PROCESSED.value,
|
||||
message='{0} - {1}'.format(package_name, result_message),
|
||||
data=json.dumps(res),
|
||||
content_type=self.get_content_type().APPLICATION_JSON.value)
|
||||
self.logger.debug("Package Info has sent")
|
||||
except Exception as e:
|
||||
self.logger.debug(str(e))
|
||||
self.context.create_response(code=self.message_code.TASK_ERROR.value,
|
||||
|
|
Loading…
Reference in a new issue