Python platform.python_version() Examples
The following are 30
code examples of platform.python_version().
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: L.E.S.M.A. - Fabrica de Noobs Speedtest.py From L.E.S.M.A with Apache License 2.0 | 8 votes |
def build_user_agent(): """Build a Mozilla/5.0 compatible User-Agent string""" global USER_AGENT if USER_AGENT: return USER_AGENT ua_tuple = ( 'Mozilla/5.0', '(%s; U; %s; en-us)' % (platform.system(), platform.architecture()[0]), 'Python/%s' % platform.python_version(), '(KHTML, like Gecko)', 'speedtest-cli/%s' % __version__ ) USER_AGENT = ' '.join(ua_tuple) printer(USER_AGENT, debug=True) return USER_AGENT
Example #2
Source File: mns_client.py From aliyun-mns with MIT License | 6 votes |
def build_header(self, req, req_inter): if req.request_id is not None: req_inter.header["x-mns-user-request-id"] = req.request_id if self.http.is_keep_alive(): req_inter.header["Connection"] = "Keep-Alive" if req_inter.data != "": req_inter.header["content-md5"] = base64.b64encode(hashlib.md5(req_inter.data).hexdigest().encode('UTF-8')).decode() req_inter.header["content-type"] = "text/xml;charset=UTF-8" req_inter.header["x-mns-version"] = self.version req_inter.header["host"] = self.host req_inter.header["date"] = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime()) req_inter.header["user-agent"] = "aliyun-sdk-python/%s(%s/%s;%s)" % \ (pkg_info.version, platform.system(), platform.release(), platform.python_version()) req_inter.header["Authorization"] = self.get_signature(req_inter.method, req_inter.header, req_inter.uri) if self.security_token != "": req_inter.header["security-token"] = self.security_token
Example #3
Source File: computer.py From pyspectator with BSD 3-Clause "New" or "Revised" License | 6 votes |
def __init__(self): self.datetime_format = '%H:%M:%S %d/%m/%Y' self.__raw_boot_time = psutil.boot_time() self.__boot_time = datetime.fromtimestamp(self.raw_boot_time) self.__boot_time = self.__boot_time.strftime(self.datetime_format) self.__hostname = platform.node() self.__os = Computer.__get_os_name() self.__architecture = platform.machine() self.__python_version = '{} ver. {}'.format( platform.python_implementation(), platform.python_version() ) self.__processor = Cpu(monitoring_latency=1) self.__nonvolatile_memory = NonvolatileMemory.instances_connected_devices(monitoring_latency=10) self.__nonvolatile_memory_devices = set( [dev_info.device for dev_info in self.__nonvolatile_memory] ) self.__virtual_memory = VirtualMemory(monitoring_latency=1) self.__swap_memory = SwapMemory(monitoring_latency=1) self.__network_interface = NetworkInterface(monitoring_latency=3) super().__init__(monitoring_latency=3)
Example #4
Source File: client_test.py From contentful.py with MIT License | 6 votes |
def test_client_headers(self): client = Client( 'cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, application_name='foobar_app', application_version='1.1.0', integration_name='foobar integ', integration_version='0.1.0') from contentful import __version__ import platform expected = [ 'sdk contentful.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()), 'app foobar_app/1.1.0;', 'integration foobar integ/0.1.0;' ] header = client._request_headers()['X-Contentful-User-Agent'] for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header)) # Integration Tests
Example #5
Source File: client_test.py From contentful.py with MIT License | 6 votes |
def test_client_with_all_headers(self): client = Client( 'cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False, application_name='foobar_app', application_version='1.1.0', integration_name='foobar integ', integration_version='0.1.0') from contentful import __version__ import platform expected = [ 'sdk contentful.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()), 'app foobar_app/1.1.0;', 'integration foobar integ/0.1.0;' ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header))
Example #6
Source File: client_test.py From contentful.py with MIT License | 6 votes |
def test_client_default_contentful_user_agent_headers(self): client = Client('cfexampleapi', 'b4c0n73n7fu1', content_type_cache=False) from contentful import __version__ import platform expected = [ 'sdk contentful.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()) ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header)) self.assertTrue('integration' not in header) self.assertTrue('app' not in header)
Example #7
Source File: markers.py From recruit with Apache License 2.0 | 6 votes |
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, }
Example #8
Source File: client_test.py From contentful-management.py with MIT License | 6 votes |
def test_client_default_contentful_user_agent_headers(self): client = Client(PLAYGROUND_SPACE, raise_errors=False) from contentful_management import __version__ import platform expected = [ 'sdk contentful-management.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()) ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header)) self.assertTrue('integration' not in header) self.assertTrue('app' not in header)
Example #9
Source File: client_test.py From contentful-management.py with MIT License | 6 votes |
def test_client_with_all_headers(self): client = Client( PLAYGROUND_SPACE, raise_errors=False, application_name='foobar_app', application_version='1.1.0', integration_name='foobar integ', integration_version='0.1.0') from contentful_management import __version__ import platform expected = [ 'sdk contentful-management.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()), 'app foobar_app/1.1.0;', 'integration foobar integ/0.1.0;' ] header = client._contentful_user_agent() for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header))
Example #10
Source File: client_test.py From contentful-management.py with MIT License | 6 votes |
def test_client_headers(self): client = Client( PLAYGROUND_SPACE, raise_errors=False, application_name='foobar_app', application_version='1.1.0', integration_name='foobar integ', integration_version='0.1.0') from contentful_management import __version__ import platform expected = [ 'sdk contentful-management.py/{0};'.format(__version__), 'platform python/{0};'.format(platform.python_version()), 'app foobar_app/1.1.0;', 'integration foobar integ/0.1.0;' ] header = client._request_headers()['X-Contentful-User-Agent'] for e in expected: self.assertTrue(e in header) self.assertTrue(re.search('os (Windows|macOS|Linux)(\/.*)?;', header))
Example #11
Source File: cli.py From stdpopsim with GNU General Public License v3.0 | 6 votes |
def get_environment(): """ Returns a dictionary describing the environment in which stdpopsim is currently running. """ env = { "os": { "system": platform.system(), "node": platform.node(), "release": platform.release(), "version": platform.version(), "machine": platform.machine(), }, "python": { "implementation": platform.python_implementation(), "version": platform.python_version(), }, "libraries": { "msprime": {"version": msprime.__version__}, "tskit": {"version": tskit.__version__}, } } return env
Example #12
Source File: markers.py From jbox with MIT License | 6 votes |
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, }
Example #13
Source File: markers.py From jbox with MIT License | 6 votes |
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, }
Example #14
Source File: backend.py From aetros-cli with MIT License | 6 votes |
def collect_environment(self, overwrite_variables=None): import socket import os import pip import platform env = {} if not overwrite_variables: overwrite_variables = {} import aetros env['aetros_version'] = aetros.__version__ env['python_version'] = platform.python_version() env['python_executable'] = sys.executable env['hostname'] = socket.gethostname() env['variables'] = dict(os.environ) env['variables'].update(overwrite_variables) if 'AETROS_SSH_KEY' in env['variables']: del env['variables']['AETROS_SSH_KEY'] if 'AETROS_SSH_KEY_BASE64' in env['variables']: del env['variables']['AETROS_SSH_KEY_BASE64'] env['pip_packages'] = sorted([[i.key, i.version] for i in pip.get_installed_distributions()]) self.set_system_info('environment', env)
Example #15
Source File: channel0.py From ReadableWebProxy with BSD 3-Clause "New" or "Revised" License | 6 votes |
def _client_properties(): """AMQPStorm Client Properties. :rtype: dict """ return { 'product': 'AMQPStorm', 'platform': 'Python %s (%s)' % (platform.python_version(), platform.python_implementation()), 'capabilities': { 'basic.nack': True, 'connection.blocked': True, 'publisher_confirms': True, 'consumer_cancel_notify': True, 'authentication_failure_close': True, }, 'information': 'See https://github.com/eandersson/amqpstorm', 'version': __version__ }
Example #16
Source File: help.py From a4kScrapers with MIT License | 6 votes |
def _pythonVersion(): interpreter = platform.python_implementation() interpreter_version = platform.python_version() if interpreter == 'PyPy': interpreter_version = '{}.{}.{}'.format( sys.pypy_version_info.major, sys.pypy_version_info.minor, sys.pypy_version_info.micro ) if sys.pypy_version_info.releaselevel != 'final': interpreter_version = '{}{}'.format( interpreter_version, sys.pypy_version_info.releaselevel ) return { 'name': interpreter, 'version': interpreter_version } # ------------------------------------------------------------------------------- #
Example #17
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 #18
Source File: markers.py From python-netsurv with MIT License | 6 votes |
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, }
Example #19
Source File: terminal.py From python-netsurv with MIT License | 6 votes |
def pytest_sessionstart(self, session): self._session = session self._sessionstarttime = time.time() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) verinfo = platform.python_version() msg = "platform {} -- Python {}".format(sys.platform, verinfo) if hasattr(sys, "pypy_version_info"): verinfo = ".".join(map(str, sys.pypy_version_info[:3])) msg += "[pypy-{}-{}]".format(verinfo, sys.pypy_version_info[3]) msg += ", pytest-{}, py-{}, pluggy-{}".format( pytest.__version__, py.__version__, pluggy.__version__ ) if ( self.verbosity > 0 or self.config.option.debug or getattr(self.config.option, "pastebin", None) ): msg += " -- " + str(sys.executable) self.write_line(msg) lines = self.config.hook.pytest_report_header( config=self.config, startdir=self.startdir ) self._write_report_lines_from_hooks(lines)
Example #20
Source File: markers.py From python-netsurv with MIT License | 6 votes |
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, }
Example #21
Source File: markers.py From python-netsurv with MIT License | 6 votes |
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, }
Example #22
Source File: terminal.py From python-netsurv with MIT License | 6 votes |
def pytest_sessionstart(self, session): self._session = session self._sessionstarttime = time.time() if not self.showheader: return self.write_sep("=", "test session starts", bold=True) verinfo = platform.python_version() msg = "platform {} -- Python {}".format(sys.platform, verinfo) if hasattr(sys, "pypy_version_info"): verinfo = ".".join(map(str, sys.pypy_version_info[:3])) msg += "[pypy-{}-{}]".format(verinfo, sys.pypy_version_info[3]) msg += ", pytest-{}, py-{}, pluggy-{}".format( pytest.__version__, py.__version__, pluggy.__version__ ) if ( self.verbosity > 0 or self.config.option.debug or getattr(self.config.option, "pastebin", None) ): msg += " -- " + str(sys.executable) self.write_line(msg) lines = self.config.hook.pytest_report_header( config=self.config, startdir=self.startdir ) self._write_report_lines_from_hooks(lines)
Example #23
Source File: plugins.py From king-phisher with BSD 3-Clause "New" or "Revised" License | 6 votes |
def compatibility_iter(self): """ Iterate over each of the requirements, evaluate them and yield a tuple regarding them. """ StrictVersion = distutils.version.StrictVersion if self._storage.get('minimum-python-version'): # platform.python_version() cannot be used with StrictVersion because it returns letters in the version number. available = StrictVersion(self._storage['minimum-python-version']) <= StrictVersion('.'.join(map(str, sys.version_info[:3]))) yield ('Minimum Python Version', self._storage['minimum-python-version'], available) if self._storage.get('minimum-version'): available = StrictVersion(self._storage['minimum-version']) <= StrictVersion(version.distutils_version) yield ('Minimum King Phisher Version', self._storage['minimum-version'], available) if self._storage.get('packages'): for name, available in self._storage['packages'].items(): yield ('Required Package', name, available) if self._storage.get('platforms'): platforms = tuple(p.title() for p in self._storage['platforms']) system = platform.system() yield ('Supported Platforms', ', '.join(platforms), system.title() in platforms)
Example #24
Source File: markers.py From lambda-packs with MIT License | 6 votes |
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, }
Example #25
Source File: markers.py From lambda-packs with MIT License | 6 votes |
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, }
Example #26
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 #27
Source File: markers.py From ironpython2 with Apache License 2.0 | 6 votes |
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, }
Example #28
Source File: markers.py From ironpython2 with Apache License 2.0 | 6 votes |
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, }
Example #29
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 #30
Source File: test_pattern_search.py From pymoo with Apache License 2.0 | 5 votes |
def toms178_test(): # *****************************************************************************80 # ## TOMS178_TEST tests TOMS178. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 23 January 2016 # # Author: # # John Burkardt # import platform print('') print('TOMS178_TEST:') print(' Python version: %s' % (platform.python_version())) print(' Test TOMS178.') rosenbrock_test() woods_test() # # Terminate. # print('') print('TOMS178_TEST:') print(' Normal end of execution.') return