Browse Source

better process handling

Sebastian Wiedenroth 13 years ago
parent
commit
b7ffcf0f00
1 changed files with 11 additions and 1 deletions
  1. 11 1
      client/gepd

+ 11 - 1
client/gepd

@@ -6,17 +6,27 @@ import portage
 
 
 class Gepd:
+	def __init__(self):
+		self._ep = None
+	
 	def get_packet_list(self):
 		return "\n".join(portage.db["/"]["vartree"].getallcpv())
 	
 	def start_update(self):
+		if self._ep not None and self._ep.returncode = None:
+			return 'nok: running'
+					
 		self._update_buffer = []
 		self._ep = subprocess.Popen(['sudo', 'emerge',  '-uND', 'world'], stdout=subprocess.PIPE)
+		return 'ok: started'
 	
 	def kill_update(self):
-		self._ep.kill()
+		if self._ep not None:
+			self._ep.kill()
 		
 	def get_update_status(self):
+		if self._ep = None:
+			return ''
 		self._update_buffer += self._ep.readlines()
 		return "\n".join(self._update_buffer)