Home | Top | ← | → | Overview | Module | Class | Index | Help |
|
About |
---|
|
||||
1 # -*- coding: utf-8 -*- 2 """The module 'platforms' provides the class for the representation of platform parameters. 3 This includes the scan of the current platform and the calculation of arbitrary hexadecimal 4 labels for the fast processing of repetitive comparisons. 5 6 The supported implementations are: CPython, IPython, IronPython, Jython, and PyPy. 7 8 """ 9 ############################################# 10 # 11 # See manuals for the detailed API. 12 # 13 ############################################# 14 15 from __future__ import absolute_import 16 from __future__ import print_function 17 18 import sys 19 import platform 20 import re 21 22 23 from pythonids.pythondist import ISINT 24 # from platformids import _debug, _verbose 25 import platformids 26 from platformids import RTE, ISSTR, RTE_DIST, RTE_GENERIC 27 28 29 __author__ = 'Arno-Can Uestuensoez' 30 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints" 31 __copyright__ = "Copyright (C) 2010-2018 Arno-Can Uestuensoez" \ 32 " @Ingenieurbuero Arno-Can Uestuensoez" 33 __version__ = '0.1.35' 34 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9" 35 36 __docformat__ = "restructuredtext en" 37 38 39 # : The corresponding *bash* environment names for print out. 40 bash_map = { 41 'category': "CATEGORY", 42 'dist': "DIST", 43 'distrel': "DISTREL", 44 'distrel_hexversion': "distrel_hexversion", 45 'distrel_key': "DISTRIBUTION_KEY", 46 'distrel_name': "DISTRIBUTION_NAME", 47 'distrel_version': "DISTRIBUTION_VERSION", 48 'ostype': "OSTYPE", 49 'ostype_id': "OS_ID", 50 'ostype_version': "OS_VERSION", 51 52 'cpu': "CPU", 53 'cpudata': "CPUDATA", 54 } 55 56 # : The mapping of attributes to values for pretty print. 57 attribute_map = { 58 'category': "category", 59 'dist': "dist", 60 'distrel': "distrel", 61 'distrel_hexversion': "distrel_hexversion", 62 'distrel_key': "distribution_key", 63 'distrel_name': "distribution_name", 64 'distrel_version': "distribution_version", 65 'ostype': "ostype", 66 'ostype_id': "ostype_id", 67 'ostype_version': "ostype_version", 68 69 'cpu': "cpu", 70 'cpudata': "cpudata", 71 } 72 73 if platformids.osname in ('nt', 'cygwin'): 74 # 75 # specials for ostype NT for bash print outs and pretty print 76 # 77 bash_map.update({ 78 'wServicePack': "WSERVICEPACK", 79 'wProductType': "WPRODUCTTYPE", 80 'wSuiteMask': "WSUITEMASK", 81 }) 82 83 attribute_map.update({ 84 'wServicePack': "wServicePack", 85 'wProductType': "wProductType", 86 'wSuiteMask': "wSuiteMask", 87 }) 88 89 92 939561997 """Creates an empty object. 98 No automatic call of *PlatformParameters.scan()*. 99 The instance could be either initialized by the provided 100 parameters, or remains empty - which is zero *0*. 101 102 Each call of *PlatformParameters.scan()* replaces the previous 103 values. 104 105 Args: 106 args: 107 Optional positional parameters in the following order. 108 The corresponding keyword-arguments dominate. :: 109 110 args[0] := category 111 args[1] := ostype 112 args[2] := dist 113 args[3] := distrel 114 115 kargs: 116 category: 117 The *category* for initialization. 118 119 default := 0 120 121 ostype: 122 The *ostype* for initialization. 123 124 default := 0 125 126 dist: 127 The *dist* for initialization. 128 129 default := 0 130 131 distrel: 132 The *distrel* for initialization. 133 134 default := 0 135 136 Returns: 137 Initial instance, optionally initialized by the provided 138 parameters. 139 140 Raises: 141 pass-through 142 143 """ 144 self.category = self.ostype = self.distrel_hexversion = self.wProductType = self.wSuiteMask = 0 145 self.dist = self.distrel = 0 146 self.distrel_name = self.distrel_key = '' 147 self.ostype_id = self.ostype_id = '' 148 self.distrel_version = self.ostype_version = [] 149 150 # 151 # first check positional arguments 152 # 153 self.osrel_sp = [] 154 _myargs = list(args) 155 if _myargs: 156 self.category = _myargs[0] #: category 157 _myargs.pop(0) 158 if _myargs: 159 self.ostype = _myargs[0] #: ostype - cumulated sub-vector 160 _myargs.pop(0) 161 if _myargs: 162 self.dist = _myargs[0] #: dist - cumulated sub-vector 163 _myargs.pop(0) 164 if _myargs: 165 self.distrel_hexversion = self.distrel = _myargs[0] #: distrel - cumulated sub-vector 166 # _myargs.pop(0) 167 168 # 169 # second check keyword arguments, when present superpose current values 170 # 171 self.category = kargs.get('category', self.category) 172 self.ostype = kargs.get('ostype', self.ostype) 173 self.dist = kargs.get('dist', self.dist) 174 self.distrel_hexversion = self.distrel = kargs.get('distrel', self.distrel)175177 """The *&* operator for the resulting *hexversion*: :: 178 179 self-bitmask & other-bitmask 180 181 Args: 182 other: 183 The bitmask for operations. :: 184 185 other := ( 186 <int-32bit-mask> # compare with hexversion 187 | <dictionary>) # compare keys only 188 | <tuple>) # compare key-index only 189 | <instance-of-PlatformParameters> # compare both hexversions 190 ) 191 192 Returns: 193 The resulting bitmask as numeric value. 194 195 Raises: 196 pass-through 197 198 """ 199 if not self.distrel_hexversion: 200 self.distrel_hexversion = self.get_hexversion() 201 202 if isinstance(other, int): 203 return self.distrel_hexversion & other 204 205 elif isinstance(other, PlatformParameters): 206 return self.distrel_hexversion & other.get_hexversion() 207 208 elif isinstance(other, dict): 209 # use other as init parameters - simply trust or pass exception 210 return self.distrel_hexversion & PlatformParameters(**other).get_hexversion() 211 212 elif isinstance(other, tuple): 213 return self.distrel_hexversion & PlatformParameters(*other).get_hexversion() 214 215 raise platformids.PlatformIDsError("type not supported: other = " + str(other))216218 """Supports standard comparison with the types 219 *PlatformParameters*, and *dict*. In case of 220 a dict the attributes are used as keys literally. 221 222 Args: 223 other: 224 The instannce to be compared. The comparison is provided as: 225 226 * literal contents of objects: 227 228 literally for objects *PlatformParameters*, or partially 229 for *dict*. 230 231 * partial hierarchical matches 232 233 The partial comparison is based on the keys provided by 234 the dictionary argument. Only attributes with a corresponding 235 key are compared. 236 237 The following items are handled specially: 238 239 distrel_version, ostype_version: 240 The present values are compared only, e.g. 241 the following is considered as *True* :: 242 243 self.distrel_version = [1, 2, 3] 244 other.distrel_version = [1, 2,] 245 246 TRUE: self.distrel_version == other.distrel_version 247 248 While still: :: 249 250 self.distrel_version = [1, 2, 3] 251 other.distrel_version = [1, 2, 7] 252 253 FALSE: self.distrel_version == other.distrel_version 254 255 distrel: 256 Valuesa are compared by *startswith()* e.g. 257 the following is considered as *True* :: 258 259 self.distrel = 'fedora-27.0.0' 260 other.distrel = 'fedora-27.0' 261 262 TRUE: self.distrel == other.distrel 263 264 While still: :: 265 266 self.distrel = 'fedora-27.0.0' 267 other.distrel = 'fedora-27.0.1' 268 269 FALSE: self.distrel == other.distrel 270 271 * integer bit masks 272 273 Special treatment of integers is provided: 274 275 * *category*: 276 277 When a valid *category*, *self.category* is compared only. 278 279 * *ostype*: 280 281 When a valid *ostype*, *self.ostype* is compared only. 282 283 * *dist* and/or *distrel*: 284 285 The value is compared to the same maximal extend. 286 287 Returns: 288 True: relevant parts are equal - see args. 289 False: else 290 291 Raises: 292 KeyError 293 AttributeError 294 295 """ 296 res = False 297 298 if type(other) in ISINT: 299 # some special type comparison 300 # hex id of dist and/or distrel 301 if self.distrel_hexversion == other: 302 return True 303 elif ( 304 self.distrel_hexversion & RTE_DIST == other 305 and other & RTE_DIST == other # it is actually a dist only 306 ): 307 return True 308 309 return False 310 311 elif isinstance(other, PlatformParameters): 312 return self.distrel_hexversion == other.get_hexversion() 313 314 elif isinstance(other, dict): 315 # compare selected keys only 316 res = True 317 for k, v in other.items(): 318 try: 319 if k in ("osrel_sp", "wProductType", "wSuiteMask"): 320 if self.ostype in ('nt', 'cygwin'): 321 res &= self.__dict__[k] == v 322 else: 323 res = False 324 elif k in ("distrel_version", "ostype_version",): 325 res &= self.__dict__['distrel_version'][:len(v)] == v 326 elif k == "distrel": 327 res &= self.__dict__['distrel'] == v 328 else: 329 res &= self.__dict__[k] == v 330 except KeyError: 331 res = False 332 333 elif isinstance(other, tuple): 334 # compare selected keys only 335 336 res = True 337 self.osrel_sp = [] 338 _myargs = list(other) 339 if _myargs: 340 res &= self.category == _myargs[0] 341 _myargs.pop(0) 342 if _myargs: 343 res &= self.ostype == _myargs[0] 344 _myargs.pop(0) 345 if _myargs: 346 res &= self.dist == _myargs[0] 347 _myargs.pop(0) 348 if _myargs: 349 res &= self.distrel == _myargs[0] 350 _myargs.pop(0) 351 352 return res353 358360 """Iterates the non-private attribute names. 361 """ 362 for k in self.__dict__.keys(): 363 if k[0] != '_': 364 yield k365367 """Yields the non-private attributes as key-value-pairs. 368 """ 369 for k in self.__dict__.keys(): 370 if k[0] != '_': 371 yield (k, self.__dict__[k],)372374 """Yields the non-private attribute names. 375 """ 376 for k in self.__dict__.keys(): 377 if k[0] != '_': 378 yield k379381 """Counts and returns the number of non-private attributes - not starting with underscore. 382 """ 383 l = 0 384 for k in self.__dict__.keys(): 385 if k[0] != '_': 386 l += 1 387 return l388390 """Yields the values of non-private attributes. 391 """ 392 for k in self.__dict__.keys(): 393 if k[0] != '_': 394 yield self.__dict__[k]395 400 403405 res = ( 406 '{"category": "%s", "ostype": "%s", "dist": "%s", "distrel": "%s", ' 407 '"distrel_name": "%s", "distrel_key": "%s", ' 408 '"distrel_version": %s, "ostype_version": %s, "distrel_hexversion": %s, "ostype_id": %s, "ostype_id": %s}') % ( 409 str(self.category), 410 str(self.ostype), 411 str(self.dist), 412 str(self.distrel), 413 str(self.distrel_name), 414 str(self.distrel_key), 415 str(self.distrel_version), 416 str(self.ostype_version), 417 str(self.distrel_hexversion), 418 str(self.ostype_id), 419 str(self.ostype_id) 420 ) 421 422 if self.ostype in ('nt', 'cygwin'): 423 res += '"wServicePack": %s, ' % str(self.osrel_sp) 424 res += '"wProductType": %s, ' % str(self.wProductType) 425 res += '"wSuiteMask": %s' % str(self.wSuiteMask) 426 res += "}" 427 428 return res429 432434 """ Formats and returns a string of attributes. 435 436 Args: 437 raw: 438 Controls the use of the value types:: 439 440 raw := ( 441 True # prints the internal types 442 | False # prints the symbolic names where applicable 443 ) 444 445 default := False 446 447 kargs: 448 quiet: 449 Supress standard display contents. 450 451 default := False 452 453 terse: 454 Format for postprocessing. 455 456 default := False 457 458 type: 459 Defines the type for the output:: 460 461 type := ( 462 bashvars 463 | json 464 | raw 465 | repr 466 | str 467 ) 468 469 default := str 470 471 Returns: 472 Formatted string of attributes. 473 474 Raises: 475 TypeError 476 477 pass-through 478 479 """ 480 _type = kargs.get('type', 'str') 481 _terse = kargs.get('terse', False) 482 _quiet = kargs.get('quiet', False) 483 _select = kargs.get( 484 'select', 485 attribute_map.keys() 486 ) 487 488 res = "" 489 490 def _get_value_str(v): 491 if raw: 492 return str(self.__getattribute__(k)) 493 else: 494 return str(self.__getattribute__(attribute_map.get(k)))495 496 print("4TEST:a") 497 if _type in ('str',): 498 try: 499 for k in sorted(_select): 500 if _terse and _quiet: 501 res += "\n%s" % (_get_value_str(k)) 502 503 elif _terse: 504 res += "\n%s=%s" % (str(k), _get_value_str(k)) 505 506 else: 507 res += "\n%-25s = %s" % (str(k), _get_value_str(k)) 508 509 except TypeError as e: 510 exinfo = sys.exc_info() 511 exinfo[1].args += ( 512 "%s attribute error for str-map key: %s" %(str(self.__class__.__name__), str(k), ), ) 513 raise 514 515 elif _type in ('raw',): 516 try: 517 for k in _select: 518 if _terse and _quiet: 519 res += "\n%s" % (_get_value_str(k)) 520 521 else: 522 res += "\n%s=%s" % (str(k), _get_value_str(k)) 523 524 except TypeError as e: 525 exinfo = sys.exc_info() 526 exinfo[1].args += ( 527 "%s attribute error for raw-map key: %s" %(str(self.__class__.__name__), str(k), ), ) 528 raise 529 530 elif _type in ('repr',): 531 if _terse and _quiet: 532 res = '[' 533 else: 534 res = '{' 535 for k in _select: 536 if type(k) in ISSTR: 537 _k = '"%s"' % k 538 else: 539 _k = '%s' % str(k) 540 541 try: 542 v = _get_value_str(k) 543 except TypeError as e: 544 exinfo = sys.exc_info() 545 exinfo[1].args += ( 546 "%s attribute error for repr-map key: %s" %(str(self.__class__.__name__), str(k), ), ) 547 raise 548 549 if type(v) in ISSTR: 550 _v = '"%s"' % v 551 else: 552 _v = '%s' % str(v) 553 554 if _terse and _quiet: 555 res += '%s, ' % (_v) 556 else: 557 res += '%s: %s, ' % (_k, _v) 558 559 if _terse and _quiet: 560 res += ']' 561 else: 562 res += '}' 563 564 elif _type in ('json',): 565 try: 566 567 # REMINDER: For now dropped due to layering architecture. 568 # if _terse: 569 # sys.stdout.write(repr(JSONData(self.get_json(select=_select)))) 570 # else: 571 # sys.stdout.write(str(JSONData(self.get_json(select=_select)))) 572 573 if _terse: 574 sys.stdout.write(repr(self.get_json(select=_select))) 575 else: 576 sys.stdout.write(str(self.get_json(select=_select))) 577 sys.stdout.write('\n') 578 except TypeError as e: 579 raise TypeError( 580 str(e) 581 +"\n\nTypeError: Check the contents of the environment variables for JSON conformity," 582 +"\n and/or Choose another output format.\n" 583 ) 584 585 elif _type in ('bashvars',): 586 for k in _select: 587 v = _get_value_str(k) 588 if type(v) in ISSTR: 589 res += "\n%s='%s'" % ( 590 str(bash_map.get(k)), 591 _get_value_str(k) 592 ) 593 elif type(v) in (list, tuple): 594 res += "\ntypeset -a %s" % (str(bash_map.get(k))) 595 res += "\n%s=%s" % ( 596 str(bash_map.get(k)), 597 str(tuple(_get_value_str(k))) 598 ) 599 elif type(v) is dict: 600 res += "\ntypeset -A %s" % (str(bash_map.get(k))) 601 res += "\n%s=(" % (str(bash_map.get(k))) 602 for k0 in v.keys(): 603 res += '"\n %s[%s]="%a' % ( 604 str(bash_map.get(k)), 605 str(bash_map.get(k0)), 606 str(tuple(_get_value_str(k))) 607 ) 608 res += "\n)" 609 else: 610 res += "\n%s=%s" % ( 611 str(bash_map.get(k)), 612 _get_value_str(k) 613 ) 614 615 print("4TEST:b:<" + str(res) + ">") 616 print("4TEST:c:") 617 618 return res621 """The in-place *&* operator for the resulting *hexversion*: :: 622 623 self-bitmask &= other-bitmask 624 625 Args: 626 other: 627 The bitmask for operations. :: 628 629 other := (<int-32bit-mask> | <instance-of-PlatformParameters>) 630 631 Returns: 632 The resulting bitmask as numeric value. 633 634 Raises: 635 pass-through 636 637 """ 638 if not self.distrel_hexversion: 639 self.distrel_hexversion = self.get_hexversion() 640 641 if isinstance(other, int): 642 self.distrel_hexversion &= other 643 return self 644 645 elif isinstance(other, PlatformParameters): 646 self.distrel_hexversion &= other.get_hexversion() 647 return self 648 649 elif isinstance(other, dict): 650 self.distrel_hexversion &= PlatformParameters(**other).get_hexversion() 651 return self 652 653 elif isinstance(other, tuple): 654 self.distrel_hexversion &= PlatformParameters(*other).get_hexversion() 655 return self 656 657 raise platformids.PlatformIDsError("type not supported: other = " + str(other))658660 """ The cast operator into the botmask: :: 661 662 int(self) == self-bitmask 663 664 Args: 665 none 666 667 Returns: 668 The resulting bitmask of self as numeric value. 669 670 Raises: 671 pass-through 672 673 """ 674 if not self.distrel_hexversion: 675 self.distrel_hexversion = self.get_hexversion() 676 return self.distrel_hexversion677679 """The in-place *|* operator for the resulting *hexversion*:: 680 681 self-bitmask |= other-bitmask 682 683 Args: 684 other: 685 The bitmask for operations. :: 686 687 other := (<int-32bit-mask> | <instance-of-PlatformParameters>) 688 689 Returns: 690 The resulting bitmask as numeric value. 691 692 Raises: 693 pass-through 694 695 """ 696 if not self.distrel_hexversion: 697 self.distrel_hexversion = self.get_hexversion() 698 699 if isinstance(other, int): 700 self.distrel_hexversion |= other 701 return self 702 703 elif isinstance(other, PlatformParameters): 704 self.distrel_hexversion |= other.get_hexversion() 705 return self 706 707 elif isinstance(other, dict): 708 self.distrel_hexversion |= PlatformParameters(**other).get_hexversion() 709 return self 710 711 elif isinstance(other, tuple): 712 self.distrel_hexversion |= PlatformParameters(*other).get_hexversion() 713 return self 714 715 raise platformids.PlatformIDsError("type not supported: other = " + str(other))716718 """The *|* operator for the resulting *hexversion*: :: 719 720 self-bitmask | other-bitmask 721 722 Args: 723 other: 724 The bitmask for operations. :: 725 726 other := (<int-32bit-mask> | <instance-of-PlatformParameters>) 727 728 Returns: 729 The resulting bitmask as numeric value. 730 731 Raises: 732 pass-through 733 734 """ 735 if not self.distrel_hexversion: 736 self.distrel_hexversion = self.get_hexversion() 737 738 if isinstance(other, int): 739 return self.distrel_hexversion | other 740 741 elif isinstance(other, PlatformParameters): 742 return self.distrel_hexversion | other.get_hexversion() 743 744 elif isinstance(other, dict): 745 # use other as init parameters - simply trust or pass exception 746 return self.distrel_hexversion | PlatformParameters(**other).get_hexversion() 747 748 elif isinstance(other, tuple): 749 return self.distrel_hexversion | PlatformParameters(*other).get_hexversion() 750 751 raise platformids.PlatformIDsError("type not supported: other = " + str(other))752754 """ The r-side *&* operator for the resulting *hexversion*: :: 755 756 other-bitmask & self-bitmask 757 758 Args: 759 other: 760 The bitmask for operations. :: 761 762 other := (<int-32bit-mask> | <instance-of-PlatformParameters>) 763 764 Returns: 765 The resulting bitmask as numeric value. 766 767 Raises: 768 pass-through 769 770 """ 771 return self.__and__(other)772774 """ The right-side *|* operator for the resulting *hexversion*: :: 775 776 other-bitmask | self-bitmask 777 778 Args: 779 other: 780 The bitmask for operations. :: 781 782 other := (<int-32bit-mask> | <instance-of-PlatformParameters>) 783 784 Returns: 785 The resulting bitmask as numeric value. 786 787 Raises: 788 pass-through 789 790 """ 791 return self.__or__(other)792794 """Returns a dictionary of attributes prepared to be processed 795 as JSON data. 796 797 Args: 798 kargs: 799 select: 800 List of attributes to be returned. 801 802 default: all non-private 803 804 Returns: 805 Dictionary of key-value-pairs. 806 807 Raises: 808 pass-through 809 810 """ 811 _select = kargs.get( 812 'select', 813 attribute_map.keys() 814 ) 815 res = {} 816 for k in _select: 817 res[k] = self.__getattribute__(attribute_map.get(k)) 818 return res819821 """Scans local platform for attributes specifying the underlying 822 OS platform including the distribution. The provided data is 823 consistent across all supported *Python* implementations 824 including *Jython*. 825 Internally calls *platformids.platformids.fetch_platform_distribution()*. 826 827 * dist 828 * distrel 829 * distrel_hexversion 830 * distrel_id 831 * distrel_version 832 * ostype 833 * ostype_id 834 * ostype_version 835 836 """ 837 838 # 839 # Common standard data 840 # 841 842 # numeric bitmasks 843 self.category = platformids.fetch_category() 844 self.ostype = platformids.fetch_ostype() 845 self.dist = platformids.fetch_dist() 846 self.distrel = self.distrel_hexversion = RTE 847 848 # 849 # native platform string representation 850 # 851 # platform info - OS release 852 self.ostype_key, self.ostype_version, self.ostype_version_num, self.ostype_id, = platformids.fetch_platform_os() 853 854 # platform info - distribution release 855 self.distribution = platformids.fetch_platform_distribution() 856 ( 857 self.distribution_key, self.distribution_version, self.distribution_name, 858 self.distribution_name, self.distribution_version_num, self.distribution 859 ) = platformids.fetch_platform_distribution() 860 861 # 862 # Common basic HW data 863 # 864 865 # CPU architecture 866 self.cpu = platform.machine() 867 try: 868 self.cpudata = re.sub(r'bit', r'', platform.architecture()[0]) 869 except: 870 try: 871 self.cpudata = int(self.cpu[-2:]) 872 except: 873 self.cpudata = 0 # for now... 874 875 876 # 877 # Jython with optional special data about Java and JVM 878 # 879 880 if platformids.isJython: 881 # some optional data about Java 882 883 _jv = platform.java_ver() 884 self.java_version = tuple(int(x) for x in re.split(r'[._]',_jv[0])) 885 886 try: 887 self.javadata = int(re.sub(r'.*([0-9]+)-[Bb]it.*', r'\1', _jv[2][0])) # could be different from platform, e.g. 32 on 64 888 except: 889 self.javadata = self.cpudata # for now... 890 891 if re.sub(r'.*(HotSpot).*', r'\1', _jv[2][0]) == 'HotSpot': 892 self.jvm = 'JHS' # Java-HotSpot 893 else: 894 self.jvm = None # for now... 895 896 897 898 # 899 # Cygwin or Windows with optional special data about Windows Product and SP/build 900 # 901 902 if self.ostype in ('cygwinnt', 'nt'): 903 904 from platformids.dist.nt.windows_kernel32dll import get_win32_OSVersionInfoExa, \ 905 get_win32_OSProductInfo 906 907 908 osver = get_win32_OSVersionInfoExa() # @UndefinedVariable 909 self.osrel_sp = [osver.wServicePackMajor, osver.wServicePackMinor] 910 self.wProductType = osver.wProductType # ostype, server, workstation, domain-controller 911 self.wSuiteMask = osver.wSuiteMask 912 913 # the sub type - e.g. Ultimate, Enterprise, etc. 914 pinfo = get_win32_OSProductInfo() # @UndefinedVariable 915 self.wProductVariant = pinfo.pdwReturnedProductType 916 917 918 if osver.wProductType == 1: # VER_NT_WORKSTATION 919 self.dist = 'winws' 920 elif osver.wProductType == 4: # VER_NT_IOT 921 self.dist = 'iot' 922 else: 923 self.dist = 'wins'924 925 # base - well-known - marketing name 926 # self.distrel_name = "Windows%s" % (_uname[2]) 927 928 # specialization extension - well-known too 929 # self.distrel_name += str(prod_type_categories[prod_ext[self.wProductVariant]]) 930 931 932934 """Returns the hexversion of calculated platform from current 935 parameters. The conversion is based on the table 936 *platformids.platformids.rte2num*. 937 """ 938 res = None 939 # 1. try version steps 940 for rx in range(len(self.distrel_version), 0, -1): 941 _kx = self.dist + ''.join(str(x) for x in self.distrel_version[:rx]) 942 try: 943 res = platformids.rte2num[_kx] 944 break 945 except KeyError: 946 pass 947 948 if res: 949 return res 950 951 res = RTE_GENERIC # generic fallback 952 try: 953 # complete distribution release key in canonical platformids format 954 res = platformids.rte2num[self.distrel] 955 956 except KeyError: 957 try: 958 # complete distribution release key in accordance to the project 959 res = platformids.rte2num[self.distrel_key] 960 961 except KeyError: 962 try: 963 # distribution without release information 964 res = platformids.rte2num[self.dist] 965 966 except KeyError: 967 try: 968 # os type, very basic, almost generic 969 res = platformids.rte2num[self.ostype] 970 971 except KeyError: 972 try: 973 # category - lets say more generic than specific, 974 # even though POSIX or Windows defines a lot of 975 # standrad interfaces 976 res = platformids.rte2num[self.category] 977 978 except KeyError: 979 # keep the generic fallback 980 pass 981 982 return res983 989
Home | Top | ← | → | Overview | Module | Class | Index | Help |
|
About |
---|
Copyright(C) 2019 Arno-Can Uestuensoez @Ingenieurbuero Arno-Can Uestuensoez | https://arnocan.wordpress.com |
Generated by Epydoc 4.0.4 / Python-3.8 / fedora27 on Wed Dec 18 15:06:59 2019 | http://epydoc.sourceforge.net |