Skip to content
Snippets Groups Projects

Clean up

Merged Maxime Bombar requested to merge clean-up into newinfra
3 files
+ 24
167
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -81,7 +81,7 @@ class ActionModule(ActionBase):
search = re.search('name=\"ticket\" value=\"([^\"]*)\"', content)
if not search:
raise AnsibleError(to_native('no edit ticket was found'))
return search.group(1)
@@ -132,12 +132,10 @@ class ActionModule(ActionBase):
if task_vars is None:
task_vars = dict()
result = super(ActionModule, self).run(tmp, task_vars)
del tmp
result['changed'] = False
url = self._task.args.get("url")
user = self._task.args.get("user")
@@ -147,34 +145,32 @@ class ActionModule(ActionBase):
cookie = self.login(url, user, password)
changed = False
try:
raw = self.craft_request("?action=raw")(url, cookie)
if raw != content:
changed = True
except urllib.error.HTTPError: # We will create the page.
changed = True
raw = ""
diff = difflib.unified_diff(raw.splitlines(), content.splitlines(), fromfile="old", tofile="new", lineterm="")
i=0
# Display any change
if changed:
diff = difflib.unified_diff(raw.splitlines(), content.splitlines(), fromfile="old", tofile="new", lineterm="")
for line in diff:
if line.startswith("-"):
display.display(line, "red")
elif line.startswith("+"):
display.display(line, "green")
elif line.startswith("@"):
display.display(line, "yellow")
else:
display.display(line)
# Do apply the change if not in check mode
if not self._play_context.check_mode:
self.edit(url, user, password, content, revision_comment, cookie)
for line in diff:
i+=1
if line.startswith("-"):
display.display(line, "red")
elif line.startswith("+"):
display.display(line, "green")
elif line.startswith("@"):
display.display(line, "yellow")
else:
display.display(line)
# Do apply the change if not in check mode
if not self._play_context.check_mode:
self.edit(url, user, password, content, revision_comment, cookie)
result['changed']=i>0
self._supports_check_mode = True
self._supports_async = False
Loading