Advertisement
Guest User

Untitled

a guest
May 9th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. --- pastebinit~ 2008-10-21 23:10:38.000000000 -0400
  2. +++ pastebinit 2008-10-21 23:23:41.000000000 -0400
  3. @@ -133,9 +133,10 @@
  4. format = "text"
  5. username = ""
  6. password = ""
  7. - filename = ""
  8. + filename = "-"
  9. content = ""
  10. parentpid = ""
  11. + fp = sys.stdin
  12.  
  13. #Example configuration file string
  14. configexample = """\
  15. @@ -174,20 +175,6 @@
  16. print configexample
  17. sys.exit(1)
  18.  
  19. - #Check if some datas were passed by pipe, if yes directly assign content
  20. - l_r = select.select([sys.stdin],[],[],0)
  21. - try:
  22. - content=l_r[0][0].read()
  23. - filename="-"
  24. - except:
  25. - filename=""
  26. -
  27. - # Check number of arguments
  28. - if len(sys.argv) == 1 and filename == "":
  29. - print _("Error no arguments specified!\n")
  30. - Usage()
  31. - sys.exit(1)
  32. -
  33. # Get options
  34. try:
  35. optlist, list = getopt.getopt(sys.argv[1:], 'i:f:b:a:r:j:t:m:u:p:')
  36. @@ -221,26 +208,25 @@
  37. elif opt[0] == "-p":
  38. password = opt[1]
  39.  
  40. - if filename == "" and list[0]:
  41. + if len(list) == 1:
  42. filename = list[0]
  43. -
  44. - #If - is specified as a filename read from stdin, otherwise load the specified file.
  45. - if filename == "":
  46. - print _("Error no filename specified!\n")
  47. + elif len(list) > 1:
  48. + print _("Error too many arguments specified!\n")
  49. Usage()
  50. sys.exit(1)
  51. - elif filename == "-" and content == "":
  52. - content = sys.stdin.read()
  53. - sys.exit(_("KeyboardInterrupt caught."))
  54. - elif content == "":
  55. +
  56. + #If - is specified as a filename read from stdin, otherwise load the specified file.
  57. + if filename != "-":
  58. try:
  59. - f = open(filename)
  60. - content = f.read()
  61. - f.close()
  62. - except KeyboardInterrupt:
  63. - sys.exit(_("KeyboardInterrupt caught."))
  64. + fp = open(filename)
  65. except:
  66. - sys.exit(_("Unable to read from: %s") % filename)
  67. + sys.exit(_("Unable to open: %s") % filename)
  68. + try:
  69. + content = fp.read()
  70. + except KeyboardInterrupt:
  71. + sys.exit(_("KeyboardInterrupt caught."))
  72. + except:
  73. + sys.exit(_("Unable to read from: %s") % filename)
  74.  
  75. params = getParameters(website, content, user, jabberid, version, format, parentpid, permatag, title, username, password) #Get the parameters array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement