pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Python pastebin - collaborative debugging tool View Help


Posted by Zamber on Fri 26 Oct 12:57
report abuse | download | new post

  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. #imports
  4. import os
  5. import sys
  6. import subprocess
  7. from urllib import urlencode
  8.  
  9. def ivnot():
  10.  
  11.     # Create output log file
  12.     outFile = os.path.join(os.curdir, "output.log")
  13.     outptr = file(outFile, "w")
  14.     # Create error log file
  15.     errFile = os.path.join(os.curdir, "error.log")
  16.     errptr = file(errFile, "w")
  17.    
  18.     # pl chars not recognized!
  19.     # leave the b on the ond cause the site reader cuts the last word ;/
  20.     text = "I can read this fluently for you! b"
  21.     url_text = urlencode({'tresc':text})
  22.  
  23.     # Voices:
  24.     # Jennifer                     | eng fem
  25.     # Ewa                          | pol fem
  26.     # Jacek                        | pol mal
  27.     # Carmen+%28drugie+wydanie%29  | hun fem
  28.     # insert after glos= in line 3 of cmd
  29.  
  30.     cmd = [\
  31.            'curl '\
  32.            '-d '\
  33.            '"' + url_text + '&glos=Jennifer&IVONA_odczytaj=%20%20%20Odczytaj20%20" '\
  34.            'http://www.ivo.pl/ivonaonline.html '\
  35.            '| '\
  36.            'grep '\
  37.            '-e '\
  38.            'http:\/\/www.ivo.pl\/media\/ivonaonline\/[a-Z0-9]*.mp3 '\
  39.            '-o '\
  40.            '| '\
  41.            'tail '\
  42.            '-n '\
  43.            '1'\
  44.            ]
  45.  
  46.     #command = str('curl -d "' + url_tresc + '&glos=Ewa&IVONA_odczytaj=%20%20%20Odczytaj20%20" http://www.ivo.pl/ivonaonline.html | grep -e http:\/\/www.ivo.pl\/media\/ivonaonline\/[a-Z0-9]*.mp3 -o | tail -n 1')
  47.  
  48.     retval = subprocess.call(cmd, 0, None, None, outptr, errptr, None, False, True)
  49.  
  50.     # Close log handles
  51.     errptr.close()
  52.     outptr.close()
  53.  
  54.         # Check the process exit code
  55.     if not retval == 0:
  56.         errptr = file(errFile, "r")
  57.         errData = errptr.read()
  58.         errptr.close()
  59.         raise Exception("Error executing command: " + repr(errData))
  60.  
  61.     # mplayer
  62.     outptr = file(outFile, "r")
  63.     outData = outptr.read()
  64.     outptr.close()
  65.     play = "mplayer " + str(outData.replace("\n",""))
  66.     os.system(play)
  67.  
  68. if __name__ == '__main__':
  69.     ivnot()

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me