Active Topics

 


Reply
Thread Tools
Posts: 32 | Thanked: 2 times | Joined on Jul 2007
#1
Hi; does anyone have duplicity working on OS2008? I installed it apparently successfully, but when I try to run it from the command line, I get

ImportError: No module named getpass

Since getpass is a python system module, it looks like my python installation is hosed.. but other apps, using python from the launcher, seem to run OK. So I guess it is possibly a path problem. If so, does anyone know what magic I need to get python to find the system classes? Or do I need to install the python development system for the system libraries to be available (I tried to install it, but get an uninformative error from application manager - just tells me it failed to install, with no diagnostics)

TIA
Bob
 
jkq's Avatar
Posts: 251 | Thanked: 131 times | Joined on Oct 2009 @ USA
#2
Originally Posted by urilabob View Post
Hi; does anyone have duplicity working on OS2008? I installed it apparently successfully, but when I try to run it from the command line, I get

ImportError: No module named getpass

Since getpass is a python system module,
Just a stab in the dark here, but are you running with the correct version of python? I believe 2.3 comes by default, and 2.5 is available thru the repos.

Running 'python' from the command line gets you 2.3, maybe try running 'python2.5 <script>' instead?

-jkq
__________________
Class .. : Quiet One
Humor .. : [*********-] Alignment: Chaotic Good
Patience : [******----] Weapon(s): Python scripts
Agro ... : [***-------] Relic(s) : N900
 

The Following User Says Thank You to jkq For This Useful Post:
Posts: 32 | Thanked: 2 times | Joined on Jul 2007
#3
Originally Posted by jkq View Post
Running 'python' from the command line gets you 2.3, maybe try running 'python2.5 <script>' instead?

