Change language

Python | os.uname () method

The os.uname () method in Python is used to retrieve information about the current operating system. This method returns information such as the name, version and version of the current operating system, the computer name on the network, and the hardware ID as attributes of a tuple-like object.

Syntax: os.uname()

Parameters: Not required

Return Type: This method returns a tuple-like object which has five attributes:

  • sysname – operating system name
  • nodename – name of machine on network (implementation-defined)
  • release – operating system release
  • version – operating system version
  • machine – hardware identifier

Example #1

def main():
    arguments = docopt(__doc__)

    logger.setLevel(logging.WARNING)

    if arguments[’--debug’]:
        logger.setLevel(logging.DEBUG)
        logging.getLogger(’ciftify’).setLevel(logging.DEBUG)

    ## set up the top of the log
    logger.info(’{}{}’.format(ciftify.utils.ciftify_logo(),
        ciftify.utils.section_header(’Starting ciftify_atlas_report’)))

    ciftify.utils.log_arguments(arguments)

    with ciftify.utils.TempDir() as tmpdir:
        logger.info(’Creating tempdir:{} on host:{}’.format(tmpdir,
                    os.uname()[1]))
        ret = run_ciftify_dlabel_report(arguments, tmpdir) 

Example #2

def _syscmd_uname(option,default=’’):

    """ Interface to the system’s uname command.
    """
    if sys.platform in (’dos’,’win32’,’win16’,’os2’):
        # XXX Others too ?
        return default
    try:
        f = os.popen(’uname %s 2> %s’ % (option, DEV_NULL))
    except (AttributeError,os.error):
        return default
    output = f.read().strip()
    rc = f.close()
    if not output or rc:
        return default
    else:
        return output 

Example #3

def _mac_ver_xml():
    fn = ’/System/Library/CoreServices/SystemVersion.plist’
    if not os.path.exists(fn):
        return None

    try:
        import plistlib
    except ImportError:
        return None

    pl = plistlib.readPlist(fn)
    release = pl[’ProductVersion’]
    versioninfo=(’’, ’’, ’’)
    machine = os.uname().machine
    if machine in (’ppc’, ’Power Macintosh’):
        # for compatibility with the gestalt based code
        machine = ’PowerPC’

    return release,versioninfo,machine 

Example #4

def main():
    arguments = docopt(__doc__)

    logger.setLevel(logging.WARNING)

    if arguments[’--debug’]:
        logger.setLevel(logging.DEBUG)
        logging.getLogger(’ciftify’).setLevel(logging.DEBUG)

    ## set up the top of the log
    logger.info(’{}{}’.format(ciftify.utils.ciftify_logo(),
        ciftify.utils.section_header(’Starting ciftify_statclust_report’)))

    ciftify.utils.log_arguments(arguments)

    with ciftify.utils.TempDir() as tmpdir:
        logger.info(’Creating tempdir:{} on host:{}’.format(tmpdir,
                    os.uname()[1]))
        ret = run_ciftify_dlabel_report(arguments, tmpdir) 

Example #5

def main():
    arguments = docopt(__doc__)

    logger.setLevel(logging.WARNING)

    if arguments[’--debug’]:
        logger.setLevel(logging.DEBUG)
        logging.getLogger(’ciftify’).setLevel(logging.DEBUG)

    ## set up the top of the log
    logger.info(’{}{}’.format(ciftify.utils.ciftify_logo(),
        ciftify.utils.section_header(’Starting ciftify_dlabel_to_vol’)))

    ciftify.utils.log_arguments(arguments)

    with ciftify.utils.TempDir() as tmpdir:
        logger.info(’Creating tempdir:{} on host:{}’.format(tmpdir,
                    os.uname()[1]))
        ret = run_ciftify_dlabel_to_vol(arguments, tmpdir) 

Shop

Gifts for programmers

Best laptop for Excel

$
Gifts for programmers

Best laptop for Solidworks

$399+
Gifts for programmers

Best laptop for Roblox

$399+
Gifts for programmers

Best laptop for development

$499+
Gifts for programmers

Best laptop for Cricut Maker

$299+
Gifts for programmers

Best laptop for hacking

$890
Gifts for programmers

Best laptop for Machine Learning

$699+
Gifts for programmers

Raspberry Pi robot kit

$150

Latest questions

PythonStackOverflow

Common xlabel/ylabel for matplotlib subplots

1947 answers

PythonStackOverflow

Check if one list is a subset of another in Python

1173 answers

PythonStackOverflow

How to specify multiple return types using type-hints

1002 answers

PythonStackOverflow

Printing words vertically in Python

909 answers

PythonStackOverflow

Python Extract words from a given string

798 answers

PythonStackOverflow

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

606 answers

PythonStackOverflow

Python os.path.join () method

384 answers

PythonStackOverflow

Flake8: Ignore specific warning for entire file

360 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

How to specify multiple return types using type-hints

Printing words vertically in Python

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically