Re: [master 4/6] logging: simplify stdout logging in execWithCallback().

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/20/2010 08:22 AM, Ales Kozumplik wrote:
> ---
>  iutil.py |   13 ++++---------
>  1 files changed, 4 insertions(+), 9 deletions(-)
> 
> diff --git a/iutil.py b/iutil.py
> index 63582c4..d026bcf 100644
> --- a/iutil.py
> +++ b/iutil.py
> @@ -294,7 +294,7 @@ def execWithCallback(command, argv, stdin = None, stdout = None,
>      os.close(p[1])
>      os.close(p_stderr[1])
>  
> -    logline = ''
> +    log_output = ''
>      while 1:
>          try:
>              s = os.read(p[0], 1)
> @@ -304,12 +304,7 @@ def execWithCallback(command, argv, stdin = None, stdout = None,
>  
>          if echo:
>              os.write(stdout, s)
> -
> -        if s == '\n':
> -            program_log.info(logline)
> -            logline = ''
> -        else:
> -            logline += s
> +        log_output += s
>  
>          if callback:
>              callback(s, callback_data=callback_data)
> @@ -325,8 +320,8 @@ def execWithCallback(command, argv, stdin = None, stdout = None,
>  
>          if len(s) < 1:
>              break
> -    if len(logline) > 0:
> -        program_log.info(logline)
> +
> +    map(program_log.info, log_output.splitlines())
>  
>      log_errors = ''
>      while 1:

I like that. One question though -- what about when an IOError != 4 is
raised? We will lose all of the output. This appears to be the case for
stderr output in the existing code as well.

I'm not sure how important that is -- I don't know exactly what would
raise IOError != 4 so maybe it isn't really an issue.


- -- 
Brian C. Lane <bcl@xxxxxxxxxx>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iQEVAwUBS/WBSBF+jBaO/jp/AQJomAgAmELJuOcOCSiPMTCD02kEnh7kn04mNPdY
uEGz4UBYtLX3o+gA/TvTuIeV9FbjtPQCsKFG+zhHyRk6xbsXdQUMs+S9v8oGlkFd
SHrw9O/4wBduIFNaxOzt/wVF+Jn/fSdgc32oTWi9ml/Tt9uTgpS+1DuwYJhZQ7+u
8rg0fRjkOfEQcEdheg1UkaGULfRyLFG7nkLd5rHVoADmAbV+O69IuFrGtKd8nITZ
kGx9lfH15u+IR7C96lBfomdURQFAofultGs2vPK2F50GP8G9qmcTe5pFwhNWXLcc
7+QDyCGL/7s+5dfXD+tBQPoMAAsrsRbqH4vfDRRV7NxLBFUqCFnZuA==
=kaON
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux