From 0e8941a7073b2da86498580288d73791c664f96a Mon Sep 17 00:00:00 2001
From: Edileuton Henrique de Oliveira <eho09@c3sl.ufpr.br>
Date: Wed, 19 Mar 2014 14:32:07 -0300
Subject: [PATCH] Fix Windows agent update

Signed-off-by: Edileuton Henrique de Oliveira <eho09@c3sl.ufpr.br>
---
 windows-collect/src/collect.py          |  5 +++--
 windows-collect/src/proinfodataAgent.py | 12 ++++++------
 windows-installer/src/installer.nsi     | 22 +++++++++++-----------
 3 files changed, 20 insertions(+), 19 deletions(-)

diff --git a/windows-collect/src/collect.py b/windows-collect/src/collect.py
index 33b2211..b661177 100644
--- a/windows-collect/src/collect.py
+++ b/windows-collect/src/collect.py
@@ -37,11 +37,12 @@ def getRegistryValue(key, subkey, value):
     key = getattr(_winreg, key)
     handle = _winreg.OpenKey(key, subkey)
     (value, type) = _winreg.QueryValueEx(handle, value)
-    return value
+
+    return value.split('\n')[0]
 
 # Return INEP
 def getINEP():
-    return getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "INEP")[:-1]
+    return getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "INEP")
 
 # Return Windows version
 def getOSInfo(key):
diff --git a/windows-collect/src/proinfodataAgent.py b/windows-collect/src/proinfodataAgent.py
index 96b6069..d54401f 100644
--- a/windows-collect/src/proinfodataAgent.py
+++ b/windows-collect/src/proinfodataAgent.py
@@ -104,10 +104,10 @@ def callClient(args):
 
 # Get proxy information from Windows registry
 def getProxyInfo():
-	phost = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyHost")[:-1]
-	pport = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyPort")[:-1]
-	puser = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyUser")[:-1]
-	ppass = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyPass")[:-1]
+	phost = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyHost")
+	pport = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyPort")
+	puser = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyUser")
+	ppass = collect.getRegistryValue("HKEY_LOCAL_MACHINE", "SOFTWARE\\ProInfoData", "ProxyPass")
 	return (phost, pport, puser, ppass)
 
 # Check for updates
@@ -295,8 +295,8 @@ if not elapsedTime():
 # Collect data
 try:
     collectData = collect.collect()
-except:
-    log.write("ERROR(8): Failed to collect data.")
+except Exception, e:
+    log.write("ERROR(8): Failed to collect data: " + str(e))
     log.close()
     sys.exit(8)
 
diff --git a/windows-installer/src/installer.nsi b/windows-installer/src/installer.nsi
index 7cb32e9..a0c3982 100644
--- a/windows-installer/src/installer.nsi
+++ b/windows-installer/src/installer.nsi
@@ -121,16 +121,6 @@ Function .onInit
     está em execução."
     Abort
 
-    ;Kill proinfodataAgent.exe process
-    StrCpy $0 "proinfodataAgent.exe"
-    DetailPrint "Killing all processes called '$0'"
-    KillProc::KillProcesses 
-
-    ;Kill datasidAgent.exe process
-    StrCpy $0 "netmon.exe"
-    DetailPrint "Killing all processes called '$0'"
-    KillProc::KillProcesses
-
     ;Verify if INEP exists in Windows registry
     ClearErrors
     ReadRegStr $R2 HKLM "SOFTWARE\${PRODUCT_NAME}" "INEP"
@@ -143,7 +133,17 @@ FunctionEnd
 ;Main installer section
 Section "SeçãoPrincipal" SEC01
     SetOutPath "$INSTDIR"
-    SetOverwrite ifnewer
+    SetOverwrite on
+
+    ;Kill proinfodataAgent.exe process
+    StrCpy $0 "proinfodataAgent.exe"
+    DetailPrint "Killing all processes called '$0'"
+    KillProcDLL::KillProc "proinfodataAgent.exe"
+
+    ;Kill netmon.exe process
+    StrCpy $0 "netmon.exe"
+    DetailPrint "Killing all processes called '$0'"
+    KillProcDLL::KillProc "netmon.exe"
 
     ;Verify INEP in Windows registry. If not exists, creates a new one.
 	ClearErrors
-- 
GitLab