# HG changeset patch
# User remy-d1
# Date 1362479041 18000
# Node ID 33bb43de178f14f7adc2216fb9eb685b34680a9d
# Parent ec6fdbac353fd7863a4b8d4fe2046fc68486ab9a
1st upload for print.py
diff -r ec6fdbac353f -r 33bb43de178f print.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/print.py Tue Mar 05 05:24:01 2013 -0500
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+
+import sys
+import subprocess
+import json
+
+def sendcommand(cmd):
+ """
+ Take a shell bash command
+ Return the stdout value for a pipe subprocess
+ """
+ proc = subprocess.Popen("bash",shell=True,stdin=subprocess.PIPE\
+,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
+ return proc.communicate(cmd)[0]
+
+
+def nl2br(string, is_xhtml= True ):
+ if is_xhtml:
+ return string.replace('\n','
\n')
+ else:
+ return string.replace('\n','
\n')
+
+
+if __name__=="__main__":
+ nb_args = len(sys.argv)
+ html = "
"
+ if nb_args == 1:
+ html += sys.argv[1]
+ else:
+ cmd = sys.argv[1]+" "+sys.argv[2]+" "+sys.argv[3]
+ html += cmd+"
"
+ html += "Result(s) :
"
+ content = sendcommand(sys.argv[1]+" "+sys.argv[2]+" "+sys.argv[3])
+ content = nl2br(content)
+ if sys.argv[4] == 'false':
+ #content = json.dumps(json.loads(content), sort_keys = True, indent = 2)
+ #content = json.dumps(content, sort_keys=True, indent=4, separators=(',', ': ')
+ html += content
+ else:
+ html += "
"+content+"" + html += "" + html += "" + print html