def get_apk(self, _hash, apk = None, **kwargs): ''' Get the `EAndroApk` from `_hash`. Parameters ---------- _hash : str Hash of the .apk (sha256) apk : Apk Carries metainformation needed to build the whole path to the element in S3. Raises ------ S3StorageLoadException Returns ------- EAndroApk Apk constructed from raw data and meta infos. ''' # use to hold apk meta infos #fast_apk = FastApk(package_name, version_name, path, _hash, import_date, tag) try: apk_raw = BytesIO() if apk is None: raise S3StorageLoadException(self, content = "Apk:%s" % apk.short_description(), caused_by = RuntimeError("No APK metainformation given!")), None, sys.exc_info()[2] _id = Util.get_apk_path_incl_filename(apk) self.bucket_get(_id).get_contents_to_file(apk_raw) apk_raw.seek(0) eandro_apk = AnalyzeUtil.open_apk(apk_raw.read(), None, raw = True) return eandro_apk except (BotoClientError, S3ResponseError) as e: raise S3StorageLoadException(self, content = "Apk:%s" % apk.short_description(), caused_by = e), None, sys.exc_info()[2]
def get_s3_id(apk): ''' Parameters ---------- apk : Apk Returns ------- str The id for the apk in the S3 storage ''' return Util.get_apk_path_incl_filename(apk)
def get_s3_id(apk): ''' Parameters ---------- apk : Apk Returns ------- str The id for the apk in the S3 storage ''' return Util.get_apk_path_incl_filename(apk)
def get_apk(self, _hash, apk=None, **kwargs): ''' Get the `EAndroApk` from `_hash`. Parameters ---------- _hash : str Hash of the .apk (sha256) apk : Apk Carries metainformation needed to build the whole path to the element in S3. Raises ------ S3StorageLoadException Returns ------- EAndroApk Apk constructed from raw data and meta infos. ''' # use to hold apk meta infos #fast_apk = FastApk(package_name, version_name, path, _hash, import_date, tag) try: apk_raw = BytesIO() if apk is None: raise S3StorageLoadException( self, content="Apk:%s" % apk.short_description(), caused_by=RuntimeError("No APK metainformation given!" )), None, sys.exc_info()[2] _id = Util.get_apk_path_incl_filename(apk) self.bucket_get(_id).get_contents_to_file(apk_raw) apk_raw.seek(0) eandro_apk = AnalyzeUtil.open_apk(apk_raw.read(), None, raw=True) return eandro_apk except (BotoClientError, S3ResponseError) as e: raise S3StorageLoadException(self, content="Apk:%s" % apk.short_description(), caused_by=e), None, sys.exc_info()[2]