summaryrefslogtreecommitdiff
path: root/lib/chef/provider/windows_task.rb
diff options
context:
space:
mode:
authornimisha <nimisha.sharad@msystechnologies.com>2017-03-23 19:12:29 +0530
committernimisha <nimisha.sharad@msystechnologies.com>2017-03-31 20:47:21 +0530
commitd9caf0a379054fc81549726ff415b25af3144870 (patch)
tree69993544ef1cc86885d159c97ef5e5e08b5e5122 /lib/chef/provider/windows_task.rb
parent54dedad68c925399c3aeb0680c7e05e93725fc22 (diff)
downloadchef-d9caf0a379054fc81549726ff415b25af3144870.tar.gz
Using chcp 437 and fixed some bugs
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/provider/windows_task.rb')
-rw-r--r--lib/chef/provider/windows_task.rb12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/chef/provider/windows_task.rb b/lib/chef/provider/windows_task.rb
index 3f3e88db0d..0147e47a55 100644
--- a/lib/chef/provider/windows_task.rb
+++ b/lib/chef/provider/windows_task.rb
@@ -172,7 +172,7 @@ class Chef
def task_need_update?
# gsub needed as schtasks converts single quotes to double quotes on creation
@current_resource.command != @new_resource.command.tr("'", '"') ||
- @current_resource.user != @new_resource.user ||
+ @current_resource.user.encode('external') != @new_resource.user ||
@current_resource.run_level != @new_resource.run_level ||
@current_resource.cwd != @new_resource.cwd ||
@current_resource.frequency_modifier != @new_resource.frequency_modifier ||
@@ -251,7 +251,7 @@ class Chef
Chef::Log.debug 'Looking for existing tasks'
# we use shell_out here instead of shell_out! because a failure implies that the task does not exist
- output = shell_out("schtasks /Query /FO LIST /V /TN \"#{task_name}\"").stdout
+ output = shell_out("chcp 65001 >nul 2>&1 && schtasks /Query /FO LIST /V /TN \"#{task_name}\"").stdout.force_encoding('UTF-8')
if output.empty?
task = false
else
@@ -266,13 +266,15 @@ class Chef
end
end
end
- task.merge!(load_task_xml task_name) if task
+
+ task_xml = load_task_xml task_name
+ task.merge!(task_xml) if task && task_xml
task
end
def load_task_xml task_name
- xml_cmd = shell_out("schtasks /Query /TN \"#{task_name}\" /XML")
+ xml_cmd = shell_out("chcp 65001 >nul 2>&1 && schtasks /Query /TN \"#{task_name}\" /XML")
return if xml_cmd.exitstatus != 0
doc = REXML::Document.new(xml_cmd.stdout)
@@ -386,7 +388,7 @@ class Chef
@current_resource.frequency(:once) if task_hash[:once]
end
- def set_idle_time(idle_time)
+ def set_current_idle_time(idle_time)
duration = ISO8601::Duration.new(idle_time)
@current_resource.idle_time(duration.minutes.atom.to_i)
end