View | Details | Raw Unified | Return to bug 40453
Collapse All | Expand All

(-)a/ucs-school-umc-installer/umc/python/schoolinstaller/__init__.py (-10 / +31 lines)
 Lines 43-48   import traceback Link Here 
43
import ast
43
import ast
44
import urllib
44
import urllib
45
import filecmp
45
import filecmp
46
import fcntl
47
import errno
46
48
47
# related third party
49
# related third party
48
import notifier
50
import notifier
 Lines 359-377   def system_join(username, password, info_handler = _dummyFunc, error_handler = _ Link Here 
359
				process = subprocess.Popen(['/usr/sbin/univention-run-join-scripts', '-dcaccount', username, '-dcpwd', passwordFile.name], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
361
				process = subprocess.Popen(['/usr/sbin/univention-run-join-scripts', '-dcaccount', username, '-dcpwd', passwordFile.name], shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
360
362
361
			failedJoinScripts = []
363
			failedJoinScripts = []
362
			while True:
364
			def parse(line):
363
				# get the next line
365
				MODULE.process(repr(line.strip()).strip('"\''))
364
				line = process.stdout.readline()
365
				if not line:
366
					# no more text from stdout
367
					break
368
				MODULE.process(line.strip())
369
366
370
				# parse output... first check for errors
367
				# parse output... first check for errors
371
				m = regError.match(line)
368
				m = regError.match(line)
372
				if m:
369
				if m:
373
					error_handler(_('Software packages have been installed, however, the system join could not be completed: %s. More details can be found in the log file /var/log/univention/join.log. Please retry the join process via the UMC module "Domain join" after resolving any conflicting issues.') % m.groupdict().get('message'))
370
					error_handler(_('Software packages have been installed, however, the system join could not be completed: %s. More details can be found in the log file /var/log/univention/join.log. Please retry the join process via the UMC module "Domain join" after resolving any conflicting issues.') % m.groupdict().get('message'))
374
					continue
371
					return
375
372
376
				# check for currently called join script
373
				# check for currently called join script
377
				m = regJoinScript.match(line)
374
				m = regJoinScript.match(line)
 Lines 380-392   def system_join(username, password, info_handler = _dummyFunc, error_handler = _ Link Here 
380
					step_handler(stepsPerScript)
377
					step_handler(stepsPerScript)
381
					if 'failed' in line:
378
					if 'failed' in line:
382
						failedJoinScripts.append(m.groupdict().get('script'))
379
						failedJoinScripts.append(m.groupdict().get('script'))
383
					continue
380
					return
384
381
385
				# check for other information
382
				# check for other information
386
				m = regInfo.match(line)
383
				m = regInfo.match(line)
387
				if m:
384
				if m:
388
					info_handler(m.groupdict().get('message'))
385
					info_handler(m.groupdict().get('message'))
389
					continue
386
					return
387
388
			# make stdout file descriptor of the process non-blocking
389
			fd = process.stdout.fileno()
390
			fl = fcntl.fcntl(fd, fcntl.F_GETFL)
391
			fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
392
393
			unfinished_line = ''
394
			while True:
395
				# get the next line
396
				try:
397
					line = process.stdout.read()
398
				except IOError as exc:
399
					if exc.errno == errno.EAGAIN:
400
						continue
401
					raise
402
403
				if not line:
404
					break # no more text from stdout
405
406
				unfinished_line = '' if line.endswith('\n') else '%s%s' % (unfinished_line, line.rsplit('\n', 1)[-1])
407
				for line in line.splitlines():
408
					parse(line)
409
				if unfinished_line:
410
					parse(unfinished_line)
390
411
391
			# get all remaining output
412
			# get all remaining output
392
			stdout, stderr = process.communicate()
413
			stdout, stderr = process.communicate()

Return to bug 40453