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)