Пример #1
0
    def __init__(self, sys_module, platform_module, executive):
        self._executive = executive
        self._platform_module = platform_module
        self.os_name = self._determine_os_name(sys_module.platform)
        self.os_version = None

        self._is_cygwin = sys_module.platform == 'cygwin'

        if self.os_name.startswith('mac'):
            # Work around for <rdar://problem/70069051>
            if apple_additions() and getattr(apple_additions(), 'os_version',
                                             None):
                self.os_version = apple_additions().os_version(self._executive)
            else:
                self.os_version = Version.from_string(
                    self._executive.run_command(['sw_vers',
                                                 '-productVersion']).rstrip())
        elif self.os_name.startswith('win'):
            self.os_version = self._win_version()
        else:
            # Most other platforms (namely iOS) return conforming version strings.
            version = re.search(r'\d+.\d+(.\d+)?', platform_module.release())
            if version:
                self.os_version = Version.from_string(version.group(0))
            else:
                _log.debug('No OS version number found')
Пример #2
0
 def test_string_constructor(self):
     v = Version.from_string('1.2.3.4.5')
     self.assertEqual(v.major, 1)
     self.assertEqual(v.minor, 2)
     self.assertEqual(v.tiny, 3)
     self.assertEqual(v.micro, 4)
     self.assertEqual(v.nano, 5)
Пример #3
0
    def strip_name_formatting(name):
        # <OS> major.minor.tiny should map to <OS> major
        if ' ' in name:
            try:
                name = '{}{}'.format(''.join(name.split(' ')[:-1]), Version.from_string(name.split(' ')[-1]).major)
            except ValueError:
                pass
        else:
            try:
                split = re.split(r'\d', name)
                name = '{}{}'.format(split[0], Version.from_string(name[(len(split) - 1):]).major)
            except ValueError:
                pass

        # Strip out any spaces, make everything lower-case
        result = name.replace(' ', '').lower()
        return result
Пример #4
0
 def xcode_sdk_version(self, sdk_name):
     if self.is_mac():
         # Assumes that xcrun does not write to standard output on failure (e.g. SDK does not exist).
         xcrun_output = self._executive.run_command(
             ['xcrun', '--sdk', sdk_name, '--show-sdk-version'],
             return_stderr=False,
             ignore_errors=True).rstrip()
         if xcrun_output:
             return Version.from_string(xcrun_output)
     return None
Пример #5
0
    def __init__(self, sys_module, platform_module, executive):
        self._executive = executive
        self._platform_module = platform_module
        self.os_name = self._determine_os_name(sys_module.platform)
        self.os_version = None

        self._is_cygwin = sys_module.platform == 'cygwin'

        if self.os_name.startswith('mac'):
            self.os_version = Version.from_string(platform_module.mac_ver()[0])
        elif self.os_name.startswith('win'):
            self.os_version = self._win_version()
        else:
            # Most other platforms (namely iOS) return conforming version strings.
            version = re.search(r'\d+.\d+(.\d+)?', platform_module.release())
            if version:
                self.os_version = Version.from_string(version.group(0))
            else:
                _log.debug('No OS version number found')
Пример #6
0
    def device_version(self):
        if self.get_option('version'):
            return Version.from_string(self.get_option('version'))

        if not self.DEVICE_MANAGER:
            raise RuntimeError(self.NO_ON_DEVICE_TESTING)

        if not self.DEVICE_MANAGER.available_devices(host=self.host):
            raise RuntimeError('No devices are available')
        version = None
        for device in self.DEVICE_MANAGER.available_devices(host=self.host):
            if not device.platform.is_ios():
                continue
            if not version:
                version = device.platform.os_version
            else:
                if device.platform.os_version != version:
                    raise RuntimeError(
                        'Multiple connected devices have different iOS versions'
                    )
        return version
Пример #7
0
 def __init__(self, runtime_dict):
     self.build_version = runtime_dict['buildversion']
     self.os_variant = runtime_dict['name'].split(' ')[0]
     self.version = Version.from_string(runtime_dict['version'])
     self.identifier = runtime_dict['identifier']
     self.name = runtime_dict['name']
Пример #8
0
 def device_version(self):
     if self.get_option('version'):
         return Version.from_string(self.get_option('version'))
     return IOSSimulatorPort._version_from_name(self._name) if IOSSimulatorPort._version_from_name(self._name) else self.host.platform.xcode_sdk_version('iphonesimulator')
Пример #9
0
 def _version_from_name(name):
     if len(name.split('-')) > 2 and name.split('-')[2].isdigit():
         return Version.from_string(name.split('-')[2])
     return None
Пример #10
0
 def xcode_version(self):
     if not self.xcode_sdk_version('macosx'):
         raise NotImplementedError
     return Version.from_string(
         self._executive.run_command(['xcodebuild', '-version']).split()[1])
Пример #11
0
 def device_version(self):
     if self.get_option('version'):
         return Version.from_string(self.get_option('version'))
     return WatchSimulatorPort._version_from_name(self._name) or self.host.platform.xcode_sdk_version('watchsimulator')
Пример #12
0
 def svn_version(self):
     return Version.from_string(self._run_svn(['--version', '--quiet']))