Not enough arguments for format string

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kevin Walzer

    #1

    Not enough arguments for format string

    I'm getting an error in a Python script I'm writing: "not enough
    arguments for format string." The error comes at the end of the
    os.system command, referenced below. Any ideas?

    ---

    import EasyDialogs
    import os
    import sys


    password = EasyDialogs.Ask Password("To launch Ethereal, please enter
    your password:")
    binpath = os.path.join(os .path.dirname(s ys.argv[0]),
    '/opt/local/bin/ethereal')

    os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
    DISPLAY; echo %s | sudo -S %s; sudo -k' %password %binpath)

    TypeError: not enough arguments for format string


    --
    Cheers,

    Kevin Walzer, PhD
    WordTech Software - "Tame the Terminal"

    sw at wordtech-software.com
  • Pierre Barbier de Reuille

    #2
    Re: Not enough arguments for format string

    Kevin Walzer a écrit :[color=blue]
    > I'm getting an error in a Python script I'm writing: "not enough
    > arguments for format string." The error comes at the end of the
    > os.system command, referenced below. Any ideas?
    >
    > ---
    >
    > import EasyDialogs
    > import os
    > import sys
    >
    >
    > password = EasyDialogs.Ask Password("To launch Ethereal, please enter
    > your password:")
    > binpath = os.path.join(os .path.dirname(s ys.argv[0]),
    > '/opt/local/bin/ethereal')
    >
    > os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
    > DISPLAY; echo %s | sudo -S %s; sudo -k' %password %binpath)
    >
    > TypeError: not enough arguments for format string
    >
    >[/color]

    Well, just try :
    os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
    DISPLAY; echo %s | sudo -S %s; sudo -k' % (password, binpath) )

    The reason is, you have 2 "%s" in yor string, thus after the "%"
    operator, you need a 2-element tuple ! If you have either more or less
    element, you'll get a TypeError ! In your code above you put a single
    element ...

    Pierre

    Comment

    • James

      #3
      Re: Not enough arguments for format string

      Missing a comma there :)

      On 14/11/05, johnnie pittman <johnnie.pittma n@gmail.com> wrote:[color=blue]
      > So the line above should be:
      >
      > os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
      > DISPLAY; echo %s | sudo -S %s; sudo -k' % (password binpath))
      >
      > try that.[/color]

      os.system('open -a X11.app; cd ~/; printenv; DISPLAY=:0.0; export
      DISPLAY; echo %s | sudo -S %s; sudo -k' % (password, binpath))

      Comment

      Working...