Henrique de Moraes Holschuh wrote:
> ------------------------------------------------------------------------
> 
> #! /bin/sh /usr/share/dpatch/dpatch-run
> ## 60_lp_instead_of_lpr.dpatch by  <[EMAIL PROTECTED]>
> ##
> ## All lines beginning with `## DP:' are a description of the patch.
> ## DP: Use SysV lp instead of BSD lpr
> 
> @DPATCH@
> diff -urNad hplip~/base/device.py hplip/base/device.py
> --- hplip~/base/device.py     2006-06-16 09:59:42.000000000 -0300
> +++ hplip/base/device.py      2006-06-16 10:03:22.033189743 -0300
> @@ -1634,23 +1634,22 @@
>                  self.writePrint(file(file_name, 'r').read())
>  
>          else:
> -            raw_str = ''
> -            rem_str = ''
> -
>              if raw:
> -                raw_str = '-l'
> -
> -            if remove:
> -                rem_str = '-r'
> +                lp_opt = '-oraw'
> +            else:
> +                lp_opt = ''
>  
>              if is_gzip:
> -                c = 'gunzip -c %s | lpr %s %s -P%s' % (file_name, raw_str, 
> rem_str, printer_name)
> +                c = 'gunzip -c %s | lp -c -d%s %s' % (file_name, 
> printer_name, lp_opt)
>              else:
> -                c = 'lpr -P%s %s %s %s' % (printer_name, raw_str, rem_str, 
> file_name)
> +                c = 'lp -c -d%s %s %s' % (printer_name, lp_opt, file_name)
>  
>              log.debug(c)
>              os.system(c)
>  
> +            if remove:
> +                os.remove(file_name)
> +
>  

I am a little concerned in this case about a race condition with the 
'lp' command and the os.remove(). Isn't there a possibility that the 
os.remove() will remove the file before 'lp' has had a chance to process 
it? That was a real advantage to 'lpr' and the use of -r.

-Don



_______________________________________________
HPLIP-Devel mailing list
HPLIP-Devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/hplip-devel

Reply via email to