asuka-sato / parallel-ssh

Automatically exported from code.google.com/p/parallel-ssh
Other
0 stars 0 forks source link

pssh inserts extra spaces between output chunks in outdir files #6

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Example:

> pssh --par=1 --print --hosts=hosts.txt --outdir=outdir --errdir=errdir
'for i in 5 4 3 2 1;do echo -n "$i,";sleep 0.01;done;echo "done"'
hosta01: 5, hosta01: 4,3,2, hosta01: 1, hosta01: done
[1] 13:54:56 [SUCCESS] hosta01
hosta02: 5, hosta02: 4,3,2, hosta02: 1, hosta02: done
[2] 13:54:56 [SUCCESS] hosta02
hostb01: 5, hostb01: 4,3,2,1,done
[3] 13:54:56 [SUCCESS] hostb01
hostb02: 5, hostb02: 4,3,2,1,done
[4] 13:54:57 [SUCCESS] hostb02
hostc01: 5, hostc01: 4,3,2, hostc01: 1, hostc01: done
[5] 13:54:57 [SUCCESS] hostc01
hostc02: 5, hostc02: 4,3,2, hostc02: 1, hostc02: done
[6] 13:54:57 [SUCCESS] hostc02
hostd01: 5, hostd01: 4,3,2,1,done
[7] 13:54:58 [SUCCESS] hostd01
hostd02: 5,4, hostd02: 3,2,1,done
[8] 13:54:58 [SUCCESS] hostd02

> cat outdir/*
5, 4,3,2, 1, done
5, 4,3,2, 1, done
5, 4,3,2,1,done
5, 4,3,2,1,done
5, 4,3,2, 1, done
5, 4,3,2, 1, done
5, 4,3,2,1,done
5,4, 3,2,1,done

The spaces correspond to the chunks of output as reported by --print, but
they should not be there. --inline shows the proper output (without spaces)
so the bug would likely be in the --outdir code.

This is pssh-2.0 on Red Hat Enterprise Linux 5 (python-2.4.3-24.el5)

Original issue reported on code.google.com by mark.d.k...@gmail.com on 7 Dec 2009 at 7:24

GoogleCodeExporter commented 8 years ago
This appears to fix it:

*** manager.py.save1    Tue Oct 20 17:20:51 2009
--- manager.py  Thu Dec 10 16:55:14 2009
***************
*** 205,211 ****
                  if data == self.EOF:
                      dest.close()
                  else:
!                     print >>dest, data,

      def open_files(self, host):
          """Called from another thread to create files for stdout and stderr.
--- 205,211 ----
                  if data == self.EOF:
                      dest.close()
                  else:
!                     dest.write(data)

      def open_files(self, host):
          """Called from another thread to create files for stdout and stderr.

Original comment by mark.d.k...@gmail.com on 10 Dec 2009 at 9:56

GoogleCodeExporter commented 8 years ago
I would have gotten back to you on this earlier, but Google Code wasn't sending 
me 
emails about updates to issues.  Sorry about that.  I just tested this and was 
able to 
reproduce the problem.  I'm going to look into this for a few more minutes, but 
I 
think I'll probably end up applying your patch as-is.  Thanks for finding the 
problem 
and looking into it.

Original comment by amcna...@gmail.com on 16 Feb 2010 at 7:59

GoogleCodeExporter commented 8 years ago
I've applied your patch and pushed the changes into Git.  This will be included 
in the 
next release of PSSH.  Thanks.

By the way, you learn something new every day.  I didn't realize that Python's 
print 
statement adds spaces even when used with a trailing comma.  Maybe I knew this 
at some 
point, but it was a surprise to me today. :)

Original comment by amcna...@gmail.com on 16 Feb 2010 at 8:13