liarcn / parallel-ssh

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

Wouldn't it be nice if you could comment the HOSTS? #69

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

Wouldn't it be nice if you could comment the HOSTS?

Like:
====
dms@ubuntu2:~/pssh/pssh$<mailto:dms@ubuntu2:~/pssh/pssh$> more 
~/nodes_test.txt
198.18.1.97 #dmsapp1-sh
198.18.1.98 #dmsdb1-sh
198.18.1.99 #dmsfe1-sh
198.18.1.100 #dmsindex1-sh
198.18.1.101 #dmsgraph1-sh
198.18.1.102 #dmsprobe1-sh
198.18.1.104 #dmsdev1-sh
198.18.1.117 #dmsfeb12
dms@ubuntu2:~/pssh/pssh$

dms@ubuntu2:~/pssh/pssh$<mailto:dms@ubuntu2:~/pssh/pssh$> diff -u 
psshlib/psshutil.py 
/usr/lib/python2.5/site-packages/psshlib/psshutil.py
--- psshlib/psshutil.py 2012-04-21 14:28:27.000000000 +0200
+++ /usr/lib/python2.5/site-packages/psshlib/psshutil.py        012-04-21 
14:35:58.000000000 +0200
@@ -54,7 +54,15 @@

     Returns a (host, port, user) triple.
     """
-    fields = line.split()
+    import re
+
+    if re.search("#", line):
+       line1, line2= re.split("#", line);
+    else:
+       line1= line;
+
+    fields = line1.split()
+
     if len(fields) > 2:
         sys.stderr.write('Bad line: "%s". Format should be'
                 ' [user@]host[:port] [user]\n' % line) 
dms@ubuntu2:~/pssh/pssh$<mailto:dms@ubuntu2:~/pssh/pssh$>

Original issue reported on code.google.com by tripled...@gmail.com on 23 Apr 2012 at 4:12

GoogleCodeExporter commented 9 years ago
This seems like a reasonable request. Right now, single line comments work, but 
pssh doesn't support trailing comments.

One minor concern is that regular expressions are a little heavy for this task. 
A simple split on '#' would be a little simpler. Or alternatively, we could use 
a regular expression for all of the parsing, but that might be more complicated 
than what we already have.

Original comment by amcna...@gmail.com on 23 Apr 2012 at 4:29

GoogleCodeExporter commented 9 years ago
The attached patch implements support for trailing comments

Original comment by jcp...@gmail.com on 11 Jan 2013 at 6:29

Attachments: