Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let platform.uname try harder #47161

Closed
benjaminp opened this issue May 19, 2008 · 18 comments
Closed

let platform.uname try harder #47161

benjaminp opened this issue May 19, 2008 · 18 comments
Assignees
Labels
easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@benjaminp
Copy link
Contributor

BPO 2912
Nosy @malemburg, @benjaminp
Files
  • platform.patch: Patch for platform.py to correct bug 2912
  • platform2.diff
  • platform3.diff
  • platform4.diff
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/malemburg'
    closed_at = <Date 2008-06-13.15:12:04.993>
    created_at = <Date 2008-05-19.00:16:09.904>
    labels = ['easy', 'type-feature', 'library']
    title = 'let platform.uname try harder'
    updated_at = <Date 2008-06-13.15:12:04.992>
    user = 'https://github.com/benjaminp'

    bugs.python.org fields:

    activity = <Date 2008-06-13.15:12:04.992>
    actor = 'benjamin.peterson'
    assignee = 'lemburg'
    closed = True
    closed_date = <Date 2008-06-13.15:12:04.993>
    closer = 'benjamin.peterson'
    components = ['Library (Lib)']
    creation = <Date 2008-05-19.00:16:09.904>
    creator = 'benjamin.peterson'
    dependencies = []
    files = ['10594', '10607', '10619', '10620']
    hgrepos = []
    issue_num = 2912
    keywords = ['patch', 'easy']
    message_count = 18.0
    messages = ['67052', '67796', '67798', '67799', '67804', '67913', '67914', '67924', '68029', '68098', '68108', '68111', '68139', '68162', '68165', '68166', '68167', '68168']
    nosy_count = 3.0
    nosy_names = ['lemburg', 'benjamin.peterson', 'jjt009']
    pr_nums = []
    priority = 'low'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue2912'
    versions = ['Python 2.6']

    @benjaminp
    Copy link
    Contributor Author

    Sometimes os.uname (which is used to bootstrap platform.uname) can
    return 'unknown' for some items. The fallback code in platform.uname can
    usually fill these blanks in. However, this is only used when os.uname
    is not present. It would be useful if platform tried to fill these
    unknowns in.

    @benjaminp benjaminp added easy type-feature A feature request or enhancement stdlib Python modules in the Lib dir labels May 19, 2008
    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 7, 2008

    I can work on this task.

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 7, 2008

    i'm looking at the source and there doesn't appear to be a function
    uname within os.py. are we just considering the uname function in
    platform.py?

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 7, 2008

    much handling code already seems to exist under the line
    except AttributeError:
    in platform.py (function uname(), lines 1101-1161 platform.py)
    i'm not too familiar with the Python codebase (i just began developing
    with Python a few days back)

    @benjaminp
    Copy link
    Contributor Author

    Thanks for volunteering, James! I think you misunderstood the task. Do
    you see how in platform's uname, it only tries to find missing values
    for os.uname if os.uname doesn't exist? Sometimes os.uname exists, but
    it doesn't provide all the values. Your task is to modify platform.uname
    to try to fill in missing values in os.uname if they are present.

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 10, 2008

    Alright, that makes things much clearer.
    I'm looking at this code snippet in platform.py:
    if system == 'unknown':
    system = ''
    if node == 'unknown':
    node = ''
    if release == 'unknown':
    release = ''
    if version == 'unknown':
    version = ''
    if machine == 'unknown':
    machine = ''
    if processor == 'unknown':
    processor = ''

    So essentially what you want me to do is add code that tries to replace
    the ''s with meaningful information. From what I understand, os.uname()
    is only defined in posix-based systems (it is imported from the module
    posix, after all). That means that 'unknown' is returned because the
    uname command is unable to retrieve the necessary information. Are there
    any alternatives to uname that could provide me with system info?

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 10, 2008

    Ah, ok, the code under except AttributeError: gives me some good ideas.
    Should I use the methods utilized there to extract information from the
    system?

    @benjaminp
    Copy link
    Contributor Author

    Ah, ok, the code under except AttributeError: gives me some good ideas.
    Should I use the methods utilized there to extract information from the
    system?

    Right on! You don't need to write any new code, just make sure the code
    under the except AttributeError is utilized even if os.uname returns
    blank spots.

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 11, 2008

    Here is the patch (apply to platform.py)

    @benjaminp
    Copy link
    Contributor Author

    Thanks for doing this. Would you please try on Windows the patch, I'm
    attaching now?

    @jjt009
    Copy link
    Mannequin

    jjt009 mannequin commented Jun 13, 2008

    Your patch works perfectly on windows. Thanks for your help.

    @benjaminp
    Copy link
    Contributor Author

    Marc, could you look at this please?

    @malemburg
    Copy link
    Member

    There are two patches. Which one do you want me to look at ?

    Note that platform.py should stay Python 1.5.2 compatible, ie. no new
    builtins, no True/False.

    The second patch also appears to mix tabs/spaces.

    @benjaminp
    Copy link
    Contributor Author

    Ok. I ran it through reindent.py and removed the True and False.

    @malemburg
    Copy link
    Member

    On 2008-06-13 16:20, Benjamin Peterson wrote:

    Benjamin Peterson <musiccomposition@gmail.com> added the comment:

    Ok. I ran it through reindent.py and removed the True and False.

    Thanks, but the all() is still there :-)

    You can change that to:

    ... or not filter(None, [system, node, release, version, machine]):

    should work on all Python versions.

    @benjaminp
    Copy link
    Contributor Author

    Wow, I really admire you for keeping it compatible with Python 1.5. As
    you may have noticed, I'm addicted to new feature. :)

    @malemburg
    Copy link
    Member

    On 2008-06-13 16:59, Benjamin Peterson wrote:

    Benjamin Peterson <musiccomposition@gmail.com> added the comment:

    Wow, I really admire you for keeping it compatible with Python 1.5. As
    you may have noticed, I'm addicted to new feature. :)

    Yeah, well... it's a hobby :-)

    We can probably bump that to Python 2.1 or even 2.3 after 2.6
    is out.

    The main reason for keeping 1.5.2 compatibility was mxCGIPython
    which started platform.py in the first place. Since it turned out
    to be useful for all kinds of things, it's good to be able to
    backport any changes to installations still using older Python
    versions.

    The patches look OK now.

    Thanks,

    Marc-Andre Lemburg
    eGenix.com

    Professional Python Services directly from the Source  (#1, Jun 13 2008)
     >>> Python/Zope Consulting and Support ...        http://www.egenix.com/
     >>> mxODBC.Zope.Database.Adapter ...             http://zope.egenix.com/
     >>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
    ________________________________________________________________________
    2008-07-07: EuroPython 2008, Vilnius, Lithuania            23 days to go

    :::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,MacOSX for free ! ::::

    eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
     D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
            Registered at Amtsgericht Duesseldorf: HRB 46611
    

    @benjaminp
    Copy link
    Contributor Author

    Ok. I applied the patch in r64233.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    easy stdlib Python modules in the Lib dir type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants