我们从Python开源项目中,提取了以下49个代码示例,用于说明如何使用platform.release()。
def default_environment(): if hasattr(sys, 'implementation'): iver = format_full_version(sys.implementation.version) implementation_name = sys.implementation.name else: iver = '0' implementation_name = '' return { "implementation_name": implementation_name, "implementation_version": iver, "os_name": os.name, "platform_machine": platform.machine(), "platform_release": platform.release(), "platform_system": platform.system(), "platform_version": platform.version(), "python_full_version": platform.python_version(), "platform_python_implementation": platform.python_implementation(), "python_version": platform.python_version()[:3], "sys_platform": sys.platform, }
def get_firefox_db(db_file): '''Return the full path of firefox sqlite databases, platform independent''' success = False plat_dict = {"Windows 7" : r"C:\Users\%s\AppData\Roaming\Mozilla\Firefox\Profiles" % os.getlogin(), "Windows XP" : r"C:\Documents and Settings\%s\Application Data\Mozilla\Firefox\Profiles" % os.getlogin(), "Linux" : r"/home/%s/.mozilla/firefox/" % os.getlogin(), "Darwin" : r"/Users/%s/Library/Application Support/Firefox/Profiles" % os.getlogin()} if platform.system() == "Windows": string = plat_dict[platform.system() + " " + platform.release()] else: string = plat_dict[platform.system()] for item in os.listdir(string): if os.path.isdir(os.path.join(string, item)) and "default" in item: if os.path.isfile(os.path.join(string, item, db_file)): success = True return os.path.join(string, item, db_file) if not success: sys.exit("Couldn't find the database file in the default location! Try providing a different location using the -b option...")
def _redraw(self): """ Redraw the plot and ask the widget to display the update. """ # Perform the redraw with the render lock held, preventing the graphics # thread from trying to do a redraw at the same time. self._renderLock.acquire() try: # NB: In matplotlib 0.99, if you call the canvas' draw() method # directly, it immediately redraws the canvas, but sets replot # to true, leading to another redraw when the update is handled # by the graphics thread. FigureCanvasAgg.draw(self._canvas) self._canvas.replot = False self._canvas.update() finally: self._renderLock.release()
def _addTrace(self, port, name): self._linesLock.acquire() try: traceName = '%s-%s' % (port['Port Name'], name) if traceName in self._lines: raise KeyError, "Trace '%s' already exists" % traceName sink = self._createSink(port['Port Interface']) options = self._lineOptions() line, = self._plot.plot([], [], label=name, scalex=False, scaley=False, **options) trace = { 'sink': sink, 'xdelta': None, 'line': line, 'id': name } self._lines[traceName] = trace finally: self._linesLock.release() if self._started: self.start()
def get_items(self): upMinionCount = Host.objects.filter(minion_status=1).count() downMinionCount = Host.objects.filter(minion_status=0).count() # ?????? item_info = Item( html_id='SysInfo', name='??????', display=Item.AS_TABLE, value=( ('??', '%s, %s, %s' % ( platform.system(), ' '.join(platform.linux_distribution()), platform.release())), ('??', ' '.join(platform.architecture())), ('???', platform.processor()), ('Python??', platform.python_version()), ('??????', Host.objects.count()), ('????', Project.objects.count()), ('???????', '??? %s,??? %s' % (upMinionCount, downMinionCount)), ), classes='table-bordered table-condensed ' 'table-hover table-striped' ) return [item_info]
def get_platform_info(self): """ Information regarding the computer where the fuzzer is running """ try: node_properties = { 'node_name' : platform.node(), 'os_release': platform.release(), 'os_version': platform.version(), 'machine' : platform.machine(), 'processor' : platform.processor() } except: self.ae.m_alert('[x] Error getting platform information') return None return node_properties
def render(self): view = View('none') box = BoxElement(title='widget.info.header', icon='server', padding=False) table = TableElement( content=[ ('widget.info.os', '%s %s (%s)' % (platform.system(), platform.release(), platform.architecture()[0])), ('widget.info.hostname', platform.node()), ('widget.info.ipaddress', prism.settings.PRISM_CONFIG['host']), ('widget.info.uptime', self.get_uptime()) ] ) box.add(table) view.add(box) return view
def get_os_info(filepath="/etc/os-release"): """ Get OS name and version :param str filepath: File path of os-release file :returns: (os_name, os_version) :rtype: `tuple` of `str` """ if os.path.isfile(filepath): # Systemd os-release parsing might be viable os_name, os_version = get_systemd_os_info(filepath=filepath) if os_name: return (os_name, os_version) # Fallback to platform module return get_python_os_info()
def get_os_info_ua(filepath="/etc/os-release"): """ Get OS name and version string for User Agent :param str filepath: File path of os-release file :returns: os_ua :rtype: `str` """ if os.path.isfile(filepath): os_ua = _get_systemd_os_release_var("PRETTY_NAME", filepath=filepath) if not os_ua: os_ua = _get_systemd_os_release_var("NAME", filepath=filepath) if os_ua: return os_ua # Fallback return " ".join(get_python_os_info())