예제 #1
0
파일: archive.py 프로젝트: leoaday/isign
    def precheck(self):
        """ Checks if an archive looks like this kind of app. Have to examine
            within the zipfile, b/c we don't want to make temp dirs just yet. This
            recapitulates a very similar precheck in the Bundle class """
        relative_app_dir = None
        is_native = False
        if (self.is_archive_extension_match()
                and zipfile.is_zipfile(self.path)):
            log.debug("this is an archive, and a zipfile")
            z = zipfile.ZipFile(self.path)
            apps = set()
            file_list = z.namelist()
            for file_name in file_list:
                matched = re.match(self.app_dir_pattern, file_name)
                if matched:
                    apps.add(matched.group(1))
            if len(apps) == 1:
                log.debug("found one app")
                relative_app_dir = apps.pop()
                plist_path = join(relative_app_dir, "Info.plist")
                plist_bytes = z.read(plist_path)
                plist = biplist.readPlistFromString(plist_bytes)
                is_native = is_info_plist_native(plist)
                log.debug("is_native: {}".format(is_native))
            if len(apps) > 1:
                log.warning('more than one app found in archive')

        return (relative_app_dir, is_native)
예제 #2
0
파일: archive.py 프로젝트: 0x5e/isign
    def precheck(self):
        """ Checks if an archive looks like this kind of app. Have to examine
            within the zipfile, b/c we don't want to make temp dirs just yet. This
            recapitulates a very similar precheck in the Bundle class """
        relative_app_dir = None
        is_native = False
        if (self.is_archive_extension_match() and
                zipfile.is_zipfile(self.path)):
            log.debug("this is an archive, and a zipfile")
            z = zipfile.ZipFile(self.path)
            apps = set()
            file_list = z.namelist()
            for file_name in file_list:
                matched = re.match(self.app_dir_pattern, file_name)
                if matched:
                    apps.add(matched.group(1))
            if len(apps) == 1:
                log.debug("found one app")
                relative_app_dir = apps.pop()
                plist_path = join(relative_app_dir, "Info.plist")
                plist_bytes = z.read(plist_path)
                plist = biplist.readPlistFromString(plist_bytes)
                is_native = is_info_plist_native(plist)
                log.debug("is_native: {}".format(is_native))
            if len(apps) > 1:
                log.warning('more than one app found in archive')

        return (relative_app_dir, is_native)
예제 #3
0
 def precheck(cls, path):
     if not isdir(path):
         return False
     if not os.path.exists(cls._get_plist_path(path)):
         return False
     plist = cls.get_info(path)
     is_native = is_info_plist_native(plist)
     log.debug("is_native: {}".format(is_native))
     return is_native
예제 #4
0
파일: archive.py 프로젝트: saucelabs/isign
 def precheck(cls, path):
     if not isdir(path):
         return False
     if not os.path.exists(cls._get_plist_path(path)):
         return False
     plist = cls.get_info(path)
     is_native = is_info_plist_native(plist)
     log.debug("is_native: {}".format(is_native))
     return is_native
예제 #5
0
 def precheck(cls, path):
     """ Checks if an archive looks like this kind of app. Have to examine
         within the zipfile, b/c we don't want to make temp dirs just yet. This
         recapitulates a very similar precheck in the Bundle class """
     if not isfile(path):
         return False
     if not cls.is_helpers_present():
         raise MissingHelpers("helpers not present")
     is_native = False
     log.debug('precheck')
     log.debug('path: %s', path)
     if (cls.is_archive_extension_match(path) and zipfile.is_zipfile(path)):
         log.debug("this is an archive, and a zipfile")
         zipfile_obj = zipfile.ZipFile(path)
         relative_bundle_dir = cls.find_bundle_dir(zipfile_obj)
         if relative_bundle_dir is not None:
             plist_path = cls._get_plist_path(relative_bundle_dir)
             if plist_path not in zipfile_obj.namelist():
                 return False
             plist = cls.get_info(relative_bundle_dir, zipfile_obj)
             is_native = is_info_plist_native(plist)
             log.debug("is_native: {}".format(is_native))
     return is_native
예제 #6
0
파일: archive.py 프로젝트: saucelabs/isign
 def precheck(cls, path):
     """ Checks if an archive looks like this kind of app. Have to examine
         within the zipfile, b/c we don't want to make temp dirs just yet. This
         recapitulates a very similar precheck in the Bundle class """
     if not isfile(path):
         return False
     if not cls.is_helpers_present():
         raise MissingHelpers("helpers not present")
     is_native = False
     log.debug('precheck')
     log.debug('path: %s', path)
     if (cls.is_archive_extension_match(path) and
             zipfile.is_zipfile(path)):
         log.debug("this is an archive, and a zipfile")
         zipfile_obj = zipfile.ZipFile(path)
         relative_bundle_dir = cls.find_bundle_dir(zipfile_obj)
         if relative_bundle_dir is not None:
             plist_path = cls._get_plist_path(relative_bundle_dir)
             if plist_path not in zipfile_obj.namelist():
                 return False
             plist = cls.get_info(relative_bundle_dir, zipfile_obj)
             is_native = is_info_plist_native(plist)
             log.debug("is_native: {}".format(is_native))
     return is_native