Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- pastebinit~ 2008-10-21 23:10:38.000000000 -0400
- +++ pastebinit 2008-10-21 23:23:41.000000000 -0400
- @@ -133,9 +133,10 @@
- format = "text"
- username = ""
- password = ""
- - filename = ""
- + filename = "-"
- content = ""
- parentpid = ""
- + fp = sys.stdin
- #Example configuration file string
- configexample = """\
- @@ -174,20 +175,6 @@
- print configexample
- sys.exit(1)
- - #Check if some datas were passed by pipe, if yes directly assign content
- - l_r = select.select([sys.stdin],[],[],0)
- - try:
- - content=l_r[0][0].read()
- - filename="-"
- - except:
- - filename=""
- -
- - # Check number of arguments
- - if len(sys.argv) == 1 and filename == "":
- - print _("Error no arguments specified!\n")
- - Usage()
- - sys.exit(1)
- -
- # Get options
- try:
- optlist, list = getopt.getopt(sys.argv[1:], 'i:f:b:a:r:j:t:m:u:p:')
- @@ -221,26 +208,25 @@
- elif opt[0] == "-p":
- password = opt[1]
- - if filename == "" and list[0]:
- + if len(list) == 1:
- filename = list[0]
- -
- - #If - is specified as a filename read from stdin, otherwise load the specified file.
- - if filename == "":
- - print _("Error no filename specified!\n")
- + elif len(list) > 1:
- + print _("Error too many arguments specified!\n")
- Usage()
- sys.exit(1)
- - elif filename == "-" and content == "":
- - content = sys.stdin.read()
- - sys.exit(_("KeyboardInterrupt caught."))
- - elif content == "":
- +
- + #If - is specified as a filename read from stdin, otherwise load the specified file.
- + if filename != "-":
- try:
- - f = open(filename)
- - content = f.read()
- - f.close()
- - except KeyboardInterrupt:
- - sys.exit(_("KeyboardInterrupt caught."))
- + fp = open(filename)
- except:
- - sys.exit(_("Unable to read from: %s") % filename)
- + sys.exit(_("Unable to open: %s") % filename)
- + try:
- + content = fp.read()
- + except KeyboardInterrupt:
- + sys.exit(_("KeyboardInterrupt caught."))
- + except:
- + sys.exit(_("Unable to read from: %s") % filename)
- 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