def load(self): if os.path.isfile( os.path.join( JustUpdateConstants.REPO_FOLDER, "archive", "metadata-{}.ju".format(get_platform_name_short( )))) == False and os.path.isfile( os.path.join( JustUpdateConstants.REPO_FOLDER, "deploy", "metadata-{}.ju".format( get_platform_name_short()))) == False: logging.debug("No metadata for platform {} found.".format( get_platform_name_short())) return {} # ok the metadata file most exist. Try to load it. # first see if there's one in deploy, if not, go for the one in archive. data = b"" try: data = data_manager.open_file( os.path.join( JustUpdateConstants.REPO_FOLDER, "deploy", "metadata-{}.ju".format(get_platform_name_short())), "rb") except FileNotFoundError: data = data_manager.open_file( os.path.join( JustUpdateConstants.REPO_FOLDER, "archive", "metadata-{}.ju".format(get_platform_name_short())), "rb") data = data_manager.decompress(data) data = json.loads(data) return data
def test_platform_names(): platform_name = platform.system() if platform_name == "Windows": assert get_platform_name_short() == "win" if platform_name == "Darwin": assert get_platform_name_short() == "mac"
def clean(self): try: shutil.rmtree(os.path.join(JustUpdateConstants.REPO_FOLDER, "work")) except FileNotFoundError: pass # It's ok if the folder doesn't exist. cmd = getattr(self, "_clean_{}".format(get_platform_name_short())) return cmd()
def _cmd_make_spec(args, extra=None): cmd = ["pyi-makespec", "--name", get_platform_name_short()] + extra + [args.scriptname] executor = CommandExecutor() result, stdout = executor.execute(cmd, CommandType.RAW) if result > 0: # error print(stdout) logging.error("Please correct the errors above and try again.") else: logging.info("Spec file written.") return True
def _load_metadata(self, bypass_metadata_cache_cache): md = "" try: md = self._download_metadata( "metadata-{}.ju".format(get_platform_name_short()), bypass_metadata_cache_cache) except requests.ConnectTimeout: return None except: raise md = data_manager.decompress(md) md = json.loads(md) metadata = MetaData() metadata.apply_metadata(md) return metadata
def save(self): if os.path.isdir( os.path.join(JustUpdateConstants.REPO_FOLDER, "deploy")) == False: os.makedirs(os.path.join(JustUpdateConstants.REPO_FOLDER, "deploy")) data = json.dumps(self._metadata) data = data_manager.compress(data) f = open( os.path.join(JustUpdateConstants.REPO_FOLDER, "deploy", "metadata-{}.ju".format(get_platform_name_short())), "wb") f.write(data) f.close() return self
def prepare_template(version): config = Config() config.load(os.path.join(JustUpdateConstants.REPO_FOLDER, "config.ju")) cmd = getattr(sys.modules[__name__], "_prepare_template_{}".format(get_platform_name_short())) return cmd(version, config)
def post_build(self): cmd = getattr(self, "_post_build_{}".format(get_platform_name_short())) return cmd()
def get_metadata_for_version(self, version): if version not in self._metadata: raise UnknownMetaDataError( "Metadata for version {} on platform {} does not exist.". format(version, get_platform_name_short())) return self._metadata[version]
def finalize(self): cmd = getattr(self, "_finalize_{}".format(get_platform_name_short())) return cmd()
def create_metadata(self): cmd = getattr(self, "_create_metadata_{}".format(get_platform_name_short())) return cmd()
def produce_executable(self): cmd = getattr( self, "_produce_executable_{}".format(get_platform_name_short())) return cmd()
def insure_build_availability(self): cmd = getattr( self, "_insure_build_availability_{}".format(get_platform_name_short())) return cmd()