-jkq
Thanks for trying. Unfortunately that doesn't seem to be the problem. I've got 2.5.2 installed (actually, not too sure how - I can't recall ever downloading python explicitly).

The problem seems to be some kind of mis-installation: the python system libraries aren't available. I don't know a lot about python, but I would have expected the system libraries to be part of a runtime installation. Plus nothing else seems to be broken. So probably, it's just telling python about the right path. But I did try to install the developer system, package manager fails to install it, so maybe there is a misconfiguration.
 
jkq's Avatar
Posts: 251 | Thanked: 131 times | Joined on Oct 2009 @ USA
#4
Originally Posted by urilabob View Post
Thanks for trying. Unfortunately that doesn't seem to be the problem. I've got 2.5.2 installed (actually, not too sure how - I can't recall ever downloading python explicitly).
I think most of the apps that use python in the repos use 2.5, so something you installed must have pulled it in.

Originally Posted by urilabob View Post
The problem seems to be some kind of mis-installation: the python system libraries aren't available. I don't know a lot about python, but I would have expected the system libraries to be part of a runtime installation. Plus nothing else seems to be broken. So probably, it's just telling python about the right path. But I did try to install the developer system, package manager fails to install it, so maybe there is a misconfiguration.
I tried importing getpass from an interactive session on my N800, and it failed. On my windows box, it works though. So perhaps the getpass module is not provided by default on the tablets. Perhaps you should ask if someone can package it up for you.

-jkq
__________________
Class .. : Quiet One
Humor .. : [*********-] Alignment: Chaotic Good
Patience : [******----] Weapon(s): Python scripts
Agro ... : [***-------] Relic(s) : N900
 

The Following User Says Thank You to jkq For This Useful Post:
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#5
Try this as root from inside an xterm on your tablet:

scp <username>@<linux_box_with_python2.5>:/usr/lib/python2.5/getpass.py /usr/lib/python2.5

Or, as root on your tablet, you can copy and paste the following to /usr/lib/python2.5/getpass.py:

Code:
"""Utilities to get a password and/or the current user name.

getpass(prompt) - prompt for a password, with echo turned off
getuser() - get the user name from the environment or password database

On Windows, the msvcrt module will be used.
On the Mac EasyDialogs.AskPassword is used, if available.

"""

# Authors: Piers Lauder (original)
#          Guido van Rossum (Windows support and cleanup)

import sys

__all__ = ["getpass","getuser"]

def unix_getpass(prompt='Password: ', stream=None):
    """Prompt for a password, with echo turned off.
    The prompt is written on stream, by default stdout.

    Restore terminal settings at end.
    """
    if stream is None:
        stream = sys.stdout

    try:
        fd = sys.stdin.fileno()
    except:
        return default_getpass(prompt)

    old = termios.tcgetattr(fd)     # a copy to save
    new = old[:]

    new[3] = new[3] & ~termios.ECHO # 3 == 'lflags'
    try:
        termios.tcsetattr(fd, termios.TCSADRAIN, new)
        passwd = _raw_input(prompt, stream)
    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old)

    stream.write('\n')
    return passwd


def win_getpass(prompt='Password: ', stream=None):
    """Prompt for password with echo off, using Windows getch()."""
    if sys.stdin is not sys.__stdin__:
        return default_getpass(prompt, stream)
    import msvcrt
    for c in prompt:
        msvcrt.putch(c)
    pw = ""
    while 1:
        c = msvcrt.getch()
        if c == '\r' or c == '\n':
            break
        if c == '\003':
            raise KeyboardInterrupt
        if c == '\b':
            pw = pw[:-1]
        else:
            pw = pw + c
    msvcrt.putch('\r')
    msvcrt.putch('\n')
    return pw


def default_getpass(prompt='Password: ', stream=None):
    print >>sys.stderr, "Warning: Problem with getpass. Passwords may be echoed."
    return _raw_input(prompt, stream)


def _raw_input(prompt="", stream=None):
    # A raw_input() replacement that doesn't save the string in the
    # GNU readline history.
    if stream is None:
        stream = sys.stdout
    prompt = str(prompt)
    if prompt:
        stream.write(prompt)
    line = sys.stdin.readline()
    if not line:
        raise EOFError
    if line[-1] == '\n':
        line = line[:-1]
    return line


def getuser():
    """Get the username from the environment or password database.

    First try various environment variables, then the password
    database.  This works on Windows as long as USERNAME is set.

    """

    import os

    for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
        user = os.environ.get(name)
        if user:
            return user

    # If this fails, the exception will "explain" why
    import pwd
    return pwd.getpwuid(os.getuid())[0]

# Bind the name getpass to the appropriate function
try:
    import termios
    # it's possible there is an incompatible termios from the
    # McMillan Installer, make sure we have a UNIX-compatible termios
    termios.tcgetattr, termios.tcsetattr
except (ImportError, AttributeError):
    try:
        import msvcrt
    except ImportError:
        try:
            from EasyDialogs import AskPassword
        except ImportError:
            getpass = default_getpass
        else:
            getpass = AskPassword
    else:
        getpass = win_getpass
else:
    getpass = unix_getpass
__________________
N9: Go white or go home
 

The Following User Says Thank You to daperl For This Useful Post:
Posts: 32 | Thanked: 2 times | Joined on Jul 2007
#6
Thank you, that completely solved my problem! I really appreciate your help.

I guess it brings up a wider question: why system libraries that are almost certain to be required by applications (and are actually required by applications available from the standard repo via package manager) are not in the N800 base installation, or at worst available as an add-on. I know space is at a premium; but there are quite reasonable potential solutions available. But I guess this isn't the right place to raise this...

Thanks again, and Best Wishes
Bob

Originally Posted by daperl View Post
Try this as root from inside an xterm on your tablet:

scp <username>@<linux_box_with_python2.5>:/usr/lib/python2.5/getpass.py /usr/lib/python2.5

Or, as root on your tablet, you can copy and paste the following to /usr/lib/python2.5/getpass.py:

Code:
"""Utilities to get a password and/or the current user name.

getpass(prompt) - prompt for a password, with echo turned off
getuser() - get the user name from the environment or password database

On Windows, the msvcrt module will be used.
On the Mac EasyDialogs.AskPassword is used, if available.

"""

# Authors: Piers Lauder (original)
#          Guido van Rossum (Windows support and cleanup)

import sys

__all__ = ["getpass","getuser"]

def unix_getpass(prompt='Password: ', stream=None):
    """Prompt for a password, with echo turned off.
    The prompt is written on stream, by default stdout.

    Restore terminal settings at end.
    """
    if stream is None:
        stream = sys.stdout

    try:
        fd = sys.stdin.fileno()
    except:
        return default_getpass(prompt)

    old = termios.tcgetattr(fd)     # a copy to save
    new = old[:]

    new[3] = new[3] & ~termios.ECHO # 3 == 'lflags'
    try:
        termios.tcsetattr(fd, termios.TCSADRAIN, new)
        passwd = _raw_input(prompt, stream)
    finally:
        termios.tcsetattr(fd, termios.TCSADRAIN, old)

    stream.write('\n')
    return passwd


def win_getpass(prompt='Password: ', stream=None):
    """Prompt for password with echo off, using Windows getch()."""
    if sys.stdin is not sys.__stdin__:
        return default_getpass(prompt, stream)
    import msvcrt
    for c in prompt:
        msvcrt.putch(c)
    pw = ""
    while 1:
        c = msvcrt.getch()
        if c == '\r' or c == '\n':
            break
        if c == '\003':
            raise KeyboardInterrupt
        if c == '\b':
            pw = pw[:-1]
        else:
            pw = pw + c
    msvcrt.putch('\r')
    msvcrt.putch('\n')
    return pw


def default_getpass(prompt='Password: ', stream=None):
    print >>sys.stderr, "Warning: Problem with getpass. Passwords may be echoed."
    return _raw_input(prompt, stream)


def _raw_input(prompt="", stream=None):
    # A raw_input() replacement that doesn't save the string in the
    # GNU readline history.
    if stream is None:
        stream = sys.stdout
    prompt = str(prompt)
    if prompt:
        stream.write(prompt)
    line = sys.stdin.readline()
    if not line:
        raise EOFError
    if line[-1] == '\n':
        line = line[:-1]
    return line


def getuser():
    """Get the username from the environment or password database.

    First try various environment variables, then the password
    database.  This works on Windows as long as USERNAME is set.

    """

    import os

    for name in ('LOGNAME', 'USER', 'LNAME', 'USERNAME'):
        user = os.environ.get(name)
        if user:
            return user

    # If this fails, the exception will "explain" why
    import pwd
    return pwd.getpwuid(os.getuid())[0]

# Bind the name getpass to the appropriate function
try:
    import termios
    # it's possible there is an incompatible termios from the
    # McMillan Installer, make sure we have a UNIX-compatible termios
    termios.tcgetattr, termios.tcsetattr
except (ImportError, AttributeError):
    try:
        import msvcrt
    except ImportError:
        try:
            from EasyDialogs import AskPassword
        except ImportError:
            getpass = default_getpass
        else:
            getpass = AskPassword
    else:
        getpass = win_getpass
else:
    getpass = unix_getpass
 
daperl's Avatar
Posts: 2,427 | Thanked: 2,986 times | Joined on Dec 2007
#7
Originally Posted by urilabob View Post
Thank you, that completely solved my problem! I really appreciate your help.

I guess it brings up a wider question: why system libraries that are almost certain to be required by applications (and are actually required by applications available from the standard repo via package manager) are not in the N800 base installation, or at worst available as an add-on. I know space is at a premium; but there are quite reasonable potential solutions available. But I guess this isn't the right place to raise this...

Thanks again, and Best Wishes
Bob
You're welcome. No, you have a valid question. It's weird, 'cause I find getpass.py at the link below. And it seems to be part of the Diablo python2.5 source. But its not inside the Diablo python2.5 .deb at this link. So, I'm not sure what's going on. It's inside the python2.5 .deb for both etch and lenny.

https://stage.maemo.org/svn/maemo/pr...2.5-2.5.0/Lib/
__________________
N9: Go white or go home
 
Posts: 32 | Thanked: 2 times | Joined on Jul 2007
#8
Originally Posted by daperl View Post
You're welcome. No, you have a valid question. It's weird, 'cause I find getpass.py at the link below. And it seems to be part of the Diablo python2.5 source. But its not inside the Diablo python2.5 .deb at this link. So, I'm not sure what's going on. It's inside the python2.5 .deb for both etch and lenny.

https://stage.maemo.org/svn/maemo/pr...2.5-2.5.0/Lib/
It doesn't seem to be the only one missing, I also had to add statvfs.py, I guess those were just the modules that happened to be used by duplicity. Ah well, I guess someone had a valid reason.
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:10.