Python platform.platform() Examples
The following are 30
code examples of platform.platform().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
platform
, or try the search function
.
Example #1
Source File: prints.py From pyinfra with MIT License | 6 votes |
def print_support_info(): click.echo(''' If you are having issues with pyinfra or wish to make feature requests, please check out the GitHub issues at https://github.com/Fizzadar/pyinfra/issues . When adding an issue, be sure to include the following: ''') click.echo(' System: {0}'.format(platform.system())) click.echo(' Platform: {0}'.format(platform.platform())) click.echo(' Release: {0}'.format(platform.uname()[2])) click.echo(' Machine: {0}'.format(platform.uname()[4])) click.echo(' pyinfra: v{0}'.format(__version__)) click.echo(' Executable: {0}'.format(sys.argv[0])) click.echo(' Python: {0} ({1}, {2})'.format( platform.python_version(), platform.python_implementation(), platform.python_compiler(), ))
Example #2
Source File: __init__.py From aegea with Apache License 2.0 | 6 votes |
def initialize(): global config, parser from .util.printing import BOLD, RED, ENDC config = AegeaConfig(__name__, use_yaml=True, save_on_exit=False) if not os.path.exists(config.config_files[2]): config_dir = os.path.dirname(os.path.abspath(config.config_files[2])) try: os.makedirs(config_dir) except OSError as e: if not (e.errno == errno.EEXIST and os.path.isdir(config_dir)): raise shutil.copy(os.path.join(os.path.dirname(__file__), "user_config.yml"), config.config_files[2]) logger.info("Wrote new config file %s with default values", config.config_files[2]) config = AegeaConfig(__name__, use_yaml=True, save_on_exit=False) parser = argparse.ArgumentParser( description="{}: {}".format(BOLD() + RED() + __name__.capitalize() + ENDC(), fill(__doc__.strip())), formatter_class=AegeaHelpFormatter ) parser.add_argument("--version", action="version", version="%(prog)s {}\n{} {}\n{}".format( __version__, platform.python_implementation(), platform.python_version(), platform.platform() )) def help(args): parser.print_help() register_parser(help)
Example #3
Source File: core.py From brutemap with GNU General Public License v3.0 | 6 votes |
def saveErrorMessage(): """ Simpan pesan error ke directory ``error`` *brutemap* """ errMsg = "Running version: %s\n" % VERSION_STRING errMsg += "Python version: %s\n" % sys.version.split()[0] errMsg += "Operating system: %s\n" % platform.platform() errMsg += "Command line: %s\n" % re.sub( r".+?%s.py\b" % TOOL_NAME, "%s.py" % TOOL_NAME, " ".join(sys.argv) ) errMsg += ("=" * get_terminal_size()[0]) + "\n" errMsg += getErrorMessage() filename = time.strftime("%d-%m-%Y_%X").replace(":", "-") + ".txt" filepath = os.path.join(DEFAULT.ERROR_DIRECTORY, filename) with open(filepath, "w") as fp: fp.write(errMsg) return filepath
Example #4
Source File: build_verification_code_cnn_model.py From TaiwanTrainVerificationCode2text with Apache License 2.0 | 6 votes |
def build_model_process(self): self.train_data,self.train_labels = self.input_data('train_data',200000) self.test_data,self.test_labels = self.input_data('test_data',40000) self.train_verification_model() print( self.train_correct3,'\n' , self.test_correct3 ) print( self.train_final_score,'\n', self.test_final_score ) self.show_train_history() os.chdir(PATH) if 'cnn_weight' not in os.listdir(): os.makedirs('cnn_weight') if 'Windows' in platform.platform(): self.model.save_weights('{}\\cnn_weight\\verificatioin_code.h5'.format(PATH)) else: self.model.save_weights('{}/cnn_weight/verificatioin_code.h5'.format(PATH)) #===============================================================
Example #5
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def library_extensions(self): c = customized_ccompiler() static_exts = [] if c.compiler_type != 'msvc': # MSVC doesn't understand binutils static_exts.append('.a') if sys.platform == 'win32': static_exts.append('.lib') # .lib is used by MSVC and others if self.search_static_first: exts = static_exts + [so_ext] else: exts = [so_ext] + static_exts if sys.platform == 'cygwin': exts.append('.dll.a') if sys.platform == 'darwin': exts.append('.dylib') return exts
Example #6
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def _find_lib(self, lib_dir, lib, exts): assert is_string(lib_dir) # under windows first try without 'lib' prefix if sys.platform == 'win32': lib_prefixes = ['', 'lib'] else: lib_prefixes = ['lib'] # for each library name, see if we can find a file for it. for ext in exts: for prefix in lib_prefixes: p = self.combine_paths(lib_dir, prefix + lib + ext) if p: break if p: assert len(p) == 1 # ??? splitext on p[0] would do this for cygwin # doesn't seem correct if ext == '.dll.a': lib += '.dll' if ext == '.lib': lib = prefix + lib return lib return False
Example #7
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() mkl_libs = self.get_libs('mkl_libs', self._lib_mkl) info = self.check_libs2(lib_dirs, mkl_libs) if info is None: return dict_append(info, define_macros=[('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)], include_dirs=incl_dirs) if sys.platform == 'win32': pass # win32 has no pthread library else: dict_append(info, libraries=['pthread']) self.set_info(**info)
Example #8
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def calc_info(self): lib_dirs = self.get_lib_dirs() blas_libs = self.get_libs('blas_libs', self._lib_names) info = self.check_libs(lib_dirs, blas_libs, []) if info is None: return else: info['include_dirs'] = self.get_include_dirs() if platform.system() == 'Windows': # The check for windows is needed because has_cblas uses the # same compiler that was used to compile Python and msvc is # often not installed when mingw is being used. This rough # treatment is not desirable, but windows is tricky. info['language'] = 'f77' # XXX: is it generally true? else: lib = self.has_cblas(info) if lib is not None: info['language'] = 'c' info['libraries'] = [lib] info['define_macros'] = [('HAVE_CBLAS', None)] self.set_info(**info)
Example #9
Source File: system_info.py From recruit with Apache License 2.0 | 6 votes |
def calc_info(self): if sys.platform in ['win32']: return lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs() x11_libs = self.get_libs('x11_libs', ['X11']) info = self.check_libs(lib_dirs, x11_libs, []) if info is None: return inc_dir = None for d in include_dirs: if self.combine_paths(d, 'X11/X.h'): inc_dir = d break if inc_dir is not None: dict_append(info, include_dirs=[inc_dir]) self.set_info(**info)
Example #10
Source File: emergency.py From LinuxEmergency with MIT License | 6 votes |
def OSinfo(): '''操作系统基本信息查看''' core_number = psutil.cpu_count() cpu_number = psutil.cpu_count(logical=True) cpu_usage_precent = psutil.cpu_times_percent() mem_info = psutil.virtual_memory() result = { "memtotal": mem_info[0], "memavail": mem_info[1], "memprecn": mem_info[2], "memusage": mem_info[3], "memfreed": mem_info[4], } print ''' 内核版本 : %s CORE数量 : %s CPU数量 : %s CPU使用率 : %s 内存总量 : %s 内存使用率 : %s '''%(str(platform.platform()),str(core_number),str(cpu_number),str(cpu_usage_precent),str(mem_info[0]),str(mem_info[2]))
Example #11
Source File: greengrassHelloWorld.py From aws-greengrass-core-sdk-python with Apache License 2.0 | 6 votes |
def greengrass_hello_world_run(): try: if not my_platform: client.publish( topic="hello/world", queueFullPolicy="AllOrException", payload="Hello world! Sent from Greengrass Core." ) else: client.publish( topic="hello/world", queueFullPolicy="AllOrException", payload="Hello world! Sent from " "Greengrass Core running on platform: {}".format(my_platform), ) except Exception as e: logger.error("Failed to publish message: " + repr(e)) # Asynchronously schedule this function to be run again in 5 seconds Timer(5, greengrass_hello_world_run).start() # Start executing the function above
Example #12
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def library_extensions(self): c = customized_ccompiler() static_exts = [] if c.compiler_type != 'msvc': # MSVC doesn't understand binutils static_exts.append('.a') if sys.platform == 'win32': static_exts.append('.lib') # .lib is used by MSVC and others if self.search_static_first: exts = static_exts + [so_ext] else: exts = [so_ext] + static_exts if sys.platform == 'cygwin': exts.append('.dll.a') if sys.platform == 'darwin': exts.append('.dylib') return exts
Example #13
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def _find_lib(self, lib_dir, lib, exts): assert is_string(lib_dir) # under windows first try without 'lib' prefix if sys.platform == 'win32': lib_prefixes = ['', 'lib'] else: lib_prefixes = ['lib'] # for each library name, see if we can find a file for it. for ext in exts: for prefix in lib_prefixes: p = self.combine_paths(lib_dir, prefix + lib + ext) if p: break if p: assert len(p) == 1 # ??? splitext on p[0] would do this for cygwin # doesn't seem correct if ext == '.dll.a': lib += '.dll' if ext == '.lib': lib = prefix + lib return lib return False
Example #14
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def calc_info(self): lib_dirs = self.get_lib_dirs() incl_dirs = self.get_include_dirs() mkl_libs = self.get_libs('mkl_libs', self._lib_mkl) info = self.check_libs2(lib_dirs, mkl_libs) if info is None: return dict_append(info, define_macros=[('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)], include_dirs=incl_dirs) if sys.platform == 'win32': pass # win32 has no pthread library else: dict_append(info, libraries=['pthread']) self.set_info(**info)
Example #15
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def calc_info(self): lib_dirs = self.get_lib_dirs() blas_libs = self.get_libs('blas_libs', self._lib_names) info = self.check_libs(lib_dirs, blas_libs, []) if info is None: return else: info['include_dirs'] = self.get_include_dirs() if platform.system() == 'Windows': # The check for windows is needed because has_cblas uses the # same compiler that was used to compile Python and msvc is # often not installed when mingw is being used. This rough # treatment is not desirable, but windows is tricky. info['language'] = 'f77' # XXX: is it generally true? else: lib = self.has_cblas(info) if lib is not None: info['language'] = 'c' info['libraries'] = [lib] info['define_macros'] = [('HAVE_CBLAS', None)] self.set_info(**info)
Example #16
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def calc_info(self): if sys.platform in ['win32']: return lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs() x11_libs = self.get_libs('x11_libs', ['X11']) info = self.check_libs(lib_dirs, x11_libs, []) if info is None: return inc_dir = None for d in include_dirs: if self.combine_paths(d, 'X11/X.h'): inc_dir = d break if inc_dir is not None: dict_append(info, include_dirs=[inc_dir]) self.set_info(**info)
Example #17
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def _find_lib(self, lib_dir, lib, exts): assert is_string(lib_dir) # under windows first try without 'lib' prefix if sys.platform == 'win32': lib_prefixes = ['', 'lib'] else: lib_prefixes = ['lib'] # for each library name, see if we can find a file for it. for ext in exts: for prefix in lib_prefixes: p = self.combine_paths(lib_dir, prefix + lib + ext) if p: break if p: assert len(p) == 1 # ??? splitext on p[0] would do this for cygwin # doesn't seem correct if ext == '.dll.a': lib += '.dll' return lib return False
Example #18
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def calc_info(self): lib_dirs = self.get_lib_dirs() blas_libs = self.get_libs('blas_libs', self._lib_names) info = self.check_libs(lib_dirs, blas_libs, []) if info is None: return if platform.system() == 'Windows': # The check for windows is needed because has_cblas uses the # same compiler that was used to compile Python and msvc is # often not installed when mingw is being used. This rough # treatment is not desirable, but windows is tricky. info['language'] = 'f77' # XXX: is it generally true? else: lib = self.has_cblas(info) if lib is not None: info['language'] = 'c' info['libraries'] = [lib] info['define_macros'] = [('HAVE_CBLAS', None)] self.set_info(**info)
Example #19
Source File: what3words.py From w3w-python-wrapper with MIT License | 6 votes |
def _request(self, url_path, params=None): """ Executes request Params ------ :param string url_path: API method URI :param dict params: parameters :rtype: dict """ if params is None: params = {} params.update({ 'key': self.api_key, }) url = self.end_point+url_path headers = {'X-W3W-Wrapper': 'what3words-Python/{} (Python {}; {})'.format(__version__, platform.python_version(), platform.platform())} r = requests.get(url, params=params, headers=headers) response = r.text return json.loads(response)
Example #20
Source File: system_info.py From lambda-packs with MIT License | 6 votes |
def calc_info(self): if sys.platform in ['win32']: return lib_dirs = self.get_lib_dirs() include_dirs = self.get_include_dirs() x11_libs = self.get_libs('x11_libs', ['X11']) info = self.check_libs(lib_dirs, x11_libs, []) if info is None: return inc_dir = None for d in include_dirs: if self.combine_paths(d, 'X11/X.h'): inc_dir = d break if inc_dir is not None: dict_append(info, include_dirs=[inc_dir]) self.set_info(**info)
Example #21
Source File: compile_and_run.py From VEX_Syntax with MIT License | 6 votes |
def common_install(): """Returns the common houdini install parent directory based on the platform as well as the regex for the install name pattern.""" plat = platform.platform(terse=True) if plat.startswith('Win'): install = WIN_DEFAULT regex = '^Houdini.*' # Houdini 13.0.376 elif plat.startswith('Dar'): install = OSX_DEFAULT regex = '^Houdini.*' # Houdini 13.0.376 elif plat.startswith('Lin'): install = LIN_DEFAULT regex = '^hfs.*' # hfs13.0.376 else: raise Exception('Unknown platform, cannot find Houdini.') return (os.path.normpath(install), regex)
Example #22
Source File: debug.py From myhdl with GNU Lesser General Public License v2.1 | 5 votes |
def print_versions(): versions = [ ("myhdl", __version__), ("Python Version", platform.python_version()), ("Python Implementation", platform.python_implementation()), ("OS", platform.platform()), ] print() print("INSTALLED VERSIONS") print("------------------") for k, v in versions: print("{}: {}".format(k, v))
Example #23
Source File: host_info.py From sacred with MIT License | 5 votes |
def _cpu(): if platform.system() == "Windows": return _get_cpu_by_pycpuinfo() try: if platform.system() == "Darwin": return _get_cpu_by_sysctl() elif platform.system() == "Linux": return _get_cpu_by_proc_cpuinfo() except Exception: # Use pycpuinfo only if other ways fail, since it takes about 1 sec return _get_cpu_by_pycpuinfo()
Example #24
Source File: verification_code2text.py From TaiwanTrainVerificationCode2text with Apache License 2.0 | 5 votes |
def validation(test_path): file_path = 'success_vcode' os.chdir(PATH) if file_path not in os.listdir(): os.makedirs(file_path) if 'Windows' in platform.platform(): file_path = '{}\\{}\\'.format(PATH,'success_vcode') test_image_path = [file_path + i for i in os.listdir(file_path+'\\')] else: file_path = '{}/{}/'.format(PATH,'success_vcode') test_image_path = [file_path + i for i in os.listdir(file_path+'/')] sum_count = len(test_image_path) data_set = np.ndarray(( sum_count , 60, 200,3), dtype=np.uint8) i=0 #s = time.time() while( i < sum_count ): image_name = test_image_path[i] image = cv2.imread(image_name) data_set[i] = image i=i+1 if i%50 == 0: print('Processed {} of {}'.format(i, sum_count ) ) #-------------------------------------------------- real_labels = [] for text in test_image_path: if 'Windows' in platform.platform(): text = text.split('\\') else: text = text.split('/') text = text[len(text)-1] text_set = text.replace('.png','') real_labels.append(text_set) image = cv2.imread(image_name) plt.imshow(image) text = main(image) print(text)
Example #25
Source File: diagnose.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
def check_hardware(): print('----------Hardware Info----------') print('machine :', platform.machine()) print('processor :', platform.processor()) if sys.platform.startswith('darwin'): pipe = subprocess.Popen(('sysctl', '-a'), stdout=subprocess.PIPE) output = pipe.communicate()[0] for line in output.split(b'\n'): if b'brand_string' in line or b'features' in line: print(line.strip()) elif sys.platform.startswith('linux'): subprocess.call(['lscpu']) elif sys.platform.startswith('win32'): subprocess.call(['wmic', 'cpu', 'get', 'name'])
Example #26
Source File: system_info.py From lambda-packs with MIT License | 5 votes |
def calc_info(self): src_dirs = self.get_src_dirs() src_dir = '' for d in src_dirs: if os.path.isfile(os.path.join(d, 'src', 'agg_affine_matrix.cpp')): src_dir = d break if not src_dir: return if sys.platform == 'win32': agg2_srcs = glob(os.path.join(src_dir, 'src', 'platform', 'win32', 'agg_win32_bmp.cpp')) else: agg2_srcs = glob(os.path.join(src_dir, 'src', '*.cpp')) agg2_srcs += [os.path.join(src_dir, 'src', 'platform', 'X11', 'agg_platform_support.cpp')] info = {'libraries': [('agg2_src', {'sources': agg2_srcs, 'include_dirs': [os.path.join(src_dir, 'include')], } )], 'include_dirs': [os.path.join(src_dir, 'include')], } if info: self.set_info(**info) return
Example #27
Source File: system_info.py From lambda-packs with MIT License | 5 votes |
def libpaths(paths, bits): """Return a list of library paths valid on 32 or 64 bit systems. Inputs: paths : sequence A sequence of strings (typically paths) bits : int An integer, the only valid values are 32 or 64. A ValueError exception is raised otherwise. Examples: Consider a list of directories >>> paths = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib'] For a 32-bit platform, this is already valid: >>> np.distutils.system_info.libpaths(paths,32) ['/usr/X11R6/lib', '/usr/X11/lib', '/usr/lib'] On 64 bits, we prepend the '64' postfix >>> np.distutils.system_info.libpaths(paths,64) ['/usr/X11R6/lib64', '/usr/X11R6/lib', '/usr/X11/lib64', '/usr/X11/lib', '/usr/lib64', '/usr/lib'] """ if bits not in (32, 64): raise ValueError("Invalid bit size in libpaths: 32 or 64 only") # Handle 32bit case if bits == 32: return paths # Handle 64bit case out = [] for p in paths: out.extend([p + '64', p]) return out
Example #28
Source File: system_info.py From lambda-packs with MIT License | 5 votes |
def library_extensions(self): static_exts = ['.a'] if sys.platform == 'win32': static_exts.append('.lib') # .lib is used by MSVC if self.search_static_first: exts = static_exts + [so_ext] else: exts = [so_ext] + static_exts if sys.platform == 'cygwin': exts.append('.dll.a') if sys.platform == 'darwin': exts.append('.dylib') return exts
Example #29
Source File: diagnose.py From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 | 5 votes |
def check_os(): print('----------System Info----------') print('Platform :', platform.platform()) print('system :', platform.system()) print('node :', platform.node()) print('release :', platform.release()) print('version :', platform.version())
Example #30
Source File: mx_benchmark.py From mx with GNU General Public License v2.0 | 5 votes |
def before(self, bmSuiteArgs): """Called exactly once before any benchmark invocations begin. Useful for outputting information such as platform version, OS, etc. Arguments: see `run`. """